JAL-1270 Fixed anntatedPDBFileInputTest and updated implementation for testDeriveSequ...
authortcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 17 May 2016 11:11:06 +0000 (12:11 +0100)
committertcofoegbu <tcnofoegbu@dundee.ac.uk>
Tue, 17 May 2016 11:11:06 +0000 (12:11 +0100)
src/jalview/io/StructureFile.java
test/jalview/datamodel/SequenceTest.java

index 3a7419c..af5a1fa 100644 (file)
@@ -26,6 +26,7 @@ public abstract class StructureFile extends AlignFile
   private String id;
 
   private String dbRefType;
+
   /**
    * set to true to add derived sequence annotations (temp factor read from
    * file, or computed secondary structure) to the alignment
@@ -117,14 +118,11 @@ public abstract class StructureFile extends AlignFile
     sourceDBRef.setSource(DBRefSource.PDB);
     sourceDBRef.setStartRes(pdbSequence.getStart());
     sourceDBRef.setEndRes(pdbSequence.getEnd());
-
-    SequenceI chainseq = pdbSequence.deriveSequence();
-    chainseq.setSourceDBRef(sourceDBRef);
-    chainseq.addPDBId(entry);
-    chainseq.addDBRef(sourceDBRef);
-
+    pdbSequence.setSourceDBRef(sourceDBRef);
+    pdbSequence.addPDBId(entry);
+    pdbSequence.addDBRef(sourceDBRef);
+    SequenceI chainseq = pdbSequence;
     seqs.addElement(chainseq);
-
     AlignmentAnnotation[] chainannot = chainseq.getAnnotation();
 
     if (chainannot != null && visibleChainAnnotation)
@@ -185,8 +183,7 @@ public abstract class StructureFile extends AlignFile
 
   @SuppressWarnings("unchecked")
   protected void replaceAndUpdateChains(List<SequenceI> prot,
-          AlignmentI al,
-          String pep, boolean b)
+          AlignmentI al, String pep, boolean b)
   {
     List<List<? extends Object>> replaced = AlignSeq
             .replaceMatchingSeqsWith(seqs, annotations, prot, al, pep,
@@ -259,8 +256,7 @@ public abstract class StructureFile extends AlignFile
   }
 
   @SuppressWarnings({ "unchecked", "rawtypes" })
-  private void processWithJmolParser(List<SequenceI> prot)
-          throws Exception
+  private void processWithJmolParser(List<SequenceI> prot) throws Exception
   {
     try
     {
@@ -268,13 +264,11 @@ public abstract class StructureFile extends AlignFile
       Class cl = Class.forName("jalview.ext.jmol.JmolParser");
       if (cl != null)
       {
-        final Constructor constructor = cl
-.getConstructor(new Class[] {
+        final Constructor constructor = cl.getConstructor(new Class[] {
             boolean.class, boolean.class, boolean.class, FileParse.class });
         final Object[] args = new Object[] { visibleChainAnnotation,
             predictSecondaryStructure, externalSecondaryStructure,
-            new FileParse(getDataName(),
-                type) };
+            new FileParse(getDataName(), type) };
 
         StructureViewSettings.setShowSeqFeatures(false);
         StructureViewSettings.setVisibleChainAnnotation(false);
index ab11c09..03c4a96 100644 (file)
@@ -30,10 +30,12 @@ import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
 
 import jalview.datamodel.PDBEntry.Type;
 
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
 import java.util.Vector;
 
+import org.testng.Assert;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
@@ -397,7 +399,71 @@ public class SequenceTest
     sq.setStart(3);
     sq.setEnd(4);
 
+    sq.setDescription("Test sequence description..");
+    sq.setVamsasId("TestVamsasId");
+    sq.setSourceDBRef(new DBRefEntry("PDB", "version0", "1TST"));
+
+    sq.addDBRef(new DBRefEntry("PDB", "version1", "1Tst"));
+    sq.addDBRef(new DBRefEntry("PDB", "version2", "2Tst"));
+    sq.addDBRef(new DBRefEntry("PDB", "version3", "3Tst"));
+    sq.addDBRef(new DBRefEntry("PDB", "version4", "4Tst"));
+
+    sq.addPDBId(new PDBEntry("1PDB", "A", Type.PDB, "filePath/test1"));
+    sq.addPDBId(new PDBEntry("1PDB", "B", Type.PDB, "filePath/test1"));
+    sq.addPDBId(new PDBEntry("2PDB", "A", Type.MMCIF, "filePath/test2"));
+    sq.addPDBId(new PDBEntry("2PDB", "B", Type.MMCIF, "filePath/test2"));
+
+    sq.getDatasetSequence().addDBRef(
+            new DBRefEntry("PDB", "version1", "1Tst"));
+    sq.getDatasetSequence().addDBRef(
+            new DBRefEntry("PDB", "version2", "2Tst"));
+    sq.getDatasetSequence().addDBRef(
+            new DBRefEntry("PDB", "version3", "3Tst"));
+    sq.getDatasetSequence().addDBRef(
+            new DBRefEntry("PDB", "version4", "4Tst"));
+
+    sq.getDatasetSequence().addPDBId(
+            new PDBEntry("1PDB", "A", Type.PDB, "filePath/test1"));
+    sq.getDatasetSequence().addPDBId(
+            new PDBEntry("1PDB", "B", Type.PDB, "filePath/test1"));
+    sq.getDatasetSequence().addPDBId(
+            new PDBEntry("2PDB", "A", Type.MMCIF, "filePath/test2"));
+    sq.getDatasetSequence().addPDBId(
+            new PDBEntry("2PDB", "B", Type.MMCIF, "filePath/test2"));
+
+    ArrayList<Annotation> annotsList = new ArrayList<Annotation>();
+    System.out.println(">>>>>> " + sq.getSequenceAsString().length());
+    annotsList.add(new Annotation("A", "A", 'X', 0.1f));
+    annotsList.add(new Annotation("A", "A", 'X', 0.1f));
+    Annotation[] annots = annotsList.toArray(new Annotation[0]);
+    sq.addAlignmentAnnotation(new AlignmentAnnotation("Test annot",
+            "Test annot description", annots));
+    sq.getDatasetSequence().addAlignmentAnnotation(
+            new AlignmentAnnotation("Test annot", "Test annot description",
+                    annots));
+    Assert.assertEquals(sq.getDescription(), "Test sequence description..");
+    Assert.assertEquals(sq.getDBRefs().length, 4);
+    Assert.assertEquals(sq.getAllPDBEntries().size(), 4);
+    Assert.assertNotNull(sq.getAnnotation());
+    Assert.assertEquals(sq.getAnnotation()[0].annotations.length, 2);
+    Assert.assertEquals(sq.getDatasetSequence().getDBRefs().length, 4);
+    Assert.assertEquals(sq.getDatasetSequence().getAllPDBEntries().size(),
+            4);
+    Assert.assertNotNull(sq.getDatasetSequence().getAnnotation());
+
     Sequence derived = (Sequence) sq.deriveSequence();
+
+    Assert.assertEquals(derived.getDescription(),
+            "Test sequence description..");
+    Assert.assertEquals(derived.getDBRefs().length, 4);
+    Assert.assertEquals(derived.getAllPDBEntries().size(), 4);
+    Assert.assertNotNull(derived.getAnnotation());
+    Assert.assertEquals(derived.getAnnotation()[0].annotations.length, 2);
+    Assert.assertEquals(derived.getDatasetSequence().getDBRefs().length, 4);
+    Assert.assertEquals(derived.getDatasetSequence().getAllPDBEntries()
+            .size(), 4);
+    Assert.assertNotNull(derived.getDatasetSequence().getAnnotation());
+
     assertEquals("CD", derived.getSequenceAsString());
     assertSame(sq.getDatasetSequence(), derived.getDatasetSequence());