JAL-1673 new test to verify transferRESNUMFeatures()
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 2 Sep 2015 10:11:32 +0000 (11:11 +0100)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Wed, 2 Sep 2015 10:11:32 +0000 (11:11 +0100)
test/jalview/io/AnnotatedPDBFileInputTest.java
test/jalview/structure/StructureSelectionManagerTest.java

index b4a8bf6..91e816a 100644 (file)
@@ -11,9 +11,6 @@ import jalview.datamodel.PDBEntry;
 import jalview.datamodel.SequenceFeature;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
-import jalview.gui.Desktop;
-import jalview.structure.StructureMapping;
-import jalview.structure.StructureSelectionManager;
 
 import java.io.File;
 
@@ -28,10 +25,14 @@ public class AnnotatedPDBFileInputTest
 
   AlignmentI al;
 
-  String pdbStr = "examples/1gaq.txt";
-
   String pdbId;
 
+  /**
+   * Ensure 'process secondary structure from PDB and add annotations' are set
+   * in preferences, and load PDB example file 1gaq
+   * 
+   * @throws Exception
+   */
  @BeforeMethod(alwaysRun = true)
   public void setup() throws Exception
   {
@@ -40,7 +41,7 @@ public class AnnotatedPDBFileInputTest
     Cache.applicationProperties.setProperty("ADD_SS_ANN",
             Boolean.TRUE.toString());
     FileLoader loader = new FileLoader(false);
-    AlignFrame af = loader.LoadFileWaitTillLoaded(pdbStr,
+    AlignFrame af = loader.LoadFileWaitTillLoaded("examples/1gaq.txt",
             FormatAdapter.FILE);
     al = af.getViewport().getAlignment();
     pdbId = al.getSequenceAt(0).getDatasetSequence().getAllPDBEntries()
@@ -88,11 +89,6 @@ public class AnnotatedPDBFileInputTest
   @Test(groups ={ "Functional" })
   public void checkPDBSequenceFeatures()
   {
-    StructureSelectionManager ssm = StructureSelectionManager
-            .getStructureSelectionManager(Desktop.instance);
-    StructureMapping[] mappings = ssm.getMapping("1gaq");
-    // suspect we really want to make assertions on sequence features
-    // in these mappings' sequencess
     /*
      * 1GAQ/A
      */
@@ -159,8 +155,7 @@ public class AnnotatedPDBFileInputTest
   @BeforeClass(alwaysRun = true)
   public static void setUpBeforeClass() throws Exception
   {
-    jalview.bin.Jalview.main(new String[]
- { "-props",
+    jalview.bin.Jalview.main(new String[] { "-props",
         "test/jalview/io/testProps.jvprops" });
   }
 
index e4cc336..8e3e086 100644 (file)
@@ -4,6 +4,10 @@ import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertTrue;
 
 import jalview.datamodel.AlignedCodonFrame;
+import jalview.datamodel.Sequence;
+import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceI;
+import jalview.io.FormatAdapter;
 
 import java.util.HashSet;
 import java.util.Set;
@@ -11,6 +15,8 @@ import java.util.Set;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
+import MCview.PDBfile;
+
 public class StructureSelectionManagerTest
 {
   private StructureSelectionManager ssm;
@@ -72,4 +78,46 @@ public class StructureSelectionManagerTest
     assertTrue(ssm.seqmappings.contains(acf2));
     assertTrue(ssm.seqmappings.contains(acf3));
   }
+
+  /**
+   * Verify that RESNUM sequence features are present after creating a PDB
+   * mapping
+   */
+  @Test(groups = { "Functional" })
+  public void testSetMapping_seqFeatures()
+  {
+    SequenceI seq = new Sequence(
+            "1GAQ|B",
+            "ATYNVKLITPEGEVELQVPDDVYILDQAEEDGIDLPYSCRAGSCSSCAGKVVSGSVDQSDQSYLDDGQIADGWVLTCHAYPTSDVVIETHKEEELTGA");
+    StructureSelectionManager sm = new StructureSelectionManager();
+    sm.setProcessSecondaryStructure(true);
+    sm.setAddTempFacAnnot(true);
+    PDBfile pmap = sm.setMapping(true, new SequenceI[] { seq },
+            new String[] { null }, "examples/1gaq.txt",
+            FormatAdapter.FILE);
+    assertTrue(pmap != null);
+
+    assertEquals(3, pmap.getSeqs().size());
+    assertEquals("1GAQ|A", pmap.getSeqs().get(0).getName());
+    assertEquals("1GAQ|B", pmap.getSeqs().get(1).getName());
+    assertEquals("1GAQ|C", pmap.getSeqs().get(2).getName());
+
+    /*
+     * Verify a RESNUM sequence feature in the PDBfile sequence
+     */
+    SequenceFeature sf = pmap.getSeqs().get(0).getSequenceFeatures()[0];
+    assertEquals("RESNUM", sf.getType());
+    assertEquals("1gaq", sf.getFeatureGroup());
+    assertEquals("GLU:  19  1gaqA", sf.getDescription());
+
+    /*
+     * Verify a RESNUM sequence feature in the StructureSelectionManager mapped
+     * sequence
+     */
+    StructureMapping map = sm.getMapping("examples/1gaq.txt")[0];
+    sf = map.sequence.getSequenceFeatures()[0];
+    assertEquals("RESNUM", sf.getType());
+    assertEquals("1gaq", sf.getFeatureGroup());
+    assertEquals("ALA:   1  1gaqB", sf.getDescription());
+  }
 }