2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.datamodel;
23 import static org.testng.AssertJUnit.assertEquals;
25 import jalview.util.MapList;
27 import java.util.Arrays;
29 import org.testng.annotations.Test;
32 * Test class refactored from main method
34 public class MappingTest
37 * trite test of the intersectVisContigs method for a simple DNA -> Protein
38 * exon map and a range of visContigs
40 @Test(groups = { "Functional" })
41 public void testIntersectVisContigs()
43 MapList fk = new MapList(new int[] { 1, 6, 8, 13, 15, 23 }, new int[] {
45 Mapping m = new Mapping(fk);
46 Mapping m_1 = m.intersectVisContigs(new int[] { fk.getFromLowest(),
47 fk.getFromHighest() });
48 Mapping m_2 = m.intersectVisContigs(new int[] { 1, 7, 11, 20 });
50 // assertions from output values 'as is', not checked for correctness
51 String result = Arrays.deepToString(m_1.map.getFromRanges().toArray());
52 System.out.println(result);
53 assertEquals("[[1, 6], [8, 13], [15, 23]]", result);
55 result = Arrays.deepToString(m_2.map.getFromRanges().toArray());
56 System.out.println(result);
57 assertEquals("[[1, 6], [11, 13], [15, 20]]", result);
60 @Test(groups = { "Functional" })
61 public void testToString()
66 MapList fk = new MapList(new int[] { 1, 6, 8, 13 }, new int[] { 4, 7 },
68 Mapping m = new Mapping(fk);
69 assertEquals("[ [1, 6] [8, 13] ] 3:1 to [ [4, 7] ] ", m.toString());
74 SequenceI seq = new Sequence("Seq1", "");
75 m = new Mapping(seq, fk);
76 assertEquals("[ [1, 6] [8, 13] ] 3:1 to [ [4, 7] ] Seq1", m.toString());