From: Jim Procter
Date: Thu, 22 Sep 2016 13:16:53 +0000 (+0100)
Subject: JAL-2189 JAL-1812 JAL-2068 new groovy doc section and example featureCounter script
X-Git-Tag: Release_2_10_0~39^2~12
X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=c8c1f2ab3fab93b92f444063ab522b5a82cf6aee;p=jalview.git
JAL-2189 JAL-1812 JAL-2068 new groovy doc section and example featureCounter script
---
diff --git a/examples/groovy/featureCounter.groovy b/examples/groovy/featureCounter.groovy
index a16d8bb..9059dd0 100644
--- a/examples/groovy/featureCounter.groovy
+++ b/examples/groovy/featureCounter.groovy
@@ -1,3 +1,24 @@
+/*
+ * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
+ * Copyright (C) $$Year-Rel$$ The Jalview Authors
+ *
+ * This file is part of Jalview.
+ *
+ * Jalview is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation, either version 3
+ * of the License, or (at your option) any later version.
+ *
+ * Jalview is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+ * PURPOSE. See the GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Jalview. If not, see .
+ * The Jalview Authors are detailed in the 'AUTHORS' file.
+ */
+
import jalview.workers.FeatureCounterI;
import jalview.workers.AlignmentAnnotationFactory;
diff --git a/help/help.jhm b/help/help.jhm
index 53b09e5..1760d43 100755
--- a/help/help.jhm
+++ b/help/help.jhm
@@ -130,6 +130,7 @@
+
diff --git a/help/helpTOC.xml b/help/helpTOC.xml
index c4476fd..ed95a61 100755
--- a/help/helpTOC.xml
+++ b/help/helpTOC.xml
@@ -156,9 +156,11 @@
+
+
+
-
diff --git a/help/html/features/groovy.html b/help/html/features/groovy.html
index a2bc627..079cf9e 100644
--- a/help/html/features/groovy.html
+++ b/help/html/features/groovy.html
@@ -27,21 +27,23 @@
The Groovy Shell
- Groovy is an "agile
- and dynamic language for the Java platform". The groovy
- scripting language makes it extremely easy to programmatically
- interact with Java programs, in much the same way that Javascript is
- used to generate and interact with applets and other objects on the
- page.
+ Groovy (www.groovy-lang.org)
+ is an "agile and dynamic language for the Java
+ platform". The groovy scripting language makes it extremely
+ easy to programmatically interact with Java programs, in much the
+ same way that Javascript is used to generate and interact with
+ applets and other objects on the page.
- Getting Groovy...
Jalview comes with
- an embedded installation of Groovy. All you need is to select Tools→Groovy
- Console... menu option from the Jalview Desktop's
- drop-down menu. After a short pause, you should then see the Groovy Console appear. This allows you to interactively execute Groovy
- scripts within the Jalview run-time environment.
+ Getting Groovy...
Jalview comes with an embedded
+ installation of Groovy. Just select Tools→Groovy
+ Console... from the Jalview Desktop's drop-down menu. After a
+ short pause, you should then see the Groovy
+ Console appear. This allows you to interactively execute Groovy
+ scripts whilst Jalview is running. We've also provided a Calculations→Execute
+ Groovy Script button so you can execute the currently loaded
+ groovy script whilst viewing an alignment.
Executing groovy scripts on Jalview startup
@@ -56,18 +58,29 @@
- Executing a groovy script on a particular alignment
-
-
Access to Jalview's functions from Groovy Scripts
- There is as yet no properly defined scripting interface to Jalview,
- but all the public methods of the jalview class hierarchy can be
- called from Groovy scripts. The access point for this is the Jalview
- object defined in the groovy environment which corresponds to the
-
jalview.gui.Desktop
- object which manages all the Jalview windows. Here's an example to get
- you started:
-
+ The scripting interface to Jalview is still a work in progress, so
+ we recommend you also take a look at Jalview's source, since all the
+ public methods of the jalview class hierarchy can be called from
+ Groovy scripts. In addition, the following objects are also defined:
+
+
+
+ - Jalview - this is bound to
jalview.bin.Jalview
.
Useful
+ methods include:
+
+ - Jalview.getAlignFrames() - returns a list of
+ jalview.gui.AlignFrame objects
+ - Jalview.getCurrentAlignFrame() - returns the alignment
+ window which is currently being looked at by the user
+
+ - currentAlFrame - this is only defined when
+ running a Groovy script via the -groovy command line argument. It
+ returns the first alignment window created after acting on the
+ other arguments passed on the command line.
+
+
+ A simple script
- Getting the title, alignment and first sequence from the
current alignFrame
@@ -77,13 +90,26 @@ def alignment = alf[0].viewport.alignment;
def seq = alignment.getSequenceAt(0);
- - When running a groovy script from the command line, the
- alignment that was just loaded can be referred to like so:
-
+
- If you wanted to do the same thing from the command line, you can refer to
+ alignment that was just loaded with currentAlFrame:
+
print currentAlFrame.getTitle();
- If you have downloaded the InstallAnywhere version of Jalview, you can
- find additional groovy scripts in the examples/groovy subfolder of the
- installation directory.
+
+ Example scripts
If you have downloaded the
+ InstallAnywhere version of Jalview, you can find additional groovy
+ scripts in the examples/groovy subfolder of the installation
+ directory. The examples are also available at http://www.jalview.org/examples/groovy.
+
+
+ Using Groovy to add new Alignment Calculations
We've
+ simplified the alignment analysis programming interface in Jalview
+ 2.10 to make it easy for you to add your own dynamic annotation
+ tracks with Groovy. Have a look at the featureCounter.groovy
+ example for more information.
+
+