d29c25d2c6f1cf924e166ef4194d779cdaca0ce9
[jabaws.git] / docs / v_2_2_0 / develop.rst
1 For Developers
2 ==============
3
4 .. _jabaws_source:
5
6 Source Code
7 -----------
8
9 .. note:: This is an open source project. If you want to contribute or report an issue have a look at our  `Git-tracker`_.
10
11 Publicly available Git repository: http://source.jalview.org/gitweb/?p=jabaws.git
12
13 .. code:: bash
14
15     git clone http://source.jalview.org/git/jabaws.git
16
17
18 ------------
19
20 .. _jabaws_api:
21
22 The API
23 -------
24
25 `Data Model JavaDoc`_ - read this if your are coding against JABA Web Services
26
27 `Complete JavaDoc`_ - for developers who want to use JABAWS framework and use Engines and Executables directly
28
29
30 -------------
31
32 .. _jabaws_structure:
33
34 Structure of the project
35 ------------------------
36
37 | |folder| *binaries* contains native executables e.g. clustalw
38 |     |folder| *src* contains sources of native executables
39 |     |folder| *windows* contains pre-compiled Windows binaries
40 |     |folder| *compilebin.sh* the script to complile binaries
41 |     |folder| *setexecflag.sh* the script to set executable flag for the binaries
42 | |folder| *conf*       contains JABAWS configuration files
43 | |folder| *ExecutionStatistics*        the database for storing collected execution statistics
44 | |folder| *jobsout* a default folder for temporary job directories
45 | |folder| *statpages* the web pages for execution statistics display
46 | |folder| *WEB-INF* default
47 | |folder| *docs* contains the reStructuredText documentation files
48 | |folder| *website* contains the JABAWS web pages
49 |     |folder| *archive* contains JABAWS packages, the WAR and JAR files
50 | |folder| *datamodel* contains the JABAWS datamodel
51 | |folder| *engine* contains the JABAWS engine - the code that abstract the execution environment and executes native binaries
52 | |folder| *runner* contains the JABAWS runners - thin wrappers for native binaries
53 | |folder| *webservices* contains the JABAWS SOAP web services
54 | |folder| *testsrc* contains the JABAWS unit tests
55
56
57 ------------
58
59 .. _jabaws_code:
60
61 The code structure
62 ------------------
63
64 .. image:: ../../website/static/img/ws-structure.png
65   :height: 414
66   :width: 282
67   :scale: 95 %
68   :align: left
69
70
71 Each source folder depends on the upper folders for compilation. For example, the datamodel is the top level folder so it has no other dependencies on other JABAWS code. The Engine level depends on the datamodel to compile etc. The web services folder is the bottom layer and depends on all the other source code.
72
73 So the JABAWS project is split into 4 layers. From bottom-up the first layer consists from the value classes used by all other layers of the hierarchy, in particular web services. So, to be able to use JABAWS one needs to have these classes. At the same time classes on this layer does not have any dependencies on the layers above.
74
75 The second layer contains code for execution of the wrappers, which are the abstraction describing native executables. JABAWS can execute tasks locally that is on the same machine as JVM and on the cluster. Thus currently code on this layer contain two engines. This layer depends on the layer underneath, the data model layer, but is completely independent from the code above.
76
77 The third layer consists of the wrappers for the native executables and classes to handle their configuration. It depends on the engines and the data model, but know nothing about the web services.
78
79 Finally, the upper layer contains the web services, that depend on all the layers below.
80
81 The layer isolation is archived though specially designed compilation task which is executed sequentially in several stages so that the first layer compiles before any other layers, second layer compiles after that and process continies before all the code is compiled. Any violation of the layer boundaries results in the compilation failure. Use Ant "Compile" or "Complile_with_debug" tasks to perform the staged compilation.
82
83 A client package contains only classes from data model layer and a simple web services client. Framework package is for anyone who want to use JABAWS framework for controlling native executables in local or cluster environments. Framework exclude the web services layer. Server package contains all the code.
84
85
86 ------------
87
88 .. _jabaws_tests:
89
90 Unit Testing
91 ------------
92
93 JABAWS uses `TestNG`_ framework for testing. The test results for the JABAWS package offered for download can be found at: `Test Results`_
94 JABAWS uses TestNG for testing. There is a TestNG plugin available for Eclipse which has functionality similar to JUnit. However, no plugins are necessary to run the test cases, as testng jar is supplied with JABAWS together with an ant tasks to run the test cases.
95
96
97 Several testing groups are supported:
98
99 * All tests ('Test')
100 * Cluster tests ('Run_cluster_dependent_test')
101 * Cluster independent tests ('All_cluster_independent_tests')
102 * Windows only tests ('All_cluster_independent_windows_only_tests')
103 * Performance and stability tests ('Long_tests')
104 * Re-run failed tests ('Rerun_failed_tests')
105 * Run custom test ('CustomTest')
106
107 To run the tests you need to download all sources from repository. Once you have done that, enter into the command line mode, change directory to the project directory and type:
108
109 .. code:: bash
110
111     ant -f build.xml <test group name>
112
113
114 Make sure you have `Apache Ant`_ installed and path to ant executable is defined in your path environmental variable. Replace test group name with the one of the names given in the list above to run required group of tests e.g for running cluster only tests use the following command:
115
116 .. code:: bash
117
118     ant -f build.xml Run_cluster_dependent_test
119
120
121 If you work under Linux you could use a simple script from the root folder of repository called ``runtests.sh``. This script simply contains a collection of the test commands described above and paths to java home directory and an ant executable, which you can define once for your system and then reuse.
122
123 A handy feature of TestNG is its ability to re-run failed tests. Failed test ant file is stored in ``test-output/testng-failed.xml``. and is used in the ant task called ``Rerun_failed_tests``. So re-running failed tests requires no more work than running any other test group and could be accomplished with the command:
124
125 .. code:: bash
126
127     ant -f build.xml Rerun_failed_tests
128
129
130 CustomTest runs the test defined in the project root directory file called ``temp-testng-customsuite.xml``. This file is generated by TestNG plugin every time you run the test from Eclipse. Thus an easy way to run a test in a different environment is to run it from Eclipse first and then from ant using a custom test procedure.
131
132 For cluster execution make sure that the property ``LD_LIBRARY_PATH`` defined in build.xml points to cluster engine LD libraries directory in your local system.
133
134
135 ------------
136
137 .. _jabaws_conn_services:
138
139 Accessing JABAWS from your program
140 ----------------------------------
141
142 .. _jabaws_conn_functions:
143
144 Web services functions overview
145 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
146
147
148 All JABAWS multiple sequence alignment web services comply to the same interface, thus the function described below are available from all the services.
149
150 Functions for initiating the alignment
151
152 .. code:: bash
153
154     String id = align(List<FastaSequence> list)
155     String id = customAlign(List<FastaSequence> sequenceList, List<Option> optionList)
156     String id = presetAlign(List<FastaSequence> sequenceList, Preset preset)
157
158 Functions pertaining to job monitoring and control
159
160 .. code:: bash
161
162     JobStatus status = getJobStatus(String id)
163     Alignment al = getResult(String id)
164     boolean cancelled = cancelJob(String id)
165     ChunkHolder chunk = pullExecStatistics(String id, long marker)
166
167 Functions relating to service features discovery
168
169 .. code:: bash
170
171     RunnerConfig rc = getRunnerOptions()
172     Limit limit = getLimit(String name)
173     LimitsManager lm = getLimits()
174     PresetManager pm = getPresets()
175
176 Please refer to a Data Model JavaDoc for a detailed description of each methods.
177
178
179 ------------
180
181 .. _jabaws_conn_functions2:
182
183 Structure of the template command line client
184 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
185
186 +------------------------+------------------------------------------------------------------------+
187 | Packages               |  Classes and Interfaces                                                |
188 +========================+========================================================================+
189 | compbio.data.msa       |  MsaWS the interface for all multiple sequence alignment web services  |
190 +------------------------+------------------------------------------------------------------------+
191 | compbio.data.sequence  |  JABAWS data types                                                     |
192 +------------------------+------------------------------------------------------------------------+
193 | compbio.metadata       |  JABAWS meta data types                                                |
194 +------------------------+------------------------------------------------------------------------+
195 | compbio.ws.client      |  JABAWS command line client                                            |
196 +------------------------+------------------------------------------------------------------------+
197
198 Additional utility libraries that this client depend upon is the compbio-util-1.3.jar and compbio-annotation-1.0.jar.
199
200 Please refer to a `Data Model JavaDoc`_ for a detailed description of each class and its methods.
201
202
203 ------------
204
205 .. _jabaws_conn_conn:
206
207 Connecting to JABAWS
208 ~~~~~~~~~~~~~~~~~~~~
209
210 For a complete working example of JABAWS command line client please see compbio.ws.client.Jws2Client class. JABAWS command line client source code is available from the `download page`_. Please note that for now all the examples are in Java, other languages will follow if there is sufficient demand.
211
212 Download a binary JABAWS client. Add the client to the class path. The following code excerpt will connect your program to Clustal web service deployed in the University of Dundee.
213
214 .. code-block:: java
215
216     import java.net.URL;
217     import javax.xml.namespace.QName;
218     import javax.xml.ws.Service;
219     // (...)
220     String qualifiedName = "http://msa.data.compbio/01/01/2010/";
221     URL url = new URL("http://www.compbio.dundee.ac.uk/jabaws/ClustalWS?wsdl");
222     QName qname = new QName(, "ClustalWS");
223     Service serv = Service.create(url, qname);
224     MsaWS msaws = serv.getPort(new QName(qualifiedName, "ClustalWSPort"),
225     MsaWS.class);
226
227 Line 1 makes a qualified name for JABA web services.
228
229 Line 2 constructs the URL to the web services WSDL.
230
231 Line 3 makes a qualified name instance for Clustal JABA web service.
232
233 Line 4 creates a service instance.
234
235 Line 5 makes a connection to the server.
236
237 A more generic connection method would look like this
238
239 .. code-block:: java
240
241     import java.net.URL;
242     import javax.xml.namespace.QName;
243     import javax.xml.ws.Service;
244     import compbio.ws.client.Services
245     // (...)
246     String qualifiedServiceName = "http://msa.data.compbio/01/01/2010/";
247     String host = "http://www.compbio.dundee.ac.uk/jabaws";
248     // In real life the service name can come from args
249     Services clustal = Services.ClustalWS;
250     URL url = new URL(host + "/" + clustal.toString() + "?wsdl");
251     QName qname = new QName(qualifiedServiceName, clustal.toString());
252     Service serv = Service.create(url, qname);
253     MsaWS msaws = serv.getPort(new QName(qualifiedServiceName, clustal + "Port"), MsaWS.class);
254
255
256 Where Services is enumeration of JABAWS web services. All JABAWS multiple sequence alignment methods confirm to MsaWS specification, thus from the caller point of view all JABAWS web services can be represented by MsaWS interface. The full documentation of MsaWS functions is available from the `JavaDoc`_.
257
258
259 ------------
260
261 .. _jabaws_conn_aln:
262
263 Aligning Sequences
264 ~~~~~~~~~~~~~~~~~~
265
266 Given that *msaws* is web service proxy, created as described in "Connecting to JABAWS" section, the actual alignment can be obtained as follows:
267
268 .. code:: bash
269
270     List<FastaSequence> fastalist = SequenceUtil.readFasta(new FileInputStream(file));
271     String jobId = msaws.align(fastalist);
272     Alignment alignment = msaws.getResult(jobId);
273     Line one loads FASTA sequence from the file.
274
275 Line two submits them to web service represented by msaws proxy.
276
277 Line three retrieves the alignment from a web service. This line will block the execution until the result is available. Use this with caution. In general, you should make sure that the calculation has been completed before attempting retrieving results. This is to avoid keeping the connection to the server on hold for a prolonged periods of time. While this may be ok with your local server, our public server (www.compbio.dundee.ac.uk/jabaws) will not let you hold the connection for longer than 10 minutes. This is done to prevent excessive load on the server. The next section describes how to check the status of the calculation.
278 Methods and classes mentioned in the excerpt are available from the JABAWS client library.
279
280
281 ------------
282
283 .. _jabaws_conn_status:
284
285 Checking the status of the calculation
286 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
287
288 You may have noticed that there was no pause between submitting the job and retrieving of the results. This is because getResult(jobId) method block the processing until the calculation is completed. However, taking into account that the connection holds server resources, our public server (www.compbio.dundee.ac.uk/jabaws) is configured to reset the connection after 10 minutes of waiting. To work around the connection reset you are encouraged to check whether the calculation has been completed before accessing the results. You can do it like this:
289
290 .. code-block:: java
291
292     while (msaws.getJobStatus(jobId) != JobStatus.FINISHED) {
293         Thread.sleep(2000); // wait two  seconds, then recheck the status
294     }
295
296
297 ------------
298
299 .. _jabaws_conn_aln_presets:
300
301 Aligning with presets
302 ~~~~~~~~~~~~~~~~~~~~~
303
304 .. code:: bash
305
306     PresetManager presetman = msaws.getPresets();
307     Preset preset = presetman.getPresetByName(presetName);
308     List<FastaSequence> fastalist = SequenceUtil.readFasta(new FileInputStream(file));
309     String jobId = msaws.presetAlign(fastalist, preset);
310     Alignment alignment = msaws.getResult(jobId);
311
312 Line one obtains the lists of presets supported by a web service.
313
314 Line two return a particular Preset by its name.
315
316 Lines three to five are doing the same job as in the `first aligning sequences example`_.
317
318
319 ------------
320
321 .. _jabaws_conn_aln_params:
322
323 Aligning with custom parameters
324 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
325
326 .. code:: bash
327
328     RunnerConfig options = msaws.getRunnerOptions();
329     Argument matrix = options.getArgument("MATRIX");
330     matrix.setValue("PAM300");
331     Argument gapopenpenalty = options.getArgument("GAPOPEN");
332     gapopenpenalty.setValue("20");
333     List<Argument> arguments = new ArrayList<Argument>();
334     arguments.add(matrix); arguments.add(gapopenpenalty);
335     List<FastaSequence> fastalist = SequenceUtil.readFasta(new FileInputStream(file));
336     String jobId = msaws.customAlign(fastalist, arguments);
337     Alignment alignment = msaws.getResult(jobId);
338
339 Line one obtains the ``RunnerConfig`` object that holds information on supported parameters and their values
340
341 Line two retrieve a particular parameter from the holder by its name.
342
343 Lines three sets a value to this parameter which will be used in the calculation.
344
345 Line four and five do the same but for another parameter.
346
347 Line six makes a List to hold the parameters.
348
349 Line seven puts the parameters into that list.
350
351 Line eight and ten is the same as in previous examples.
352
353 Line nine submit an alignment request with the sequences and the parameters.
354
355 The names of all the parameters supported by a web service e.g. "PAM300" can be obtained using ``options.getArguments()`` method. Further details on the methods available from ``RunnerConfig`` object are available from the JavaDoc.
356
357
358 ------------
359
360 .. _jabaws_conn_aln_file:
361
362 Writing alignments to a file
363 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
364
365 There is a utility method in the client library that does exactly that.
366
367 .. code-block:: java
368
369     Alignment alignment = align(...)
370     FileOutputStream outStream = new FileOutputStream(file);
371     ClustalAlignmentUtil.writeClustalAlignment(outStream, align);
372
373
374 ------------
375
376 .. _jabaws_conn_aln_example:
377
378 A complete client example
379 ~~~~~~~~~~~~~~~~~~~~~~~~~
380
381 Finally, a complete example of the program that connects to JABAWS Clustal service and aligns sequences using one of the Clustal web service presets. All you need for this to work is a `JABAWS CLI client`_. Please make sure that the client is in the Java class path before running this example.
382
383 .. code-block:: java
384
385     import java.io.ByteArrayInputStream;
386     import java.io.FileNotFoundException;
387     import java.io.IOException;
388     import java.net.URL;
389     import java.util.List;
390
391     import javax.xml.namespace.QName;
392     import javax.xml.ws.Service;
393
394     import compbio.data.msa.MsaWS;
395     import compbio.data.sequence.Alignment;
396     import compbio.data.sequence.FastaSequence;
397     import compbio.data.sequence.SequenceUtil;
398     import compbio.metadata.JobSubmissionException;
399     import compbio.metadata.LimitExceededException;
400     import compbio.metadata.Preset;
401     import compbio.metadata.PresetManager;
402     import compbio.metadata.ResultNotAvailableException;
403     import compbio.metadata.UnsupportedRuntimeException;
404     import compbio.metadata.WrongParameterException;
405
406     public class Example {
407
408       /*
409        * Input sequences for alignment
410        */
411       static final String input = ">Foo\r\n"
412                 + "MTADGPRELLQLRAAVRHRPQDFVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGR"
413                 + "VRWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDAGQAEAAAAAYTRAHQLLPEEPYITAQ"
414                 + "LLNWRRRLCDWRALDVLSAQVRAAVAQGVGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPL"
415                 + "APTRVRSKGPLRVGFVSNGFGAHPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQA"
416                 + "STLHDVTALGHLATAKHIRHHGIDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMD"
417                 + "YVLGDAFALPPALEPFYSEHVLRLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLN"
418                 + "PQSMARMLAVLREVPDSVLWLLSGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHAD"
419                 + "LFLDTHPYNAHTTASDALWTGCPVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALAS"
420                 + "DPAALTALHARVDVLRRESGVFEMDGFADDFGALLQALARRHGWLGI\r\n"
421                 + "\r\n"
422                 + ">Bar\r\n"
423                 + "MGDTTAGEMAVQRGLALHQQRHAEAAVLLQQASDAAPEHPGIALWLHALEDAGQAEAAAAYTRAH"
424                 + "QLLPEEPYITAQLLNAVAQGVGAVEPFAFLSEDASAAESVRPLAPTRVRSKGPLRVGFVSNGFGA"
425                 + "HPTGLLTVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHG"
426                 + "IDLLFDLRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVL"
427                 + "RLQGAFQPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLL"
428                 + "SGPGEADARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGC"
429                 + "PVLTTPGETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESGV"
430                 + "FEMDGFADDFGALLQALARRHGWLGI\r\n"
431                 + "\r\n"
432                 + ">Friends\r\n"
433                 + "MTADGPRELLQLRAAVRHRPQDVAWLMLADAELGMGDTTAGEMAVQRGLALHPGHPEAVARLGRV"
434                 + "RWTQQRHAEAAVLLQQASDAAPEHPGIALWLGHALEDHQLLPEEPYITAQLDVLSAQVRAAVAQG"
435                 + "VGAVEPFAFLSEDASAAEQLACARTRAQAIAASVRPLAPTRVRSKGPLRVGFVSNGFGAHPTGLL"
436                 + "TVALFEALQRRQPDLQMHLFATSGDDGSTLRTRLAQASTLHDVTALGHLATAKHIRHHGIDLLFD"
437                 + "LRGWGGGGRPEVFALRPAPVQVNWLAYPGTSGAPWMDYVLGDAFALPPALEPFYSEHVLRLQGAF"
438                 + "QPSDTSRVVAEPPSRTQCGLPEQGVVLCCFNNSYKLNPQSMARMLAVLREVPDSVLWLLSGPGEA"
439                 + "DARLRAFAHAQGVDAQRLVFMPKLPHPQYLARYRHADLFLDTHPYNAHTTASDALWTGCPVLTTP"
440                 + "GETFAARVAGSLNHHLGLDEMNVADDAAFVAKAVALASDPAALTALHARVDVLRRESI";
441
442       public static void main(String[] args) throws UnsupportedRuntimeException,
443                 LimitExceededException, JobSubmissionException,
444                 WrongParameterException, FileNotFoundException, IOException,
445                 ResultNotAvailableException, InterruptedException {
446
447                 String qualifiedServiceName = "http://msa.data.compbio/01/01/2010/";
448
449                 /* Make a URL pointing to web service WSDL */
450                 URL url = new URL("http://www.compbio.dundee.ac.uk/jabaws/ClustalWS?wsdl");
451
452                 /*
453                  * If you are making a client that connects to different web services
454                  * you can use something like this:
455                  */
456                 // URL url = new URL(host + "/" + Services.ClustalWS.toString() +
457                 // "?wsdl");
458
459         QName qname = new QName(qualifiedServiceName, "ClustalWS");
460         Service serv = Service.create(url, qname);
461         /*
462          * Multiple sequence alignment interface for Clustal web service
463          * instance
464          */
465         MsaWS msaws = serv.getPort(new QName(qualifiedServiceName, "ClustalWS"
466                         + "Port"), MsaWS.class);
467
468         /* Get the list of available presets */
469         PresetManager presetman = msaws.getPresets();
470
471         /* Get the Preset object by preset name */
472         Preset preset = presetman
473                         .getPresetByName("Disable gap weighting (Speed-oriented)");
474
475         /*
476          * Load sequences in FASTA format from the file You can use something
477          * like new FileInputStream(<filename>) to load sequence from the file
478          */
479         List<FastaSequence> fastalist = SequenceUtil
480                         .readFasta(new ByteArrayInputStream(input.getBytes()));
481
482         /*
483          * Submit loaded sequences for an alignment using preset. The job
484          * identifier is returned by this method, you can retrieve the results
485          * with it sometime later.
486          */
487         String jobId = msaws.presetAlign(fastalist, preset);
488
489         /* This method will block for the duration of the calculation */
490         Alignment alignment = msaws.getResult(jobId);
491
492         /*
493          * This is a better way of obtaining results, it does not involve
494          * holding the connection open for the duration of the calculation,
495          * Besides, as the University of Dundee public server will reset the
496          * connection after 10 minutes of idling, this is the only way to obtain
497          * the results of long running task from our public server.
498          */
499         // while (msaws.getJobStatus(jobId) != JobStatus.FINISHED) {
500         // Thread.sleep(1000); // wait a second, then recheck the status
501         // }
502
503         /* Output the alignment to standard out */
504         System.out.println(alignment);
505
506         // Alternatively, you can record retrieved alignment into the file in
507         // ClustalW format
508
509         // ClustalAlignmentUtil.writeClustalAlignment(new FileOutputStream(
510         // "output.al"), alignment);
511
512       }
513     }
514
515 For a more detailed description of all available types and their functions please refer to the `Data Model JavaDoc`_.
516
517
518 ------------
519
520 .. _jabaws_new_services:
521
522 Adding new web-services
523 -----------------------
524
525 .. _jabaws_new_guide:
526
527 Brief Guide
528 ~~~~~~~~~~~
529
530
531 1. Add a new executable which you'd like to wrap as a JABAWS web service to the binaries folder. If it has the source code and can be recompiled for different platforms include it under ``binaries/src``. Edit ``setexecutableflag.sh`` and ``compilebin.sh`` scripts in ``binaries/src`` accordingly.
532
533 2. Make sure that all the dependencies of the software being installed are satisfied. If there are other binaries they should be included as well. Keep the dependent binaries in a subfolder for the main executable. Update ``compilebin.sh`` and ``setexecflag.sh`` scripts accordingly.
534
535 3. Make sure that the new executable does not have any hard links to its dependencies, e.g. is able to run from any installation folder and does not contain any hard coded paths.
536
537 4. Describe executable in ``conf/Exectuable.properties`` file. The lowercase name of the wrapper should be included in the name of the property for example Clustal properties all include clustal as a part of the name e.g. ``local.clustalw.bin``. The same property for MAFFT will be called ``local.mafft.bin``. For more help please refer to the Executable.properties file.
538
539 5. Describe the executable supported parameters in the ``<ExecutableName>Parameters.xml``, presets in the ``<ExecutableName>Presets.xml`` and the execution limits in the ``<ExecutableName>Limit.xml``. By convention these files are stored in ``conf/settings``. All of these are optional. If the executable does not support parameters you do not have to mention the ``XXXParameter.xml`` file in the ``Executable.properties`` file at all. The same is true for Presets and Limits.
540
541 6. Create a Java wrapper class for your executable. Create it within runner source directory. Examples of other wrappers can be found in ``compbio.runner.msa`` or in other ``compbio.runner.*`` packages. Wrapper should extend ``SkeletalExecutable<T>`` and implement ``PipedExecutable<T>`` if you need to pass the input or collect the results from the standard in/out. Please see Mafft code as example. Wrapper should expend ``SkeletalExecutable<T>`` if input/output can be set as a parameter for an executable. Please see the ClustalW code as example.
542
543 7. Create a testcase suit for your wrapper in ``testsrc`` and run the test cases.
544
545 8. Create parser for the output files of your executable. Suggested location ``compbio.data.sequence.SequenceUtil``.
546
547 9. Test the parser.
548
549 10. Decide which web services interfaces your executable is going to match. For example if the executable output can be represented as SequenceAnnotation then SequenceAnnotation interface might be appropriate. For multiple sequence alignment an Msa interface should be used.
550
551 11. If you find a web interface that matches your returning data type, then implement a web service which confirms to it within a webservices source folder.
552
553 12. Register web service in ``WEB-INF/web.xml`` and ``WEB-INF/sun-jaxws.xml``.
554
555 13. Add generated wsdl to wsbuild.xml ant script to generate the stubs.
556
557 14. Run build-server task in wsbuild file. Watch for errors. If the task fails that means that JAXB cannot serialize some of your new data structures. Add appropriate annotations to your data types. Also check that:
558
559         * you do not have interfaces to serialize, since JAXB cannot serialize them
560         * you have a default no args constructor (can be private if you do not need it)
561         * JAXB cannot serialize Java Map class, use a custom data structure instead
562         * Enum cannot be serialized as its abstract class (do not confuse with enum which is fine)
563         * Fields serialization leaves a little more space for manoeuvre. If you do this then you may accept and return interfaces, e.g. List, Map; abstract classes etc, from your methods
564
565     If you have the data on the server side, but nothing is coming through to the client, this is a JAXB serialization problem. They tend to be very silent and thus hard to debug. Check your data structure can be serialized!
566
567 15. Modify the client to work with your new web service. Update Services enumeration to include new service and ensure that all the methods of this enumeration take into account the new service. Update the client help text (``client_help.txt``) and insert it into the Constraints class.
568
569 16. Test the web service with the client.
570
571 17. Test on the cluster.
572
573
574 ------------
575
576 .. _jabaws_artifacts:
577
578 Building web services artifacts
579 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
580
581 JABAWS are the standard `JAX-WS`_ SOAP web services, which are `WS-I`_ basic profile compatible. This means that you could use whatever tool your language has to work with web services. Below is how you can generate portable artifacts to work with JABAWS from Java. However if programming in Java, we recommend using our client library as it provides a handful of useful methods in addition to plain data types.
582
583 .. code:: bash
584
585     wsimport -keep http://www.compbio.dundee.ac.uk/jabaws/ClustalWS?wsdl
586
587
588 Server side artifacts should be rebuild whenever the data model, meta model or MSA interface were changed. To do that run build-server task from wsbuild.xml ant build file. WSDL files will be generated in ``webservices/compbio/ws/server/resource`` directory. It is not necessary to edit them if any of the JABAWS clients are used. JABAWS are the standard JAX-WS web services, which are WS-I basic profile compatible.
589
590
591 ------------
592
593 .. _jabaws_distributives:
594
595 Preparing Distributives
596 ~~~~~~~~~~~~~~~~~~~~~~~
597
598 There are a number of ant tasks aimed for preparing distributives for download. Currently a few types of JABAWS packages are offered:
599
600 1. Client only (contains classes required to access JABA Web Services)
601 2. Platform specific JABAWS (windows and other)
602 3. JABAWS with and without binaries
603 4. JABAWS framework and complete project
604
605 The easiest way to build all distributives is to call ``build-all`` ant task. There are more tasks defined in build.xml than described here. They are mostly self explanatory.
606
607 If you made any changes to the data model and would like to generate a complete JABAWS distro make sure you have rebuilt jaxws artifact as described below.
608
609
610
611 .. |folder| image:: ../../website/static/img/folder-small.png
612    :align: middle
613    :width: 15
614
615
616 .. links
617 .. _Git-tracker: https://source.jalview.org/crucible/changelog/jabaws
618 .. _Data Model JavaDoc: ../dm_javadoc/index.html
619 .. _Complete JavaDoc: ../full_javadoc/index.html
620 .. _JavaDoc: http://www.compbio.dundee.ac.uk/jabaws/full_javadoc/index.html
621 .. _Test Results: http://www.compbio.dundee.ac.uk/user/www-jws2/tests/index.html
622 .. _TestNG: http://testng.org/doc/index.html
623 .. _Apache Ant: http://ant.apache.org/
624 .. _download page: download.jsp
625 .. _JABAWS CLI client: download.jsp#client
626 .. _first aligning sequences example: develop.html#aligning-sequences
627 .. _JAX-WS: http://jax-ws.java.net/
628 .. _WS-I: http://www.ws-i.org/