Skip to content

Problems with PDB atom names with 4 letters generated by GROMACS tools #2

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

Open
patrickfuchs opened this issue May 15, 2020 · 0 comments

Comments

@patrickfuchs
Copy link
Owner

patrickfuchs commented May 15, 2020

I realised that when I use GROMACS tools (editconf or trjconv) to convert a gro to a pdb, some atom names with 4 letters get changed: for example on the first POPC in the file described in issue #1 C310 becomes 0C31, H101 becomes 1H10. I think that could be a problem for generating some mapping or .def files. Here is a quick script (named fix_atom_name_4letters.py) I wrote to fix this:

import sys

if len(sys.argv) != 2:
    exit("Usage: python ./fix_atom_name_4letters.py 1POPC.pdb")

with open(sys.argv[1]) as f:
    for line in f:
        atname = line[12:16].strip()
        if len(atname) == 4:
            if atname[0] not in "HCPN":
                right_atname = atname[1:] + atname[0]
                print(line.replace(atname, right_atname), end="")
            else:
                print(line, end="")
        else:
            print(line, end="")

Then one can launch it like this:

python ./fix_atom_name_4letters.py 1POPC.pdb > 1POPC_OK.pdb
@patrickfuchs patrickfuchs changed the title PDB atom names with 4 letters generated by GROMACS tools Problems with PDB atom names with 4 letters generated by GROMACS tools May 15, 2020
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

No branches or pull requests

1 participant