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

Reading a Gromacs topology fails with insertion code or negative number #1222

Merged
merged 5 commits into from Feb 15, 2022
Merged

Reading a Gromacs topology fails with insertion code or negative number #1222

merged 5 commits into from Feb 15, 2022

Conversation

Valdes-Tresanco-MS
Copy link
Contributor

Hi Jason. I found a bug in my previous PR. Although rare, negative residues numbers fail with this setup. So I replaced the conditional with a try-except clause. According to the tests I did, it should work correctly in all cases.

@@ -491,10 +491,10 @@ def _parse_atoms(self, line, params):
atom = Atom(atomic_number=atomic_number, name=words[4],
type=words[1], charge=charge, mass=mass)
# check for insertion code
if words[2].isnumeric():
try:
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like the problem is that a leading - leads to isnumeric() returning False. What about we change line 494 to this instead:

if words[2].isnumeric() or (words[2].startswith('-') and words[2][1:].isnumeric()):

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done via a8d0e3f

@swails
Copy link
Contributor

swails commented Feb 15, 2022

Thanks!

@swails swails merged commit ac67ac2 into ParmEd:v3.4 Feb 15, 2022
@Valdes-Tresanco-MS Valdes-Tresanco-MS deleted the fix_icode_resn branch February 16, 2022 02:45
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.

None yet

2 participants