Skip to content

Commit

Permalink
swap asym ids and fix downstream
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmkrieger committed Oct 12, 2023
1 parent cd3e513 commit 1005eb5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 7 deletions.
26 changes: 22 additions & 4 deletions prody/proteins/ciffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from .cifheader import getCIFHeaderDict
from .header import buildBiomolecules, assignSecstr, isHelix, isSheet

__all__ = ['parseMMCIFStream', 'parseMMCIF']
__all__ = ['parseMMCIFStream', 'parseMMCIF', 'parseCIF']


class MMCIFParseError(Exception):
Expand Down Expand Up @@ -122,9 +122,27 @@ def parseMMCIF(pdb, **kwargs):
result = parseMMCIFStream(cif, chain=chain, **kwargs)
cif.close()
if unite_chains:
result.setSegnames(result.getChids())
if isinstance(result, AtomGroup):
result.setChids(result.getSegnames())

elif isinstance(result, list):
# e.g. multiple biomol assemblies
[r.setChids(r.getSegnames()) for r in result if isinstance(r, AtomGroup)]

elif isinstance(result, tuple):
# atoms, header
if isinstance(result[0], AtomGroup):
result[0].setChids(result[0].getSegnames())

elif isinstance(result[0], list):
# e.g. multiple biomol assemblies
[r.setChids(r.getSegnames()) for r in result[0] if isinstance(r, AtomGroup)]

else:
raise TypeError('result from parseMMCIFStream should be a tuple, AtomGroup or list')
return result

parseCIF = parseMMCIF

def parseMMCIFStream(stream, **kwargs):
"""Returns an :class:`.AtomGroup` and/or a class:`.StarDict`
Expand Down Expand Up @@ -375,14 +393,14 @@ def _parseMMCIFLines(atomgroup, lines, model, chain, subset,
if not (atomname in subset and resname in protein_resnames):
continue

chID = line.split()[fields['auth_asym_id']]
chID = line.split()[fields['label_asym_id']]
if chain is not None:
if isinstance(chain, str):
chain = chain.split(',')
if not chID in chain:
continue

segID = line.split()[fields['label_asym_id']]
segID = line.split()[fields['auth_asym_id']]

alt = line.split()[fields['label_alt_id']]
if alt not in which_altlocs and which_altlocs != 'all':
Expand Down
2 changes: 1 addition & 1 deletion prody/proteins/cifheader.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ def _getBiomoltrans(lines):
currentBiomolecule = item1["_pdbx_struct_assembly_gen.assembly_id"]
applyToChains = []

chains = item1["_pdbx_struct_assembly_gen.asym_id_list"].split(',')
chains = item1["_pdbx_struct_assembly_gen.asym_id_list"].replace(';','').strip().split(',')
applyToChains.extend(chains)

biomt = biomolecule[currentBiomolecule]
Expand Down
4 changes: 2 additions & 2 deletions prody/proteins/header.py
Original file line number Diff line number Diff line change
Expand Up @@ -1111,10 +1111,10 @@ def buildBiomolecules(header, atoms, biomol=None):
translation[2] = line2[3]
t = Transformation(rotation, translation)

newag = atoms.select('chain ' + ' or chain '.join(mt[times*4+0])).copy()
newag = atoms.select('chain ' + ' or chain '.join(mt[times*4+0]))
if newag is None:
continue
newag.all.setSegnames(decToHybrid36(times+1,resnum=True))
newag = newag.copy()
for acsi in range(newag.numCoordsets()):
newag.setACSIndex(acsi)
newag = t.apply(newag)
Expand Down

0 comments on commit 1005eb5

Please sign in to comment.