1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.gui; |
22 |
|
|
23 |
|
import static org.testng.Assert.assertFalse; |
24 |
|
import static org.testng.AssertJUnit.assertEquals; |
25 |
|
|
26 |
|
import jalview.analysis.AnnotationSorter.SequenceAnnotationOrder; |
27 |
|
import jalview.bin.Cache; |
28 |
|
import jalview.datamodel.AlignmentAnnotation; |
29 |
|
import jalview.datamodel.AlignmentI; |
30 |
|
import jalview.datamodel.Annotation; |
31 |
|
import jalview.datamodel.HiddenColumns; |
32 |
|
import jalview.datamodel.SequenceI; |
33 |
|
import jalview.io.DataSourceType; |
34 |
|
import jalview.io.FileFormat; |
35 |
|
import jalview.io.FormatAdapter; |
36 |
|
|
37 |
|
import java.io.IOException; |
38 |
|
import java.util.Iterator; |
39 |
|
|
40 |
|
import org.testng.annotations.BeforeClass; |
41 |
|
import org.testng.annotations.BeforeMethod; |
42 |
|
import org.testng.annotations.Test; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
47 |
|
@author |
48 |
|
|
49 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (71) |
Complexity: 4 |
Complexity Density: 0.06 |
|
50 |
|
public class AnnotationColumnChooserTest |
51 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
52 |
1 |
@BeforeClass(alwaysRun = true)... |
53 |
|
public void setUpJvOptionPane() |
54 |
|
{ |
55 |
1 |
JvOptionPane.setInteractiveMode(false); |
56 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
final static String TEST_DATA = ">FER_CAPAA Ferredoxin\n" |
61 |
|
+ "TIETHKEAELVG-\n" |
62 |
|
+ ">FER_CAPAN Ferredoxin, chloroplast precursor\n" |
63 |
|
+ "TIETHKEAELVG-\n" |
64 |
|
+ ">FER1_SOLLC Ferredoxin-1, chloroplast precursor\n" |
65 |
|
+ "TIETHKEEELTA-\n" + ">Q93XJ9_SOLTU Ferredoxin I precursor\n" |
66 |
|
+ "TIETHKEEELTA-\n"; |
67 |
|
|
68 |
|
AnnotationChooser testee; |
69 |
|
|
70 |
|
AlignmentPanel parentPanel; |
71 |
|
|
72 |
|
AlignFrame af; |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
|
74 |
1 |
@BeforeMethod(alwaysRun = true)... |
75 |
|
public void setUp() throws IOException |
76 |
|
{ |
77 |
1 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
78 |
|
|
79 |
1 |
Cache.applicationProperties.setProperty(Preferences.SORT_ANNOTATIONS, |
80 |
|
SequenceAnnotationOrder.NONE.name()); |
81 |
1 |
final String TRUE = Boolean.TRUE.toString(); |
82 |
1 |
Cache.applicationProperties.setProperty(Preferences.SHOW_AUTOCALC_ABOVE, |
83 |
|
TRUE); |
84 |
1 |
Cache.applicationProperties.setProperty("SHOW_QUALITY", TRUE); |
85 |
1 |
Cache.applicationProperties.setProperty("SHOW_CONSERVATION", TRUE); |
86 |
1 |
Cache.applicationProperties.setProperty("SHOW_IDENTITY", TRUE); |
87 |
|
|
88 |
1 |
AlignmentI al = new FormatAdapter().readFile(TEST_DATA, |
89 |
|
DataSourceType.PASTE, FileFormat.Fasta); |
90 |
1 |
af = new AlignFrame(al, 700, 500); |
91 |
1 |
parentPanel = new AlignmentPanel(af, af.getViewport()); |
92 |
1 |
addAnnotations(); |
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
98 |
|
|
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (17) |
Complexity: 1 |
Complexity Density: 0.06 |
|
103 |
1 |
private void addAnnotations()... |
104 |
|
{ |
105 |
1 |
Annotation an = new Annotation(2f); |
106 |
1 |
Annotation[] anns = new Annotation[] { an, an, an }; |
107 |
1 |
AlignmentAnnotation ann0 = new AlignmentAnnotation("IUPRED", "", anns); |
108 |
1 |
AlignmentAnnotation ann1 = new AlignmentAnnotation("Beauty", "", anns); |
109 |
1 |
AlignmentAnnotation ann2 = new AlignmentAnnotation("JMol", "", anns); |
110 |
1 |
AlignmentAnnotation ann3 = new AlignmentAnnotation("IUPRED", "", anns); |
111 |
1 |
AlignmentAnnotation ann4 = new AlignmentAnnotation("JMol", "", anns); |
112 |
1 |
SequenceI[] seqs = parentPanel.getAlignment().getSequencesArray(); |
113 |
1 |
ann0.setSequenceRef(seqs[0]); |
114 |
1 |
ann2.setSequenceRef(seqs[3]); |
115 |
1 |
ann3.setSequenceRef(seqs[2]); |
116 |
1 |
ann4.setSequenceRef(seqs[1]); |
117 |
1 |
parentPanel.getAlignment().addAnnotation(ann0); |
118 |
1 |
parentPanel.getAlignment().addAnnotation(ann1); |
119 |
1 |
parentPanel.getAlignment().addAnnotation(ann2); |
120 |
1 |
parentPanel.getAlignment().addAnnotation(ann3); |
121 |
1 |
parentPanel.getAlignment().addAnnotation(ann4); |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (37) |
Complexity: 1 |
Complexity Density: 0.03 |
1PASS
|
|
127 |
1 |
@Test(groups = { "Functional" })... |
128 |
|
public void testReset() |
129 |
|
{ |
130 |
1 |
AnnotationColumnChooser acc = new AnnotationColumnChooser( |
131 |
|
af.getViewport(), af.alignPanel); |
132 |
|
|
133 |
1 |
HiddenColumns oldhidden = new HiddenColumns(); |
134 |
1 |
oldhidden.hideColumns(10, 20); |
135 |
1 |
acc.setOldHiddenColumns(oldhidden); |
136 |
|
|
137 |
1 |
HiddenColumns newHidden = new HiddenColumns(); |
138 |
1 |
newHidden.hideColumns(0, 3); |
139 |
1 |
newHidden.hideColumns(22, 25); |
140 |
1 |
af.getViewport().setHiddenColumns(newHidden); |
141 |
|
|
142 |
1 |
HiddenColumns currentHidden = af.getViewport().getAlignment() |
143 |
|
.getHiddenColumns(); |
144 |
1 |
Iterator<int[]> regions = currentHidden.iterator(); |
145 |
1 |
int[] next = regions.next(); |
146 |
1 |
assertEquals(0, next[0]); |
147 |
1 |
assertEquals(3, next[1]); |
148 |
1 |
next = regions.next(); |
149 |
1 |
assertEquals(22, next[0]); |
150 |
1 |
assertEquals(25, next[1]); |
151 |
|
|
152 |
|
|
153 |
1 |
acc.reset(); |
154 |
1 |
currentHidden = af.getViewport().getAlignment().getHiddenColumns(); |
155 |
1 |
regions = currentHidden.iterator(); |
156 |
1 |
next = regions.next(); |
157 |
1 |
assertEquals(10, next[0]); |
158 |
1 |
assertEquals(20, next[1]); |
159 |
|
|
160 |
|
|
161 |
1 |
oldhidden = new HiddenColumns(); |
162 |
1 |
acc.setOldHiddenColumns(oldhidden); |
163 |
1 |
acc.reset(); |
164 |
1 |
currentHidden = af.getViewport().getAlignment().getHiddenColumns(); |
165 |
1 |
assertFalse(currentHidden.hasHiddenColumns()); |
166 |
|
|
167 |
|
|
168 |
1 |
oldhidden.hideColumns(10, 20); |
169 |
1 |
acc.setOldHiddenColumns(oldhidden); |
170 |
1 |
currentHidden = af.getViewport().getAlignment().getHiddenColumns(); |
171 |
1 |
assertFalse(currentHidden.hasHiddenColumns()); |
172 |
|
|
173 |
1 |
acc.reset(); |
174 |
1 |
currentHidden = af.getViewport().getAlignment().getHiddenColumns(); |
175 |
1 |
regions = currentHidden.iterator(); |
176 |
1 |
next = regions.next(); |
177 |
1 |
assertEquals(10, next[0]); |
178 |
1 |
assertEquals(20, next[1]); |
179 |
|
} |
180 |
|
} |