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 static org.testng.AssertJUnit.assertEquals; |
24 |
|
|
25 |
|
import jalview.gui.JvOptionPane; |
26 |
|
|
27 |
|
import java.util.ArrayList; |
28 |
|
import java.util.List; |
29 |
|
|
30 |
|
import org.testng.Assert; |
31 |
|
import org.testng.annotations.BeforeClass; |
32 |
|
import org.testng.annotations.Test; |
33 |
|
|
34 |
|
import compbio.data.msa.MsaWS; |
35 |
|
import compbio.data.msa.RegistryWS; |
36 |
|
import compbio.data.sequence.FastaSequence; |
37 |
|
import compbio.metadata.JobStatus; |
38 |
|
import compbio.ws.client.Jws2Client; |
39 |
|
import compbio.ws.client.Services; |
40 |
|
|
|
|
| 0% |
Uncovered Elements: 50 (50) |
Complexity: 13 |
Complexity Density: 0.41 |
|
41 |
|
public class MinJabawsClientTests |
42 |
|
{ |
43 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
44 |
0 |
@BeforeClass(alwaysRun = true)... |
45 |
|
public void setUpJvOptionPane() |
46 |
|
{ |
47 |
0 |
JvOptionPane.setInteractiveMode(false); |
48 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
49 |
|
} |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
@throws |
55 |
|
|
|
|
| 0% |
Uncovered Elements: 46 (46) |
Complexity: 12 |
Complexity Density: 0.4 |
4-
|
|
56 |
0 |
@SuppressWarnings("rawtypes")... |
57 |
|
@Test(groups = { "Network" }) |
58 |
|
public void msaTest() throws Exception |
59 |
|
{ |
60 |
0 |
String url; |
61 |
0 |
RegistryWS registry = Jws2Client.connectToRegistry( |
62 |
|
url = "http://www.compbio.dundee.ac.uk/jabaws"); |
63 |
0 |
if (registry != null) |
64 |
|
{ |
65 |
|
|
66 |
0 |
MsaWS msaservice = null; |
67 |
0 |
for (Services service : registry.getSupportedServices()) |
68 |
|
{ |
69 |
0 |
if (service == null) |
70 |
|
{ |
71 |
|
|
72 |
0 |
continue; |
73 |
|
} |
74 |
0 |
if (service.equals(Services.ClustalOWS)) |
75 |
|
{ |
76 |
0 |
msaservice = (MsaWS) Jws2Client.connect(url, service); |
77 |
0 |
if (msaservice != null) |
78 |
|
{ |
79 |
0 |
break; |
80 |
|
} |
81 |
|
} |
82 |
|
} |
83 |
0 |
if (msaservice == null) |
84 |
|
{ |
85 |
0 |
Assert.fail( |
86 |
|
"couldn't find a clustalO service on the public registry"); |
87 |
|
} |
88 |
0 |
FastaSequence fsq = new FastaSequence("seqA", |
89 |
|
"SESESESESESESESSESESSESESESESESESESESESEEEEEESSESESESESSSSESESESESESESE"); |
90 |
0 |
List<FastaSequence> iseqs = new ArrayList<FastaSequence>(); |
91 |
0 |
for (int i = 0; i < 9; i++) |
92 |
|
{ |
93 |
0 |
iseqs.add(new FastaSequence(fsq.getId() + i, fsq.getSequence() |
94 |
|
+ fsq.getSequence().substring(i + 3, i + 3 + i))); |
95 |
|
} |
96 |
|
|
97 |
0 |
String jobid = msaservice.align(iseqs); |
98 |
0 |
if (jobid != null) |
99 |
|
{ |
100 |
0 |
JobStatus js = null; |
101 |
0 |
do |
102 |
|
{ |
103 |
0 |
try |
104 |
|
{ |
105 |
0 |
Thread.sleep(500); |
106 |
|
} catch (InterruptedException q) |
107 |
|
{ |
108 |
|
} |
109 |
0 |
; |
110 |
0 |
js = msaservice.getJobStatus(jobid); |
111 |
0 |
} while (!js.equals(JobStatus.FAILED) |
112 |
|
&& !js.equals(JobStatus.CANCELLED) |
113 |
|
&& !js.equals(JobStatus.FINISHED)); |
114 |
0 |
assertEquals("Trial alignment failed. State was " + js.name(), js, |
115 |
|
JobStatus.FINISHED); |
116 |
0 |
assertEquals( |
117 |
|
"Mismatch in number of input and result sequences - assume alignment service wasn't interacted with correctly", |
118 |
|
msaservice.getResult(jobid).getSequences().size(), |
119 |
|
iseqs.size()); |
120 |
0 |
for (FastaSequence t : msaservice.getResult(jobid).getSequences()) |
121 |
|
{ |
122 |
0 |
System.out.println(">" + t.getId()); |
123 |
0 |
System.out.println(t.getFormattedFasta()); |
124 |
|
} |
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
} |
133 |
|
|
134 |
|
} |
135 |
|
} |
136 |
|
} |