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 gromacs topologies with insertion codes fixed #1220

Merged
merged 1 commit into from
Feb 7, 2022
Merged
Changes from all 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
12 changes: 10 additions & 2 deletions parmed/gromacs/gromacstop.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ def read(self, fname, defines=None, parametrize=True):
dihedral_types = dict()
exc_types = dict()
elif current_section == 'atoms':
molecule.add_atom(*self._parse_atoms(line, params))
atom, resname, resnum, icode = self._parse_atoms(line, params)
molecule.add_atom(atom, resname, resnum, inscode=icode)
elif current_section == 'bonds':
bond, bond_type = self._parse_bonds(line, bond_types, molecule.atoms)
molecule.bonds.append(bond)
Expand Down Expand Up @@ -489,7 +490,14 @@ def _parse_atoms(self, line, params):
else:
atom = Atom(atomic_number=atomic_number, name=words[4],
type=words[1], charge=charge, mass=mass)
return atom, words[3], int(words[2])
# check for insertion code
if words[2].isnumeric():
icode = ''
resnum = int(words[2])
else:
icode = words[2][-1]
resnum = int(words[2][:-1])
return atom, words[3], resnum, icode

def _parse_bonds(self, line, bond_types, atoms):
""" Parses a bond line. Returns a Bond, BondType/None """
Expand Down