Skip to content

extract res if only 1 in extendAtoms#1963

Merged
jamesmkrieger merged 1 commit intoprody:mainfrom
jamesmkrieger:extend_extract
Sep 30, 2024
Merged

extract res if only 1 in extendAtoms#1963
jamesmkrieger merged 1 commit intoprody:mainfrom
jamesmkrieger:extend_extract

Conversation

@jamesmkrieger
Copy link
Copy Markdown
Contributor

fixes #1962

for some reason HierView getResidue gets atoms from multiple residues for GLN 357 and it's fixed in the list comprehension of _getResidue so we only have one entry in the list. So, it throws an error that there's a list when really we can extract it, which we now do.

@karolamik13
Copy link
Copy Markdown
Contributor

Could you provide the PDB code and what to check?
It would be easier for me to test changes. Although the code looks ok.

@jamesmkrieger
Copy link
Copy Markdown
Contributor Author

I'll forward you the pdb file with the problem. The code and error should be the following

Python 3.9.19 (main, May  6 2024, 19:43:03) 
Type 'copyright', 'credits' or 'license' for more information
IPython 8.15.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from prody import *

In [2]: fex = parsePDB('comp_min.pdb')
@> 136109 atoms and 1 coordinate set(s) were parsed in 1.56s.

In [3]: fex_bb = fex.select('protein name CA C N O or resname CY1 name CA C N O')

In [4]: fex_ca = fex.select('protein name CA or resname CY1 name CA')

In [5]: y = extendAtoms(fex_ca, fex_bb)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[5], line 1
----> 1 y = extendAtoms(fex_ca, fex_bb)

File ~/software/scipion3/software/em/prody-github/ProDy/prody/atomic/functions.py:349, in extendAtoms(nodes, atoms, is3d)
    347     raise ValueError('atoms must contain a residue for all atoms')
    348 if isinstance(res, list):
--> 349     raise ValueError('not enough data to get a single residue for all atoms')
    351 res_atom_indices = res._getIndices()
    352 if not fastin(res, residues):

ValueError: not enough data to get a single residue for all atoms

@karolamik13 karolamik13 self-requested a review September 27, 2024 20:38
Copy link
Copy Markdown
Contributor

@karolamik13 karolamik13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old code:
In [1]: from prody import *

In [2]: fex = parsePDB('comp_min.pdb')
@> 136109 atoms and 1 coordinate set(s) were parsed in 2.23s.

In [3]: fex_bb = fex.select('protein name CA C N O or resname CY1 name CA C N O')

In [4]: fex_ca = fex.select('protein name CA or resname CY1 name CA')

In [5]: y = extendAtoms(fex_ca, fex_bb)

ValueError Traceback (most recent call last)
in
----> 1 y = extendAtoms(fex_ca, fex_bb)

~/anaconda3/lib/python3.9/site-packages/ProDy-2.5.0-py3.9-linux-x86_64.egg/prody/atomic/functions.py in extendAtoms(nodes, atoms, is3d)
347 raise ValueError('atoms must contain a residue for all atoms')
348 if isinstance(res, list):
--> 349 raise ValueError('not enough data to get a single residue for all atoms')
350
351 res_atom_indices = res._getIndices()

ValueError: not enough data to get a single residue for all atoms

New code:
In [1]: from prody import *

In [2]: x = parsePDB('comp_min.pdb')
@> 136109 atoms and 1 coordinate set(s) were parsed in 2.24s.

In [3]: x_bb = x.select('protein name CA C N O or resname CY1 name CA C N O')

In [4]: x_ca = x.select('protein name CA or resname CY1 name CA')

In [5]: y = extendAtoms(x_ca, x_bb)

In [6]: y
Out[7]:
(array([ 0, 0, 0, ..., 680, 680, 680]),
<AtomMap: comp_min from comp_min (2724 atoms)>)

@jamesmkrieger jamesmkrieger merged commit 7bcf0e3 into prody:main Sep 30, 2024
@jamesmkrieger jamesmkrieger deleted the extend_extract branch September 30, 2024 10:15
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

Successfully merging this pull request may close these issues.

ExtendModel Nodes and Atoms Incompatible

2 participants