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.List;
\r
13 import org.testng.annotations.BeforeTest;
\r
14 import org.testng.annotations.Test;
\r
16 import compbio.data.msa.JABAService;
\r
17 import compbio.data.msa.SequenceAnnotation;
\r
18 import compbio.data.sequence.ConservationMethod;
\r
19 import compbio.data.sequence.FastaSequence;
\r
20 import compbio.data.sequence.ScoreManager;
\r
21 import compbio.data.sequence.SequenceUtil;
\r
22 import compbio.metadata.JobSubmissionException;
\r
23 import compbio.metadata.LimitExceededException;
\r
24 import compbio.metadata.PresetManager;
\r
25 import compbio.metadata.ResultNotAvailableException;
\r
26 import compbio.metadata.RunnerConfig;
\r
27 import compbio.metadata.UnsupportedRuntimeException;
\r
28 import compbio.metadata.WrongParameterException;
\r
29 import compbio.runner.conservation.AACon;
\r
30 import compbio.util.SysPrefs;
\r
32 public class TestAAConWS {
\r
34 SequenceAnnotation<AACon> msaws;
\r
37 void initConnection() {
\r
39 * URL url = null; try { url = new
\r
40 * URL("http://localhost:8080/jabaws/AAConWS?wsdl"); } catch
\r
41 * (MalformedURLException e) { e.printStackTrace();
\r
42 * fail(e.getLocalizedMessage()); } String namespace =
\r
43 * "http://msa.data.compbio/01/12/2010/"; QName qname = new
\r
44 * QName(namespace, "AAConWS"); Service serv = Service.create(url,
\r
45 * qname); msaws = serv.getPort(new QName(namespace, "AAConWSPort"),
\r
46 * Annotation.class);
\r
48 JABAService client = Jws2Client.connect("http://localhost:8080/jabaws",
\r
50 msaws = (SequenceAnnotation<AACon>) client;
\r
54 public void testAnalize() throws FileNotFoundException, IOException {
\r
57 * MsaWS msaws = serv.getPort(new QName(
\r
58 * "http://msa.data.compbio/01/01/2010/", "ClustalWSPort"),
\r
61 // Annotation<AACon> msaws = serv.getPort(new QName(namespace,
\r
62 // "ClustalWSPort"), Annotation.class);
\r
64 // List<FastaSequence> fsl = SequenceUtil.readFasta(new FileInputStream(
\r
65 // AAConTester.test_alignment_input));
\r
67 String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()
\r
70 List<FastaSequence> fsl = SequenceUtil.readFasta(new FileInputStream(
\r
71 CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata"
\r
72 + File.separator + "TO1381.fasta.aln"));
\r
75 System.out.println("Pres: " + msaws.getPresets().getPresets());
\r
76 String jobId = msaws.analize(fsl);
\r
77 System.out.println("J: " + jobId);
\r
78 ScoreManager result = msaws.getAnnotation(jobId);
\r
79 assertNotNull(result);
\r
80 assertEquals(result.getFirstSequenceScores().getNumberOfScores(), 1);
\r
82 assertEquals(result.getFirstSequenceScores().getFirstScore()
\r
83 .getMethod(), ConservationMethod.SHENKIN);
\r
84 List<Float> scores = result.getFirstSequenceScores()
\r
85 .getFirstScore().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.getFirstSequenceScores().getNumberOfScores(),
\r
98 jobId = msaws.presetAnalize(fsl,
\r
99 presets.getPresetByName("Slow conservation"));
\r
100 result = msaws.getAnnotation(jobId);
\r
101 assertNotNull(result);
\r
102 assertEquals(result.getFirstSequenceScores().getNumberOfScores(), 5);
\r
104 jobId = msaws.presetAnalize(fsl,
\r
105 presets.getPresetByName("Complete conservation"));
\r
106 result = msaws.getAnnotation(jobId);
\r
107 assertNotNull(result);
\r
108 assertEquals(result.getFirstSequenceScores().getNumberOfScores(),
\r
111 } catch (UnsupportedRuntimeException e) {
\r
112 e.printStackTrace();
\r
113 fail(e.getMessage());
\r
114 } catch (LimitExceededException e) {
\r
115 e.printStackTrace();
\r
116 fail(e.getMessage());
\r
117 } catch (JobSubmissionException e) {
\r
118 e.printStackTrace();
\r
119 fail(e.getMessage());
\r
120 } catch (ResultNotAvailableException e) {
\r
121 e.printStackTrace();
\r
122 fail(e.getMessage());
\r
123 } catch (WrongParameterException e) {
\r
124 e.printStackTrace();
\r
125 fail(e.getMessage());
\r
130 public void testPresetAnalize() throws FileNotFoundException, IOException {
\r
132 String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()
\r
135 List<FastaSequence> fsl = SequenceUtil.readFasta(new FileInputStream(
\r
136 CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata"
\r
137 + File.separator + "TO1381.fasta.aln"));
\r
140 System.out.println("Pres: " + msaws.getPresets().getPresets());
\r
143 PresetManager<AACon> presets = msaws.getPresets();
\r
144 String jobId = msaws.presetAnalize(fsl,
\r
145 presets.getPresetByName("Quick conservation"));
\r
146 ScoreManager result = msaws.getAnnotation(jobId);
\r
147 assertNotNull(result);
\r
148 assertEquals(result.getFirstSequenceScores().getNumberOfScores(),
\r
151 jobId = msaws.presetAnalize(fsl,
\r
152 presets.getPresetByName("Slow conservation"));
\r
153 result = msaws.getAnnotation(jobId);
\r
154 assertNotNull(result);
\r
155 assertEquals(result.getFirstSequenceScores().getNumberOfScores(), 5);
\r
157 jobId = msaws.presetAnalize(fsl,
\r
158 presets.getPresetByName("Complete conservation"));
\r
159 result = msaws.getAnnotation(jobId);
\r
160 assertNotNull(result);
\r
161 assertEquals(result.getFirstSequenceScores().getNumberOfScores(),
\r
164 } catch (UnsupportedRuntimeException e) {
\r
165 e.printStackTrace();
\r
166 fail(e.getMessage());
\r
167 } catch (LimitExceededException e) {
\r
168 e.printStackTrace();
\r
169 fail(e.getMessage());
\r
170 } catch (JobSubmissionException e) {
\r
171 e.printStackTrace();
\r
172 fail(e.getMessage());
\r
173 } catch (ResultNotAvailableException e) {
\r
174 e.printStackTrace();
\r
175 fail(e.getMessage());
\r
176 } catch (WrongParameterException e) {
\r
177 e.printStackTrace();
\r
178 fail(e.getMessage());
\r
184 public void testCustomAnalize() throws FileNotFoundException, IOException {
\r
186 String CURRENT_DIRECTORY = SysPrefs.getCurrentDirectory()
\r
189 List<FastaSequence> fsl = SequenceUtil.readFasta(new FileInputStream(
\r
190 CURRENT_DIRECTORY + "testsrc" + File.separator + "testdata"
\r
191 + File.separator + "TO1381.fasta.aln"));
\r
194 RunnerConfig<AACon> options = msaws.getRunnerOptions();
\r
195 // System.out.println(options.getArguments());
\r
198 options.getArgument("Calculation method").setDefaultValue("SMERFS");
\r
199 // options.getArgument("SMERFS Column Scoring Method")
\r
200 // .setDefaultValue("MAX_SCORE");
\r
201 // options.getArgument("SMERFS Gap Threshhold").setDefaultValue("1");
\r
202 String jobId = msaws.customAnalize(fsl, options.getArguments());
\r
203 ScoreManager result = msaws.getAnnotation(jobId);
\r
204 assertNotNull(result);
\r
205 assertEquals(result.getFirstSequenceScores().getNumberOfScores(), 1);
\r
206 assertEquals(result.getFirstSequenceScores().getFirstScore()
\r
207 .getScores().get(0), 0.698f);
\r
209 options.getArgument("Calculation method").setDefaultValue("SMERFS");
\r
210 options.removeArgument("Normalize");
\r
211 System.out.println(options);
\r
212 jobId = msaws.customAnalize(fsl, options.getArguments());
\r
213 result = msaws.getAnnotation(jobId);
\r
214 assertNotNull(result);
\r
215 assertEquals(result.getFirstSequenceScores().getNumberOfScores(), 1);
\r
216 assertEquals(result.getFirstSequenceScores().getFirstScore()
\r
217 .getScores().get(0), 0.401f);
\r
219 } catch (WrongParameterException e) {
\r
220 e.printStackTrace();
\r
221 fail(e.getMessage());
\r
222 } catch (UnsupportedRuntimeException e) {
\r
223 e.printStackTrace();
\r
224 fail(e.getMessage());
\r
225 } catch (LimitExceededException e) {
\r
226 e.printStackTrace();
\r
227 fail(e.getMessage());
\r
228 } catch (JobSubmissionException e) {
\r
229 e.printStackTrace();
\r
230 fail(e.getMessage());
\r
231 } catch (ResultNotAvailableException e) {
\r
232 e.printStackTrace();
\r
233 fail(e.getMessage());
\r