Skip to content

Conversation

Copy link

Copilot AI commented Dec 15, 2025

calcHydrophobic() crashes with AttributeError: Selection object has no attribute 'strip' when a Selection object is passed to .select() instead of a string.

Root Cause

Line 1508 contains a nested .select() call that passes a Selection object as an argument:

sele2_filter = sele2_filter.select(sele2.select('all and not (resid '+str(i[0])+' and chain '+i[1]+')'))

The inner sele2.select() returns a Selection object, but .select() expects a string argument.

Changes

  • Remove redundant inner .select() call on line 1508 to pass the string directly, matching the pattern on line 1505:
sele2_filter = sele2_filter.select('all and not (resid '+str(i[0])+' and chain '+i[1]+')')
  • Add *.npy to .gitignore to prevent test artifacts from being committed

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • files.rcsb.org
    • Triggering command: /usr/bin/python3 python3 (dns block)
  • ftp.wwpdb.org
    • Triggering command: /usr/bin/python3 python3 (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>AttributeError: Selection object has no attribute strip and 'strip' is not a valid selection string</issue_title>
<issue_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.

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)                       prody/ProDy#4
   4298 Pi_cation = calcPiCation(atoms.protein, **kwargs)                           prody/ProDy#5
-> 4299 Hydroph_calculations = calcHydrophobic(atoms.protein, **kwargs)             prody/ProDy#6
   4300 Disulfide_Bonds = calcDisulfideBonds(atoms.protein, **kwargs)               prody/ProDy#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 ...


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits December 15, 2025 20:21
…call

Co-authored-by: AnthonyBogetti <34397256+AnthonyBogetti@users.noreply.github.com>
Co-authored-by: AnthonyBogetti <34397256+AnthonyBogetti@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix AttributeError in protein interaction calculation Fix AttributeError in calcHydrophobic from nested select() call Dec 15, 2025
Copilot AI requested a review from AnthonyBogetti December 15, 2025 20:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: Selection object has no attribute strip and 'strip' is not a valid selection string

2 participants