Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InSty: NameError: name 'Interactions' is not defined #1932

Open
TangYiChing opened this issue Aug 7, 2024 · 9 comments
Open

InSty: NameError: name 'Interactions' is not defined #1932

TangYiChing opened this issue Aug 7, 2024 · 9 comments
Assignees

Comments

@TangYiChing
Copy link

Which module is this Interactions class dependent on?

interactions = Interactions()
http://www.bahargroup.org/prody/tutorials/insty_tutorial/insty_tutorial.pdf

@karolamik13
Copy link
Contributor

Did you install the developed version of ProDy (from GitHub: https://github.com/prody/ProDy)?
If not, you may not have this module, and that is why you have this error. InSty module works independently (it needs only ProDy).

On the GitHub version, everything is working:
Python 3.9.15 (main, Nov 24 2022, 14:31:59)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.7.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from prody import *
In [2]: PDBfile = '5kqm_all_sci.pdb'
In [3]: coords = parsePDB(PDBfile)
@> 19321 atoms and 1 coordinate set(s) were parsed in 0.17s.
In [4]: atoms = coords.select('protein')
In [5]: interactions = Interactions()
In [6]: all_interactions = interactions.calcProteinInteractions(atoms)
@> Calculating interations.
@> Calculating hydrogen bonds.
@> DONOR (res chid atom) <---> ACCEPTOR (res chid atom) Distance Angle
@> ARG101 P NH1_1516 <---> ASP98 P OD1_1463 2.0 33.1
@> HIS72 P NE2_1042 <---> ASN15 P OD1_165 2.6 34.8
@> GLN143 P NE2_2192 <---> GLU139 P OE2_2126 2.7 9.2
@> HIS66 P NE2_957 <---> GLU139 P OE1_2125 2.7 6.4
@> ARG40 P N_561 <---> LYS6 P O_37 2.7 17.1
@> ARG58 P N_813 <---> ASP56 P OD1_788 2.7 30.0
@> ALA45 P N_634 <---> ARG75 P O_1097 2.8 35.1
@> ASN53 P ND2_747 <---> GLU50 P OE1_708 2.8 18.2
@> ALA74 P N_1064 <---> ASN53 P O_751 2.8 21.3
@> ASP56 P N_780 <---> ILE16 P O_189 2.8 27.0
@> LYS110 P NZ_1667 <---> THR84 P O_1240 2.8 38.2
@> LEU116 P N_1758 <---> CYS90 P O_1342 2.8 15.0
@> SER103 P N_1546 <---> LEU99 P O_1485 2.8 29.1
@> ASN134 P N_2045 <---> ASP137 P OD2_2091 2.8 22.6
...

@karolamik13 karolamik13 self-assigned this Aug 7, 2024
@jamesmkrieger
Copy link
Contributor

Yes and in the released versions it is not. We have the same issue in #1924

@karolamik13
Copy link
Contributor

karolamik13 commented Aug 7, 2024

In case someone does not know what to do:
(1) Go to Github: https://github.com/prody/ProDy and download this version of ProDy. You can do it via git or just using download.
(2) cd ProDy (unpack if needed)
(3) Use the following commands:

python setup.py build
python setup.py install

Done. Enjoy using InSty and WatFinder.

@TangYiChing
Copy link
Author

Thank you. Re-install the developed version works for me.
However, I encountered some issue with the use case "addHydrogen":

from prody import *
from pylab import *
import matplotlib
ion()

fetchPDB('5kqm', compressed=False)
PDBname = '5kqm.pdb'
addMissingAtoms(PDBname, method='pdbfixer')
atoms = parsePDB('addH_'+str(PDBname)).select('protein')
interactions = Interactions('addH_5qkm')
all_interactions = interactions.calcProteinInteractions(atoms)

@> PDB file is found in working directory (5kqm.pdb).
@> Hydrogens were added to the structure. New structure is saved as addH_5kqm.pdb.
@> 2800 atoms and 1 coordinate set(s) were parsed in 0.02s.
@> Calculating interations.
AttributeError Traceback (most recent call last)
Cell In[30], line 1
----> 1 all_interactions = interactions.calcProteinInteractions(atoms)

File /tools/ProDy/prody/proteins/interactions.py:2731, in Interactions.calcProteinInteractions(self, atoms, **kwargs)
2727 raise TypeError('coords must be an object '
2728 'with getCoords method')
2730 LOGGER.info('Calculating interations.')
-> 2731 HBs_calculations = calcHydrogenBonds(atoms.protein, **kwargs) #1 in scoring
2732 SBs_calculations = calcSaltBridges(atoms.protein, **kwargs) #2
2733 SameChargeResidues = calcRepulsiveIonicBonding(atoms.protein, **kwargs) #3

File /tools/ProDy/prody/proteins/interactions.py:434, in calcHydrogenBonds(atoms, **kwargs)
431 if atoms.hydrogen == None or atoms.hydrogen.numAtoms() < 10:
432 LOGGER.info("Provide structure with hydrogens or install Openbabel to add missing hydrogens using addMissingAtoms(pdb_name) first.")
--> 434 contacts = findNeighbors(atoms.heavy, distA)
435 short_contacts = cleanNumbers(contacts)
436 pairList = [] # list with Donor-Hydrogen-Acceptor(indices)-distance-Angle

File /tools/ProDy/prody/measure/contacts.py:306, in findNeighbors(atoms, radius, atoms2, unitcell, seqsep)
302 def findNeighbors(atoms, radius, atoms2=None, unitcell=None, seqsep=None):
303 """Returns list of neighbors that are within radius of each other and the
304 distance between them. See :func:iterNeighbors for more details."""
--> 306 return list(iterNeighbors(atoms, radius, atoms2, unitcell, seqsep))

File /tools/ProDy/prody/measure/contacts.py:217, in iterNeighbors(atoms, radius, atoms2, unitcell, seqsep)
215 yield (i, j, r)
216 else:
--> 217 for (i, j), r in zip(*kdtree(radius)):
218 a1 = _dict.get(i)
219 if a1 is None:

File /tools/ProDy/prody/kdtree/kdtree.py:179, in KDTree.call(self, radius, center)
177 self.search(radius, center)
178 if self._oncall == 'both':
--> 179 return self.getIndices(), self.getDistances()
180 elif self._oncall == 'dist':
181 return self.getDistances()

File /tools/ProDy/prody/kdtree/kdtree.py:259, in KDTree.getIndices(self)
255 def getIndices(self):
256 """Returns array of indices for points or pairs, depending on the type
257 of the most recent search."""
--> 259 if self.getCount():
260 if self._unitcell is None:
261 if self._neighbors is None:

File /tools/ProDy/prody/kdtree/kdtree.py:291, in KDTree.getCount(self)
289 return self._kdtree.get_count()
290 else:
--> 291 return self._kdtree.neighbor_get_count()
292 else:
293 return len(self._pbcdict)

AttributeError: 'C KDTree' object has no attribute 'neighbor_get_count'

@karolamik13
Copy link
Contributor

That's interesting.
That is what I am receiving with this code (see below).
Hydrogens are added and atoms are parsed successfully. For some reason, interactions failed.
@jamesmkrieger any idea?

In [1]: from prody import *
...: from pylab import *
...: import matplotlib
...: ion()
...:
...: fetchPDB('5kqm', compressed=False)
...: PDBname = '5kqm.pdb'
...: addMissingAtoms(PDBname, method='pdbfixer')
...: atoms = parsePDB('addH_'+str(PDBname)).select('protein')
...: interactions = Interactions('addH_5qkm')
...: all_interactions = interactions.calcProteinInteractions(atoms)

@> Connecting wwPDB FTP server RCSB PDB (USA).
@> 5kqm downloaded (5kqm.pdb)
@> PDB download via FTP completed (1 downloaded, 0 failed).
@> Hydrogens were added to the structure. New structure is saved as addH_5kqm.pdb.
@> 2800 atoms and 1 coordinate set(s) were parsed in 0.03s.
@> Calculating interations.
@> Calculating hydrogen bonds.
@> DONOR (res chid atom) <---> ACCEPTOR (res chid atom) Distance Angle
@> ASN130 A N_2045 <---> ASP133 A OD2_2093 2.8 39.9
@> ARG23 A N_340 <---> GLU19 A O_284 2.8 36.9
@> ARG93 A N_1431 <---> GLU89 A O_1377 2.9 39.8
@> LYS60 A N_900 <---> GLN56 A O_849 2.9 12.8
@> ASN96 A N_1486 <---> LEU92 A O_1417 2.9 23.4
@> GLU150 A N_2360 <---> ARG146 A O_2292 3.0 33.0
@> ILE31 A N_478 <---> VAL26 A O_410 3.0 28.6
@> VAL142 A N_2225 <---> TYR138 A O_2164 3.0 37.2
@> ASN49 A N_738 <---> GLU46 A O_702 3.0 28.7
@> LEU25 A N_386 <---> VAL21 A O_309 3.0 27.0
@> SER43 A N_658 <---> LEU9 A O_136 3.0 27.1
@> VAL26 A N_405 <---> PHE22 A O_325 3.0 22.4
@> GLN101 A N_1571 <---> LYS98 A O_1529 3.0 38.6
@> CYS58 A N_872 <---> ARG54 A O_818 3.1 24.4
...

@jamesmkrieger
Copy link
Contributor

Try this

python setup.py build_ext --inplace --force
pip install -Ue .

@jamesmkrieger
Copy link
Contributor

Building the C extensions should fix kdtree and using inplace and -e should make sure python can find them

@TangYiChing
Copy link
Author

problem solved!

@jamesmkrieger
Copy link
Contributor

Great. Let’s keep it open so other people see it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants