Unverified Commit 40c04f74 authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #2563 from peastman/chains

Add chain break when either auth_asym_id or label_asym_id changes
parents 484e6b99 c8bc7593
...@@ -6,7 +6,7 @@ Simbios, the NIH National Center for Physics-Based Simulation of ...@@ -6,7 +6,7 @@ Simbios, the NIH National Center for Physics-Based Simulation of
Biological Structures at Stanford, funded under the NIH Roadmap for Biological Structures at Stanford, funded under the NIH Roadmap for
Medical Research, grant U54 GM072970. See https://simtk.org. Medical Research, grant U54 GM072970. See https://simtk.org.
Portions copyright (c) 2015-2019 Stanford University and the Authors. Portions copyright (c) 2015-2020 Stanford University and the Authors.
Authors: Peter Eastman Authors: Peter Eastman
Contributors: Jason Swails Contributors: Jason Swails
...@@ -98,6 +98,9 @@ class PDBxFile(object): ...@@ -98,6 +98,9 @@ class PDBxFile(object):
chainIdCol = atomData.getAttributeIndex('auth_asym_id') chainIdCol = atomData.getAttributeIndex('auth_asym_id')
if chainIdCol == -1: if chainIdCol == -1:
chainIdCol = atomData.getAttributeIndex('label_asym_id') chainIdCol = atomData.getAttributeIndex('label_asym_id')
altChainIdCol = -1
else:
altChainIdCol = atomData.getAttributeIndex('label_asym_id')
elementCol = atomData.getAttributeIndex('type_symbol') elementCol = atomData.getAttributeIndex('type_symbol')
altIdCol = atomData.getAttributeIndex('label_alt_id') altIdCol = atomData.getAttributeIndex('label_alt_id')
modelCol = atomData.getAttributeIndex('pdbx_PDB_model_num') modelCol = atomData.getAttributeIndex('pdbx_PDB_model_num')
...@@ -105,6 +108,7 @@ class PDBxFile(object): ...@@ -105,6 +108,7 @@ class PDBxFile(object):
yCol = atomData.getAttributeIndex('Cartn_y') yCol = atomData.getAttributeIndex('Cartn_y')
zCol = atomData.getAttributeIndex('Cartn_z') zCol = atomData.getAttributeIndex('Cartn_z')
lastChainId = None lastChainId = None
lastAltChainId = None
lastResId = None lastResId = None
lastInsertionCode = '' lastInsertionCode = ''
atomTable = {} atomTable = {}
...@@ -130,11 +134,13 @@ class PDBxFile(object): ...@@ -130,11 +134,13 @@ class PDBxFile(object):
insertionCode = row[resInsertionCol] insertionCode = row[resInsertionCol]
if insertionCode in ('.', '?'): if insertionCode in ('.', '?'):
insertionCode = '' insertionCode = ''
if lastChainId != row[chainIdCol]: if lastChainId != row[chainIdCol] or (altChainIdCol != -1 and lastAltChainId != row[altChainIdCol]):
# The start of a new chain. # The start of a new chain.
chain = top.addChain(row[chainIdCol]) chain = top.addChain(row[chainIdCol])
lastChainId = row[chainIdCol] lastChainId = row[chainIdCol]
lastResId = None lastResId = None
if altChainIdCol != -1:
lastAltChainId = row[altChainIdCol]
if lastResId != row[resNumCol] or lastChainId != row[chainIdCol] or lastInsertionCode != insertionCode or (lastResId == '.' and row[atomNameCol] in atomsInResidue): if lastResId != row[resNumCol] or lastChainId != row[chainIdCol] or lastInsertionCode != insertionCode or (lastResId == '.' and row[atomNameCol] in atomsInResidue):
# The start of a new residue. # The start of a new residue.
resId = (None if resNumCol == -1 else row[resNumCol]) resId = (None if resNumCol == -1 else row[resNumCol])
......
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