Skip to content
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

Open
wants to merge 6 commits into
base: develop
Choose a base branch
from

Conversation

Bernadette-Mohr
Copy link
Collaborator

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 an AttributeError.

@Bernadette-Mohr Bernadette-Mohr linked an issue Feb 6, 2025 that may be closed by this pull request
@coveralls
Copy link

coveralls commented Feb 6, 2025

Pull Request Test Coverage Report for Build 13291507229

Details

  • 30 of 47 (63.83%) changed or added relevant lines in 1 file are covered.
  • 31 unchanged lines in 1 file lost coverage.
  • Overall coverage decreased (-0.2%) to 87.943%

Changes Missing Coverage Covered Lines Changed/Added Lines %
atomisticparsers/gromacs/parser.py 30 47 63.83%
Files with Coverage Reduction New Missed Lines %
atomisticparsers/gromacs/parser.py 31 78.34%
Totals Coverage Status
Change from base Build 12950540275: -0.2%
Covered Lines: 6346
Relevant Lines: 7216

💛 - Coveralls

try:
thermo_data = self.energy_parser
except Exception as e:
self.logger.warning(f'Error parsing edr file: {e}')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no return here?

Copy link
Collaborator

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

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.')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove string format

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)
Copy link
Collaborator

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.

if trajectory_file:
return [trajectory_file]
except FileNotFoundError:
logging.warning(f'No coordinates found, no visualization possible.')
Copy link
Collaborator

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

trajectory_file = _get_file_or_fallback('pdb', 'gro')
if trajectory_file:
return [trajectory_file]
except FileNotFoundError:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there other exceptions?

@@ -840,7 +841,10 @@ def parse_thermodynamic_data(self):

if not thermo_data:
Copy link
Collaborator

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

self.energy_parser.mainfile = edr_file
# get it from edr file
if self.energy_parser.keys():
thermo_data = self.energy_parser
else:
Copy link
Collaborator

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?


return trajectory_file

try:
Copy link
Collaborator

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:

  1. Why the try:, where can it break in error exactly?

  2. 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 []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Visualize systems with topology information only
4 participants