2 * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2)
3 * Copyright (C) 2014 The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.javascript;
23 import jalview.appletgui.AlignFrame;
26 * The following public methods may be called
27 * externally, eg via javascript in an HTML page.
29 * <br><em>TODO: introduce abstract interface for jalview.appletgui.AlignFrame</em><br>
31 * Most function arguments are strings, which contain serialised versions of lists.
32 * Lists of things are separated by a separator character - either the default or a user supplied one.
33 * Ranges and positions on an alignment or sequence can be specified as a list, where an item containing a single number is a single position, and an item like 1-2 specifies columns 1 and 2 as a range.
40 public interface JalviewLiteJsApi
44 * @return String list of selected sequence IDs, each terminated by the
45 * 'boolean not' character (""+0x00AC) or (¬)
47 public abstract String getSelectedSequences();
51 * separator string or null for default
52 * @return String list of selected sequence IDs, each terminated by given
55 public abstract String getSelectedSequences(String sep);
59 * alignframe containing selection
60 * @return String list of selected sequence IDs, each terminated by current
61 * default separator sequence
64 public abstract String getSelectedSequencesFrom(AlignFrame alf);
67 * get list of selected sequence IDs separated by given separator
70 * window containing selection
72 * separator string to use - default is 'boolean not'
73 * @return String list of selected sequence IDs, each terminated by the given
76 public abstract String getSelectedSequencesFrom(AlignFrame alf, String sep);
81 * id of sequence to highlight
83 * integer position [ tobe implemented or range ] on sequence
84 * @param alignedPosition
85 * true/false/empty string - indicate if position is an alignment
86 * column or unaligned sequence position
88 public abstract void highlight(String sequenceId, String position,
89 String alignedPosition);
94 * id of sequence to highlight
96 * integer position [ tobe implemented or range ] on sequence
97 * @param alignedPosition
98 * false, blank or something else - indicate if position is an
99 * alignment column or unaligned sequence position
101 public abstract void highlightIn(AlignFrame alf, String sequenceId,
102 String position, String alignedPosition);
105 * select regions of the currrent alignment frame
108 * String separated list of sequence ids or empty string
110 * String separated list { column range or column, ..} or empty
113 public abstract void select(String sequenceIds, String columns);
116 * select regions of the currrent alignment frame
119 * String separated list { column range, seq1...seqn sequence ids }
121 * separator between toselect fields
123 public abstract void select(String sequenceIds, String columns, String sep);
126 * select regions of the given alignment frame
130 * String separated list { column range, seq1...seqn sequence ids }
132 * separator between toselect fields
134 public abstract void selectIn(AlignFrame alf, String sequenceIds,
138 * select regions of the given alignment frame
142 * String separated list { column range, seq1...seqn sequence ids }
144 * separator between toselect fields
146 public abstract void selectIn(AlignFrame alf, String sequenceIds,
147 String columns, String sep);
150 * get sequences selected in current alignFrame and return their alignment in
151 * format 'format' either with or without suffix
154 * - where selection is
156 * - format of alignment file
158 * - "true" to append /start-end string to each sequence ID
159 * @return selected sequences as flat file or empty string if there was no
162 public abstract String getSelectedSequencesAsAlignment(String format,
166 * get sequences selected in alf and return their alignment in format 'format'
167 * either with or without suffix
170 * - where selection is
172 * - format of alignment file
174 * - "true" to append /start-end string to each sequence ID
175 * @return selected sequences as flat file or empty string if there was no
178 public abstract String getSelectedSequencesAsAlignmentFrom(
179 AlignFrame alf, String format, String suffix);
182 * get a separator separated list of sequence IDs reflecting the order of the
187 public abstract String getAlignmentOrder();
190 * get a separator separated list of sequence IDs reflecting the order of the
196 public abstract String getAlignmentOrderFrom(AlignFrame alf);
199 * get a sep separated list of sequence IDs reflecting the order of the
207 public abstract String getAlignmentOrderFrom(AlignFrame alf, String sep);
210 * re-order the current alignment using the given list of sequence IDs
213 * - sep separated list
215 * - string to use when referring to ordering action in undo buffer
216 * @return 'true' if alignment was actually reordered. empty string if
217 * alignment did not contain sequences.
219 public abstract String orderBy(String order, String undoName);
222 * re-order the current alignment using the given list of sequence IDs
226 * - sep separated list
228 * - string to use when referring to ordering action in undo buffer
230 * @return 'true' if alignment was actually reordered. empty string if
231 * alignment did not contain sequences.
233 public abstract String orderBy(String order, String undoName, String sep);
236 * re-order the given alignment using the given list of sequence IDs separated
241 * - sep separated list
243 * - string to use when referring to ordering action in undo buffer
245 * @return 'true' if alignment was actually reordered. empty string if
246 * alignment did not contain sequences.
248 public abstract String orderAlignmentBy(AlignFrame alf, String order,
249 String undoName, String sep);
252 * get alignment as format (format names FASTA, BLC, CLUSTAL, MSF, PILEUP,
253 * PFAM - see jalview.io.AppletFormatAdapter for full list)
258 public abstract String getAlignment(String format);
261 * get alignment displayed in alf as format
267 public abstract String getAlignmentFrom(AlignFrame alf, String format);
270 * get alignment as format with jalview start-end sequence suffix appended
276 public abstract String getAlignment(String format, String suffix);
279 * get alignment displayed in alf as format with or without the jalview
280 * start-end sequence suffix appended
287 public abstract String getAlignmentFrom(AlignFrame alf, String format,
291 * add the given features or annotation to the current alignment
295 public abstract void loadAnnotation(String annotation);
298 * add the given features or annotation to the given alignment view
303 public abstract void loadAnnotationFrom(AlignFrame alf, String annotation);
306 * parse the given string as a jalview feature or GFF annotation file and
307 * optionally enable feature display on the current alignFrame
310 * - gff or features file
311 * @param autoenabledisplay
312 * - when true, feature display will be enabled if any features can
313 * be parsed from the string.
315 public abstract void loadFeatures(String features,
316 boolean autoenabledisplay);
319 * parse the given string as a jalview feature or GFF annotation file and
320 * optionally enable feature display on the given alignFrame.
324 * - gff or features file
325 * @param autoenabledisplay
326 * - when true, feature display will be enabled if any features can
327 * be parsed from the string.
328 * @return true if data parsed as features
330 public abstract boolean loadFeaturesFrom(AlignFrame alf, String features,
331 boolean autoenabledisplay);
334 * get the sequence features in the given format (Jalview or GFF)
339 public abstract String getFeatures(String format);
342 * get the sequence features in alf in the given format (Jalview or GFF)
348 public abstract String getFeaturesFrom(AlignFrame alf, String format);
351 * get current alignment's annotation as an annotation file
355 public abstract String getAnnotation();
358 * get alignment view alf's annotation as an annotation file
363 public abstract String getAnnotationFrom(AlignFrame alf);
366 * create a new view and return the alignFrame instance
370 public abstract AlignFrame newView();
373 * create a new view named name and return the alignFrame instance
378 public abstract AlignFrame newView(String name);
381 * create a new view on alf and return the alignFrame instance
386 public abstract AlignFrame newViewFrom(AlignFrame alf);
389 * create a new view named name on alf
395 public abstract AlignFrame newViewFrom(AlignFrame alf, String name);
400 * alignment file as a string
403 * @return null or new alignment frame
405 public abstract AlignFrame loadAlignment(String text, String title);
408 * register a javascript function to handle any alignment mouseover events
411 * name of javascript function (called with arguments
412 * [jalview.appletgui.AlignFrame,String(sequence id),String(column in
413 * alignment), String(position in sequence)]
415 public abstract void setMouseoverListener(String listener);
418 * register a javascript function to handle mouseover events
421 * (null or specific alignframe for which events are to be listened
424 * name of javascript function
426 public abstract void setMouseoverListener(AlignFrame af, String listener);
429 * register a javascript function to handle any alignment selection events.
430 * Events are generated when the user completes a selection event, or when the
431 * user deselects all selected regions.
434 * name of javascript function (called with arguments
435 * [jalview.appletgui.AlignFrame, String(sequence set id),
436 * String(separator separated list of sequences which were selected),
437 * String(separator separated list of column ranges (i.e. single
438 * number or hyphenated range) that were selected)]
440 public abstract void setSelectionListener(String listener);
442 public abstract void setSelectionListener(AlignFrame af, String listener);
445 * register a javascript function to handle events normally routed to a Jmol
449 * - javascript function (arguments are variable, see
450 * jalview.javascript.MouseOverStructureListener for full details)
452 * - separator separated list of PDB file URIs that this viewer is
453 * handling. These files must be in the same order they appear in
454 * Jmol (e.g. first one is frame 1, second is frame 2, etc).
455 * @see jalview.javascript.MouseOverStructureListener
457 public abstract void setStructureListener(String listener, String modelSet);
460 * remove any callback using the given listener function and associated with
461 * the given alignFrame (or null for all callbacks)
468 public abstract void removeJavascriptListener(AlignFrame af,
472 * send a mouseover message to all the alignment windows associated with the
473 * given residue in the pdbfile
479 public abstract void mouseOverStructure(String pdbResNum, String chain,
483 * bind a pdb file to a sequence in the given alignFrame.
486 * - null or specific alignFrame. This specifies the dataset that
487 * will be searched for a seuqence called sequenceId
489 * - sequenceId within the dataset.
490 * @param pdbEntryString
491 * - the short name for the PDB file
493 * - pdb file - either a URL or a valid PDB file.
494 * @return true if binding was as success TODO: consider making an exception
495 * structure for indicating when PDB parsing or sequenceId location
498 public abstract boolean addPdbFile(AlignFrame alFrame, String sequenceId,
499 String pdbEntryString, String pdbFile);
502 * adjust horizontal/vertical scroll to make the given location the top left
503 * hand corner for the given view
507 * @param leftHandColumn
509 public abstract void scrollViewToIn(AlignFrame alf, String topRow,
510 String leftHandColumn);
513 * adjust vertical scroll to make the given row the top one for given view
518 public abstract void scrollViewToRowIn(AlignFrame alf, String topRow);
521 * adjust horizontal scroll to make the given column the left one in the given
525 * @param leftHandColumn
527 public abstract void scrollViewToColumnIn(AlignFrame alf,
528 String leftHandColumn);
533 * @see jalview.appletgui.AlignFrame#getFeatureGroups()
535 public abstract String getFeatureGroups();
539 * alignframe to get feature groups on
541 * @see jalview.appletgui.AlignFrame#getFeatureGroups()
543 public abstract String getFeatureGroupsOn(AlignFrame alf);
548 * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean)
550 public abstract String getFeatureGroupsOfState(boolean visible);
554 * align frame to get groups of state visible
557 * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean)
559 public abstract String getFeatureGroupsOfStateOn(AlignFrame alf,
564 * tab separated list of group names
567 * @see jalview.appletgui.AlignFrame#setFeatureGroupState(java.lang.String[],
570 public abstract void setFeatureGroupStateOn(AlignFrame alf,
571 String groups, boolean state);
573 public abstract void setFeatureGroupState(String groups, boolean state);
576 * List separator string
578 * @return the separator
580 public abstract String getSeparator();
583 * List separator string
586 * the separator to set. empty string will reset separator to default
588 public abstract void setSeparator(String separator);
591 * Retrieve fragments of a large packet of data made available by JalviewLite.
593 * @param messageclass
595 * @return next chunk of message
597 public abstract String getJsMessage(String messageclass, String viewId);