Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chain alignment fixes #1220

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions prody/database/dali.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,13 @@ def daliFilterMultimer(atoms, dali_rec, n_chains=None):
if not isinstance(dali_rec, DaliRecord):
raise TypeError("dali_rec should be a DaliRecord")
try:
keys = dali_rec._alignPDB
_ = dali_rec._alignPDB
except:
raise AttributeError("Dali Record does not have any data yet. Please run fetch.")

numChains = 0
atommap = None
for i, chain in enumerate(atoms.iterChains()):
for chain in atoms.iterChains():
m = dali_rec.getMapping(chain.getTitle()[:4] + chain.getChid())
if m is not None:
numChains += 1
Expand Down
2 changes: 1 addition & 1 deletion prody/ensemble/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ def buildPDBEnsemble(atomics, ref=None, title='Unknown', labels=None, atommaps=N

# find the mapping of chains of atoms to those of target
debug[labels[i]] = {}
atommaps_ = alignChains(atoms, target, debug=debug[labels[i]], **kwargs)
atommaps_ = alignChains(atoms, target, debug=debug[labels[i]], label=labels[i], **kwargs)

if len(atommaps_) == 0:
unmapped.append(labels[i])
Expand Down
29 changes: 17 additions & 12 deletions prody/proteins/compare.py
Original file line number Diff line number Diff line change
Expand Up @@ -966,6 +966,7 @@ def mapChainOntoChain(mobile, target, **kwargs):
coverage = kwargs.get('coverage', coverage)
pwalign = kwargs.get('pwalign', 'auto')
pwalign = kwargs.get('mapping', pwalign)
label = kwargs.get('label', None)
alignment = None

if isinstance(pwalign, basestring):
Expand Down Expand Up @@ -1042,7 +1043,7 @@ def mapChainOntoChain(mobile, target, **kwargs):
result = getAlignedMapping(simple_target, simple_mobile)
else:
if isinstance(alignment, dict):
result = getDictMapping(simple_target, simple_mobile, alignment)
result = getDictMapping(simple_target, simple_mobile, alignment, label)
else:
result = getAlignedMapping(simple_target, simple_mobile, alignment)

Expand Down Expand Up @@ -1271,17 +1272,21 @@ def getTrivialMapping(target, chain):

return target_list, chain_list, n_match, n_mapped

def getDictMapping(target, chain, map_dict):
def getDictMapping(target, chain, map_dict, label=None):
"""Returns lists of matching residues (based on *map_dict*)."""

pdbid = chain._chain.getTitle()[:4].lower()
chid = chain._chain.getChid().upper()
key = pdbid + chid

mapping = map_dict.get(key)
if mapping is None:
LOGGER.warn('map_dict does not have the mapping for {0}'.format(key))
return None
try:
key = label
mapping = map_dict[key]
except KeyError:
try:
pdbid = chain._chain.getTitle()[:4].lower()
chid = chain._chain.getChid().upper()
key = pdbid + chid
mapping = map_dict[key]
except KeyError:
LOGGER.warn('map_dict does not have the mapping for {0}'.format(key))
return None

tar_indices = mapping[0]
chn_indices = mapping[1]
Expand All @@ -1299,13 +1304,13 @@ def getDictMapping(target, chain, map_dict):
try:
n = index(tar_indices, i)
except IndexError:
LOGGER.warn('\nthe number of residues in the map_dict ({0} residues) is inconsistent with {2} ({1} residues)'
LOGGER.warn('the number of residues in the map_dict ({0} residues) is inconsistent with {2} ({1} residues)'
.format(max(tar_indices)+1, len(chain_res_list), target.getTitle()))
return None
try:
b = chain_res_list[chn_indices[n]]
except IndexError:
LOGGER.warn('\nthe number of residues in the map_dict ({0} residues) is inconsistent with {2} ({1} residues)'
LOGGER.warn('the number of residues in the map_dict ({0} residues) is inconsistent with {2} ({1} residues)'
.format(max(chn_indices)+1, len(chain_res_list), chain.getTitle()))
return None
bres = b.getResidue()
Expand Down