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
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions parmed/gromacs/gromacstop.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

icode = ''
resnum = int(words[2])
else:
except:
icode = words[2][-1]
resnum = int(words[2][:-1])
return atom, words[3], resnum, icode
Expand Down