-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
139 visualize systems with topology information only #145
base: develop
Are you sure you want to change the base?
139 visualize systems with topology information only #145
Conversation
…or presence of *.edr file before parsing attempt successful.
Pull Request Test Coverage Report for Build 13291507229Details
💛 - Coveralls |
atomisticparsers/gromacs/parser.py
Outdated
try: | ||
thermo_data = self.energy_parser | ||
except Exception as e: | ||
self.logger.warning(f'Error parsing edr file: {e}') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no return here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
log msg should not be formatted string, remove e, add it as exc_info
atomisticparsers/gromacs/parser.py
Outdated
edr_file = os.path.basename(self.energy_parser.mainfile) | ||
sec_input_output_files.x_gromacs_inout_file_eneredr = edr_file | ||
except TypeError: | ||
logging.warning(f'Error parsing *.edr file, no energy data available.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove string format
atomisticparsers/gromacs/parser.py
Outdated
primary_file = self.get_gromacs_file(primary_ext) | ||
primary_file_nopath = primary_file.rsplit('.', 1)[0] | ||
primary_file_nopath = primary_file_nopath.rsplit('/')[-1] | ||
secondary_file = self.get_gromacs_file(secondary_ext) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
execute only secondary file search if primary file is not found.
atomisticparsers/gromacs/parser.py
Outdated
if trajectory_file: | ||
return [trajectory_file] | ||
except FileNotFoundError: | ||
logging.warning(f'No coordinates found, no visualization possible.') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return [] here so you do not need additional handling
atomisticparsers/gromacs/parser.py
Outdated
trajectory_file = _get_file_or_fallback('pdb', 'gro') | ||
if trajectory_file: | ||
return [trajectory_file] | ||
except FileNotFoundError: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are there other exceptions?
atomisticparsers/gromacs/parser.py
Outdated
@@ -840,7 +841,10 @@ def parse_thermodynamic_data(self): | |||
|
|||
if not thermo_data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this completely redundant? We already checked if the edr files has keys to parse
atomisticparsers/gromacs/parser.py
Outdated
self.energy_parser.mainfile = edr_file | ||
# get it from edr file | ||
if self.energy_parser.keys(): | ||
thermo_data = self.energy_parser | ||
else: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you have an edr file but there are no keys? Then you won't end up in here!
if edr_file:
if keys:
if not thermo_data:
<try getting from input>
right?
atomisticparsers/gromacs/parser.py
Outdated
|
||
return trajectory_file | ||
|
||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really understand a few things here:
-
Why the
try:
, where can it break in error exactly? -
Why separate the trr/xtc vs. pdb/gro cases? Can't you do something like:
def find_trajectory_files(self):
def _get_traj_file(ext):
primary_file = self.get_gromacs_file(primary_ext)
if primary_file is '':
return None
primary_file_nopath = primary_file.rsplit('.', 1)[0] #! Check what happens if there are multiple files found in get_gromacs_file
primary_file_nopath = primary_file_nopath.rsplit('/')[-1]
return primary_file_nopath
traj_file_priority_list = ['trr', 'xtc', 'pdb', 'gro']
for ext in traj_file_priority_list:
traj_file = _get_traj_file(ext)
if traj_file:
return [traj_file]
return []
Added visualization option from a single frame (
*.gro
file or*.pdb
file).Parser now ensures an
*.edr
file is present in the upload before attempting to access it, preventing anAttributeError
.