Skip to content

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

Merged
swails merged 5 commits into
ParmEd:v3.4from
Valdes-Tresanco-MS:fix_icode_resn
Feb 15, 2022
Merged

Reading a Gromacs topology fails with insertion code or negative number#1222
swails merged 5 commits into
ParmEd:v3.4from
Valdes-Tresanco-MS:fix_icode_resn

Conversation

@Valdes-Tresanco-MS

Copy link
Copy Markdown
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.

Comment thread parmed/gromacs/gromacstop.py Outdated
type=words[1], charge=charge, mass=mass)
# check for insertion code
if words[2].isnumeric():
try:

Copy link
Copy Markdown
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
Copy Markdown
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

swails commented Feb 15, 2022

Copy link
Copy Markdown
Contributor

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.

2 participants