1 |
|
package jalview.analysis; |
2 |
|
|
3 |
|
import static org.testng.Assert.assertSame; |
4 |
|
|
5 |
|
import jalview.datamodel.Alignment; |
6 |
|
import jalview.datamodel.AlignmentI; |
7 |
|
import jalview.datamodel.Sequence; |
8 |
|
import jalview.datamodel.SequenceFeature; |
9 |
|
import jalview.datamodel.SequenceI; |
10 |
|
|
11 |
|
import java.util.Arrays; |
12 |
|
import java.util.List; |
13 |
|
|
14 |
|
import junit.extensions.PA; |
15 |
|
|
16 |
|
import org.testng.annotations.Test; |
17 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (50) |
Complexity: 2 |
Complexity Density: 0.04 |
|
18 |
|
public class AlignmentSorterTest |
19 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (48) |
Complexity: 1 |
Complexity Density: 0.02 |
1PASS
|
|
20 |
1 |
@Test(groups = "Functional")... |
21 |
|
public void testSortByFeature_score() |
22 |
|
{ |
23 |
1 |
SequenceI seq1 = new Sequence("Seq1", "ABC--D-EFGHIJ"); |
24 |
1 |
SequenceI seq2 = new Sequence("Seq2", "ABCDEFGHIJ"); |
25 |
1 |
SequenceI seq3 = new Sequence("Seq3", "ABCDE-FGHIJ"); |
26 |
1 |
SequenceI seq4 = new Sequence("Seq4", "ABCDEFGHIJ"); |
27 |
1 |
SequenceI[] seqs = new SequenceI[] { seq1, seq2, seq3, seq4 }; |
28 |
1 |
AlignmentI al = new Alignment(seqs); |
29 |
1 |
al.setDataset(null); |
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
1 |
PA.setValue(AlignmentSorter.class, "sortByFeatureCriteria", null); |
35 |
|
|
36 |
1 |
AlignmentSorter.sortByFeature(null, null, 0, al.getWidth(), al, |
37 |
|
AlignmentSorter.FEATURE_SCORE); |
38 |
1 |
assertSame(al.getSequenceAt(0), seq1); |
39 |
1 |
assertSame(al.getSequenceAt(1), seq2); |
40 |
1 |
assertSame(al.getSequenceAt(2), seq3); |
41 |
1 |
assertSame(al.getSequenceAt(3), seq4); |
42 |
|
|
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
1 |
seq1.addSequenceFeature(new SequenceFeature("Cath", "", 2, 3, 2.0f, |
51 |
|
"g1")); |
52 |
1 |
seq1.addSequenceFeature(new SequenceFeature("Pfam", "", 4, 5, 4.0f, |
53 |
|
"g2")); |
54 |
1 |
seq2.addSequenceFeature(new SequenceFeature("Cath", "", 2, 3, 2.5f, |
55 |
|
"g3")); |
56 |
1 |
seq2.addSequenceFeature(new SequenceFeature("Metal", "", 2, 3, |
57 |
|
Float.NaN, "g4")); |
58 |
1 |
seq3.addSequenceFeature(new SequenceFeature("kD", "", 2, 3, -4f, "g5")); |
59 |
1 |
seq3.addSequenceFeature(new SequenceFeature("kD", "", 5, 6, 3.0f, "g6")); |
60 |
1 |
seq4.addSequenceFeature(new SequenceFeature("Helix", "", 2, 3, |
61 |
|
Float.NaN, "g7")); |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
1 |
PA.setValue(AlignmentSorter.class, "sortByFeatureAscending", true); |
68 |
1 |
AlignmentSorter.sortByFeature(null, null, 0, al.getWidth(), al, |
69 |
|
AlignmentSorter.FEATURE_SCORE); |
70 |
1 |
assertSame(al.getSequenceAt(3), seq3); |
71 |
1 |
assertSame(al.getSequenceAt(2), seq2); |
72 |
1 |
assertSame(al.getSequenceAt(1), seq1); |
73 |
1 |
assertSame(al.getSequenceAt(0), seq4); |
74 |
|
|
75 |
|
|
76 |
|
|
77 |
|
|
78 |
1 |
AlignmentSorter.sortByFeature(null, null, 0, al.getWidth(), al, |
79 |
|
AlignmentSorter.FEATURE_SCORE); |
80 |
1 |
assertSame(al.getSequenceAt(0), seq3); |
81 |
1 |
assertSame(al.getSequenceAt(1), seq2); |
82 |
1 |
assertSame(al.getSequenceAt(2), seq1); |
83 |
1 |
assertSame(al.getSequenceAt(3), seq4); |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
|
|
89 |
|
|
90 |
1 |
List<String> types = Arrays.asList(new String[] { "Cath", "kD" }); |
91 |
1 |
AlignmentSorter.sortByFeature(types, null, 0, al.getWidth(), al, |
92 |
|
AlignmentSorter.FEATURE_SCORE); |
93 |
1 |
assertSame(al.getSequenceAt(0), seq3); |
94 |
1 |
assertSame(al.getSequenceAt(1), seq1); |
95 |
1 |
assertSame(al.getSequenceAt(2), seq2); |
96 |
1 |
assertSame(al.getSequenceAt(3), seq4); |
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
1 |
List<String> groups = Arrays.asList(new String[] { "g1", "g2", "g3", |
104 |
|
"g6" }); |
105 |
1 |
AlignmentSorter.sortByFeature(types, groups, 0, al.getWidth(), al, |
106 |
|
AlignmentSorter.FEATURE_SCORE); |
107 |
1 |
assertSame(al.getSequenceAt(0), seq1); |
108 |
1 |
assertSame(al.getSequenceAt(1), seq2); |
109 |
1 |
assertSame(al.getSequenceAt(2), seq3); |
110 |
1 |
assertSame(al.getSequenceAt(3), seq4); |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
|
117 |
|
|
118 |
1 |
AlignmentSorter.sortByFeature(null, null, 0, 4, al, |
119 |
|
AlignmentSorter.FEATURE_SCORE); |
120 |
1 |
assertSame(al.getSequenceAt(0), seq3); |
121 |
1 |
assertSame(al.getSequenceAt(1), seq1); |
122 |
1 |
assertSame(al.getSequenceAt(2), seq2); |
123 |
1 |
assertSame(al.getSequenceAt(3), seq4); |
124 |
|
} |
125 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
1PASS
|
|
126 |
1 |
@Test(groups = "Functional")... |
127 |
|
public void testSortByFeature_density() |
128 |
|
{ |
129 |
|
|
130 |
|
} |
131 |
|
} |