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

fix altloc to coordinate sets #1783

Merged
merged 37 commits into from
Nov 5, 2023

Conversation

jamesmkrieger
Copy link
Contributor

Old behaviour:

$ prody select "name CA" 6flr.pdb
@> WARNING failed to parse altloc 'B' at line 1821, could not read coordinates
@> WARNING failed to parse altloc 'B' at line 1829, could not read coordinates
@> WARNING failed to parse altloc 'B' at line 1833, could not read coordinates
@> WARNING failed to parse altloc 'B' at line 1837, could not read coordinates
@> WARNING failed to parse altloc 'B' at line 1841, could not read coordinates
@> WARNING failed to parse altloc 'B' at line 1845, could not read coordinates
@> WARNING failed to parse altloc 'B' at line 10264, could not read coordinates
@> WARNING failed to parse altloc 'B' at line 10272, could not read coordinates
@> WARNING failed to parse altloc 'B' at line 10276, could not read coordinates
@> WARNING failed to parse altloc 'B' at line 10280, could not read coordinates
@> WARNING failed to parse altloc 'B' at line 10284, could not read coordinates
@> WARNING failed to parse altloc 'B' at line 10288, could not read coordinates
@> WARNING failed to parse altloc 'B' at line 10292, could not read coordinates
@> 13 out of 26 altloc 'B' lines were parsed.
@> Altloc 'B' is appended as a coordinate set to atomgroup 6flr.
@> 6073 atoms and 2 coordinate set(s) were parsed in 0.06s.
@> Secondary structures were assigned to 484 residues.
@> Selection 'name CA' matched 741 atoms.
@> Selection is written into: 6flr_selected.pdb

Fixed behaviour:

$ prody select "name CA" 6flr.pdb
@> 6086 atoms and 1 coordinate set(s) were parsed in 0.05s.
@> Secondary structures were assigned to 484 residues.
@> Selection 'name CA' matched 743 atoms.
@> Selection is written into: 6flr_selected.pdb

@jamesmkrieger
Copy link
Contributor Author

jamesmkrieger commented Nov 2, 2023

There's also a pdb writing issue associated with this.

Old behaviour (ATOM line takes next ANISOU value):

ATOM    602  CA AHIS B 234      14.092 -10.803  78.631  0.50 76.86           C  
ANISOU  602  CA AHIS B 234    13327   8826   7048    444   3365   1618       C  
.
.
.
ENDMDL                                                                          
MODEL        2
.
.
.
ATOM    602  CA  HIS B 234    13306.000 -10.729  78.621  0.50 76.86           C  
ANISOU  602  CA  HIS B 234    13327   8826   7048    444   3365   1618       C  

Fixed behaviour:

ATOM    603  CA AHIS B 234      14.092 -10.803  78.631  0.50 76.86           C  
ANISOU  603  CA AHIS B 234    13327   8826   7048    444   3365   1618       C  
ATOM    604  CA BHIS B 234      13.993 -10.729  78.621  0.50 76.83           C  
ANISOU  604  CA BHIS B 234    13306   8825   7058    438   3380   1608       C  

@jamesmkrieger
Copy link
Contributor Author

The problem there was that we were putting ANISOU lines into the dictionary that is fed to _evalAltloc, which only knows how to handle ATOM lines. What it does is makes another coordinate set with coords from another altloc if it exists.

New fixed result:

Python 3.9.18 (main, Sep 11 2023, 13:41:44) 
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]: ag = parsePDB("6flr.pdb", altloc=None)
@> 13 out of 13 altloc 'B' lines were parsed.
@> Altloc 'B' is appended as a coordinate set to atomgroup 6flr.
@> 6073 atoms and 2 coordinate set(s) were parsed in 0.08s.
@> Secondary structures were assigned to 484 residues.

In [3]: ag
Out[3]: <AtomGroup: 6flr (6073 atoms; active #0 of 2 coordsets)>

In [4]: hisB234 = ag.select('resname HIS and chain B and resnum 234')

In [5]: hisB234
Out[5]: <Selection: 'resname HIS and... and resnum 234' from 6flr (10 atoms; active #0 of 2 coordsets)>

In [6]: [(atom.getAltloc(), atom.getName(), atom.getCoords(), atom.getAnisou(), atom.getBeta()) for atom in hisB234.ca]
Out[6]: 
[('A',
  'CA',
  array([ 14.092, -10.803,  78.631]),
  array([1.3306, 0.8825, 0.7058, 0.0438, 0.338 , 0.1608]),
  76.86)]

In [7]: hisB234.setACSIndex(1)

In [8]: [(atom.getAltloc(), atom.getName(), atom.getCoords(), atom.getAnisou(), atom.getBeta()) for atom in hisB234.ca]
Out[8]: 
[('A',
  'CA',
  array([ 13.993, -10.729,  78.621]),
  array([1.3306, 0.8825, 0.7058, 0.0438, 0.338 , 0.1608]),
  76.86)]

In [9]: writePDB('6flr_his_B_234_ca.pdb', hisB234.ca)
Out[9]: '6flr_his_B_234_ca.pdb'

New fixed output:

REMARK Selection '(ca) and (resna...and resnum 234)'
HELIX   21 AC3 HIS B  234  HIS B  234  1                                   1    
MODEL        1
ATOM      1  CA AHIS B 234      14.092 -10.803  78.631  0.50 76.86           C  
ANISOU    1  CA AHIS B 234    13306   8825   7058    438   3380   1608       C  
ENDMDL                                                                          
MODEL        2
ATOM      1  CA  HIS B 234      13.993 -10.729  78.621  0.50 76.86           C  
ANISOU    1  CA  HIS B 234    13306   8825   7058    438   3380   1608       C  
ENDMDL                                                                          
END                                                                             

@jamesmkrieger
Copy link
Contributor Author

We actually need to overhaul the anisou handling to give each coordset a different set of them.

@jamesmkrieger jamesmkrieger marked this pull request as draft November 3, 2023 09:18
@jamesmkrieger jamesmkrieger changed the title fix select app default altloc fix altloc to coordinate sets Nov 3, 2023
@jamesmkrieger
Copy link
Contributor Author

This will also need to be included in mmcif and mmtf parsers

@jamesmkrieger
Copy link
Contributor Author

This will also need to be included in mmcif and mmtf parsers

These don't use _evalAltlocs anyway so probably that's something for another time

@jamesmkrieger
Copy link
Contributor Author

We'll still need tests for this too

@jamesmkrieger jamesmkrieger marked this pull request as ready for review November 3, 2023 17:35
@jamesmkrieger jamesmkrieger marked this pull request as draft November 3, 2023 17:36
@jamesmkrieger jamesmkrieger marked this pull request as ready for review November 5, 2023 14:14
@jamesmkrieger jamesmkrieger merged commit 55a5585 into prody:master Nov 5, 2023
4 checks passed
@jamesmkrieger jamesmkrieger deleted the select_app_altloc branch November 5, 2023 15:30
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.

1 participant