JAL-3438 spotless for 2.11.2.0
[jalview.git] / test / jalview / datamodel / AlignedCodonFrameTest.java
index 337ac1a..3474880 100644 (file)
@@ -83,14 +83,14 @@ public class AlignedCodonFrameTest
     /*
      * DNA seq1 maps to AA seq2
      */
-    assertEquals(aa.getSequenceAt(1), acf.findAlignedSequence(cdna
-            .getSequenceAt(0).getDatasetSequence(), aa));
+    assertEquals(aa.getSequenceAt(1), acf.findAlignedSequence(
+            cdna.getSequenceAt(0).getDatasetSequence(), aa));
     // can also find this from the dna aligned sequence
     assertEquals(aa.getSequenceAt(1),
             acf.findAlignedSequence(cdna.getSequenceAt(0), aa));
 
-    assertEquals(cdna.getSequenceAt(0), acf.findAlignedSequence(aa
-            .getSequenceAt(1).getDatasetSequence(), cdna));
+    assertEquals(cdna.getSequenceAt(0), acf.findAlignedSequence(
+            aa.getSequenceAt(1).getDatasetSequence(), cdna));
   }
 
   /**
@@ -121,11 +121,13 @@ public class AlignedCodonFrameTest
      * Set up the mappings for the exons (upper-case bases)
      * Note residue Q is unmapped
      */
-    MapList map1 = new MapList(new int[] { 11, 13, 15, 15, 17, 18 }, new int[] {
-        3, 4 }, 3, 1);
+    MapList map1 = new MapList(new int[] { 11, 13, 15, 15, 17, 18 },
+            new int[]
+            { 3, 4 }, 3, 1);
     acf.addMap(dna1.getDatasetSequence(), pep1.getDatasetSequence(), map1);
-    MapList map2 = new MapList(new int[] { 20, 21, 23, 24, 26, 27 }, new int[] { 7, 9 },
-            3, 1);
+    MapList map2 = new MapList(new int[] { 20, 21, 23, 24, 26, 27 },
+            new int[]
+            { 7, 9 }, 3, 1);
     acf.addMap(dna2.getDatasetSequence(), pep2.getDatasetSequence(), map2);
 
     /*
@@ -149,7 +151,7 @@ public class AlignedCodonFrameTest
      * No mapping from dna1 to pep2
      */
     assertNull(acf.getMappedRegion(dna1, pep2, 7));
-    
+
     /*
      * get peptide position for codon position
      */
@@ -181,20 +183,17 @@ public class AlignedCodonFrameTest
     /*
      * Set up the mappings for the exons (upper-case bases)
      */
-    MapList map = new MapList(new int[] { 2, 4, 6, 6, 8, 9 }, new int[] {
-        1, 2 }, 3, 1);
+    MapList map = new MapList(new int[] { 2, 4, 6, 6, 8, 9 },
+            new int[]
+            { 1, 2 }, 3, 1);
     acf.addMap(seq1.getDatasetSequence(), aseq1.getDatasetSequence(), map);
 
-    assertEquals(1, acf.getMappedCodons(aseq1.getDatasetSequence(), 1)
-            .size());
-    assertEquals(
-            "[G, T, A]",
-            Arrays.toString(acf.getMappedCodons(aseq1.getDatasetSequence(),
-                    1).get(0)));
-    assertEquals(
-            "[C, T, T]",
-            Arrays.toString(acf.getMappedCodons(aseq1.getDatasetSequence(),
-                    2).get(0)));
+    assertEquals(1,
+            acf.getMappedCodons(aseq1.getDatasetSequence(), 1).size());
+    assertEquals("[G, T, A]", Arrays.toString(
+            acf.getMappedCodons(aseq1.getDatasetSequence(), 1).get(0)));
+    assertEquals("[C, T, T]", Arrays.toString(
+            acf.getMappedCodons(aseq1.getDatasetSequence(), 2).get(0)));
   }
 
   /**
@@ -216,19 +215,20 @@ public class AlignedCodonFrameTest
     /*
      * Set up the mappings for the exons (upper-case bases)
      */
-    MapList map = new MapList(new int[] { 2, 4, 6, 6, 8, 9 }, new int[] {
-        1, 2 }, 3, 1);
+    MapList map = new MapList(new int[] { 2, 4, 6, 6, 8, 9 },
+            new int[]
+            { 1, 2 }, 3, 1);
     acf.addMap(seq1.getDatasetSequence(), aseq1.getDatasetSequence(), map);
     acf.addMap(seq2.getDatasetSequence(), aseq1.getDatasetSequence(), map);
 
-    assertEquals(2, acf.getMappedCodons(aseq1.getDatasetSequence(), 1)
-            .size());
-    List<char[]> codonsForV = acf.getMappedCodons(
-            aseq1.getDatasetSequence(), 1);
+    assertEquals(2,
+            acf.getMappedCodons(aseq1.getDatasetSequence(), 1).size());
+    List<char[]> codonsForV = acf
+            .getMappedCodons(aseq1.getDatasetSequence(), 1);
     assertEquals("[G, T, A]", Arrays.toString(codonsForV.get(0)));
     assertEquals("[G, T, T]", Arrays.toString(codonsForV.get(1)));
-    List<char[]> codonsForL = acf.getMappedCodons(
-            aseq1.getDatasetSequence(), 2);
+    List<char[]> codonsForL = acf
+            .getMappedCodons(aseq1.getDatasetSequence(), 2);
     assertEquals("[C, T, T]", Arrays.toString(codonsForL.get(0)));
     assertEquals("[T, T, A]", Arrays.toString(codonsForL.get(1)));
   }
@@ -250,17 +250,14 @@ public class AlignedCodonFrameTest
      */
     AlignedCodonFrame acf = new AlignedCodonFrame();
     MapList map = new MapList(new int[] { 28, 30, 32, 32, 34, 35 },
-            new int[] { 12, 13 }, 3, 1);
+            new int[]
+            { 12, 13 }, 3, 1);
     acf.addMap(seq1.getDatasetSequence(), aseq1.getDatasetSequence(), map);
 
-    assertEquals(
-            "[G, T, A]",
-            Arrays.toString(acf.getMappedCodons(aseq1.getDatasetSequence(),
-                    12).get(0)));
-    assertEquals(
-            "[C, T, T]",
-            Arrays.toString(acf.getMappedCodons(aseq1.getDatasetSequence(),
-                    13).get(0)));
+    assertEquals("[G, T, A]", Arrays.toString(
+            acf.getMappedCodons(aseq1.getDatasetSequence(), 12).get(0)));
+    assertEquals("[C, T, T]", Arrays.toString(
+            acf.getMappedCodons(aseq1.getDatasetSequence(), 13).get(0)));
   }
 
   @Test(groups = { "Functional" })
@@ -273,13 +270,13 @@ public class AlignedCodonFrameTest
     assertTrue(AlignedCodonFrame.couldRealiseSequence(seq1proxy, seq1, 12,
             17));
     // map to region overlapping sequence is ok
-    assertTrue(AlignedCodonFrame.couldRealiseSequence(seq1proxy, seq1, 5,
-            10));
+    assertTrue(
+            AlignedCodonFrame.couldRealiseSequence(seq1proxy, seq1, 5, 10));
     assertTrue(AlignedCodonFrame.couldRealiseSequence(seq1proxy, seq1, 21,
             26));
     // map to region before sequence is not ok
-    assertFalse(AlignedCodonFrame.couldRealiseSequence(seq1proxy, seq1, 4,
-            9));
+    assertFalse(
+            AlignedCodonFrame.couldRealiseSequence(seq1proxy, seq1, 4, 9));
     // map to region after sequence is not ok
     assertFalse(AlignedCodonFrame.couldRealiseSequence(seq1proxy, seq1, 22,
             27));
@@ -312,7 +309,8 @@ public class AlignedCodonFrameTest
      * a real sequence can't replace a real one
      */
     SequenceI seq1a = new Sequence("Seq1/10-21", "aaacccgggttt");
-    assertFalse(AlignedCodonFrame.couldRealiseSequence(seq1, seq1a, 12, 17));
+    assertFalse(
+            AlignedCodonFrame.couldRealiseSequence(seq1, seq1a, 12, 17));
   }
 
   /**
@@ -434,7 +432,8 @@ public class AlignedCodonFrameTest
      * map Seq1 to all of Seq2 and part of Seq3
      */
     AlignedCodonFrame acf = new AlignedCodonFrame();
-    MapList map = new MapList(new int[] { 1, 12 }, new int[] { 1, 4 }, 3, 1);
+    MapList map = new MapList(new int[] { 1, 12 }, new int[] { 1, 4 }, 3,
+            1);
     acf.addMap(seq1.getDatasetSequence(), seq2.getDatasetSequence(), map);
     map = new MapList(new int[] { 1, 12 }, new int[] { 3, 6 }, 3, 1);
     acf.addMap(seq1.getDatasetSequence(), seq3.getDatasetSequence(), map);
@@ -490,8 +489,9 @@ public class AlignedCodonFrameTest
     aseq1.createDatasetSequence();
 
     AlignedCodonFrame acf = new AlignedCodonFrame();
-    MapList map = new MapList(new int[] { 2, 4, 6, 6, 8, 9 }, new int[] {
-        1, 2 }, 3, 1);
+    MapList map = new MapList(new int[] { 2, 4, 6, 6, 8, 9 },
+            new int[]
+            { 1, 2 }, 3, 1);
     acf.addMap(seq1.getDatasetSequence(), aseq1.getDatasetSequence(), map);
     assertEquals(1, acf.getMappingsFromSequence(seq1).size());
     Mapping before = acf.getMappingsFromSequence(seq1).get(0);
@@ -503,7 +503,7 @@ public class AlignedCodonFrameTest
     assertEquals(1, acf.getMappingsFromSequence(seq1).size());
     assertSame(before, acf.getMappingsFromSequence(seq1).get(0));
   }
-  
+
   @Test(groups = { "Functional" })
   public void testGetCoveringMapping()
   {
@@ -511,53 +511,52 @@ public class AlignedCodonFrameTest
     SequenceI cds = new Sequence("cds/7-15", "ATGGCGGAC");
     cds.setDatasetSequence(dna);
     SequenceI pep = new Sequence("pep", "MAD");
-    
+
     /*
      * with null argument or no mappings
      */
     AlignedCodonFrame acf = new AlignedCodonFrame();
-    assertNull(acf.getCoveringMapping(null,  null));
-    assertNull(acf.getCoveringMapping(dna,  null));
-    assertNull(acf.getCoveringMapping(null,  pep));
-    assertNull(acf.getCoveringMapping(dna,  pep));
+    assertNull(acf.getCoveringMapping(null, null));
+    assertNull(acf.getCoveringMapping(dna, null));
+    assertNull(acf.getCoveringMapping(null, pep));
+    assertNull(acf.getCoveringMapping(dna, pep));
 
     /*
      * with a non-covering mapping e.g. overlapping exon
      */
-    MapList map = new MapList(new int[] { 7, 9 }, new int[] {
-        1, 1 }, 3, 1);
+    MapList map = new MapList(new int[] { 7, 9 }, new int[] { 1, 1 }, 3, 1);
     acf.addMap(dna, pep, map);
-    assertNull(acf.getCoveringMapping(dna,  pep));
-    
+    assertNull(acf.getCoveringMapping(dna, pep));
+
     acf = new AlignedCodonFrame();
-    MapList map2 = new MapList(new int[] { 13, 18 }, new int[] {
-        2, 2 }, 3, 1);
+    MapList map2 = new MapList(new int[] { 13, 18 }, new int[] { 2, 2 }, 3,
+            1);
     acf.addMap(dna, pep, map2);
-    assertNull(acf.getCoveringMapping(dna,  pep));
-    
+    assertNull(acf.getCoveringMapping(dna, pep));
+
     /*
      * with a covering mapping from CDS (dataset) to protein
      */
     acf = new AlignedCodonFrame();
-    MapList map3 = new MapList(new int[] { 7, 15 }, new int[] {
-        1, 3 }, 3, 1);
+    MapList map3 = new MapList(new int[] { 7, 15 }, new int[] { 1, 3 }, 3,
+            1);
     acf.addMap(dna, pep, map3);
-    assertNull(acf.getCoveringMapping(dna,  pep));
-    SequenceToSequenceMapping mapping = acf.getCoveringMapping(cds,  pep);
+    assertNull(acf.getCoveringMapping(dna, pep));
+    SequenceToSequenceMapping mapping = acf.getCoveringMapping(cds, pep);
     assertNotNull(mapping);
-    
+
     /*
      * with a mapping that extends to stop codon
      */
     acf = new AlignedCodonFrame();
-    MapList map4 = new MapList(new int[] { 7, 18 }, new int[] {
-        1, 3 }, 3, 1);
+    MapList map4 = new MapList(new int[] { 7, 18 }, new int[] { 1, 3 }, 3,
+            1);
     acf.addMap(dna, pep, map4);
-    assertNull(acf.getCoveringMapping(dna,  pep));
-    assertNull(acf.getCoveringMapping(cds,  pep));
+    assertNull(acf.getCoveringMapping(dna, pep));
+    assertNull(acf.getCoveringMapping(cds, pep));
     SequenceI cds2 = new Sequence("cds/7-18", "ATGGCGGACtaa");
     cds2.setDatasetSequence(dna);
-    mapping = acf.getCoveringMapping(cds2,  pep);
+    mapping = acf.getCoveringMapping(cds2, pep);
     assertNotNull(mapping);
   }
 
@@ -572,12 +571,12 @@ public class AlignedCodonFrameTest
     dna1.createDatasetSequence();
     final Sequence dna2 = new Sequence("Seq2/20-28", "-TA-gG-Gg-CG-a");
     dna2.createDatasetSequence();
-  
+
     final Sequence pep1 = new Sequence("Seq1/3-4", "-P-R");
     pep1.createDatasetSequence();
     final Sequence pep2 = new Sequence("Seq2/7-9", "-LY-Q");
     pep2.createDatasetSequence();
-  
+
     /*
      * First with no mappings
      */
@@ -585,24 +584,26 @@ public class AlignedCodonFrameTest
     SearchResults sr = new SearchResults();
     acf.markMappedRegion(dna1, 12, sr);
     assertTrue(sr.isEmpty());
-  
+
     /*
      * Set up the mappings for the exons (upper-case bases)
      * Note residue Q is unmapped
      */
-    MapList map1 = new MapList(new int[] { 11, 13, 15, 15, 17, 18 }, new int[] {
-        3, 4 }, 3, 1);
+    MapList map1 = new MapList(new int[] { 11, 13, 15, 15, 17, 18 },
+            new int[]
+            { 3, 4 }, 3, 1);
     acf.addMap(dna1.getDatasetSequence(), pep1.getDatasetSequence(), map1);
-    MapList map2 = new MapList(new int[] { 20, 21, 23, 24, 26, 27 }, new int[] { 7, 8 },
-            3, 1);
+    MapList map2 = new MapList(new int[] { 20, 21, 23, 24, 26, 27 },
+            new int[]
+            { 7, 8 }, 3, 1);
     acf.addMap(dna2.getDatasetSequence(), pep2.getDatasetSequence(), map2);
-    
+
     /*
      * intron bases are not mapped
      */
     acf.markMappedRegion(dna1, 10, sr);
     assertTrue(sr.isEmpty());
-  
+
     /*
      * Q is not mapped
      */
@@ -614,7 +615,7 @@ public class AlignedCodonFrameTest
      */
     acf.markMappedRegion(dna1, 11, sr);
     SearchResults expected = new SearchResults();
-    expected.addResult(pep1.getDatasetSequence(),  3, 3);
+    expected.addResult(pep1.getDatasetSequence(), 3, 3);
     assertEquals(sr, expected);
 
     /*
@@ -623,29 +624,30 @@ public class AlignedCodonFrameTest
     sr = new SearchResults();
     acf.markMappedRegion(dna1.getDatasetSequence(), 11, sr);
     assertEquals(sr, expected);
-    
+
     /*
      * marking the same position a second time should not create a duplicate match
      */
     acf.markMappedRegion(dna1.getDatasetSequence(), 12, sr);
     assertEquals(sr, expected);
-    
+
     /*
      * mark exon positions for peptide position (of aligned sequence)
      */
     sr = new SearchResults();
     acf.markMappedRegion(pep2, 7, sr); // codon positions 20, 21, 23
     expected = new SearchResults();
-    expected.addResult(dna2.getDatasetSequence(),  20, 21);
-    expected.addResult(dna2.getDatasetSequence(),  23, 23);
+    expected.addResult(dna2.getDatasetSequence(), 20, 21);
+    expected.addResult(dna2.getDatasetSequence(), 23, 23);
     assertEquals(sr, expected);
-    
+
     /*
      * add another codon to the same SearchResults
      */
-    acf.markMappedRegion(pep1.getDatasetSequence(), 4, sr); // codon positions 15, 17, 18
-    expected.addResult(dna1.getDatasetSequence(),  15, 15);
-    expected.addResult(dna1.getDatasetSequence(),  17, 18);
+    acf.markMappedRegion(pep1.getDatasetSequence(), 4, sr); // codon positions
+                                                            // 15, 17, 18
+    expected.addResult(dna1.getDatasetSequence(), 15, 15);
+    expected.addResult(dna1.getDatasetSequence(), 17, 18);
     assertEquals(sr, expected);
   }
 
@@ -657,7 +659,7 @@ public class AlignedCodonFrameTest
     SequenceI cds = new Sequence("cds/1-9", "-A--TGGC-GGAC");
     cds.createDatasetSequence();
     SequenceI pep = new Sequence("pep/1-3", "MAD");
-    
+
     /*
      * with null argument or no mappings
      */
@@ -665,36 +667,37 @@ public class AlignedCodonFrameTest
     assertNull(acf.getCoveringCodonMapping(null));
     assertNull(acf.getCoveringCodonMapping(dna));
     assertNull(acf.getCoveringCodonMapping(pep));
-  
+
     /*
      * with a non-covering mapping e.g. overlapping exon
      */
-    MapList map = new MapList(new int[] { 16, 18 }, new int[] {
-        1, 1 }, 3, 1);
+    MapList map = new MapList(new int[] { 16, 18 }, new int[] { 1, 1 }, 3,
+            1);
     acf.addMap(dna, pep, map);
     assertNull(acf.getCoveringCodonMapping(dna));
     assertNull(acf.getCoveringCodonMapping(pep));
-    
+
     acf = new AlignedCodonFrame();
-    MapList map2 = new MapList(new int[] { 13, 18 }, new int[] {
-        2, 2 }, 3, 1);
+    MapList map2 = new MapList(new int[] { 13, 18 }, new int[] { 2, 2 }, 3,
+            1);
     acf.addMap(dna, pep, map2);
     assertNull(acf.getCoveringCodonMapping(dna));
     assertNull(acf.getCoveringCodonMapping(pep));
-    
+
     /*
      * with a covering mapping from CDS (dataset) to protein
      */
     acf = new AlignedCodonFrame();
-    MapList map3 = new MapList(new int[] { 1, 9 }, new int[] {
-        1, 3 }, 3, 1);
+    MapList map3 = new MapList(new int[] { 1, 9 }, new int[] { 1, 3 }, 3,
+            1);
     acf.addMap(cds.getDatasetSequence(), pep, map3);
     assertNull(acf.getCoveringCodonMapping(dna));
     SequenceToSequenceMapping mapping = acf.getCoveringCodonMapping(pep);
     assertNotNull(mapping);
-    SequenceToSequenceMapping mapping2 = acf.getCoveringCodonMapping(cds.getDatasetSequence());
+    SequenceToSequenceMapping mapping2 = acf
+            .getCoveringCodonMapping(cds.getDatasetSequence());
     assertSame(mapping, mapping2);
-    
+
     /*
      * with a mapping that extends to stop codon
      * (EMBL CDS location often includes the stop codon)
@@ -703,8 +706,8 @@ public class AlignedCodonFrameTest
     SequenceI cds2 = new Sequence("cds/1-12", "-A--TGGC-GGACTAA");
     cds2.createDatasetSequence();
     acf = new AlignedCodonFrame();
-    MapList map4 = new MapList(new int[] { 1, 12 }, new int[] {
-        1, 3 }, 3, 1);
+    MapList map4 = new MapList(new int[] { 1, 12 }, new int[] { 1, 3 }, 3,
+            1);
     acf.addMap(cds2, pep, map4);
     mapping = acf.getCoveringCodonMapping(cds2.getDatasetSequence());
     assertNotNull(mapping);