JAL-2089 patch broken merge to master for Release 2.10.0b1
[jalview.git] / test / MCview / PDBfileTest.java
index 2ac1c6e..2863643 100644 (file)
@@ -1,6 +1,6 @@
 /*
- * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9.0b2)
- * Copyright (C) 2015 The Jalview Authors
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
  * 
  * This file is part of Jalview.
  * 
@@ -26,6 +26,7 @@ import static org.testng.AssertJUnit.assertNull;
 import static org.testng.AssertJUnit.assertSame;
 import static org.testng.AssertJUnit.assertTrue;
 
+import jalview.bin.Cache;
 import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentAnnotation;
 import jalview.datamodel.AlignmentI;
@@ -33,10 +34,12 @@ import jalview.datamodel.PDBEntry;
 import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceI;
 import jalview.io.AppletFormatAdapter;
+import jalview.structure.StructureImportSettings;
 
 import java.io.IOException;
 import java.util.List;
 
+import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 public class PDBfileTest
@@ -72,17 +75,19 @@ public class PDBfileTest
     PDBfile pf = new PDBfile(false, false, false, "examples/3W5V.pdb",
             AppletFormatAdapter.FILE);
 
-    assertEquals("3W5V", pf.id);
+    assertEquals("3W5V", pf.getId());
     // verify no alignment annotations created
     assertNull(getAlignmentAnnotations(pf));
 
-    assertEquals(4, pf.chains.size());
-    assertEquals("A", pf.chains.get(0).id);
-    assertEquals("B", pf.chains.get(1).id);
-    assertEquals("C", pf.chains.get(2).id);
-    assertEquals("D", pf.chains.get(3).id);
+    assertEquals(4, pf.getChains().size());
+    assertEquals("A", pf.getChains().get(0).id);
+    assertEquals("B", pf.getChains().get(1).id);
+    assertEquals("C", pf.getChains().get(2).id);
+    assertEquals("D", pf.getChains().get(3).id);
+
+    PDBChain chainA = pf.getChains().get(0);
+    SequenceI seqA = pf.getSeqs().get(0);
 
-    PDBChain chainA = pf.chains.get(0);
     assertEquals(0, chainA.seqstart); // not set
     assertEquals(0, chainA.seqend); // not set
     assertEquals(18, chainA.sequence.getStart());
@@ -91,27 +96,27 @@ public class PDBfileTest
     assertTrue(chainA.sequence.getSequenceAsString().endsWith("WNVEVY"));
     assertEquals("3W5V|A", chainA.sequence.getName());
     assertNull(chainA.sequence.getAnnotation());
-    assertEquals(1, chainA.sequence.getAllPDBEntries().size());
-    PDBEntry pdb = chainA.sequence.getAllPDBEntries().get(0);
+    assertEquals(1, seqA.getAllPDBEntries().size());
+    PDBEntry pdb = seqA.getAllPDBEntries().get(0);
     assertEquals("A", pdb.getChainCode());
     assertEquals("PDB", pdb.getType());
     assertEquals("3W5V", pdb.getId());
 
-    PDBChain chainB = pf.chains.get(1);
+    PDBChain chainB = pf.getChains().get(1);
     assertEquals(1, chainB.sequence.getStart());
     assertEquals(96, chainB.sequence.getEnd());
     assertTrue(chainB.sequence.getSequenceAsString().startsWith("ATYNVK"));
     assertTrue(chainB.sequence.getSequenceAsString().endsWith("KEEELT"));
     assertEquals("3W5V|B", chainB.sequence.getName());
 
-    PDBChain chainC = pf.chains.get(2);
+    PDBChain chainC = pf.getChains().get(2);
     assertEquals(18, chainC.sequence.getStart());
     assertEquals(314, chainC.sequence.getEnd());
     assertTrue(chainC.sequence.getSequenceAsString().startsWith("KCSKKQEE"));
     assertTrue(chainC.sequence.getSequenceAsString().endsWith("WNVEVY"));
     assertEquals("3W5V|C", chainC.sequence.getName());
 
-    PDBChain chainD = pf.chains.get(3);
+    PDBChain chainD = pf.getChains().get(3);
     assertEquals(1, chainD.sequence.getStart());
     assertEquals(96, chainD.sequence.getEnd());
     assertTrue(chainD.sequence.getSequenceAsString().startsWith("ATYNVK"));
@@ -215,7 +220,7 @@ public class PDBfileTest
      * no sequence annotations created - tempFactor annotation is not added
      * unless the flag to 'addAlignmentAnnotations' is set true
      */
-    for (PDBChain c : pf.chains)
+    for (PDBChain c : pf.getChains())
     {
       assertNull(c.sequence.getAnnotation());
     }
@@ -251,10 +256,10 @@ public class PDBfileTest
     /*
      * PDBFileWithJmol (unlike PDBChain!) leaves PDB id upper case
      */
-    assertEquals("Secondary Structure for 3W5VA", anns[0].description);
-    assertEquals("Secondary Structure for 3W5VB", anns[2].description);
-    assertEquals("Secondary Structure for 3W5VC", anns[4].description);
-    assertEquals("Secondary Structure for 3W5VD", anns[6].description);
+    assertEquals("Secondary Structure for 3w5vA", anns[0].description);
+    assertEquals("Secondary Structure for 3w5vB", anns[2].description);
+    assertEquals("Secondary Structure for 3w5vC", anns[4].description);
+    assertEquals("Secondary Structure for 3w5vD", anns[6].description);
 
     /*
      * Verify SS annotations are linked to respective sequences (chains)
@@ -305,4 +310,19 @@ public class PDBfileTest
     pf.addAnnotations(al);
     return al.getAlignmentAnnotation();
   }
+
+  // @formatter:on
+
+  @BeforeMethod(alwaysRun = true)
+  public void setUp()
+  {
+    Cache.loadProperties("test/jalview/io/testProps.jvprops");
+    Cache.applicationProperties.setProperty("STRUCT_FROM_PDB",
+            Boolean.TRUE.toString());
+    Cache.applicationProperties.setProperty("ADD_TEMPFACT_ANN",
+            Boolean.TRUE.toString());
+    Cache.applicationProperties.setProperty("ADD_SS_ANN",
+            Boolean.TRUE.toString());
+    StructureImportSettings.setDefaultStructureFileFormat("PDB");
+  }
 }