2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ 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,
82 * id of sequence to highlight
84 * integer position [ tobe implemented or range ] on sequence
85 * @param alignedPosition
86 * true/false/empty string - indicate if position is an alignment
87 * column or unaligned sequence position
89 public abstract void highlight(String sequenceId, String position,
90 String alignedPosition);
95 * id of sequence to highlight
97 * integer position [ tobe implemented or range ] on sequence
98 * @param alignedPosition
99 * false, blank or something else - indicate if position is an
100 * alignment column or unaligned sequence position
102 public abstract void highlightIn(AlignFrame alf, String sequenceId,
103 String position, String alignedPosition);
106 * select regions of the currrent alignment frame
109 * String separated list of sequence ids or empty string
111 * String separated list { column range or column, ..} or empty
114 public abstract void select(String sequenceIds, String columns);
117 * select regions of the currrent alignment frame
120 * String separated list { column range, seq1...seqn sequence ids }
122 * separator between toselect fields
124 public abstract void select(String sequenceIds, String columns,
128 * select regions of the given alignment frame
132 * String separated list { column range, seq1...seqn sequence ids }
134 * separator between toselect fields
136 public abstract void selectIn(AlignFrame alf, String sequenceIds,
140 * select regions of the given alignment frame
144 * String separated list { column range, seq1...seqn sequence ids }
146 * separator between toselect fields
148 public abstract void selectIn(AlignFrame alf, String sequenceIds,
149 String columns, String sep);
152 * get sequences selected in current alignFrame and return their alignment in
153 * format 'format' either with or without suffix
156 * - where selection is
158 * - format of alignment file
160 * - "true" to append /start-end string to each sequence ID
161 * @return selected sequences as flat file or empty string if there was no
164 public abstract String getSelectedSequencesAsAlignment(String format,
168 * get sequences selected in alf and return their alignment in format 'format'
169 * either with or without suffix
172 * - where selection is
174 * - format of alignment file
176 * - "true" to append /start-end string to each sequence ID
177 * @return selected sequences as flat file or empty string if there was no
180 public abstract String getSelectedSequencesAsAlignmentFrom(AlignFrame alf,
181 String format, String suffix);
184 * get a separator separated list of sequence IDs reflecting the order of the
189 public abstract String getAlignmentOrder();
192 * get a separator separated list of sequence IDs reflecting the order of the
198 public abstract String getAlignmentOrderFrom(AlignFrame alf);
201 * get a sep separated list of sequence IDs reflecting the order of the
209 public abstract String getAlignmentOrderFrom(AlignFrame alf, String sep);
212 * re-order the current alignment using the given list of sequence IDs
215 * - sep separated list
217 * - string to use when referring to ordering action in undo buffer
218 * @return 'true' if alignment was actually reordered. empty string if
219 * alignment did not contain sequences.
221 public abstract String orderBy(String order, String undoName);
224 * re-order the current alignment using the given list of sequence IDs
228 * - sep separated list
230 * - string to use when referring to ordering action in undo buffer
232 * @return 'true' if alignment was actually reordered. empty string if
233 * alignment did not contain sequences.
235 public abstract String orderBy(String order, String undoName, String sep);
238 * re-order the given alignment using the given list of sequence IDs separated
243 * - sep separated list
245 * - string to use when referring to ordering action in undo buffer
247 * @return 'true' if alignment was actually reordered. empty string if
248 * alignment did not contain sequences.
250 public abstract String orderAlignmentBy(AlignFrame alf, String order,
251 String undoName, String sep);
254 * get alignment as format (format names FASTA, BLC, CLUSTAL, MSF, PILEUP,
255 * PFAM - see jalview.io.AppletFormatAdapter for full list)
260 public abstract String getAlignment(String format);
263 * get alignment displayed in alf as format
269 public abstract String getAlignmentFrom(AlignFrame alf, String format);
272 * get alignment as format with jalview start-end sequence suffix appended
278 public abstract String getAlignment(String format, String suffix);
281 * get alignment displayed in alf as format with or without the jalview
282 * start-end sequence suffix appended
289 public abstract String getAlignmentFrom(AlignFrame alf, String format,
293 * add the given features or annotation to the current alignment
297 public abstract void loadAnnotation(String annotation);
300 * add the given features or annotation to the given alignment view
305 public abstract void loadAnnotationFrom(AlignFrame alf,
309 * parse the given string as a jalview feature or GFF annotation file and
310 * optionally enable feature display on the current alignFrame
313 * - gff or features file
314 * @param autoenabledisplay
315 * - when true, feature display will be enabled if any features can
316 * be parsed from the string.
318 public abstract void loadFeatures(String features,
319 boolean autoenabledisplay);
322 * parse the given string as a jalview feature or GFF annotation file and
323 * optionally enable feature display on the given alignFrame.
327 * - gff or features file
328 * @param autoenabledisplay
329 * - when true, feature display will be enabled if any features can
330 * be parsed from the string.
331 * @return true if data parsed as features
333 public abstract boolean loadFeaturesFrom(AlignFrame alf, String features,
334 boolean autoenabledisplay);
337 * get the sequence features in the given format (Jalview or GFF)
342 public abstract String getFeatures(String format);
345 * get the sequence features in alf in the given format (Jalview or GFF)
351 public abstract String getFeaturesFrom(AlignFrame alf, String format);
354 * get current alignment's annotation as an annotation file
358 public abstract String getAnnotation();
361 * get alignment view alf's annotation as an annotation file
366 public abstract String getAnnotationFrom(AlignFrame alf);
369 * create a new view and return the alignFrame instance
373 public abstract AlignFrame newView();
376 * create a new view named name and return the alignFrame instance
381 public abstract AlignFrame newView(String name);
384 * create a new view on alf and return the alignFrame instance
389 public abstract AlignFrame newViewFrom(AlignFrame alf);
392 * create a new view named name on alf
398 public abstract AlignFrame newViewFrom(AlignFrame alf, String name);
403 * alignment file as a string
406 * @return null or new alignment frame
408 public abstract AlignFrame loadAlignment(String text, String title);
411 * register a javascript function to handle any alignment mouseover events
414 * name of javascript function (called with arguments
415 * [jalview.appletgui.AlignFrame,String(sequence id),String(column in
416 * alignment), String(position in sequence)]
418 public abstract void setMouseoverListener(String listener);
421 * register a javascript function to handle mouseover events
424 * (null or specific alignframe for which events are to be listened
427 * name of javascript function
429 public abstract void setMouseoverListener(AlignFrame af, String listener);
432 * register a javascript function to handle any alignment selection events.
433 * Events are generated when the user completes a selection event, or when the
434 * user deselects all selected regions.
437 * name of javascript function (called with arguments
438 * [jalview.appletgui.AlignFrame, String(sequence set id),
439 * String(separator separated list of sequences which were selected),
440 * String(separator separated list of column ranges (i.e. single
441 * number or hyphenated range) that were selected)]
443 public abstract void setSelectionListener(String listener);
445 public abstract void setSelectionListener(AlignFrame af, String listener);
448 * register a javascript function to handle events normally routed to a Jmol
452 * - javascript function (arguments are variable, see
453 * jalview.javascript.MouseOverStructureListener for full details)
455 * - separator separated list of PDB file URIs that this viewer is
456 * handling. These files must be in the same order they appear in
457 * Jmol (e.g. first one is frame 1, second is frame 2, etc).
458 * @see jalview.javascript.MouseOverStructureListener
460 public abstract void setStructureListener(String listener,
464 * remove any callback using the given listener function and associated with
465 * the given alignFrame (or null for all callbacks)
472 public abstract void removeJavascriptListener(AlignFrame af,
476 * send a mouseover message to all the alignment windows associated with the
477 * given residue in the pdbfile
483 public abstract void mouseOverStructure(String pdbResNum, String chain,
487 * bind a pdb file to a sequence in the given alignFrame.
490 * - null or specific alignFrame. This specifies the dataset that
491 * will be searched for a seuqence called sequenceId
493 * - sequenceId within the dataset.
494 * @param pdbEntryString
495 * - the short name for the PDB file
497 * - pdb file - either a URL or a valid PDB file.
498 * @return true if binding was as success TODO: consider making an exception
499 * structure for indicating when PDB parsing or sequenceId location
502 public abstract boolean addPdbFile(AlignFrame alFrame, String sequenceId,
503 String pdbEntryString, String pdbFile);
506 * adjust horizontal/vertical scroll to make the given location the top left
507 * hand corner for the given view
511 * @param leftHandColumn
513 public abstract void scrollViewToIn(AlignFrame alf, String topRow,
514 String leftHandColumn);
517 * adjust vertical scroll to make the given row the top one for given view
522 public abstract void scrollViewToRowIn(AlignFrame alf, String topRow);
525 * adjust horizontal scroll to make the given column the left one in the given
529 * @param leftHandColumn
531 public abstract void scrollViewToColumnIn(AlignFrame alf,
532 String leftHandColumn);
537 * @see jalview.appletgui.AlignFrame#getFeatureGroups()
539 public abstract String getFeatureGroups();
543 * alignframe to get feature groups on
545 * @see jalview.appletgui.AlignFrame#getFeatureGroups()
547 public abstract String getFeatureGroupsOn(AlignFrame alf);
552 * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean)
554 public abstract String getFeatureGroupsOfState(boolean visible);
558 * align frame to get groups of state visible
561 * @see jalview.appletgui.AlignFrame#getFeatureGroupsOfState(boolean)
563 public abstract String getFeatureGroupsOfStateOn(AlignFrame alf,
568 * tab separated list of group names
571 * @see jalview.appletgui.AlignFrame#setFeatureGroupState(java.lang.String[],
574 public abstract void setFeatureGroupStateOn(AlignFrame alf, String groups,
577 public abstract void setFeatureGroupState(String groups, boolean state);
580 * List separator string
582 * @return the separator
584 public abstract String getSeparator();
587 * List separator string
590 * the separator to set. empty string will reset separator to default
592 public abstract void setSeparator(String separator);
595 * Retrieve fragments of a large packet of data made available by JalviewLite.
597 * @param messageclass
599 * @return next chunk of message
601 public abstract String getJsMessage(String messageclass, String viewId);