1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2 <html><!-- InstanceBegin template="/Templates/jtemplate.dwt" codeOutsideHTMLIsLocked="false" -->
4 <!-- InstanceBeginEditable name="doctitle" -->
5 <TITLE>JalviewLite API documentation</TITLE>
6 <!-- InstanceEndEditable -->
7 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><meta http-equiv="keywords" content="jalview,multiple,sequence,alignment,editor,viewer,java,download,barton group,protein,dna,das,distributed annotation system">
8 <!-- InstanceBeginEditable name="head" -->
9 <!-- InstanceEndEditable -->
10 <style type="text/css">
13 font-family: Geneva, Arial, Helvetica, sans-serif;
17 font-family: Verdana, Arial, Helvetica, sans-serif;
19 text-decoration: none;
22 background-color:#000000; color: #F2F2FF;
27 <script language="JavaScript">
30 var s1 = "ml:ljvwr", s2 = "athpai.g", s3 = "ioe@leo ", href="";
32 {href = href + s1.charAt(i) + s2.charAt(i) + s3.charAt(i); }
35 function getEventTarget(e)
45 <body alink="#000000" vlink="#000000" link="#000000">
46 <script type="text/javascript">
47 var gaJsHost = (("https:" == document.location.protocol) ?
48 "https://ssl." : "http://www.");
49 document.write(unescape("%3Cscript src='" + gaJsHost +
50 "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
52 <script type="text/javascript">
54 var pageTracker = _gat._getTracker("UA-9060947-1");
55 pageTracker._trackPageview();
59 <table width="805" height="100" cellpadding="5">
61 <td background="../jalview.gif"> <a href="http://www.compbio.dundee.ac.uk" target="NEW"><img src="../uodc_r1_c1.gif" width="143" height="101" border="1"></a></td>
64 <table width="805" border="0" cellpadding="5" cellspacing="5">
66 <td width="183" valign="top" bgcolor="#F2F2FF" border="5">
69 <table width="182" height="386" border="0" cellpadding="0" cellspacing="0">
71 <td align="left" valign="middle"><a href="../index.html" class="plain">Home</a></td>
74 <td align="left" valign="middle"><a href="../overview.html" class="plain">Overview</a></td>
77 <td align="left" valign="middle"><a href="../download.html" class="plain">Download</a></td>
80 <td align="left" valign="middle"><a href="applets.html" class="plain">Applet
84 <td align="left" valign="middle"><a href="examples.html" class="plain">Screenshots</a></td>
87 <td align="left" valign="middle"><a href="../faq.html" class="plain">FAQ</a></td>
90 <td align="left" valign="middle"><a href="../documentList.html" class="plain">Documentation</a></td>
93 <td align="left" valign="middle" ><a href="../releaseHistory.html" class="plain">Release
97 <td align="left" valign="middle"><a href="../source/source.html" class="plain">Source
101 <td align="left" valign="middle"><a href="../versions.html" class="plain">Development Version</a></td>
104 <td align="left" valign="middle"><a href="../links.html" class="plain">Links</a></td>
107 <td align="left" valign="middle"><a href="http://www.jalview.org/mailman/listinfo/jalview-announce" class="plain" target="NEW">News
108 Mailing List</a></td>
111 <td align="left" valign="middle"><a
112 href="http://www.jalview.org/mailman/listinfo/jalview-discuss"
113 class="plain" target="NEW">Discussion Mailing List</a><br><br><em>Please send problems<br>and
114 bug reports to the discussion list.</em></td>
118 <!--<td align="left" valign="middle"><br>
119 Please send problems<br>and
120 bug reports to:<br><a href="#" onClick="javascript:genHref();"><img src="../help.gif" width="123" height="19" border="0"></a></td>-->
124 <div align="center"> <a href="http://www.bbsrc.ac.uk/" target="NEW"><br>
125 <img src="../bbsrc-new.gif" width="179" height="64" border="1"></a>
128 <td valign="top" width="587" bgcolor="#F2F2FF"><!-- InstanceBeginEditable name="Contents" -->
130 <strong>JalviewLite Javascript API<br></strong>
131 <p>The jalviewLite applet's application programming interface (API) includes two components. A <a href="javascript/jalview.js">JalviewLite Javascript Library</a> and the <a href="#api">public methods on the JalviewLite applet</a>.
132 <p>The best way to learn how to use the API is to see it in action on the demonstration pages below:</p>
134 <li><a href="formComplete.html">use Javascript to control and get data from JalviewLite</a></li>
135 <li><a href="linkedapplets_ng.html">use Javascript to make two jalviewLite instances talk to each other.</a></li>
136 <li><a href="embeddedWJmol.html">configure JalviewLite to talk to a Jmol applet on the page (EXPERIMENTAL! please provide feedback!).</a></li>
137 <li><a href="javascriptLaunch.html">launch JalviewLite from a javascript button</a></li>
142 <li>Unfortunately Javascript - Java communication is not possible
143 using Internet Explorer or Opera on Macs. Please use Safari or
145 <li>If more than one Jalview window is open, Jalview returns the
146 alignment in the active window, unless you provide an AlignFrame
147 object reference.</li>
148 <li>The alignment output format can be either Fasta, PFAM, Clustal,
149 MSF, PIR, or BLC.</li>
150 <li>When referring to the Jalview applet in javascript, you must
151 either give Jalview a name in the applet tag or use the document.applets index.</li>
152 <li>When creating javascript functions that are called by jalviewLite (e.g. the <em>oninit</em> parameter, or any mouseOver, selection or structureListener handlers), ensure they complete very quickly, and do not access any jalview API methods that might result in more javascript calls (this which will cause your browser to hang). If you need to do this, we suggest that jalviewLite callbacks are used to add new javascript events to a queue (e.g. using a Jquery timer callback) to avoid any concurrency issues.
156 <h4>JalviewLite's Java API</h4></a>
157 <p>The following public methods on the jalviewLite applet are available to be called from javascript:</p>
158 <pre>//get list of IDs of selected sequences
159 public String getSelectedSequences()
161 // list of IDs of selected sequences terminated by sep or, if sep is null, '¬' (&#172;)
162 public String getSelectedSequences(sep)
164 // get list of selected sequences from specific alignFrame. (2.7)
165 public String getSelectedSequencesFrom(AlignFrame alf)
166 public String getSelectedSequencesFrom(AlignFrame alf, String sep)
168 // highlight a position in a specific sequence or a column in an alignment containing it
169 // provide ID sequence to highlight, integer (range highlighting will be supported in future versions)
170 // and flag indicating if position is an alignment column or given according to sequence numbering (2.7)
171 public void highlight(String sequenceId, String position, String alignedPosition)
172 public void highlightIn(AlignFrame alf, String sequenceId, String position, String alignedPosition)
175 // select regions of the currrent alignment frame using a list of sequence ids and a list of
176 // column numbers and ranges (with minus sign indicating start-end) (separated by default separator) (2.7)
177 public void select(String sequenceIds, String columns)
178 public void select(String sequenceIds, String columns, String sep)
179 public void selectIn(AlignFrame alf, String sequenceIds, String columns)
180 public void selectIn(AlignFrame alf, String sequenceIds, String columns, String sep)
183 // get selected sequences as alignment as format with or without start-end suffix
184 public String getSelectedSequencesAsAlignment(String format, boolean suffix)
186 // get selected sequences as alignment from given view as format with or without start-end suffix
187 public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf, String format, boolean suffix)
189 // get a separator separated list of sequence IDs reflecting the order of the current alignment (2.7)
190 public String getAlignmentOrder();
191 public String getAlignmentOrderFrom(AlignFrame alf);
192 public String getAlignmentOrderFrom(AlignFrame alf, String sep);
194 // re-order the current alignment using the given list of sequence IDs separated by sep
195 // undoName - is string to use when referring to ordering action in undo buffer
196 // returns 'true' if alignment was actually reordered. empty string if alignment did not contain sequences.
198 public String orderBy(String order, String undoName)
199 public String orderBy(String order, String undoName, String sep)
200 String orderAlignmentBy(AlignFrame alf, String order, String undoName, String sep)
203 // get alignment as format
204 public String getAlignment(String format)
206 // get alignment as format with jalview
207 // start-end sequence suffix appended
208 public String getAlignment(String format, String suffix)
210 // get alignment displayed in alf as format
211 public String getAlignmentFrom(AlignFrame alf, String format)
213 // get alignment displayed in alf as format
214 // with jalview start-end sequence suffix appended
215 public String getAlignmentFrom(AlignFrame alf, String format, String suffix)
217 // add the given features or annotation to the current alignment
218 public void loadAnnotation(String annotation)
220 // add the given features or annotation to the given alignment view
221 public void loadAnnotationFrom(AlignFrame alf, String annotation)
223 // get the sequence features in the given format (Jalview or GFF)
224 public String getFeatures(String format)
226 // get the sequence features in alf in the given format (Jalview or GFF)
227 public String getFeaturesFrom(AlignFrame alf, String format)
229 // get current alignment's annotation as an annotation file
230 public String getAnnotation()
232 // get alignment view alf's annotation as an annotation file
233 public String getAnnotationFrom(AlignFrame alf)
235 // create a new view and return the alignFrame instance
236 public AlignFrame newView()
238 // create a new view named name and return the alignFrame instance
239 public AlignFrame newView(String name)
241 // create a new view on alf and return the alignFrame instance
242 public AlignFrame newViewFrom(AlignFrame alf)
244 // create a new view named name on alf
245 // and return the alignFrame instance
246 public AlignFrame newViewFrom(AlignFrame alf, String name)
248 // load a new alignment
249 // remember to store the AlignFrame object reference
250 // if you want to manipulate the new alignment view.
251 public AlignFrame loadAlignment(String text, String title)
254 // register a javascript function to handle any alignment mouseover events
255 // listener is name of javascript function which will be called
256 // with arguments [jalview.appletgui.AlignFrame,String(sequence id),
257 // String(column in alignment), String(position in sequence)]
259 public void setMouseoverListener(String listener)
261 // register a javascript function to handle mouseover events for specific alignframe
263 public void setMouseoverListener(AlignFrame af, String listener)
265 // register a javascript function to handle alignment selection events.
266 // Events are generated when the user completes a selection event, or when
267 // the user deselects all selected regions.
268 // listener is name of javascript function that will be called with arguments
269 // [jalview.appletgui.AlignFrame, String(sequence set id),
270 // String(separator separated list of sequences which were selected),
271 // String(separator separated list of column ranges)]
273 public void setSelectionListener(String listener)
275 // register a selection listener for a specific alignment frame
277 public void setSelectionListener(AlignFrame af, String listener)
279 // register a javascript function to handle events normally routed
280 // to a Jmol structure viewer.
281 // listener is a javascript function called with several different types
282 // of arguments, dependent on the type of structure callback event.
283 // See jalview.javascript.MouseOverStructureListener for full details or
284 // the embedded Jmol example.
285 // modelSet - is a separator separated list of PDB file URIs that this viewer is handling (where position in list equals model number in Jmol).
287 public void setStructureListener(String listener, String modelSet)
289 // remove any callback using the given listener function and associated with
290 // the given alignFrame (or null for all callbacks) (v2.7)
291 public void removeJavascriptListener(AlignFrame af, String listener)
293 // send a mouseover message to all the alignment windows associated with the
294 // given residue in the pdbfile (v2.7)
295 public void mouseOverStructure(String pdbResNum, String chain, String pdbfile)
297 // bind a pdb file to a sequence in the given alignFrame - this will be searched
298 // for sequences matching sequenceId. The PDB file in pdbFile is either the contents
299 // of a PDB file or a URI that can be used to retrieve the file, and the pdbEntryString
300 // is the user friendly name (or PDBID) shown in jalview's user interface.
301 // returns true if binding was as success (v2.7)
302 public boolean addPdbFile(AlignFrame alFrame,
303 String sequenceId, String pdbEntryString, String pdbFile)
305 // adjust horizontal/vertical scroll in alf to the make
306 // the given location the top left hand corner for given current view (v2.7)
307 public void scrollViewToIn(AlignFrame alf, String topRow, String leftHandColumn)
309 // adjust horizontal scroll in alf to the make
310 // the given location the left hand corner for given current view (v2.7)
311 public void scrollViewToColumnIn(AlignFrame alf, String leftHandColumn)
313 // adjust horizontal/vertical scroll in alf to the make
314 // the given location the top row for given current view (v2.7)
315 public void scrollViewToRowIn(AlignFrame alf, String topRow)
318 // return separator separated list of feature groups
319 // on the current alignment
320 public String getFeatureGroups()
322 // return separator separated list of feature groups on alf
323 public String getFeatureGroupsOn(AlignFrame alf)
325 // return separator separated list of feature groups
326 // either visible or hidden
327 public String getFeatureGroupsOfState(boolean state)
329 // return separator separated list of feature groups
330 // either visible or hidden on alf
331 public String getFeatureGroupsOfStateOn(AlignFrame alf, boolean state)
333 // set the separator separated list of feature groups as
334 // visible or hidden on the current alignment
335 public void setFeatureGroupState(String groupList, boolean state)
337 // set the separator separated list of feature groups
338 // as visible or hidden on alf
339 public void setFeatureGroupStateOn(AlignFrame alf, String groupList, boolean state)
343 // Asynchronously retrieve next chunk of a large packet of data made available
344 // for a JalviewLite event handler, or the empty string if no more data is available.
345 // messageclass and viewId are keys used to retrieve a specific message related
347 // Use this in a javascript timer or GUI update thread to retrieve data without
348 // blocking the JalviewLite applet. DO NOT USE IN THE CALLBACK THAT HANDLED THE EVENT
350 public String getJsMessage(String messageclass, String viewId)
353 // convert list to a separator separated array
354 public String arrayToSeparatorList(String[] list)
356 // get a string array from a list
357 public String[] separatorListToArray(String list)
359 // get the current separator
360 public String getSeparator()
362 // set the current separator
363 public void setSeparator(String)
365 //// JalviewLite global state methods and fields
367 // return the build date as a string
368 public static String getBuildDate()
370 // return the JalviewLite version as a string
371 public static String getVersion()
373 // debug flag - controls output to standard out
374 public static boolean debug
376 </pre> <!-- InstanceEndEditable --></td>
381 <!-- InstanceEnd --></html>