diff --git a/prody/database/dali.py b/prody/database/dali.py index a36976fd4..4108c18bf 100644 --- a/prody/database/dali.py +++ b/prody/database/dali.py @@ -539,7 +539,7 @@ def daliFilterMultimer(atoms, dali_rec, n_chains=None, reverse=False): 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.") @@ -551,7 +551,7 @@ def daliFilterMultimer(atoms, dali_rec, n_chains=None, reverse=False): 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 diff --git a/prody/ensemble/functions.py b/prody/ensemble/functions.py index ffa7d9c97..ee4c7dde7 100644 --- a/prody/ensemble/functions.py +++ b/prody/ensemble/functions.py @@ -515,7 +515,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 a287ef921..27835c596 100644 --- a/prody/proteins/compare.py +++ b/prody/proteins/compare.py @@ -968,6 +968,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): @@ -1044,7 +1045,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) @@ -1284,17 +1285,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] @@ -1312,13 +1317,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()