From bd232341ec52df7d88596c61449ca670dcd90458 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 22 Oct 2020 12:25:44 +0100 Subject: [PATCH 1/2] cleaned daliFilterMultimer --- prody/database/dali.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/prody/database/dali.py b/prody/database/dali.py index 8a4011274..de6f33480 100644 --- a/prody/database/dali.py +++ b/prody/database/dali.py @@ -494,13 +494,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 From ac84366653a87e3c75d5598787515f306d352b3c Mon Sep 17 00:00:00 2001 From: James Krieger Date: Thu, 22 Oct 2020 15:33:01 +0100 Subject: [PATCH 2/2] first changes --- prody/ensemble/functions.py | 2 +- prody/proteins/compare.py | 29 +++++++++++++++++------------ 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/prody/ensemble/functions.py b/prody/ensemble/functions.py index b5ab6b4bb..ac8e585ed 100644 --- a/prody/ensemble/functions.py +++ b/prody/ensemble/functions.py @@ -443,7 +443,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]) diff --git a/prody/proteins/compare.py b/prody/proteins/compare.py index 02b6a33e2..254c26c63 100644 --- a/prody/proteins/compare.py +++ b/prody/proteins/compare.py @@ -958,6 +958,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): @@ -1034,7 +1035,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) @@ -1263,17 +1264,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] @@ -1291,13 +1296,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()