2424
2525import java .io .IOException ;
2626import java .io .InputStream ;
27+ import java .util .ArrayList ;
28+ import java .util .List ;
2729import java .util .zip .GZIPInputStream ;
2830
2931import org .biojava .nbio .structure .align .util .AtomCache ;
3032import org .biojava .nbio .structure .io .FileParsingParameters ;
3133import org .biojava .nbio .structure .io .PDBFileParser ;
34+ import org .junit .Ignore ;
3235import org .junit .Test ;
3336
34- public class TestCompoundResIndexMapping {
37+ /**
38+ * Various tests for functionality in {@link EntityInfo} and {@link org.biojava.nbio.structure.io.EntityFinder}
39+ * @author Jose Duarte
40+ */
41+ public class TestEntityResIndexMapping {
3542
3643 private static final String PATH_TO_TEST_FILES = "/org/biojava/nbio/structure/io/" ;
3744
@@ -67,7 +74,6 @@ public void test1SMT() throws IOException, StructureException {
6774 params .setAlignSeqRes (true );
6875 cache .setFileParsingParams (params );
6976
70-
7177 StructureIO .setAtomCache (cache );
7278
7379 cache .setUseMmCif (false );
@@ -78,7 +84,11 @@ public void test1SMT() throws IOException, StructureException {
7884 assertEquals ("First residue in 1smtA " +chainA .getAtomGroup (0 ).toString ()+" should map to 24 in SEQRES" ,24 ,i );
7985 Chain chainB = s .getPolyChainByPDB ("B" );
8086 i = chainB .getEntityInfo ().getAlignedResIndex (chainB .getAtomGroup (0 ),chainB );
81- assertEquals ("First residue in 1smtB " +chainA .getAtomGroup (0 ).toString ()+" should map to 20 in SEQRES" ,20 ,i );
87+ assertEquals ("First residue in 1smtB " +chainB .getAtomGroup (0 ).toString ()+" should map to 20 in SEQRES" ,20 ,i );
88+
89+ // group with seqres index 19 is observed in chain B but not in chain A, we should still get the index back from getAlignedResIndex
90+ i = chainA .getEntityInfo ().getAlignedResIndex (chainA .getSeqResGroup (19 ),chainA );
91+ assertEquals ("Seqres residue 20 in 1smtA " +chainA .getSeqResGroup (19 ).toString ()+" should map to 20 in SEQRES" ,20 ,i );
8292
8393 checkAllResidues (s );
8494 }
@@ -97,17 +107,25 @@ private void checkAllResidues(Structure s) {
97107 }
98108
99109 // This doesn't work yet, since for raw files without a SEQRES, the seqres groups are not populated. Instead
100- // in that case Compound .getAlignedResIndex() returns residue numbers as given (without insertion codes) and
110+ // in that case EntityInfo .getAlignedResIndex() returns residue numbers as given (without insertion codes) and
101111 // thus in general residues will not be correctly aligned between different chains of same entity. This breaks
102112 // cases like 3ddo (with no SEQRES records) where residue numbering is different in every chain of the one entity.
103113 // see https://github.com/eppic-team/eppic/issues/39
104- //@Test
114+ @ Ignore
115+ @ Test
105116 public void test3ddoRawNoSeqres () throws IOException , StructureException {
106117
107118 // 3ddo has 6 chains in 1 entity, all of them with different residue numbering (chain A is 1000+, chain B 2000+ ...)
108119 Structure s = getStructure ("3ddo_raw_noseqres.pdb.gz" , true );
109120
110- assertEquals (1 ,s .getEntityInfos ().size ());
121+ List <EntityInfo > polyEntities = new ArrayList <>();
122+ for (EntityInfo entityInfo : s .getEntityInfos ()) {
123+ if (entityInfo .getType () == EntityType .POLYMER ) {
124+ polyEntities .add (entityInfo );
125+ }
126+ }
127+
128+ assertEquals (1 , polyEntities .size ());
111129
112130 Chain chainA = s .getPolyChainByPDB ("A" );
113131 Chain chainB = s .getPolyChainByPDB ("B" );
@@ -134,10 +152,17 @@ public void test3ddoRawNoSeqres() throws IOException, StructureException {
134152
135153
136154
137- // this should work either with or without setAlignSeqRes, since the mapping happens in CompoundFinder
155+ // this should work either with or without setAlignSeqRes, since the mapping happens in EntityFinder
138156 s = getStructure ("3ddo_raw_noseqres.pdb.gz" , false );
139157
140- assertEquals (1 ,s .getEntityInfos ().size ());
158+ polyEntities = new ArrayList <>();
159+ for (EntityInfo entityInfo : s .getEntityInfos ()) {
160+ if (entityInfo .getType () == EntityType .POLYMER ) {
161+ polyEntities .add (entityInfo );
162+ }
163+ }
164+
165+ assertEquals (1 , polyEntities .size ());
141166
142167 chainA = s .getPolyChainByPDB ("A" );
143168 chainB = s .getPolyChainByPDB ("B" );
0 commit comments