Merge branch 'feature/JAL-3187linkedFeatures' into feature/JAL-3251biotypedMappings
[jalview.git] / test / jalview / io / gff / ExonerateHelperTest.java
index ce52ee5..940859c 100644 (file)
@@ -1,3 +1,23 @@
+/*
+ * 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.gff;
 
 import static org.testng.AssertJUnit.assertEquals;
@@ -15,8 +35,9 @@ import jalview.datamodel.Sequence;
 import jalview.datamodel.SequenceDummy;
 import jalview.datamodel.SequenceI;
 import jalview.gui.AlignFrame;
+import jalview.gui.JvOptionPane;
+import jalview.io.DataSourceType;
 import jalview.io.FileLoader;
-import jalview.io.FormatAdapter;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -24,28 +45,37 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 public class ExonerateHelperTest
 {
+
+  @BeforeClass(alwaysRun = true)
+  public void setUpJvOptionPane()
+  {
+    JvOptionPane.setInteractiveMode(false);
+    JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION);
+  }
+
   @Test(groups = "Functional")
   public void testGetMappingType()
   {
     // protein-to-dna:
-    assertSame(MappingType.PeptideToNucleotide,
+    assertSame(MappingType.PeptideToGenome,
             ExonerateHelper
                     .getMappingType("exonerate:protein2genome:local"));
-    assertSame(MappingType.PeptideToNucleotide,
+    assertSame(MappingType.PeptideToGenome,
             ExonerateHelper.getMappingType("exonerate:protein2dna:local"));
 
     // dna-to-dna:
-    assertSame(MappingType.NucleotideToNucleotide,
+    assertSame(MappingType.GenomeToCdna,
             ExonerateHelper.getMappingType("coding2coding"));
-    assertSame(MappingType.NucleotideToNucleotide,
+    assertSame(MappingType.GenomeToCdna,
             ExonerateHelper.getMappingType("coding2genome"));
-    assertSame(MappingType.NucleotideToNucleotide,
+    assertSame(MappingType.GenomeToCdna,
             ExonerateHelper.getMappingType("cdna2genome"));
-    assertSame(MappingType.NucleotideToNucleotide,
+    assertSame(MappingType.GenomeToCdna,
             ExonerateHelper.getMappingType("genome2genome"));
     assertNull(ExonerateHelper.getMappingType("affine:local"));
   }
@@ -238,19 +268,20 @@ public class ExonerateHelperTest
   {
     FileLoader loader = new FileLoader(false);
     AlignFrame af = loader.LoadFileWaitTillLoaded(
-            "examples/testdata/exonerateseqs.fa", FormatAdapter.FILE);
-
+            "examples/testdata/exonerateseqs.fa",
+            DataSourceType.FILE);
+  
     af.loadJalviewDataFile("examples/testdata/exonerateoutput.gff",
-            FormatAdapter.FILE, null, null);
-
+            DataSourceType.FILE, null, null);
+  
     /*
      * verify one mapping to a dummy sequence, one to a real one
      */
-    List<AlignedCodonFrame> mappings = af.getViewport().getAlignment()
-            .getDataset().getCodonFrames();
+    List<AlignedCodonFrame> mappings = af
+            .getViewport().getAlignment().getDataset().getCodonFrames();
     assertEquals(2, mappings.size());
     Iterator<AlignedCodonFrame> iter = mappings.iterator();
-
+  
     // first mapping is to dummy sequence
     AlignedCodonFrame mapping = iter.next();
     Mapping[] mapList = mapping.getProtMappings();
@@ -261,7 +292,7 @@ public class ExonerateHelperTest
     // 143 in protein should map to codon [11270, 11269, 11268] in dna
     int[] mappedRegion = mapList[0].getMap().locateInFrom(143, 143);
     assertArrayEquals(new int[] { 11270, 11268 }, mappedRegion);
-
+  
     // second mapping is to a sequence in the alignment
     mapping = iter.next();
     mapList = mapping.getProtMappings();
@@ -270,23 +301,23 @@ public class ExonerateHelperTest
             .findName("DDB_G0280897");
     assertSame(proteinSeq.getDatasetSequence(), mapList[0].getTo());
     assertEquals(1, mapping.getdnaToProt().length);
-
+  
     // 143 in protein should map to codon [11270, 11269, 11268] in dna
     mappedRegion = mapList[0].getMap().locateInFrom(143, 143);
     assertArrayEquals(new int[] { 11270, 11268 }, mappedRegion);
-
+  
     // 182 in protein should map to codon [11153, 11152, 11151] in dna
     mappedRegion = mapList[0].getMap().locateInFrom(182, 182);
     assertArrayEquals(new int[] { 11153, 11151 }, mappedRegion);
-
+  
     // and the reverse mapping:
     mappedRegion = mapList[0].getMap().locateInTo(11151, 11153);
     assertArrayEquals(new int[] { 182, 182 }, mappedRegion);
-
+  
     // 11150 in dna should _not_ map to protein
     mappedRegion = mapList[0].getMap().locateInTo(11150, 11150);
     assertNull(mappedRegion);
-
+  
     // similarly 183 in protein should _not_ map to dna
     mappedRegion = mapList[0].getMap().locateInFrom(183, 183);
     assertNull(mappedRegion);