@@ -59,9 +59,11 @@ public void testRead30File() throws IOException{
5959 assertEquals ("structure does not contain the right number of nucleotides " , shouldNr ,nrNuc );
6060
6161 List <EntityInfo > compounds = s .getEntityInfos ();
62- // from Biojava 4.2 on we are creating compounds whenever an entity is found to be without an assigned compound in the file
62+ // from Biojava 5.0 on we are creating entities whenever an entity is found to be without an assigned compound
63+ // in the file, for polymer entities, nonpolymer entities and water entities.
64+ // For this file: 1 dna polymeric entity, 1 MG nonpolymeric entity, 1 water
6365 // see issues https://github.com/biojava/biojava/issues/305 and https://github.com/biojava/biojava/pull/394
64- assertEquals (2 , compounds .size ());
66+ assertEquals (3 , compounds .size ());
6567 EntityInfo mol = compounds .get (0 );
6668 assertTrue (mol .getDescription ().startsWith ("DNA" ));
6769
@@ -84,9 +86,11 @@ public void testRead23File() throws IOException{
8486 assertEquals ("structure does not contain the right number of nucleotides " , shouldNr , nrNuc );
8587
8688 List <EntityInfo > compounds = s .getEntityInfos ();
87- // from Biojava 4.2 on we are creating compounds whenever an entity is found to be without an assigned compound in the file
89+ // from Biojava 5.0 on we are creating entities whenever an entity is found to be without an assigned compound
90+ // in the file, for polymer entities, nonpolymer entities and water entities.
91+ // For this entry: we have 1 dna polymeric entity, 1 FLO nonpoly entity, 1 MO6 nonpoly entity, 1 water entity
8892 // see issues https://github.com/biojava/biojava/issues/305 and https://github.com/biojava/biojava/pull/394
89- assertEquals (2 , compounds .size ());
93+ assertEquals (4 , compounds .size ());
9094 EntityInfo mol = compounds .get (0 );
9195
9296 assertTrue (mol .getDescription ().startsWith ("DNA" ));
@@ -145,16 +149,25 @@ public void testIsLegacyFormat_pdb_COMPND_handler() throws IOException{
145149 Structure s = getStructure ("/3mk3.pdb" );
146150
147151 List <EntityInfo > compounds = s .getEntityInfos ();
148- assertTrue (compounds .size () == 1 );
152+ // we are doing heuristics to find missing compounds not specified in header
153+ // thus here we have the one specified in header plus a SO4 nonpolymer entity
154+ assertEquals (2 , compounds .size ());
149155 EntityInfo mol = compounds .get (0 );
150156 assertTrue (mol .getDescription ().equals ("6,7-DIMETHYL-8-RIBITYLLUMAZINE SYNTHASE" ));
151157 assertEquals (60 , mol .getChainIds ().size ());
152158 assertEquals (60 , mol .getChains ().size ());
153- assertTrue (mol .getChainIds ().contains ("S" ));
154- assertTrue (mol .getChainIds ().contains ("T" ));
155- assertTrue (mol .getChainIds ().contains ("U" ));
156- assertTrue (mol .getChainIds ().contains ("g" ));
157- assertTrue (mol .getChainIds ().contains ("h" ));
158- assertTrue (mol .getChainIds ().contains ("i" ));
159+ assertTrue (isChainNameInEntity (mol ,"S" ));
160+ assertTrue (isChainNameInEntity (mol ,"T" ));
161+ assertTrue (isChainNameInEntity (mol ,"U" ));
162+ assertTrue (isChainNameInEntity (mol ,"g" ));
163+ assertTrue (isChainNameInEntity (mol ,"h" ));
164+ assertTrue (isChainNameInEntity (mol ,"i" ));
165+ }
166+
167+ private boolean isChainNameInEntity (EntityInfo e , String chainName ) {
168+ for (Chain c :e .getChains ()) {
169+ if (c .getName ().equals (chainName )) return true ;
170+ }
171+ return false ;
159172 }
160173}
0 commit comments