Commit baab6f40 authored by peastman's avatar peastman
Browse files

Avoid truncating PDB file if the IDs are too long

parent e1971877
...@@ -319,7 +319,8 @@ class PDBFile(object): ...@@ -319,7 +319,8 @@ class PDBFile(object):
If True, keep the residue and chain IDs specified in the Topology If True, keep the residue and chain IDs specified in the Topology
rather than generating new ones. Warning: It is up to the caller to rather than generating new ones. Warning: It is up to the caller to
make sure these are valid IDs that satisfy the requirements of the make sure these are valid IDs that satisfy the requirements of the
PDB format. Otherwise, the output file will be invalid. PDB format. No guarantees are made about what will happen if they
are not, and the output file could be invalid.
extraParticleIdentifier : string=' ' extraParticleIdentifier : string=' '
String to write in the element column of the ATOM records for atoms whose element is None (extra particles) String to write in the element column of the ATOM records for atoms whose element is None (extra particles)
""" """
...@@ -339,7 +340,7 @@ class PDBFile(object): ...@@ -339,7 +340,7 @@ class PDBFile(object):
if modelIndex is not None: if modelIndex is not None:
print("MODEL %4d" % modelIndex, file=file) print("MODEL %4d" % modelIndex, file=file)
for (chainIndex, chain) in enumerate(topology.chains()): for (chainIndex, chain) in enumerate(topology.chains()):
if keepIds: if keepIds and len(chain.id) == 1:
chainName = chain.id chainName = chain.id
else: else:
chainName = chr(ord('A')+chainIndex%26) chainName = chr(ord('A')+chainIndex%26)
...@@ -349,7 +350,7 @@ class PDBFile(object): ...@@ -349,7 +350,7 @@ class PDBFile(object):
resName = res.name[:3] resName = res.name[:3]
else: else:
resName = res.name resName = res.name
if keepIds: if keepIds and len(res.id) < 5:
resId = res.id resId = res.id
else: else:
resId = "%4d" % ((resIndex+1)%10000) resId = "%4d" % ((resIndex+1)%10000)
......
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