Commit aff6ab55 authored by Rafal P. Wiewiora's avatar Rafal P. Wiewiora
Browse files

add removeBondsToMetals argument

parent ce042c89
...@@ -59,7 +59,7 @@ class PDBFile(object): ...@@ -59,7 +59,7 @@ class PDBFile(object):
_residueNameReplacements = {} _residueNameReplacements = {}
_atomNameReplacements = {} _atomNameReplacements = {}
def __init__(self, file): def __init__(self, file, removeBondsToMetals=False):
"""Load a PDB file. """Load a PDB file.
The atom positions and Topology can be retrieved by calling getPositions() and getTopology(). The atom positions and Topology can be retrieved by calling getPositions() and getTopology().
...@@ -68,6 +68,9 @@ class PDBFile(object): ...@@ -68,6 +68,9 @@ class PDBFile(object):
---------- ----------
file : string file : string
the name of the file to load the name of the file to load
removeBondsToMetals : bool
if True, those inter-residue CONECT bonds that indicate coordination to metals
(cf. metalc connectivity in mmCIF/PDBx) are not added to the topology
""" """
metalElements = ['Al','As','Ba','Ca','Cd','Ce','Co','Cs','Cu','Dy','Fe','Gd','Hg','Ho','In','Ir','K','Li','Mg', metalElements = ['Al','As','Ba','Ca','Cd','Ce','Co','Cs','Cu','Dy','Fe','Gd','Hg','Ho','In','Ir','K','Li','Mg',
...@@ -161,7 +164,9 @@ class PDBFile(object): ...@@ -161,7 +164,9 @@ class PDBFile(object):
for connect in pdb.models[-1].connects: for connect in pdb.models[-1].connects:
i = connect[0] i = connect[0]
for j in connect[1:]: for j in connect[1:]:
if i in atomByNumber and j in atomByNumber: if i in atomByNumber and j in atomByNumber and not removeBondsToMetals:
connectBonds.append((atomByNumber[i], atomByNumber[j]))
elif i in atomByNumber and j in atomByNumber and removeBondsToMetals:
if atomByNumber[i].element is not None and atomByNumber[j].element is not None: if atomByNumber[i].element is not None and atomByNumber[j].element is not None:
if atomByNumber[i].element.symbol in metalElements or atomByNumber[j].element.symbol in metalElements: if atomByNumber[i].element.symbol in metalElements or atomByNumber[j].element.symbol in metalElements:
if atomByNumber[i].residue == atomByNumber[j].residue: if atomByNumber[i].residue == atomByNumber[j].residue:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment