JAL-653 Gff tests moved back in to FeaturesFileTest
authorgmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 23 Nov 2015 10:16:13 +0000 (10:16 +0000)
committergmungoc <g.m.carstairs@dundee.ac.uk>
Mon, 23 Nov 2015 10:16:13 +0000 (10:16 +0000)
test/jalview/io/FeaturesFileTest.java
test/jalview/io/GffFileTest.java [deleted file]

index 1592392..ed388a5 100644 (file)
@@ -23,10 +23,14 @@ package jalview.io;
 import static org.testng.AssertJUnit.assertEquals;
 import static org.testng.AssertJUnit.assertFalse;
 import static org.testng.AssertJUnit.assertNotNull;
+import static org.testng.AssertJUnit.assertNull;
 import static org.testng.AssertJUnit.assertTrue;
 
+import jalview.datamodel.Alignment;
 import jalview.datamodel.AlignmentI;
+import jalview.datamodel.SequenceDummy;
 import jalview.datamodel.SequenceFeature;
+import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
 import jalview.schemes.AnnotationColourGradient;
 import jalview.schemes.GraduatedColor;
@@ -41,6 +45,10 @@ import org.testng.annotations.Test;
 public class FeaturesFileTest
 {
 
+  private static String exonerateSeqs = "examples/testdata/exonerateseqs.fa",
+          exonerateOutput = "examples/testdata/exonerateoutput.gff",
+          simpleGffFile = "examples/testdata/simpleGff3.gff";
+
   @Test(groups = { "Functional" })
   public void testParse() throws Exception
   {
@@ -319,4 +327,118 @@ public class FeaturesFileTest
     assertEquals(87, sf.end);
     assertEquals("METALLIC", sf.type);
   }
+
+  private void checkDatasetfromSimpleGff3(AlignmentI dataset)
+  {
+    assertEquals("no sequences extracted from GFF3 file", 2,
+            dataset.getHeight());
+  
+    SequenceI seq1 = dataset.findName("seq1"), seq2 = dataset
+            .findName("seq2");
+    assertNotNull(seq1);
+    assertNotNull(seq2);
+    assertFalse(
+            "Failed to replace dummy seq1 with real sequence",
+            seq1 instanceof SequenceDummy
+                    && ((SequenceDummy) seq1).isDummy());
+    assertFalse(
+            "Failed to replace dummy seq2 with real sequence",
+            seq2 instanceof SequenceDummy
+                    && ((SequenceDummy) seq2).isDummy());
+    String placeholderseq = new SequenceDummy("foo").getSequenceAsString();
+    assertFalse("dummy replacement buggy for seq1",
+            placeholderseq.equals(seq1.getSequenceAsString()));
+    assertFalse("dummy replacement buggy for seq2",
+            placeholderseq.equals(seq2.getSequenceAsString()));
+    assertNotNull("No features added to seq1", seq1.getSequenceFeatures());
+    assertEquals("Wrong number of features", 3,
+            seq1.getSequenceFeatures().length);
+    assertNull(seq2.getSequenceFeatures());
+    assertEquals(
+            "Wrong number of features",
+            0,
+            seq2.getSequenceFeatures() == null ? 0 : seq2
+                    .getSequenceFeatures().length);
+    assertTrue(
+            "Expected at least one CDNA/Protein mapping for seq1",
+            dataset.getCodonFrame(seq1) != null
+                    && dataset.getCodonFrame(seq1).size() > 0);
+  
+  }
+
+  @Test(groups = { "Functional" })
+  public void readGff3File() throws IOException
+  {
+    FeaturesFile gffreader = new FeaturesFile(true, simpleGffFile,
+            FormatAdapter.FILE);
+    Alignment dataset = new Alignment(gffreader.getSeqsAsArray());
+    gffreader.addProperties(dataset);
+    checkDatasetfromSimpleGff3(dataset);
+  }
+
+  @Test(groups = { "Functional" })
+  public void simpleGff3FileClass() throws IOException
+  {
+    AlignmentI dataset = new Alignment(new SequenceI[] {});
+    FeaturesFile ffile = new FeaturesFile(simpleGffFile,
+            FormatAdapter.FILE);
+  
+    boolean parseResult = ffile.parse(dataset, null, false, false);
+    assertTrue("return result should be true", parseResult);
+    checkDatasetfromSimpleGff3(dataset);
+  }
+
+  @Test(groups = { "Functional" })
+  public void simpleGff3FileIdentify()
+  {
+    assertEquals("Didn't recognise file correctly.",
+            IdentifyFile.FeaturesFile,
+            new IdentifyFile().identify(simpleGffFile, FormatAdapter.FILE));
+  }
+
+  @Test(groups = { "Functional" })
+  public void simpleGff3FileLoader() throws IOException
+  {
+    AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
+            simpleGffFile, FormatAdapter.FILE);
+    assertTrue(
+            "Didn't read the alignment into an alignframe from Gff3 File",
+            af != null);
+    // FIXME codon mappings are on the alignment but not on the dataset
+    checkDatasetfromSimpleGff3(af.getViewport().getAlignment()/* .getDataset() */);
+  }
+
+  @Test(groups = { "Functional" })
+  public void simpleGff3RelaxedIdMatching() throws IOException
+  {
+    AlignmentI dataset = new Alignment(new SequenceI[] {});
+    FeaturesFile ffile = new FeaturesFile(simpleGffFile,
+            FormatAdapter.FILE);
+  
+    boolean parseResult = ffile.parse(dataset, null, false, true);
+    assertTrue("return result (relaxedID matching) should be true",
+            parseResult);
+    checkDatasetfromSimpleGff3(dataset);
+  }
+
+  @Test(groups = { "Functional" })
+  public void testExonerateImport()
+  {
+    // exonerate does not tag sequences after features, so we have a more
+    // conventional annotation import test here
+  
+    FileLoader loader = new FileLoader(false);
+  
+    AlignFrame af = loader.LoadFileWaitTillLoaded(exonerateSeqs,
+            FormatAdapter.FILE);
+  
+    assertEquals("Unexpected number of DNA protein associations", 0, af
+            .getViewport().getAlignment().getCodonFrames().size());
+  
+    af.loadJalviewDataFile(exonerateOutput, FormatAdapter.FILE, null, null);
+  
+    assertTrue("Expected at least one DNA protein association", 0 != af
+            .getViewport().getAlignment().getDataset().getCodonFrames()
+            .size());
+  }
 }
diff --git a/test/jalview/io/GffFileTest.java b/test/jalview/io/GffFileTest.java
deleted file mode 100644 (file)
index 8e587b1..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
- * Copyright (C) $$Year-Rel$$ The Jalview Authors
- * 
- * This file is part of Jalview.
- * 
- * Jalview is free software: you can redistribute it and/or
- * modify it under the terms of the GNU General Public License 
- * as published by the Free Software Foundation, either version 3
- * of the License, or (at your option) any later version.
- *  
- * Jalview is distributed in the hope that it will be useful, but 
- * WITHOUT ANY WARRANTY; without even the implied warranty 
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
- * PURPOSE.  See the GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with Jalview.  If not, see <http://www.gnu.org/licenses/>.
- * The Jalview Authors are detailed in the 'AUTHORS' file.
- */
-package jalview.io;
-
-import static org.testng.AssertJUnit.assertEquals;
-import static org.testng.AssertJUnit.assertFalse;
-import static org.testng.AssertJUnit.assertNotNull;
-import static org.testng.AssertJUnit.assertNull;
-import static org.testng.AssertJUnit.assertTrue;
-
-import jalview.datamodel.Alignment;
-import jalview.datamodel.AlignmentI;
-import jalview.datamodel.SequenceDummy;
-import jalview.datamodel.SequenceI;
-import jalview.gui.AlignFrame;
-
-import java.io.IOException;
-
-import org.testng.annotations.Test;
-
-public class GffFileTest
-{
-
-  private static String exonerateSeqs = "examples/testdata/exonerateseqs.fa",
-          exonerateOutput = "examples/testdata/exonerateoutput.gff",
-          simpleGffFile = "examples/testdata/simpleGff3.gff";
-
-  @Test(groups = { "Functional" })
-  public void testExonerateImport()
-  {
-    // exonerate does not tag sequences after features, so we have a more
-    // conventional annotation import test here
-
-    FileLoader loader = new FileLoader(false);
-
-    AlignFrame af = loader.LoadFileWaitTillLoaded(exonerateSeqs,
-            FormatAdapter.FILE);
-
-    assertEquals("Unexpected number of DNA protein associations", 0, af
-            .getViewport().getAlignment().getCodonFrames().size());
-
-    af.loadJalviewDataFile(exonerateOutput, FormatAdapter.FILE, null, null);
-
-    assertTrue("Expected at least one DNA protein association", 0 != af
-            .getViewport().getAlignment().getDataset().getCodonFrames()
-            .size());
-  }
-
-  @Test(groups = { "Functional" })
-  public void simpleGff3FileIdentify()
-  {
-    assertEquals("Didn't recognise file correctly.",
-            IdentifyFile.FeaturesFile,
-            new IdentifyFile().identify(simpleGffFile, FormatAdapter.FILE));
-  }
-
-  @Test(groups = { "Functional" })
-  public void simpleGff3FileClass() throws IOException
-  {
-    AlignmentI dataset = new Alignment(new SequenceI[] {});
-    FeaturesFile ffile = new FeaturesFile(simpleGffFile,
-            FormatAdapter.FILE);
-
-    boolean parseResult = ffile.parse(dataset, null, false, false);
-    assertTrue("return result should be true", parseResult);
-    checkDatasetfromSimpleGff3(dataset);
-  }
-
-  @Test(groups = { "Functional" })
-  public void simpleGff3FileLoader() throws IOException
-  {
-    AlignFrame af = new FileLoader(false).LoadFileWaitTillLoaded(
-            simpleGffFile, FormatAdapter.FILE);
-    assertTrue(
-            "Didn't read the alignment into an alignframe from Gff3 File",
-            af != null);
-    // FIXME codon mappings are on the alignment but not on the dataset
-    checkDatasetfromSimpleGff3(af.getViewport().getAlignment()/* .getDataset() */);
-  }
-
-  @Test(groups = { "Functional" })
-  public void simpleGff3RelaxedIdMatching() throws IOException
-  {
-    AlignmentI dataset = new Alignment(new SequenceI[] {});
-    FeaturesFile ffile = new FeaturesFile(simpleGffFile,
-            FormatAdapter.FILE);
-
-    boolean parseResult = ffile.parse(dataset, null, false, true);
-    assertTrue("return result (relaxedID matching) should be true",
-            parseResult);
-    checkDatasetfromSimpleGff3(dataset);
-  }
-
-  @Test(groups = { "Functional" })
-  public void readGff3File() throws IOException
-  {
-    FeaturesFile gffreader = new FeaturesFile(true, simpleGffFile,
-            FormatAdapter.FILE);
-    Alignment dataset = new Alignment(gffreader.getSeqsAsArray());
-    gffreader.addProperties(dataset);
-    checkDatasetfromSimpleGff3(dataset);
-  }
-
-  private void checkDatasetfromSimpleGff3(AlignmentI dataset)
-  {
-    assertEquals("no sequences extracted from GFF3 file", 2,
-            dataset.getHeight());
-
-    SequenceI seq1 = dataset.findName("seq1"), seq2 = dataset
-            .findName("seq2");
-    assertNotNull(seq1);
-    assertNotNull(seq2);
-    assertFalse(
-            "Failed to replace dummy seq1 with real sequence",
-            seq1 instanceof SequenceDummy
-                    && ((SequenceDummy) seq1).isDummy());
-    assertFalse(
-            "Failed to replace dummy seq2 with real sequence",
-            seq2 instanceof SequenceDummy
-                    && ((SequenceDummy) seq2).isDummy());
-    String placeholderseq = new SequenceDummy("foo").getSequenceAsString();
-    assertFalse("dummy replacement buggy for seq1",
-            placeholderseq.equals(seq1.getSequenceAsString()));
-    assertFalse("dummy replacement buggy for seq2",
-            placeholderseq.equals(seq2.getSequenceAsString()));
-    assertNotNull("No features added to seq1", seq1.getSequenceFeatures());
-    assertEquals("Wrong number of features", 3,
-            seq1.getSequenceFeatures().length);
-    assertNull(seq2.getSequenceFeatures());
-    assertEquals(
-            "Wrong number of features",
-            0,
-            seq2.getSequenceFeatures() == null ? 0 : seq2
-                    .getSequenceFeatures().length);
-    assertTrue(
-            "Expected at least one CDNA/Protein mapping for seq1",
-            dataset.getCodonFrame(seq1) != null
-                    && dataset.getCodonFrame(seq1).size() > 0);
-
-  }
-}