testing interactive file import with groovy scripts

As promised, here's a vignette on using groovy for interactive testing of Jalview. Even better, I've gotten rid of the ugly perl bits (there's still one perl script here, but its not an ugly polylingual script :wink: ).

As a general caveat, I'd only recommend using groovy in Jalview 2.X if you can't do what you need by simply passing command line arguments to the jalview.jar (the jalview.bin.Jalview main method). This would usually be because you need to print out or perform some kind of validation of the resulting objects that were imported, or automate some UI actions in order to test other aspects.

Setting up groovy in jalview

···

----------------------------

Ok. So to begin with, you need to add the 'groovy-all' jar to the Jalview lib directory. All this is described in the built in help documentation:
http://www.jalview.org/help/html/features/groovy.html

What this translates to in terms of an eclipse project is - copy the groovy-*-all.jar into the lib directory and then add the lib directory to the build path for the project.

Then, you will also need to edit your jalview launch settings (go to the 'Run configurations ...' dialog box) so the groovy jar is on the class path too. Once you've done that, hit apply and run the configuration. Once Jalview launches, you should be able to open the groovy console and paste in and run the example groovy script given in the documentation.

I checked this with the current stable version - groovy-1.7.4-all.jar, which you can find in the groovy binary distribution (I used the zip download).

Running a file import test
--------------------------

I've added a directory examples/groovy which contains the test scripts:

JvLoadTestHarness.groovy : This actually runs the test - so edit this to specify where you've got the RFAM files stored.
JvLoadTester.groovy : This is the class that does the test. Its not particularly well structured, but you should be able to see where you need to change stuff.

As I said yesterday, the JvLoadTester class currently does the following basic set of actions for each file that you are testing Jalview with:

1. Imports the file
2. Once the alignment is displayed and calculation is finished, it selects all the sequences and deselects them - this was done to demonstrate large alignment timing issues.
3. It then saves the alignment as a Jalview project, closes all the alignment windows, then imports the Jalview project again.
4. Finally, it closes all the windows again ready for the next file.

You can configure a new eclipse launch configuration to run the test by:

1. make a duplicate of your jalview launch config that includes the groovy library on its runtime classpath.
2. add the examples/groovy directory to the runtime classpath (hidden in the dialog opened from the 'advanced...' button when editing the runtime classpath for the launcher).
3. Add the following commandline arguments to the launcher:
-groovy "<absolute path to the script>"

Doing the Rfam test
-------------------
I've also commited a 'splitrfam.pl' perl script to examples/rna
This will take a directory name, and either stdin or the name of one or more stockholm files. It will then write a bunch of files in the given directory, one for each family found in the given files. For the Rfam download, I used it like this :

gzip -d < Rfam.seed.gz | perl splitrfam.pl rfams

Final note: I've also committed a patch to the Jalview source which sets an 'interactive' flag which JvLoadTestHarness.groovy uses to check if it should quit jalview after the test is finished.

Ok. That about covers it. Have fun!
Jim.

--
-------------------------------------------------------------------
J. B. Procter (JALVIEW/ENFIN) Barton Bioinformatics Research Group
Phone/Fax:+44(0)1382 388734/345764 http://www.compbio.dundee.ac.uk
The University of Dundee is a Scottish Registered Charity, No. SC015096.