update author list in license for (JAL-826)
[jalview.git] / help / html / features / groovy.html
1 <html>\r
2 <!--\r
3  * Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)\r
4  * Copyright (C) 2011 J Procter, AM Waterhouse, J Engelhardt, LM Lui, G Barton, M Clamp, S Searle\r
5  * \r
6  * This file is part of Jalview.\r
7  * \r
8  * Jalview is free software: you can redistribute it and/or\r
9  * modify it under the terms of the GNU General Public License \r
10  * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\r
11  * \r
12  * Jalview is distributed in the hope that it will be useful, but \r
13  * WITHOUT ANY WARRANTY; without even the implied warranty \r
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
15  * PURPOSE.  See the GNU General Public License for more details.\r
16  * \r
17  * You should have received a copy of the GNU General Public License along with Jalview.  If not, see <http://www.gnu.org/licenses/>.\r
18 -->\r
19 <head>\r
20 <title>Groovy Shell</title>\r
21 </head>\r
22 <body>\r
23         <p>\r
24                 <strong>The Groovy Shell</strong>\r
25         </p>\r
26         <p>\r
27                 <a href="http://groovy.codehaus.org/">Groovy</a> is an &quot;<em>agile\r
28                         and dynamic language for the Java platform</em>&quot;. The groovy\r
29                 scripting language makes it extremely easy to programmatically\r
30                 interact with Java programs, in much the same way that Javascript is\r
31                 used to generate and interact with applets and other objects on the\r
32                 page.\r
33         </p>\r
34         <p>\r
35                 <strong><em>Getting Groovy...</em>\r
36                 </strong><br> Jalview Groovy support is only possible if the core groovy\r
37                 jars which include the GroovyShell are present on the CLASSPATH when\r
38                 Jalview is started.\r
39         </p>\r
40         <p>\r
41                 The jars are obtained from the <em>embedded</em> directory within the\r
42                 <a href="http://dist.codehaus.org/groovy/distributions">groovy\r
43                         distribution</a>. The easiest way of adding them to the Jalview classpath\r
44                 is to download and build jalview from it's source distribution, and\r
45                 then add the groovy-all-*.jar to the lib directory whose path is given\r
46                 in the java.ext.dirs property.\r
47         </p>\r
48         <p>\r
49                 <strong>Opening Jalview's Groovy Console</strong><br>If groovy is\r
50                 available, then the <strong>Tools&#8594;Groovy Console...</strong>\r
51                 menu entry will be available from the Jalview Desktop's drop-down\r
52                 menu. Selecting this will open the <a\r
53                         href="http://groovy.codehaus.org/Groovy+Console">Groovy Console</a>\r
54                 which allows you to interactively execute Groovy scripts within the\r
55                 Jalview run-time environment.\r
56         </p>\r
57         <p>\r
58                 <strong>Executing groovy scripts on Jalview startup</strong><br>\r
59                 The -groovy &lt;script&gt; option on the <a href="commandline.html" />\r
60                 Jalview command line</a> will execute the contents of &lt;script&gt;.\r
61                 &lt;script&gt; may be a file, a URL, or alternatively if it is\r
62                 &quot;STDIN&quot; then the standard input will be used.<br>\r
63                 <em>Note: The groovy script will be executed <strong>after</strong>\r
64                         any data is loaded, and <strong>before</strong> images or any output\r
65                         files are written. This allows you to perform customised jalview\r
66                         analysis workflows with groovy.</em>\r
67         </p>\r
68         <p>\r
69                 <strong>Access to Jalview's functions from Groovy Scripts</strong><br>\r
70                 There is as yet no properly defined scripting interface to Jalview,\r
71                 but all the public methods of the jalview class hierarchy can be\r
72                 called from Groovy scripts. The access point for this is the <strong>Jalview</strong>\r
73                 object defined in the groovy environent which corresponds to the\r
74         <pre>jalview.gui.Desktop</pre>\r
75         object which manages all the Jalview windows.\r
76         </p>\r
77         Here's an example to get you started:\r
78         <br>\r
79         <ul>\r
80                 <li>Getting the title, alignment and first sequence from the\r
81                         current alignFrame<br> <pre>\r
82 def alf = Jalview.getAlignframes();\r
83 print alf[0].getTitle();\r
84 def alignment = alf[0].viewport.alignment;\r
85 def seq = alignment.getSequenceAt(0);\r
86 </pre></li>\r
87 <li>When running a groovy script from the command line, the alignment that was just loaded can be referred to like so:<br><pre>\r
88 print currentAlFrame.getTitle();</pre>\r
89         </ul>\r
90         </p>\r
91 \r
92         <p>&nbsp;</p>\r
93 </body>\r
94 </html>\r