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
Looking at PDB ID 1AAC, residue nr 27, it turns out that some of the side-chain atoms are only listed in the alternate locations for the group, but not in the "main" group. The main group should be as complete as possible and contain a reference to the first occurrence of any atom.
I have just come across this issue (which by the way is causing also issue #48 ) and it seems to be something potentially affecting any piece of code that uses coordinates. By default getAtomArray methods in StructureTools are getting atoms from the "main" group only. In structures with alt locations that gives an incomplete structure, even at the backbone level, e.g. 3piu contains 54 CA (out of ~ 400) in alt locations.
I agree with Andreas: the solution to this should be making sure that the parsers assign all first occurrences of atoms to the "main" or let's call it better "default" group. If someone wants to do something fancy with alt locs then it should still be possible to use getAltLoc methods to choose specific locations.
I just wrote the following unit test and it seems that 3PIU is getting represented correctly. This is because Group.getAtom(name) actually checks altLocs. Need to go back and take a look at 1AAC what is going on there and come up with a unit test that can demonstrate the issue.
try {
Structure structure = StructureIO.getStructure("3PIU");
assertNotNull(structure);
Atom[] ca = StructureTools.getAtomCAArray(structure);
System.out.println(structure.getPdbId() + " has # CA atoms: " + ca.length);
List<Atom> caList = new ArrayList<Atom>();
for ( Chain c: structure.getChains()){
for (Group g: c.getAtomGroups()){
List<Atom> atoms = g.getAtoms();
boolean caInMain = false;
for (Atom a: atoms){
if ( a.getFullName().equals(StructureTools.caAtomName)) {
caList.add(a);
caInMain = true;
break;
}
}
if (! caInMain && g.hasAtom(StructureTools.caAtomName)){
// g.hasAtom checks altLocs
fail("CA is not in main group, but in altLoc");
}
}
}
assertTrue(ca.length == caList.size());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
fail(e.getMessage());
}
Awesome! I've done a very quick test with the ASA calculation code I am writing and it seems it works well with this fix. I'll have to check a few more things, but it seems that this should do it. Thanks!
I'm a little confused by the data model for altlocs. It seems like it is intended that the main group contain all atoms with a altloc column of ' ', the first altloc contain only atoms with 'A' in that column, the second 'B', etc. (Although @josemduarte found that this is not the case currently for 3PUI). Thus, to get all atoms for a particular conformation requires joining the atoms of the parent group with those of one altloc group.
To me this seems like the wrong model. A 'Group' should represent all atoms of a particular residue. Thus, alternative conformation Groups should share common Atom objects between them (with atom.parent() pointing at the 'A' Group) plus include their unique Atoms.
So from my tests all seems fine with default group alt locs.
However we've found a further problem with other alt loc groups. It looks like when you get alt loc group with Group.getAltLocs() the groups are not returning what I would expect, e.g. for 3piu residue 43, there's 2 groups returned:
A 43 MET
N 219
CA A 220
CB A 224
CG A 226
SD A 228
CE A 230
A 43 MET
N 219
CA A 220
CA B 221
CB B 225
CG B 227
SD B 229
CE B 231
The first one includes an alt-loc=' ' atom (N) and the second one includes both an alt_loc=' ' (N) plus an alt_loc='A' (CA).
In fact if I modify the TestAltLocs as following, the test fails:
diff --git a/biojava3-structure/src/test/java/org/biojava/bio/structure/TestAltLocs.java b/biojava3-structure/src/test/java/org/biojava/bio/structure/TestAltLocs.java
index 3cdcacd..7f3e790 100644
--- a/biojava3-structure/src/test/java/org/biojava/bio/structure/TestAltLocs.java
+++ b/biojava3-structure/src/test/java/org/biojava/bio/structure/TestAltLocs.java
@@ -246,6 +246,9 @@ public class TestAltLocs extends TestCase {
List<Atom> caList = new ArrayList<Atom>();
for ( Chain c: structure.getChains()){
for (Group g: c.getAtomGroups()){
+
+ ensureAllAtomsSameInsCode(g);
+
List<Atom> atoms = g.getAtoms();
boolean caInMain = false;
for (Atom a: atoms){
I think this is a wrong test. Based on the new assumption the first group can have mixed insertion codes in different atoms, because we want to have all atoms in the group.
The output in my comment above was produced with the following code. I've just re-run it now and I can't reproduce that anymore after Andreas' fix. So everything is fine after all.
for (Chain chain:structure.getChains()) {
for (Group alt:chain.getAtomGroups()) {
List<Group> alllocs = alt.getAltLocs();
alllocs.add(alt);
for(Group res: alllocs) {
if (res.getType().equals(GroupType.HETATM)) continue;
System.out.printf("%1s\t%3s\t%s\n",chain.getChainID(),res.getResidueNumber().toString(),res.getPDBName());
for (Atom atom:res.getAtoms()) {
if (atom.getElement()!=Element.H) {
System.out.println(" "+atom.getName()+"\t"+atom.getAltLoc()+ "\t"+atom.getPDBserial());
}
}
}
}
}
Alright so after all there is another issue with this. The PDB parsing was working properly but not the mmCIF parsing. I've added a test for that in TestAltLocs in this new branch: https://github.com/biojava/biojava/tree/testsissue
Activity
josemduarte commentedon Feb 28, 2014
I have just come across this issue (which by the way is causing also issue #48 ) and it seems to be something potentially affecting any piece of code that uses coordinates. By default getAtomArray methods in StructureTools are getting atoms from the "main" group only. In structures with alt locations that gives an incomplete structure, even at the backbone level, e.g. 3piu contains 54 CA (out of ~ 400) in alt locations.
I agree with Andreas: the solution to this should be making sure that the parsers assign all first occurrences of atoms to the "main" or let's call it better "default" group. If someone wants to do something fancy with alt locs then it should still be possible to use getAltLoc methods to choose specific locations.
andreasprlic commentedon Feb 28, 2014
Hi Jose,
I just wrote the following unit test and it seems that 3PIU is getting represented correctly. This is because Group.getAtom(name) actually checks altLocs. Need to go back and take a look at 1AAC what is going on there and come up with a unit test that can demonstrate the issue.
try {
fixing biojava#76
fixing biojava#76
another patch needed to make sure the fix for #76 works
andreasprlic commentedon Feb 28, 2014
I think I fixed this with these commits.
josemduarte commentedon Feb 28, 2014
Awesome! I've done a very quick test with the ASA calculation code I am writing and it seems it works well with this fix. I'll have to check a few more things, but it seems that this should do it. Thanks!
a couple of more fixes to the junit tests for biojava#76
andreasprlic commentedon Feb 28, 2014
I also added a small improvement that should result in slightly lower memory consumption: all collections within Groups are now trimmed to size.
sbliven commentedon Mar 3, 2014
Does this work with AtomIterator as well?
(Also, we should make
GroupextendIterable<Atom>so we can usefor(Atom a: group))sbliven commentedon Mar 3, 2014
I'm a little confused by the data model for altlocs. It seems like it is intended that the main group contain all atoms with a altloc column of ' ', the first altloc contain only atoms with 'A' in that column, the second 'B', etc. (Although @josemduarte found that this is not the case currently for 3PUI). Thus, to get all atoms for a particular conformation requires joining the atoms of the parent group with those of one altloc group.
To me this seems like the wrong model. A 'Group' should represent all atoms of a particular residue. Thus, alternative conformation Groups should share common Atom objects between them (with
atom.parent()pointing at the 'A' Group) plus include their unique Atoms.josemduarte commentedon Mar 3, 2014
So from my tests all seems fine with default group alt locs.
However we've found a further problem with other alt loc groups. It looks like when you get alt loc group with Group.getAltLocs() the groups are not returning what I would expect, e.g. for 3piu residue 43, there's 2 groups returned:
The first one includes an alt-loc=' ' atom (N) and the second one includes both an alt_loc=' ' (N) plus an alt_loc='A' (CA).
In fact if I modify the TestAltLocs as following, the test fails:
andreasprlic commentedon Mar 7, 2014
I think this is a wrong test. Based on the new assumption the first group can have mixed insertion codes in different atoms, because we want to have all atoms in the group.
josemduarte commentedon Mar 7, 2014
You are absolutely right... that didn't really make sense, sorry about that. So of course what I was trying to do was this:
Which indeed passes without problems. So it looks like the issue can remain closed. I'll add the above in my next pull request.
sbliven commentedon Mar 8, 2014
That might be the wrong test there, but the comment before is with mixed codes in altlocs, which should be disallowed.
If the tests pass, are you getting different output for 3piu residue 43 altlocs?
josemduarte commentedon Mar 10, 2014
The output in my comment above was produced with the following code. I've just re-run it now and I can't reproduce that anymore after Andreas' fix. So everything is fine after all.
sbliven commentedon Mar 10, 2014
Good.
josemduarte commentedon Mar 18, 2014
Alright so after all there is another issue with this. The PDB parsing was working properly but not the mmCIF parsing. I've added a test for that in TestAltLocs in this new branch: https://github.com/biojava/biojava/tree/testsissue
resolving biojava#76 fixing problem when parsing altLocs
Generate correct signature for methods with parameters of Java primit…