b0f7fe59f140c4124be4b24e235d8a87e1574c0c
[jalview.git] / test / jalview / datamodel / MappingTest.java
1 /*
2  * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3  * Copyright (C) $$Year-Rel$$ The Jalview Authors
4  * 
5  * This file is part of Jalview.
6  * 
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.
11  *  
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.
16  * 
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.
20  */
21 package jalview.datamodel;
22
23 import static org.testng.AssertJUnit.assertEquals;
24
25 import jalview.util.MapList;
26
27 import java.util.Arrays;
28
29 import org.testng.annotations.Test;
30
31 /**
32  * Test class refactored from main method
33  */
34 public class MappingTest
35 {
36   /**
37    * trite test of the intersectVisContigs method for a simple DNA -> Protein
38    * exon map and a range of visContigs
39    */
40   @Test(groups = { "Functional" })
41   public void testIntersectVisContigs()
42   {
43     MapList fk = new MapList(new int[] { 1, 6, 8, 13, 15, 23 }, new int[] {
44         1, 7 }, 3, 1);
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 });
49
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);
54
55     result = Arrays.deepToString(m_2.map.getFromRanges().toArray());
56     System.out.println(result);
57     assertEquals("[[1, 6], [11, 13], [15, 20]]", result);
58   }
59
60 }