Skip to content

Deuterium atoms set atom.element to "" #980

Closed

Description

@mathuin

For historical reasons I'm sure, the PDB files that contain deuterium atoms have "D" in the element column.

When Bio.PDB.Atom._assign_element() at

biopython/Bio/PDB/Atom.py

Lines 73 to 100 in 5045a7a

def _assign_element(self, element):
"""Tries to guess element from atom name if not recognised."""
if not element or element.capitalize() not in IUPACData.atom_weights:
# Inorganic elements have their name shifted left by one position
# (is a convention in PDB, but not part of the standard).
# isdigit() check on last two characters to avoid mis-assignment of
# hydrogens atoms (GLN HE21 for example)
if self.fullname[0].isalpha() and not self.fullname[2:].isdigit():
putative_element = self.name.strip()
else:
# Hs may have digit in [0]
if self.name[0].isdigit():
putative_element = self.name[1]
else:
putative_element = self.name[0]
if putative_element.capitalize() in IUPACData.atom_weights:
msg = "Used element %r for Atom (name=%s) with given element %r" \
% (putative_element, self.name, element)
element = putative_element
else:
msg = "Could not assign element %r for Atom (name=%s) with given element %r" \
% (putative_element, self.name, element)
element = ""
warnings.warn(msg, PDBConstructionWarning)
return element
receives "D" as an argument, it fails the putative_element.capitalize() in IUPACData.atom_weights test and so atom.element is set to "".

I expected atom.element to be set to "D" or to "H", not to "".

If "D" is acceptable, then line 90 should be changed to check for the "D" value or presence in the IUPACData.atom_weights structure.

If "H" is preferred, an explicit test for "D" (and setting to "H") just before line 90 would work fine.

The only reason I haven't submitted a pull request is that I don't know which way is preferred.

Tell me, and I'll write it! Thanks!

Activity

  1. JoaoRodrigues commented on Nov 5, 2016

    @JoaoRodrigues
    Member

    Hi Jack,

    I'd just add the element to the IUPACData.atom_weights dictionary. Can you
    show an example of deuterium? How is the naming? Follows regular Hs
    convention?

    Thanks for this!

    João

    2016-11-04 17:15 GMT-07:00 Jack Twilley [email protected]:

    For historical reasons I'm sure, the PDB files that contain deuterium
    atoms have "D" in the element column.

    When Bio.PDB.Atom._assign_element() at https://github.com/biopython/
    biopython/blob/5045a7a3e86d5b32e0eaab941ab35daac86c59f8/Bio/PDB/Atom.py#
    L73-L100 receives "D" as an argument, it fails the putative_element.capitalize()
    in IUPACData.atom_weights test and so atom.element is set to "".

    I expected atom.element to be set to "D" or to "H", not to "".

    If "D" is acceptable, then line 90 should be changed to check for the "D"
    value or presence in the IUPACData.atom_weights structure.

    If "H" is preferred, an explicit test for "D" (and setting to "H") just
    before line 90 would work fine.

    The only reason I haven't submitted a pull request is that I don't know
    which way is preferred.

    Tell me, and I'll write it! Thanks!

    —
    You are receiving this because you are subscribed to this thread.
    Reply to this email directly, view it on GitHub
    #980, or mute the thread
    https://github.com/notifications/unsubscribe-auth/AAOfELHKJR9CSTInqpBnxBgM9-QtwagNks5q68qWgaJpZM4KqGsM
    .

  2. peterjc commented on Nov 5, 2016

    @peterjc
    Member

    According to wikipedia, IUPAC does use D as deuterium so that should be fine...

  3. mathuin commented on Nov 7, 2016

    @mathuin
    ContributorAuthor

    5AE0 A/204 is a disordered HIS residue with a number of deuterium atoms.

    Here are the ones from the A altloc:

    ATOM    998  D  AHIS A 204      51.975 -10.411 157.129  0.51 11.38           D  
    ATOM    999  DA AHIS A 204      54.505 -11.036 157.739  0.51 16.69           D  
    ATOM   1000  DB2AHIS A 204      53.389  -8.970 156.146  0.51 17.82           D  
    ATOM   1001  DB3AHIS A 204      54.920  -8.918 156.555  0.51 17.82           D  
    ATOM   1002  DD1AHIS A 204      52.980  -9.936 153.949  0.51 34.62           D  
    ATOM   1003  DD2AHIS A 204      56.305 -11.286 155.446  0.51 23.83           D  
    ATOM   1004  DE1AHIS A 204      53.919 -11.317 152.283  0.51 31.17           D  
    

    There might be others out there, I only noticed this one because it triggered a corner case in some code I'm working on. The naming appears to follow the same convention as H.

  4. JoaoRodrigues commented on Nov 7, 2016

    @JoaoRodrigues
    Member

    Thanks @peterjc.

    @mathuin I also found another issue with the element assignment column #981 that needs some more attention.. Adding "D" to the element list will fix this issue though, I believe. Could you test it?

  5. mathuin commented on Nov 9, 2016

    @mathuin
    ContributorAuthor

    I'm definitely interested in testing -- is it enough to just toss 'D': 2.014, into atom_weights or is there something else you'd like me to do?

  6. mathuin commented on Nov 9, 2016

    @mathuin
    ContributorAuthor

    Okay, I have made that change, and everything looks fine to me.

  7. JoaoRodrigues commented on Nov 9, 2016

    @JoaoRodrigues
    Member
  8. mathuin commented on Nov 9, 2016

    @mathuin
    ContributorAuthor

    When I run my code using BioPython with that additional line, atom.element is set correctly for me on those atoms. I don't use the actual weights, so pick a better number! :-)

  9. mathuin commented on Jan 23, 2017

    @mathuin
    ContributorAuthor

    @JoaoRodrigues @peterjc what else is required for this issue to be resolved?

  10. JoaoRodrigues commented on Jan 24, 2017

    @JoaoRodrigues
    Member

    @mathuin I did find an issue with assigning elements to HETATM, but I haven't found a proper solution at all. If this works for your Ds in your test case, could you add a line to one of the PDB files in our test suite and an appropriate test (Tests/test_PDB.py) just to cover this case?

  11. mathuin commented on Jan 24, 2017

    @mathuin
    ContributorAuthor

    After examining the tests in Tests/test_PDB.py, I found an Atom_Element class with a test_AtomElement which checked the first residue from PDB/a_structure.pdb. I modified line 13 in a_structure.pdb to look like this:

    HETATM 5 DA PCA A 1 0.869 1.560 14.229 1.00 23.27 D

    I added a line to test_AtomElement to check for this new element:
    self.assertEqual('D', atoms[4].element) # Deuterium

    I made the requisite changes to test_details to support the new values as well.

    With an unchanged atom_weights, the tests fail as follows:

    $ python run_tests.py test_PDB
    Python version: 2.7.12 (default, Nov 19 2016, 06:48:10) 
    [GCC 5.4.0 20160609]
    Operating system: posix linux2
    test_PDB ... FAIL
    ======================================================================
    FAIL: test_1_warnings (test_PDB.A_ExceptionTest)
    Check warnings: Parse a flawed PDB file in permissive mode.
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/jmt/git/biopython/Tests/test_PDB.py", line 61, in test_1_warnings
        self.assertEqual(len(w), 14)
    AssertionError: 15 != 14
    
    ======================================================================
    FAIL: test_2_strict (test_PDB.A_ExceptionTest)
    Check error: Parse a flawed PDB file in strict mode.
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/jmt/git/biopython/Tests/test_PDB.py", line 88, in test_2_strict
        self.assertEqual(len(w), 4, w)
    AssertionError: [<warnings.WarningMessage object at 0x7f0a5cec5dd0>, <warnings.WarningMessage object at 0x7f0a5cf8d4d0>, <warnings.WarningMessage object at 0x7f0a5cf8d5d0>, <warnings.WarningMessage object at 0x7f0a5cf8d6d0>, <warnings.WarningMessage object at 0x7f0a5cf8d750>]
    
    ======================================================================
    FAIL: test_AtomElement (test_PDB.Atom_Element)
    Atom Element
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/jmt/git/biopython/Tests/test_PDB.py", line 938, in test_AtomElement
        self.assertEqual('D', atoms[4].element)  # Deuterium
    AssertionError: 'D' != ''
    
    ======================================================================
    FAIL: test_details (test_PDB.ParseTest)
    Verify details of the parsed example PDB file.
    ----------------------------------------------------------------------
    Traceback (most recent call last):
      File "/home/jmt/git/biopython/Tests/test_PDB.py", line 430, in test_details
        "N C C C D O C O CA")
    AssertionError: 'N C C C  O C O CA' != 'N C C C D O C O CA'
    
    ----------------------------------------------------------------------
    Ran 1 test in 1.937 seconds
    
    FAILED (failures = 1)
    

    When I add deuterium to atom_weights, the tests pass.

    If that's acceptable, I can make a pull request referencing this issue. If you'd prefer something different, let me know!

  12. JoaoRodrigues commented on Jan 26, 2017

    @JoaoRodrigues
    Member

    I think that's good! Thanks, please do make the pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions