| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
package jalview.datamodel; |
| 22 |
|
|
| 23 |
|
import static org.testng.AssertJUnit.assertEquals; |
| 24 |
|
import static org.testng.AssertJUnit.assertSame; |
| 25 |
|
|
| 26 |
|
import jalview.gui.JvOptionPane; |
| 27 |
|
import jalview.util.MapList; |
| 28 |
|
|
| 29 |
|
import java.util.Arrays; |
| 30 |
|
|
| 31 |
|
import org.testng.annotations.BeforeClass; |
| 32 |
|
import org.testng.annotations.Test; |
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (30) |
Complexity: 4 |
Complexity Density: 0.15 |
|
| 37 |
|
public class MappingTest |
| 38 |
|
{ |
| 39 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 40 |
1 |
@BeforeClass(alwaysRun = true)... |
| 41 |
|
public void setUpJvOptionPane() |
| 42 |
|
{ |
| 43 |
1 |
JvOptionPane.setInteractiveMode(false); |
| 44 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
| 45 |
|
} |
| 46 |
|
|
| 47 |
|
|
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
| 51 |
1 |
@Test(groups = { "Functional" })... |
| 52 |
|
public void testIntersectVisContigs() |
| 53 |
|
{ |
| 54 |
1 |
MapList fk = new MapList(new int[] { 1, 6, 8, 13, 15, 23 }, |
| 55 |
|
new int[] |
| 56 |
|
{ 1, 7 }, 3, 1); |
| 57 |
1 |
Mapping m = new Mapping(fk); |
| 58 |
1 |
Mapping m_1 = m |
| 59 |
|
.intersectVisContigs(new int[] |
| 60 |
|
{ fk.getFromLowest(), fk.getFromHighest() }); |
| 61 |
1 |
Mapping m_2 = m.intersectVisContigs(new int[] { 1, 7, 11, 20 }); |
| 62 |
|
|
| 63 |
|
|
| 64 |
1 |
String result = Arrays.deepToString(m_1.map.getFromRanges().toArray()); |
| 65 |
1 |
System.out.println(result); |
| 66 |
1 |
assertEquals("[[1, 6], [8, 13], [15, 23]]", result); |
| 67 |
|
|
| 68 |
1 |
result = Arrays.deepToString(m_2.map.getFromRanges().toArray()); |
| 69 |
1 |
System.out.println(result); |
| 70 |
1 |
assertEquals("[[1, 6], [11, 13], [15, 20]]", result); |
| 71 |
|
} |
| 72 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
| 73 |
1 |
@Test(groups = { "Functional" })... |
| 74 |
|
public void testToString() |
| 75 |
|
{ |
| 76 |
|
|
| 77 |
|
|
| 78 |
|
|
| 79 |
1 |
MapList fk = new MapList(new int[] { 1, 6, 8, 13 }, new int[] { 4, 7 }, |
| 80 |
|
3, 1); |
| 81 |
1 |
Mapping m = new Mapping(fk); |
| 82 |
1 |
assertEquals("[ [1, 6] [8, 13] ] 3:1 to [ [4, 7] ] ", m.toString()); |
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
1 |
SequenceI seq = new Sequence("Seq1", ""); |
| 88 |
1 |
m = new Mapping(seq, fk); |
| 89 |
1 |
assertEquals("[ [1, 6] [8, 13] ] 3:1 to [ [4, 7] ] Seq1", m.toString()); |
| 90 |
|
} |
| 91 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
| 92 |
1 |
@Test(groups = { "Functional" })... |
| 93 |
|
public void testCopyConstructor() |
| 94 |
|
{ |
| 95 |
1 |
MapList ml = new MapList(new int[] { 1, 6, 8, 13 }, new int[] { 4, 7 }, |
| 96 |
|
3, 1); |
| 97 |
1 |
SequenceI seq = new Sequence("seq1", "agtacg"); |
| 98 |
1 |
Mapping m = new Mapping(seq, ml); |
| 99 |
1 |
m.setMappedFromId("abc"); |
| 100 |
1 |
Mapping copy = new Mapping(m); |
| 101 |
1 |
assertEquals("abc", copy.getMappedFromId()); |
| 102 |
1 |
assertEquals(ml, copy.getMap()); |
| 103 |
1 |
assertSame(seq, copy.getTo()); |
| 104 |
|
} |
| 105 |
|
} |