From e5d20489f558fc1dd49f37da6f70802265897eb9 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Wed, 9 Oct 2024 12:58:04 +0100 Subject: [PATCH 01/16] default nproc 0 not None --- prody/dynamics/clustenm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prody/dynamics/clustenm.py b/prody/dynamics/clustenm.py index 9bac6ea92..7583bc431 100644 --- a/prody/dynamics/clustenm.py +++ b/prody/dynamics/clustenm.py @@ -1076,7 +1076,7 @@ def run(self, cutoff=15., n_modes=3, gamma=1., n_confs=50, rmsd=1.0, self._sparse = kwargs.get('sparse', False) self._kdtree = kwargs.get('kdtree', False) self._turbo = kwargs.get('turbo', False) - self._nproc = kwargs.pop('nproc', None) + self._nproc = kwargs.pop('nproc', 0) if kwargs.get('zeros', False): LOGGER.warn('ClustENM cannot use zero modes so ignoring this kwarg') From 3a944d1bf18169af378ee4664e56990107cf5984 Mon Sep 17 00:00:00 2001 From: karolamik13 Date: Sat, 12 Oct 2024 10:02:49 +0200 Subject: [PATCH 02/16] cutoff changes for showFrequentInteractors() and fix for getFrequentInteractors() --- prody/proteins/interactions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prody/proteins/interactions.py b/prody/proteins/interactions.py index e6918a6cf..538e8cbc9 100644 --- a/prody/proteins/interactions.py +++ b/prody/proteins/interactions.py @@ -3590,7 +3590,7 @@ def getFrequentInteractors(self, contacts_min=3): m2 = resIDs_with_resChIDs.index((int(ii[3][3:]),ii[5])) InteractionsMap[m1][m2] = interaction_type[nr]+':'+ii[0]+ii[2]+'-'+ii[3]+ii[5] - ListOfInteractions = [ list(filter(None, InteractionsMap[:,j])) for j in range(len(interactions[0])) ] + ListOfInteractions = [list(filter(None, [row[j] for row in InteractionsMap])) for j in range(len(InteractionsMap[0]))] ListOfInteractions = list(filter(lambda x : x != [], ListOfInteractions)) ListOfInteractions = [k for k in ListOfInteractions if len(k) >= contacts_min ] ListOfInteractions_list = [ (i[0].split('-')[-1], [ j.split('-')[0] for j in i]) for i in ListOfInteractions ] @@ -3598,8 +3598,8 @@ def getFrequentInteractors(self, contacts_min=3): for res in ListOfInteractions_list: LOGGER.info('{0} <---> {1}'.format(res[0], ' '.join(res[1]))) - LOGGER.info('Legend: hb-hydrogen bond, sb-salt bridge, rb-repulsive ionic bond, ps-Pi stacking interaction,' - 'pc-Cation-Pi interaction, hp-hydrophobic interaction, dibs-disulfide bonds') + LOGGER.info('\nLegend: hb-hydrogen bond, sb-salt bridge, rb-repulsive ionic bond, ps-Pi stacking interaction,' + '\npc-Cation-Pi interaction, hp-hydrophobic interaction, dibs-disulfide bonds') try: from toolz.curried import count @@ -3612,12 +3612,12 @@ def getFrequentInteractors(self, contacts_min=3): return ListOfInteractions_list - def showFrequentInteractors(self, cutoff=5, **kwargs): + def showFrequentInteractors(self, cutoff=4, **kwargs): """Plots regions with the most frequent interactions. :arg cutoff: minimal score per residue which will be displayed. If cutoff value is to big, top 30% with the higest values will be returned. - Default is 5. + Default is 4. :type cutoff: int, float Nonstandard resiudes can be updated in a following way: From 0615587c79d0d806af99e78696195674d033a72f Mon Sep 17 00:00:00 2001 From: karolamik13 Date: Sat, 12 Oct 2024 11:07:58 +0200 Subject: [PATCH 03/16] getInteractors() is now added to InSty --- prody/proteins/interactions.py | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/prody/proteins/interactions.py b/prody/proteins/interactions.py index 538e8cbc9..edf81ebf1 100644 --- a/prody/proteins/interactions.py +++ b/prody/proteins/interactions.py @@ -3558,7 +3558,39 @@ def saveInteractionsPDB(self, **kwargs): writePDB('filename', atoms, **kw) LOGGER.info('PDB file saved.') - + + def getInteractors(self, residue_name): + """ Provide information about interactions for a particular residue + + :arg residue_name: name of a resiude + example: LEU234A, where A is a chain name + :type residue_name: str + """ + + atoms = self._atoms + interactions = self._interactions + + InteractionsMap = np.empty([atoms.select('name CA').numAtoms(),atoms.select('name CA').numAtoms()], dtype=object) + resIDs = list(atoms.select('name CA').getResnums()) + resChIDs = list(atoms.select('name CA').getChids()) + resIDs_with_resChIDs = list(zip(resIDs, resChIDs)) + interaction_type = ['hb','sb','rb','ps','pc','hp','dibs'] + ListOfInteractions = [] + + for nr,i in enumerate(interactions): + if i != []: + for ii in i: + m1 = resIDs_with_resChIDs.index((int(ii[0][3:]),ii[2])) + m2 = resIDs_with_resChIDs.index((int(ii[3][3:]),ii[5])) + ListOfInteractions.append(interaction_type[nr]+':'+ii[0]+ii[2]+'-'+ii[3]+ii[5]) + + for i in ListOfInteractions: + inter = i.split(":")[1:][0] + if inter.split('-')[0] == residue_name or inter.split('-')[1] == residue_name: + LOGGER.info(i) + + + def getFrequentInteractors(self, contacts_min=3): """Provide a list of residues with the most frequent interactions based on the following interactions: From 0ab6a942639a077065935c92ca5397cf4e26ae79 Mon Sep 17 00:00:00 2001 From: karolamik13 Date: Sun, 13 Oct 2024 14:21:50 +0200 Subject: [PATCH 04/16] Fixing getFrequentInteractors() to include several interactions for the same pair --- prody/proteins/interactions.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/prody/proteins/interactions.py b/prody/proteins/interactions.py index edf81ebf1..bf528bc21 100644 --- a/prody/proteins/interactions.py +++ b/prody/proteins/interactions.py @@ -3620,13 +3620,28 @@ def getFrequentInteractors(self, contacts_min=3): for ii in i: m1 = resIDs_with_resChIDs.index((int(ii[0][3:]),ii[2])) m2 = resIDs_with_resChIDs.index((int(ii[3][3:]),ii[5])) - InteractionsMap[m1][m2] = interaction_type[nr]+':'+ii[0]+ii[2]+'-'+ii[3]+ii[5] + + if InteractionsMap[m1][m2] is None: + InteractionsMap[m1][m2] = [] + + InteractionsMap[m1][m2].append(interaction_type[nr] + ':' + ii[0] + ii[2] + '-' + ii[3] + ii[5]) ListOfInteractions = [list(filter(None, [row[j] for row in InteractionsMap])) for j in range(len(InteractionsMap[0]))] - ListOfInteractions = list(filter(lambda x : x != [], ListOfInteractions)) - ListOfInteractions = [k for k in ListOfInteractions if len(k) >= contacts_min ] - ListOfInteractions_list = [ (i[0].split('-')[-1], [ j.split('-')[0] for j in i]) for i in ListOfInteractions ] - LOGGER.info('The most frequent interactions between:') + ListOfInteractions = list(filter(lambda x: x != [], ListOfInteractions)) + ListOfInteractions = [k for k in ListOfInteractions if len(k) >= contacts_min] + ListOfInteractions_flattened = [j for sublist in ListOfInteractions for j in sublist] + ListOfInteractions_list = [(i[0].split('-')[-1], [j.split('-')[0] for j in i]) for i in ListOfInteractions_flattened] + + merged_dict = {} + for amino_acid, interactions in ListOfInteractions_list: + if amino_acid in merged_dict: + merged_dict[amino_acid].extend(interactions) + else: + merged_dict[amino_acid] = interactions + + ListOfInteractions_list = [(key, value) for key, value in merged_dict.items()] + + LOGGER.info('The most frequent interactions:') for res in ListOfInteractions_list: LOGGER.info('{0} <---> {1}'.format(res[0], ' '.join(res[1]))) @@ -3639,8 +3654,6 @@ def getFrequentInteractors(self, contacts_min=3): LOGGER.warn('This function requires the module toolz') return - LOGGER.info('The biggest number of interactions: {}'.format(max(map(count, ListOfInteractions)))) - return ListOfInteractions_list From 9fc5d689c4ba3cb1d06b258139994785f3c4476a Mon Sep 17 00:00:00 2001 From: karolamik13 Date: Sun, 13 Oct 2024 18:58:22 +0200 Subject: [PATCH 05/16] fix for getFrequentInteractors() --- prody/proteins/interactions.py | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/prody/proteins/interactions.py b/prody/proteins/interactions.py index bf528bc21..036d773e4 100644 --- a/prody/proteins/interactions.py +++ b/prody/proteins/interactions.py @@ -3589,7 +3589,6 @@ def getInteractors(self, residue_name): if inter.split('-')[0] == residue_name or inter.split('-')[1] == residue_name: LOGGER.info(i) - def getFrequentInteractors(self, contacts_min=3): """Provide a list of residues with the most frequent interactions based @@ -3630,18 +3629,28 @@ def getFrequentInteractors(self, contacts_min=3): ListOfInteractions = list(filter(lambda x: x != [], ListOfInteractions)) ListOfInteractions = [k for k in ListOfInteractions if len(k) >= contacts_min] ListOfInteractions_flattened = [j for sublist in ListOfInteractions for j in sublist] - ListOfInteractions_list = [(i[0].split('-')[-1], [j.split('-')[0] for j in i]) for i in ListOfInteractions_flattened] + + swapped_ListOfInteractions_list = [] + for interaction_group in ListOfInteractions_flattened: + swapped_group = [] + for interaction in interaction_group: + interaction_type, pair = interaction.split(':') + swapped_pair = '-'.join(pair.split('-')[::-1]) + swapped_group.append(f"{interaction_type}:{swapped_pair}") + swapped_ListOfInteractions_list.append(swapped_group) + + doubleListOfInteractions_list = ListOfInteractions_flattened+swapped_ListOfInteractions_list + ListOfInteractions_list = [(i[0].split('-')[-1], [j.split('-')[0] for j in i]) for i in doubleListOfInteractions_list] merged_dict = {} - for amino_acid, interactions in ListOfInteractions_list: - if amino_acid in merged_dict: - merged_dict[amino_acid].extend(interactions) + for aa, ii in ListOfInteractions_list: + if aa in merged_dict: + merged_dict[aa].extend(ii) else: - merged_dict[amino_acid] = interactions + merged_dict[aa] = ii - ListOfInteractions_list = [(key, value) for key, value in merged_dict.items()] - - LOGGER.info('The most frequent interactions:') + ListOfInteractions_list = [(key, value) for key, value in merged_dict.items()] + for res in ListOfInteractions_list: LOGGER.info('{0} <---> {1}'.format(res[0], ' '.join(res[1]))) From 322fa5d1aff0d4b4c1950708cab8742f66399227 Mon Sep 17 00:00:00 2001 From: karolamik13 Date: Sun, 13 Oct 2024 19:29:53 +0200 Subject: [PATCH 06/16] final fix for getFrequentInteractors() --- prody/proteins/interactions.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/prody/proteins/interactions.py b/prody/proteins/interactions.py index 036d773e4..b22f91a67 100644 --- a/prody/proteins/interactions.py +++ b/prody/proteins/interactions.py @@ -3590,7 +3590,7 @@ def getInteractors(self, residue_name): LOGGER.info(i) - def getFrequentInteractors(self, contacts_min=3): + def getFrequentInteractors(self, contacts_min=2): """Provide a list of residues with the most frequent interactions based on the following interactions: (1) Hydrogen bonds (hb) @@ -3602,7 +3602,7 @@ def getFrequentInteractors(self, contacts_min=3): (7) Disulfide bonds (disb) :arg contacts_min: Minimal number of contacts which residue may form with other residues, - by default 3. + by default 2. :type contacts_min: int """ atoms = self._atoms @@ -3627,7 +3627,6 @@ def getFrequentInteractors(self, contacts_min=3): ListOfInteractions = [list(filter(None, [row[j] for row in InteractionsMap])) for j in range(len(InteractionsMap[0]))] ListOfInteractions = list(filter(lambda x: x != [], ListOfInteractions)) - ListOfInteractions = [k for k in ListOfInteractions if len(k) >= contacts_min] ListOfInteractions_flattened = [j for sublist in ListOfInteractions for j in sublist] swapped_ListOfInteractions_list = [] @@ -3650,8 +3649,9 @@ def getFrequentInteractors(self, contacts_min=3): merged_dict[aa] = ii ListOfInteractions_list = [(key, value) for key, value in merged_dict.items()] + ListOfInteractions_list2 = [k for k in ListOfInteractions_list if len(k[-1]) >= contacts_min] - for res in ListOfInteractions_list: + for res in ListOfInteractions_list2: LOGGER.info('{0} <---> {1}'.format(res[0], ' '.join(res[1]))) LOGGER.info('\nLegend: hb-hydrogen bond, sb-salt bridge, rb-repulsive ionic bond, ps-Pi stacking interaction,' @@ -3663,7 +3663,7 @@ def getFrequentInteractors(self, contacts_min=3): LOGGER.warn('This function requires the module toolz') return - return ListOfInteractions_list + return ListOfInteractions_list2 def showFrequentInteractors(self, cutoff=4, **kwargs): From feac8abdf728c2b2b7a2590a4e90c96defaea54f Mon Sep 17 00:00:00 2001 From: karolamik13 Date: Sun, 13 Oct 2024 19:54:21 +0200 Subject: [PATCH 07/16] return added to getInteractors() --- prody/proteins/interactions.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/prody/proteins/interactions.py b/prody/proteins/interactions.py index b22f91a67..8af6e9090 100644 --- a/prody/proteins/interactions.py +++ b/prody/proteins/interactions.py @@ -3584,10 +3584,14 @@ def getInteractors(self, residue_name): m2 = resIDs_with_resChIDs.index((int(ii[3][3:]),ii[5])) ListOfInteractions.append(interaction_type[nr]+':'+ii[0]+ii[2]+'-'+ii[3]+ii[5]) + aa_ListOfInteractions = [] for i in ListOfInteractions: inter = i.split(":")[1:][0] if inter.split('-')[0] == residue_name or inter.split('-')[1] == residue_name: LOGGER.info(i) + aa_ListOfInteractions.append(i) + + return aa_ListOfInteractions def getFrequentInteractors(self, contacts_min=2): From 87428b779029e218f499d5176dfc68f1b2541b80 Mon Sep 17 00:00:00 2001 From: karolamik13 Date: Sun, 13 Oct 2024 21:00:09 +0200 Subject: [PATCH 08/16] fixing fstrings for Python 2.7 --- prody/proteins/interactions.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prody/proteins/interactions.py b/prody/proteins/interactions.py index 8af6e9090..1dba0a7c1 100644 --- a/prody/proteins/interactions.py +++ b/prody/proteins/interactions.py @@ -3639,7 +3639,7 @@ def getFrequentInteractors(self, contacts_min=2): for interaction in interaction_group: interaction_type, pair = interaction.split(':') swapped_pair = '-'.join(pair.split('-')[::-1]) - swapped_group.append(f"{interaction_type}:{swapped_pair}") + swapped_group.append("{}:{}".format(interaction_type, swapped_pair)) swapped_ListOfInteractions_list.append(swapped_group) doubleListOfInteractions_list = ListOfInteractions_flattened+swapped_ListOfInteractions_list From c58be86c643edd6e2b48cecef772a7b76d2eec5c Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 15:18:21 +0000 Subject: [PATCH 09/16] remove test ftp --- prody/tests/proteins/test_wwpdb.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/prody/tests/proteins/test_wwpdb.py b/prody/tests/proteins/test_wwpdb.py index a6657f635..d3962cd16 100644 --- a/prody/tests/proteins/test_wwpdb.py +++ b/prody/tests/proteins/test_wwpdb.py @@ -15,15 +15,15 @@ LOGGER.verbosity = 'none' -class TestFTP(unittest.TestCase): +class TestHTTP(unittest.TestCase): def setUp(self): self.pdb = ['1ubi', '1aar', 'arg', 1234] self.fns = [] self.len = [683, 1218, None, None] - self.fetch = fetchPDBviaFTP - self.protocol = 'FTP' + self.fetch = fetchPDBviaHTTP + self.protocol = 'HTTP' @dec.slow @@ -69,12 +69,3 @@ def tearDown(self): pass except: pass - -class TestHTTP(TestFTP): - - def setUp(self): - - TestFTP.setUp(self) - self.fetch = fetchPDBviaHTTP - self.protocol = 'HTTP' - From e4e29382e652e74f7499756df3fc3c7577e5ba1d Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 16:40:58 +0000 Subject: [PATCH 10/16] fix fetch cif from http --- prody/proteins/wwpdb.py | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/prody/proteins/wwpdb.py b/prody/proteins/wwpdb.py index 54fa73d0a..d2c883f52 100644 --- a/prody/proteins/wwpdb.py +++ b/prody/proteins/wwpdb.py @@ -254,7 +254,22 @@ def fetchPDBviaHTTP(*pdb, **kwargs): output_folder = kwargs.pop('folder', None) compressed = bool(kwargs.pop('compressed', True)) - extension = '.pdb' + format = kwargs.get('format', 'pdb') + noatom = bool(kwargs.pop('noatom', False)) + if format == 'pdb': + extension = '.pdb' + elif format == 'xml': + if noatom: + extension = '-noatom.xml' + else: + extension = '.xml' + elif format == 'cif': + extension = '.cif' + elif format == 'emd' or format == 'map': + extension = '.map' + else: + raise ValueError(repr(format) + ' is not valid format') + local_folder = pathPDBFolder() if local_folder: local_folder, is_divided = local_folder @@ -294,7 +309,10 @@ def fetchPDBviaHTTP(*pdb, **kwargs): filenames.append(None) continue try: - handle = openURL(getURL(pdb)) + url = getURL(pdb) + if kwargs['format'] != 'pdb': + url = url.replace('.pdb', extension) + handle = openURL(url) except Exception as err: LOGGER.warn('{0} download failed ({1}).'.format(pdb, str(err))) failure += 1 From 81dd6121ae38bdad0f2063cc77f7ac533d5e00da Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 17:12:53 +0000 Subject: [PATCH 11/16] fix cifheader author for consortium --- prody/proteins/cifheader.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/prody/proteins/cifheader.py b/prody/proteins/cifheader.py index 9a31112da..dd4475a0b 100644 --- a/prody/proteins/cifheader.py +++ b/prody/proteins/cifheader.py @@ -745,8 +745,11 @@ def _getReference(lines): except: continue if what == 'AUTH': - surname, initials = value.split(',') - author = initials+surname + try: + surname, initials = value.split(',') + author = initials+surname + except ValueError: + author = value authors.append(author.strip().upper()) ref['authors'] = authors From 3b0caa151135996add5bea9a20a786614ac8859b Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 17:13:34 +0000 Subject: [PATCH 12/16] no checkIdentifiers for format emd as can be longer --- prody/proteins/localpdb.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/prody/proteins/localpdb.py b/prody/proteins/localpdb.py index a28cd74b5..a451f9938 100644 --- a/prody/proteins/localpdb.py +++ b/prody/proteins/localpdb.py @@ -212,12 +212,15 @@ def fetchPDB(*pdb, **kwargs): if len(pdb) == 1 and isinstance(pdb[0], list): pdb = pdb[0] - identifiers = checkIdentifiers(*pdb) - folder = kwargs.get('folder', '.') compressed = kwargs.get('compressed') format_ = kwargs.get('format', 'pdb') + if format_ != 'emd': + identifiers = checkIdentifiers(*pdb) + else: + identifiers = pdb + # check *folder* specified by the user, usually pwd ('.') filedict = findPDBFiles(folder, compressed=compressed, format=format_) From 9b9b97df86c7996e0158e69048a4d55924b0058f Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 17:14:34 +0000 Subject: [PATCH 13/16] more fixes to _parsePDB for cif --- prody/proteins/pdbfile.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/prody/proteins/pdbfile.py b/prody/proteins/pdbfile.py index a8127e72f..624ed11da 100644 --- a/prody/proteins/pdbfile.py +++ b/prody/proteins/pdbfile.py @@ -214,13 +214,15 @@ def _parsePDB(pdb, **kwargs): if filename is None: try: LOGGER.warn("Trying to parse mmCIF file instead") + chain = kwargs.pop('chain', chain) return parseMMCIF(pdb+chain, **kwargs) - except: + except OSError: try: LOGGER.warn("Trying to parse EMD file instead") + chain = kwargs.pop('chain', chain) return parseEMD(pdb+chain, **kwargs) except: - raise IOError('PDB file for {0} could not be downloaded.' + raise IOError('PDB file for {0} could not be parsed.' .format(pdb)) pdb = filename if title is None: From 0d8582459d1fa42c6d0e6e5a4ec58f97a8e3c4d8 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 8 Nov 2024 17:38:04 +0000 Subject: [PATCH 14/16] fix the url fix --- prody/proteins/wwpdb.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/prody/proteins/wwpdb.py b/prody/proteins/wwpdb.py index d2c883f52..ef520c8dc 100644 --- a/prody/proteins/wwpdb.py +++ b/prody/proteins/wwpdb.py @@ -310,7 +310,7 @@ def fetchPDBviaHTTP(*pdb, **kwargs): continue try: url = getURL(pdb) - if kwargs['format'] != 'pdb': + if kwargs.get('format', 'pdb') != 'pdb': url = url.replace('.pdb', extension) handle = openURL(url) except Exception as err: From 6f00e1d49c9fa1b9d01b03c0cb356064098a6f00 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 15 Nov 2024 12:41:29 +0100 Subject: [PATCH 15/16] zero matrix with markersize --- prody/utilities/catchall.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/prody/utilities/catchall.py b/prody/utilities/catchall.py index 33d166dcc..94a9de640 100644 --- a/prody/utilities/catchall.py +++ b/prody/utilities/catchall.py @@ -739,6 +739,8 @@ def showMatrix(matrix, x_array=None, y_array=None, **kwargs): im = ax3.imshow(matrix, aspect=aspect, vmin=vmin, vmax=vmax, norm=norm, cmap=cmap, origin=origin, **kwargs) else: + zeros_matrix = np.zeros(matrix.shape) + im = ax3.imshow(zeros_matrix, vmin=-1, vmax=1, cmap='seismic') plot_list = [] for rows,cols in zip(np.where(matrix!=0)[0],np.where(matrix!=0)[1]): plot_list.append([cols,rows,matrix[rows,cols]]) From 8d64b0037ce2f36ab9fadc256378a208a7dac9b9 Mon Sep 17 00:00:00 2001 From: James Krieger Date: Fri, 15 Nov 2024 14:28:23 +0100 Subject: [PATCH 16/16] bug fix chainsHB no ligand --- prody/proteins/interactions.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/prody/proteins/interactions.py b/prody/proteins/interactions.py index 1dba0a7c1..88e796c56 100644 --- a/prody/proteins/interactions.py +++ b/prody/proteins/interactions.py @@ -710,9 +710,11 @@ def calcChHydrogenBonds(atoms, **kwargs): ChainsHBs = [ i for i in HBS_calculations if str(i[2]) != str(i[5]) ] if not ChainsHBs: - ligand_name = list(set(atoms.select('all not protein and not ion').getResnames()))[0] - ChainsHBs = [ ii for ii in HBS_calculations if ii[0][:3] == ligand_name or ii[3][:3] == ligand_name ] - + ligand_sel = atoms.select('all not protein and not ion') + if ligand_sel: + ligand_name = list(set(ligand_sel.getResnames()))[0] + ChainsHBs = [ ii for ii in HBS_calculations if ii[0][:3] == ligand_name or ii[3][:3] == ligand_name ] + return ChainsHBs