Repository navigation
Closed
Description
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
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 |
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!
Metadata
Metadata
Assignees
Labels
No labels
Activity
JoaoRodrigues commentedon Nov 5, 2016
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]:
peterjc commentedon Nov 5, 2016
According to wikipedia, IUPAC does use D as deuterium so that should be fine...
mathuin commentedon Nov 7, 2016
5AE0 A/204 is a disordered HIS residue with a number of deuterium atoms.
Here are the ones from the A altloc:
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.
JoaoRodrigues commentedon Nov 7, 2016
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?
mathuin commentedon Nov 9, 2016
I'm definitely interested in testing -- is it enough to just toss
'D': 2.014,intoatom_weightsor is there something else you'd like me to do?mathuin commentedon Nov 9, 2016
Okay, I have made that change, and everything looks fine to me.
JoaoRodrigues commentedon Nov 9, 2016
mathuin commentedon Nov 9, 2016
When I run my code using BioPython with that additional line,
atom.elementis set correctly for me on those atoms. I don't use the actual weights, so pick a better number! :-)mathuin commentedon Jan 23, 2017
@JoaoRodrigues @peterjc what else is required for this issue to be resolved?
JoaoRodrigues commentedon Jan 24, 2017
@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?
mathuin commentedon Jan 24, 2017
After examining the tests in
Tests/test_PDB.py, I found anAtom_Elementclass with atest_AtomElementwhich checked the first residue fromPDB/a_structure.pdb. I modified line 13 ina_structure.pdbto look like this:HETATM 5 DA PCA A 1 0.869 1.560 14.229 1.00 23.27 DI added a line to
test_AtomElementto check for this new element:self.assertEqual('D', atoms[4].element) # DeuteriumI made the requisite changes to
test_detailsto support the new values as well.With an unchanged
atom_weights, the tests fail as follows: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!
JoaoRodrigues commentedon Jan 26, 2017
I think that's good! Thanks, please do make the pull request!