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