Skip to content

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

@patrickfuchs

Description

@patrickfuchs

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions