-
Notifications
You must be signed in to change notification settings - Fork 172
Description
Description of the bug.
When I tried to calculate the protein interaction for the pdb file 4i77 in the following way, I encountered the following error: "AttributeError: Selection object has no attribute strip and 'strip' is not a valid selection string."
After checking the logs, I found that there seems to be a duplicate select operation, and the select method is expected to receive a string type. I suspect this might be an accidental coding mistake, and removing the redundant select step allows the process to complete normally. Since this is my first time using ProDy, I am not very sure if this modification is correct.
ProDy/prody/proteins/interactions.py
Line 1508 in 79c6641
| sele2_filter = sele2_filter.select(sele2.select('all and not (resid '+str(i[0])+' and chain '+i[1]+')')) |
Do you have any error messages or logs?
@> Number of detected cation-pi interactions: 5.
@> Please provide hpb.so file to obtain additional data.
@> Calculating hydrophobic interactions.
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[9], line 1
----> 1 result = ia.calcProteinInteractions(atoms.select('protein'))
File ~/Documents/project/protools/.venv/lib/python3.10/site-packages/prody/proteins/interactions.py:4299, in Interactions.calcProteinInteractions(self, atoms, **kwargs)
4297 Pi_stacking = calcPiStacking(atoms.protein, **kwargs) #4
4298 Pi_cation = calcPiCation(atoms.protein, **kwargs) #5
-> 4299 Hydroph_calculations = calcHydrophobic(atoms.protein, **kwargs) #6
4300 Disulfide_Bonds = calcDisulfideBonds(atoms.protein, **kwargs) #7
4301 AllInteractions = [HBs_calculations, SBs_calculations, SameChargeResidues, Pi_stacking,
4302 Pi_cation, Hydroph_calculations, Disulfide_Bonds]
File ~/Documents/project/protools/.venv/lib/python3.10/site-packages/prody/proteins/interactions.py:1508, in calcHydrophobic(atoms, **kwargs)
1505 sele2_filter = sele2_filter.select('all and not (resname TYR PHE TRP or resid '+str(i[0])+' and chain '+i[1]+')')
1506 elif sele1_name[0] not in aromatic and i in sele2_nr:
1507 # don't include same residue interactions but don't worry about double counting pi stacking
-> 1508 sele2_filter = sele2_filter.select('all and not (resid '+str(i[0])+' and chain '+i[1]+')')
1510 if sele2_filter != None:
1511 listOfAtomToCompare = cleanNumbers(findNeighbors(sele1, distA, sele2_filter))
File ~/Documents/project/protools/.venv/lib/python3.10/site-packages/prody/atomic/atomic.py:244, in Atomic.select(self, selstr, **kwargs)
240 def select(self, selstr, **kwargs):
241 """Returns atoms matching *selstr* criteria. See :mod:`~.select` module
242 documentation for details and usage examples."""
--> 244 return SELECT.select(self, selstr, **kwargs)
File ~/Documents/project/protools/.venv/lib/python3.10/site-packages/prody/atomic/select.py:895, in Select.select(self, atoms, selstr, **kwargs)
892 self._replace = False
894 self._selstr = selstr
--> 895 indices = self.getIndices(atoms, selstr, **kwargs)
897 self._kwargs = None
899 if len(indices) == 0:
File ~/Documents/project/protools/.venv/lib/python3.10/site-packages/prody/atomic/select.py:937, in Select.getIndices(self, atoms, selstr, **kwargs)
931 def getIndices(self, atoms, selstr, **kwargs):
932 """Returns indices of atoms matching *selstr*. Indices correspond to
933 the order in *atoms* argument. If *atoms* is a subset of atoms, they
934 should not be used for indexing the corresponding :class:`.AtomGroup`
935 instance."""
--> 937 ss = selstr.strip()
938 if (len(ss.split()) == 1 and ss.isalnum() and ss not in MACROS):
939 self._evalAtoms(atoms)
File ~/Documents/project/protools/.venv/lib/python3.10/site-packages/prody/atomic/atomic.py:136, in Atomic.__getattribute__(self, name)
133 selstr = ' '.join(items)
134 return SELECT.select(self, selstr)
--> 136 raise AttributeError('{0} object has no attribute `{1}` and {2} '
137 'is not a valid selection string'
138 .format(self.__class__.__name__, name,
139 repr(selstr)))
AttributeError: Selection object has no attribute `strip` and 'strip' is not a valid selection string
What is your setup?
First test at My MacBook
- MacOS 15.7.1
- python: 3.10.17
Then test at My Ubuntu Server
- Ubuntu 22.04 LTS
- python: 3.10.16
How did you install ProDy?
Installed by uv add prody with version 2.6.1.
What did your code look like?
import prody
prody.addMissingAtoms('data/4i77.pdb', method='pdbfixer')
atoms = prody.parsePDB('data/addH_4i77.pdb')
ia = prody.Interactions()
result = ia.calcProteinInteractions(atoms.select('protein'))Anything else?
No