1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.ws.jabaws; |
22 |
|
|
23 |
|
import java.util.Locale; |
24 |
|
|
25 |
|
import static org.testng.AssertJUnit.assertNotNull; |
26 |
|
import static org.testng.AssertJUnit.assertTrue; |
27 |
|
|
28 |
|
import jalview.bin.Cache; |
29 |
|
import jalview.bin.Console; |
30 |
|
import jalview.datamodel.AlignmentAnnotation; |
31 |
|
import jalview.datamodel.AlignmentI; |
32 |
|
import jalview.gui.JvOptionPane; |
33 |
|
import jalview.io.AnnotationFile; |
34 |
|
import jalview.io.DataSourceType; |
35 |
|
import jalview.io.FileFormat; |
36 |
|
import jalview.io.FormatAdapter; |
37 |
|
import jalview.io.StockholmFileTest; |
38 |
|
import jalview.ws.jws2.AADisorderClient; |
39 |
|
import jalview.ws.jws2.Jws2Discoverer; |
40 |
|
import jalview.ws.jws2.jabaws2.Jws2Instance; |
41 |
|
|
42 |
|
import java.util.ArrayList; |
43 |
|
import java.util.List; |
44 |
|
|
45 |
|
import org.testng.Assert; |
46 |
|
import org.testng.annotations.AfterClass; |
47 |
|
import org.testng.annotations.BeforeClass; |
48 |
|
import org.testng.annotations.Test; |
49 |
|
|
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
@Test(singleThreaded = true) |
|
|
| 0% |
Uncovered Elements: 60 (60) |
Complexity: 12 |
Complexity Density: 0.27 |
|
55 |
|
public class DisorderAnnotExportImport |
56 |
|
{ |
57 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
58 |
0 |
@BeforeClass(alwaysRun = true)... |
59 |
|
public void setUpJvOptionPane() |
60 |
|
{ |
61 |
0 |
JvOptionPane.setInteractiveMode(false); |
62 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
63 |
|
} |
64 |
|
|
65 |
|
public static String testseqs = "examples/uniref50.fa"; |
66 |
|
|
67 |
|
public static Jws2Discoverer disc; |
68 |
|
|
69 |
|
public static List<Jws2Instance> iupreds; |
70 |
|
|
71 |
|
jalview.ws.jws2.AADisorderClient disorderClient; |
72 |
|
|
73 |
|
public static jalview.gui.AlignFrame af = null; |
74 |
|
|
|
|
| 0% |
Uncovered Elements: 17 (17) |
Complexity: 3 |
Complexity Density: 0.23 |
|
75 |
0 |
@BeforeClass(alwaysRun = true)... |
76 |
|
public static void setUpBeforeClass() throws Exception |
77 |
|
{ |
78 |
0 |
Cache.loadProperties("test/jalview/io/testProps.jvprops"); |
79 |
0 |
Console.initLogger(); |
80 |
0 |
disc = JalviewJabawsTestUtils.getJabawsDiscoverer(); |
81 |
|
|
82 |
0 |
while (disc.isRunning()) |
83 |
|
{ |
84 |
|
|
85 |
0 |
Thread.sleep(100); |
86 |
|
} |
87 |
|
|
88 |
0 |
iupreds = new ArrayList<Jws2Instance>(); |
89 |
0 |
for (Jws2Instance svc : disc.getServices()) |
90 |
|
{ |
91 |
0 |
if (svc.getServiceTypeURI().toLowerCase(Locale.ROOT) |
92 |
|
.contains("iupredws")) |
93 |
|
{ |
94 |
0 |
iupreds.add(svc); |
95 |
|
} |
96 |
|
} |
97 |
0 |
assertTrue("Couldn't discover any IUPred services to use to test.", |
98 |
|
iupreds.size() > 0); |
99 |
0 |
jalview.io.FileLoader fl = new jalview.io.FileLoader(false); |
100 |
0 |
af = fl.LoadFileWaitTillLoaded(testseqs, |
101 |
|
jalview.io.DataSourceType.FILE); |
102 |
0 |
assertNotNull("Couldn't load test data ('" + testseqs + "')", af); |
103 |
|
} |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
105 |
0 |
@AfterClass(alwaysRun = true)... |
106 |
|
public static void tearDownAfterClass() throws Exception |
107 |
|
{ |
108 |
0 |
if (af != null) |
109 |
|
{ |
110 |
0 |
af.setVisible(false); |
111 |
0 |
af.dispose(); |
112 |
0 |
af = null; |
113 |
|
} |
114 |
|
} |
115 |
|
|
116 |
|
|
117 |
|
|
118 |
|
|
|
|
| 0% |
Uncovered Elements: 18 (18) |
Complexity: 4 |
Complexity Density: 0.29 |
4-
|
|
119 |
0 |
@Test(groups = { "External", "Network" })... |
120 |
|
public void testDisorderAnnotExport() |
121 |
|
{ |
122 |
0 |
disorderClient = new AADisorderClient(iupreds.get(0), af, null, null); |
123 |
0 |
af.getViewport().getCalcManager().startWorker(disorderClient); |
124 |
0 |
do |
125 |
|
{ |
126 |
0 |
try |
127 |
|
{ |
128 |
0 |
Thread.sleep(50); |
129 |
|
} catch (InterruptedException x) |
130 |
|
{ |
131 |
|
} |
132 |
0 |
; |
133 |
0 |
} while (af.getViewport().getCalcManager().isWorking()); |
134 |
0 |
AlignmentI orig_alig = af.getViewport().getAlignment(); |
135 |
|
|
136 |
|
|
137 |
0 |
List<AlignmentAnnotation> toremove = new ArrayList<AlignmentAnnotation>(); |
138 |
0 |
for (AlignmentAnnotation aa : orig_alig.getAlignmentAnnotation()) |
139 |
|
{ |
140 |
0 |
if (aa.autoCalculated) |
141 |
|
{ |
142 |
0 |
toremove.add(aa); |
143 |
|
} |
144 |
|
} |
145 |
0 |
for (AlignmentAnnotation aa : toremove) |
146 |
|
{ |
147 |
0 |
orig_alig.deleteAnnotation(aa); |
148 |
|
} |
149 |
0 |
checkAnnotationFileIO("Testing IUPred Annotation IO", orig_alig); |
150 |
|
|
151 |
|
} |
152 |
|
|
|
|
| 0% |
Uncovered Elements: 12 (12) |
Complexity: 2 |
Complexity Density: 0.17 |
|
153 |
0 |
static void checkAnnotationFileIO(String testname, AlignmentI al)... |
154 |
|
{ |
155 |
0 |
try |
156 |
|
{ |
157 |
0 |
String aligfileout = FileFormat.Pfam.getWriter(al) |
158 |
|
.print(al.getSequencesArray(), true); |
159 |
0 |
String anfileout = new AnnotationFile() |
160 |
|
.printAnnotationsForAlignment(al); |
161 |
0 |
assertTrue("Test " + testname |
162 |
|
+ "\nAlignment annotation file was not regenerated. Null string", |
163 |
|
anfileout != null); |
164 |
0 |
assertTrue("Test " + testname |
165 |
|
+ "\nAlignment annotation file was not regenerated. Empty string", |
166 |
|
anfileout.length() > "JALVIEW_ANNOTATION".length()); |
167 |
|
|
168 |
0 |
System.out.println( |
169 |
|
"Output annotation file:\n" + anfileout + "\n<<EOF\n"); |
170 |
|
|
171 |
0 |
AlignmentI al_new = new FormatAdapter().readFile(aligfileout, |
172 |
|
DataSourceType.PASTE, FileFormat.Pfam); |
173 |
0 |
assertTrue("Test " + testname |
174 |
|
+ "\nregenerated annotation file did not annotate alignment.", |
175 |
|
new AnnotationFile().readAnnotationFile(al_new, anfileout, |
176 |
|
DataSourceType.PASTE)); |
177 |
|
|
178 |
|
|
179 |
0 |
StockholmFileTest.testAlignmentEquivalence(al, al_new, true, false, |
180 |
|
false); |
181 |
0 |
return; |
182 |
|
} catch (Exception e) |
183 |
|
{ |
184 |
0 |
e.printStackTrace(); |
185 |
|
} |
186 |
0 |
Assert.fail("Test " + testname |
187 |
|
+ "\nCouldn't complete Annotation file roundtrip input/output/input test."); |
188 |
|
} |
189 |
|
|
190 |
|
} |