1 package compbio.ws.client;
\r
3 import static org.testng.Assert.assertEquals;
\r
4 import static org.testng.Assert.assertNotNull;
\r
5 import static org.testng.Assert.fail;
\r
8 import java.io.FileInputStream;
\r
9 import java.io.FileNotFoundException;
\r
10 import java.io.IOException;
\r
11 import java.util.ArrayList;
\r
12 import java.util.HashSet;
\r
13 import java.util.List;
\r
15 import org.testng.annotations.BeforeTest;
\r
16 import org.testng.annotations.Test;
\r
18 import compbio.data.msa.Annotation;
\r
19 import compbio.data.msa.JABAService;
\r
20 import compbio.data.sequence.ConservationMethod;
\r
21 import compbio.data.sequence.FastaSequence;
\r
22 import compbio.data.sequence.Score;
\r
23 import compbio.data.sequence.SequenceUtil;
\r
24 import compbio.metadata.JobSubmissionException;
\r
25 import compbio.metadata.LimitExceededException;
\r
26 import compbio.metadata.PresetManager;
\r
27 import compbio.metadata.ResultNotAvailableException;
\r
28 import compbio.metadata.RunnerConfig;
\r
29 import compbio.metadata.UnsupportedRuntimeException;
\r
30 import compbio.metadata.WrongParameterException;
\r
31 import compbio.runner.conservation.AACon;
\r
32 import compbio.util.SysPrefs;
\r
34 public class TestAAConWS {
\r
36 Annotation<AACon> msaws;
\r
39 void initConnection() {
\r
41 * URL url = null; try { url = new
\r
42 * URL("http://localhost:8080/jabaws/AAConWS?wsdl"); } catch
\r
43 * (MalformedURLException e) { e.printStackTrace();
\r
44 * fail(e.getLocalizedMessage()); } String namespace =
\r
45 * "http://msa.data.compbio/01/12/2010/"; QName qname = new
\r
46 * QName(namespace, "AAConWS"); Service serv = Service.create(url,
\r
47 * qname); msaws = serv.getPort(new QName(namespace, "AAConWSPort"),
\r
48 * Annotation.class);
\r
50 JABAService client = Jws2Client.connect("http://localhost:8080/jabaws",
\r
52 msaws = (Annotation<AACon>) client;
\r
56 public void testAnalize() throws FileNotFoundException, IOException {
\r
59 * MsaWS msaws = serv.getPort(new QName(
\r
60 * "http://msa.data.compbio/01/01/2010/", "ClustalWSPort"),
\r
63 // Annotation<AACon> msaws = serv.getPort(new QName(namespace,
\r
64 // "ClustalWSPort"), Annotation.class);
\r
66 // List<FastaSequence> fsl = SequenceUtil.readFasta(new FileInputStream(
\r
67 // AAConTester.test_alignment_input));
\r
69 String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()
\r
72 List<FastaSequence> fsl = SequenceUtil.readFasta(new FileInputStream(
\r
73 CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata"
\r
74 + File.separator + "TO1381.fasta.aln"));
\r
77 System.out.println("Pres: " + msaws.getPresets().getPresets());
\r
78 String jobId = msaws.analize(fsl);
\r
79 System.out.println("J: " + jobId);
\r
80 HashSet<Score> result = msaws.getAnnotation(jobId);
\r
81 assertNotNull(result);
\r
82 assertEquals(result.size(), 1);
\r
83 assertEquals(result.iterator().next().getMethod(),
\r
84 ConservationMethod.SHENKIN);
\r
85 List<Float> scores = result.iterator().next().getScores();
\r
86 assertNotNull(scores);
\r
87 assertEquals(scores.size(), 568);
\r
90 PresetManager<AACon> presets = msaws.getPresets();
\r
91 jobId = msaws.presetAnalize(fsl,
\r
92 presets.getPresetByName("Quick conservation"));
\r
93 result = msaws.getAnnotation(jobId);
\r
94 assertNotNull(result);
\r
95 assertEquals(result.size(), 13);
\r
97 jobId = msaws.presetAnalize(fsl,
\r
98 presets.getPresetByName("Slow conservation"));
\r
99 result = msaws.getAnnotation(jobId);
\r
100 assertNotNull(result);
\r
101 assertEquals(result.size(), 5);
\r
103 jobId = msaws.presetAnalize(fsl,
\r
104 presets.getPresetByName("Complete conservation"));
\r
105 result = msaws.getAnnotation(jobId);
\r
106 assertNotNull(result);
\r
107 assertEquals(result.size(), 18);
\r
109 } catch (UnsupportedRuntimeException e) {
\r
110 e.printStackTrace();
\r
111 fail(e.getMessage());
\r
112 } catch (LimitExceededException e) {
\r
113 e.printStackTrace();
\r
114 fail(e.getMessage());
\r
115 } catch (JobSubmissionException e) {
\r
116 e.printStackTrace();
\r
117 fail(e.getMessage());
\r
118 } catch (ResultNotAvailableException e) {
\r
119 e.printStackTrace();
\r
120 fail(e.getMessage());
\r
121 } catch (WrongParameterException e) {
\r
122 e.printStackTrace();
\r
123 fail(e.getMessage());
\r
129 public void testPresetAnalize() throws FileNotFoundException, IOException {
\r
131 String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()
\r
134 List<FastaSequence> fsl = SequenceUtil.readFasta(new FileInputStream(
\r
135 CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata"
\r
136 + File.separator + "TO1381.fasta.aln"));
\r
139 System.out.println("Pres: " + msaws.getPresets().getPresets());
\r
142 PresetManager<AACon> presets = msaws.getPresets();
\r
143 String jobId = msaws.presetAnalize(fsl,
\r
144 presets.getPresetByName("Quick conservation"));
\r
145 HashSet<Score> result = msaws.getAnnotation(jobId);
\r
146 assertNotNull(result);
\r
147 assertEquals(result.size(), 13);
\r
149 jobId = msaws.presetAnalize(fsl,
\r
150 presets.getPresetByName("Slow conservation"));
\r
151 result = msaws.getAnnotation(jobId);
\r
152 assertNotNull(result);
\r
153 assertEquals(result.size(), 5);
\r
155 jobId = msaws.presetAnalize(fsl,
\r
156 presets.getPresetByName("Complete conservation"));
\r
157 result = msaws.getAnnotation(jobId);
\r
158 assertNotNull(result);
\r
159 assertEquals(result.size(), 18);
\r
161 } catch (UnsupportedRuntimeException e) {
\r
162 e.printStackTrace();
\r
163 fail(e.getMessage());
\r
164 } catch (LimitExceededException e) {
\r
165 e.printStackTrace();
\r
166 fail(e.getMessage());
\r
167 } catch (JobSubmissionException e) {
\r
168 e.printStackTrace();
\r
169 fail(e.getMessage());
\r
170 } catch (ResultNotAvailableException e) {
\r
171 e.printStackTrace();
\r
172 fail(e.getMessage());
\r
173 } catch (WrongParameterException e) {
\r
174 e.printStackTrace();
\r
175 fail(e.getMessage());
\r
181 public void testCustomAnalize() throws FileNotFoundException, IOException {
\r
183 String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()
\r
186 List<FastaSequence> fsl = SequenceUtil.readFasta(new FileInputStream(
\r
187 CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata"
\r
188 + File.separator + "TO1381.fasta.aln"));
\r
191 RunnerConfig<AACon> options = msaws.getRunnerOptions();
\r
192 // System.out.println(options.getArguments());
\r
195 options.getArgument("Calculation method").setDefaultValue("SMERFS");
\r
196 // options.getArgument("SMERFS Column Scoring Method")
\r
197 // .setDefaultValue("MAX_SCORE");
\r
198 // options.getArgument("SMERFS Gap Threshhold").setDefaultValue("1");
\r
199 String jobId = msaws.customAnalize(fsl, options.getArguments());
\r
200 HashSet<Score> result = msaws.getAnnotation(jobId);
\r
201 assertNotNull(result);
\r
202 assertEquals(result.size(), 1);
\r
204 new ArrayList<Score>(result).get(0).getScores().get(0),
\r
207 options.getArgument("Calculation method").setDefaultValue("SMERFS");
\r
208 options.removeArgument("Normalize");
\r
209 System.out.println(options);
\r
210 jobId = msaws.customAnalize(fsl, options.getArguments());
\r
211 result = msaws.getAnnotation(jobId);
\r
212 assertNotNull(result);
\r
213 assertEquals(result.size(), 1);
\r
215 new ArrayList<Score>(result).get(0).getScores().get(0),
\r
218 } catch (WrongParameterException e) {
\r
219 e.printStackTrace();
\r
220 fail(e.getMessage());
\r
221 } catch (UnsupportedRuntimeException e) {
\r
222 e.printStackTrace();
\r
223 fail(e.getMessage());
\r
224 } catch (LimitExceededException e) {
\r
225 e.printStackTrace();
\r
226 fail(e.getMessage());
\r
227 } catch (JobSubmissionException e) {
\r
228 e.printStackTrace();
\r
229 fail(e.getMessage());
\r
230 } catch (ResultNotAvailableException e) {
\r
231 e.printStackTrace();
\r
232 fail(e.getMessage());
\r