You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have recently noticed that some structural bioinformatics programs (structure refinement or modelling) generate PDB files where the Element column is missing. The element column is the last column, where the periodic table element of the Atom is indicated.
Parsing these files with BioJava currently does not allow the calculation of structural alignments or symmetry (and any other analysis using C-alpha atoms), because to extract the C-alpha atoms of a structure the name (CA) and element (C) of the Atoms is checked (in StructureTools.getRepresentativeAtoms()).
The Element column is not completely redundant, because in case of a modified aminoacid with calcium bound to it, the name CA alone does not distinguish the calcium from the C-alpha carbon and the element column is needed to do so.
On the other hand, we could print a warning when parsing such models and guess and fill the Element column from the Atom names (at least for the Atoms in aminoacids), in order to support the incomplete files.
Question: is there any drawback in guessing and filling the Element of the Atoms? Can we use the Chemical Components for that?
The Element column is not completely redundant, because in case of a modified aminoacid with calcium bound to it, the name CA alone does not distinguish the calcium from the C-alpha carbon and the element column is needed to do so.
@gcapitani noticed that the atom name column in PDB files if shifted one position to the left for calcium, with respect to C-alpha atoms, so the Element column is in this case redundant.
Thus, it is possible to identify while parsing if a CA Atom is a carbon or a calcium.
Guessing the elements for standard aminoacids should be fine, but we need to print warnings. You don't even need to look at the column where "CA" is, standard aminoacids don't have calcium so it's safe to always assign a "C". I'd say for any other molecule we shouldn't try guessing, instead fail with a nice error message "Element is missing for line ..."
Actually using the chemical component dictionary (CCD) for this would provide a general solution: if the residue's 3-letter code is that of a valid chem comp and the element is not present we can read it by looking up the atom name in the CCD. That would work for any kind of molecule.
Great! I think that the optimal solution then is to complete the Element field of Atoms from the Chemical Component information when parsing and print a warning explaining the PDB format error and the bugs it may cause.
BioJava used to include whitespace in atom names, so that " CA " (carbon) was distinct from "CA " (calcium). However, this broke in the transition to mmcif, which trims whitespace from fields. I suppose it could be used as a hint for guessing, but it shouldn't be stored in data structures.
I have been looking at the code and the Element field is parsed in PDBFileParser with the following code, which already handles missing Element column in PDB files:
// Parse element from the element field. If this field is// missing (i.e. misformatted PDB file), then parse the// name from the atom name.Elementelement = Element.R;
if ( line.length() > 77 ) {
// parse element from element fieldtry {
element = Element.valueOfIgnoreCase(line.substring (76, 78).trim());
} catch (IllegalArgumentExceptione){}
} else {
// parse the name from the atom nameStringelementSymbol = null;
// for atom names with 4 characters, the element is// at the first position, example HG23 in Valineif (fullname.trim().length() == 4) {
elementSymbol = fullname.substring(0, 1);
} elseif ( fullname.trim().length() > 1){
elementSymbol = fullname.substring(0, 2).trim();
}
try {
if (elementSymbol!=null)
element = Element.valueOfIgnoreCase(elementSymbol);
} catch (IllegalArgumentExceptione){
logger.warn("Element {} was not recognised. Assigning generic element R to it",
elementSymbol);
}
}
atom.setElement(element);
There are three things to improve:
There is a bug where Atom names of a single letter are ignored an Element.R is always assigned (the bug is in the conditional fullname.trim().length() > 1, where it should be >=1).
The Atom names have to be trimmed before taking the substrings, otherwise spaces in the beginning make a difference (like CA and CA that Spencer described).
If the Element column is present, but empty (spaces), the Element assigned is always Element.R.
I would rewrite this handling, because I think that using the Chemical Component Dictionary information is a better solution. I will create a pull request with the change.
Activity
lafita commentedon Jul 15, 2016
@gcapitani noticed that the atom name column in PDB files if shifted one position to the left for calcium, with respect to C-alpha atoms, so the
Elementcolumn is in this case redundant.Thus, it is possible to identify while parsing if a CA Atom is a carbon or a calcium.
josemduarte commentedon Jul 15, 2016
Guessing the elements for standard aminoacids should be fine, but we need to print warnings. You don't even need to look at the column where "CA" is, standard aminoacids don't have calcium so it's safe to always assign a "C". I'd say for any other molecule we shouldn't try guessing, instead fail with a nice error message "Element is missing for line ..."
josemduarte commentedon Jul 15, 2016
This relates to #305
josemduarte commentedon Jul 15, 2016
Actually using the chemical component dictionary (CCD) for this would provide a general solution: if the residue's 3-letter code is that of a valid chem comp and the element is not present we can read it by looking up the atom name in the CCD. That would work for any kind of molecule.
lafita commentedon Jul 15, 2016
Great! I think that the optimal solution then is to complete the
Elementfield ofAtomsfrom theChemical Componentinformation when parsing and print a warning explaining the PDB format error and the bugs it may cause.sbliven commentedon Jul 18, 2016
BioJava used to include whitespace in atom names, so that
" CA "(carbon) was distinct from"CA "(calcium). However, this broke in the transition to mmcif, which trims whitespace from fields. I suppose it could be used as a hint for guessing, but it shouldn't be stored in data structures.lafita commentedon Jul 27, 2016
I have been looking at the code and the
Elementfield is parsed inPDBFileParserwith the following code, which already handles missingElementcolumn in PDB files:There are three things to improve:
Atomnames of a single letter are ignored anElement.Ris always assigned (the bug is in the conditionalfullname.trim().length() > 1, where it should be>=1).Atomnames have to be trimmed before taking the substrings, otherwise spaces in the beginning make a difference (likeCAandCAthat Spencer described).Elementcolumn is present, but empty (spaces), the Element assigned is alwaysElement.R.I would rewrite this handling, because I think that using the
Chemical Component Dictionaryinformation is a better solution. I will create a pull request with the change.Handle missing element column and create test
Handle an empty Element column in a PDB file
Merge pull request #540 from lafita/fix537
Fixing issue introduced in PR biojava#537