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 // if features are loaded, feature display is automatically enabled
219 public void loadAnnotation(String annotation)
221 // add the given features or annotation to the given alignment view
222 // if features are loaded, feature display is automatically enabled
223 public void loadAnnotationFrom(AlignFrame alf, String annotation)
225 // parse the given string as a jalview or GFF features file and optionally enable feature display on the current alignment
227 public abstract void loadFeatures(String features, boolean autoenabledisplay)
229 // parse the given string as a jalview or GFF features file and optionally enable feature display on the given alignment
231 public abstract void loadFeaturesFrom(AlignFrame alf, String features, boolean autoenabledisplay)
233 // get the sequence features in the given format (Jalview or GFF)
234 public String getFeatures(String format)
236 // get the sequence features in alf in the given format (Jalview or GFF)
237 public String getFeaturesFrom(AlignFrame alf, String format)
239 // get current alignment's annotation as an annotation file
240 public String getAnnotation()
242 // get alignment view alf's annotation as an annotation file
243 public String getAnnotationFrom(AlignFrame alf)
245 // create a new view and return the alignFrame instance
246 public AlignFrame newView()
248 // create a new view named name and return the alignFrame instance
249 public AlignFrame newView(String name)
251 // create a new view on alf and return the alignFrame instance
252 public AlignFrame newViewFrom(AlignFrame alf)
254 // create a new view named name on alf
255 // and return the alignFrame instance
256 public AlignFrame newViewFrom(AlignFrame alf, String name)
258 // load a new alignment
259 // remember to store the AlignFrame object reference
260 // if you want to manipulate the new alignment view.
261 public AlignFrame loadAlignment(String text, String title)
264 // register a javascript function to handle any alignment mouseover events
265 // listener is name of javascript function which will be called
266 // with arguments [jalview.appletgui.AlignFrame,String(sequence id),
267 // String(column in alignment), String(position in sequence)]
269 public void setMouseoverListener(String listener)
271 // register a javascript function to handle mouseover events for specific alignframe
273 public void setMouseoverListener(AlignFrame af, String listener)
275 // register a javascript function to handle alignment selection events.
276 // Events are generated when the user completes a selection event, or when
277 // the user deselects all selected regions.
278 // listener is name of javascript function that will be called with arguments
279 // [jalview.appletgui.AlignFrame, String(sequence set id),
280 // String(separator separated list of sequences which were selected),
281 // String(separator separated list of column ranges)]
283 public void setSelectionListener(String listener)
285 // register a selection listener for a specific alignment frame
287 public void setSelectionListener(AlignFrame af, String listener)
289 // register a javascript function to handle events normally routed
290 // to a Jmol structure viewer.
291 // listener is a javascript function called with several different types
292 // of arguments, dependent on the type of structure callback event.
293 // See jalview.javascript.MouseOverStructureListener for full details or
294 // the embedded Jmol example.
295 // modelSet - is a separator separated list of PDB file URIs that this viewer is handling (where position in list equals model number in Jmol).
297 public void setStructureListener(String listener, String modelSet)
299 // remove any callback using the given listener function and associated with
300 // the given alignFrame (or null for all callbacks) (v2.7)
301 public void removeJavascriptListener(AlignFrame af, String listener)
303 // send a mouseover message to all the alignment windows associated with the
304 // given residue in the pdbfile (v2.7)
305 public void mouseOverStructure(String pdbResNum, String chain, String pdbfile)
307 // bind a pdb file to a sequence in the given alignFrame - this will be searched
308 // for sequences matching sequenceId. The PDB file in pdbFile is either the contents
309 // of a PDB file or a URI that can be used to retrieve the file, and the pdbEntryString
310 // is the user friendly name (or PDBID) shown in jalview's user interface.
311 // returns true if binding was as success (v2.7)
312 public boolean addPdbFile(AlignFrame alFrame,
313 String sequenceId, String pdbEntryString, String pdbFile)
315 // adjust horizontal/vertical scroll in alf to the make
316 // the given location the top left hand corner for given current view (v2.7)
317 public void scrollViewToIn(AlignFrame alf, String topRow, String leftHandColumn)
319 // adjust horizontal scroll in alf to the make
320 // the given location the left hand corner for given current view (v2.7)
321 public void scrollViewToColumnIn(AlignFrame alf, String leftHandColumn)
323 // adjust horizontal/vertical scroll in alf to the make
324 // the given location the top row for given current view (v2.7)
325 public void scrollViewToRowIn(AlignFrame alf, String topRow)
328 // return separator separated list of feature groups
329 // on the current alignment
330 public String getFeatureGroups()
332 // return separator separated list of feature groups on alf
333 public String getFeatureGroupsOn(AlignFrame alf)
335 // return separator separated list of feature groups
336 // either visible or hidden
337 public String getFeatureGroupsOfState(boolean state)
339 // return separator separated list of feature groups
340 // either visible or hidden on alf
341 public String getFeatureGroupsOfStateOn(AlignFrame alf, boolean state)
343 // set the separator separated list of feature groups as
344 // visible or hidden on the current alignment
345 public void setFeatureGroupState(String groupList, boolean state)
347 // set the separator separated list of feature groups
348 // as visible or hidden on alf
349 public void setFeatureGroupStateOn(AlignFrame alf, String groupList, boolean state)
353 // Asynchronously retrieve next chunk of a large packet of data made available
354 // for a JalviewLite event handler, or the empty string if no more data is available.
355 // messageclass and viewId are keys used to retrieve a specific message related
357 // Use this in a javascript timer or GUI update thread to retrieve data without
358 // blocking the JalviewLite applet. DO NOT USE IN THE CALLBACK THAT HANDLED THE EVENT
360 public String getJsMessage(String messageclass, String viewId)
363 // convert list to a separator separated array
364 public String arrayToSeparatorList(String[] list)
366 // get a string array from a list
367 public String[] separatorListToArray(String list)
369 // get the current separator
370 public String getSeparator()
372 // set the current separator
373 public void setSeparator(String)
375 //// JalviewLite global state methods and fields
377 // return the build date as a string
378 public static String getBuildDate()
380 // return the JalviewLite version as a string
381 public static String getVersion()
383 // debug flag - controls output to standard out
384 public static boolean debug
386 </pre> <!-- InstanceEndEditable --></td>
391 <!-- InstanceEnd --></html>