(multi-dimensional) Array
Usage:
ACRM_array(); // [] or new Array()
ACRM_array(2); // new Array(2)
ACRM_array(3, 2); // [new Array(2),
// new Array(2),
// new Array(2)]
Type
array
ACRM_confirm(title, msg, callback)
General purpose confirm() dialogue using JQueryUI dialog rather than the
simple JavaScript confirm() method
Parameters:
Name
Type
Description
title
string
title for the confirm box
msg
string
the message to be displayed
callback
function
function to be called after the OK or cancel
button is called. A boolean parameter is
passed to the function - true for OK, false
for cancel
Builds the HTML for printing a sequence as a table row. The row
starts with the identifier and is followed by each amino acid in a
separate
tag with a class to indicate the amino acid type
(e.g. taylorW for a tryptophan in Willie Taylor scheme).
Parameters:
Name
Type
Description
id
string
The identifier
sequence
string
A string containing the sequence
prevSequence
string
A string containing the previous sequence
selectable
bool
Display a selection checkbox
dotify
bool
Dotify the sequence
nocolour
bool
Don't colour dotified residues
isConsensus
bool
This is the consensus sequence
colourScheme
string
Name of colour scheme - maps to CSS -
see JSAV_initColourChoices()
idSubmit
string
URL to visit when sequence label clicked
idSubmitClean
bool
Remove non-alpha characters from sequence
before submitting it
Author:
- 30.05.14 Original By: ACRM
- 16.06.14 Added dotify and nocolour - now takes prevSequence parameter
- 17.06.14 Added isConsensus and colourScheme
- 18.06.14 Added tooltip
- 23.09.15 Added idSubmit/idSubmitClean
- 11.02.16 Added idSubmitAttribute, now takes a sequence object rather than
the sequence and the id
Builds HTML for table rows that highlight a region in the alignment as
being important (e.g. CDRs of antibodies). Note that ranges for highlighting
count from zero.
Takes two sequences as strings and calculates the number of
differences between them (effectively the Hamming distance).
If ignoreEnds is specified then don't include gap characters at
the ends of the sequences
Parameters:
Name
Type
Description
seq1
string
Sequence string
seq2
string
Sequence string
regionStart
int
Offset of start of region to sort
regionStop
int
Offset of end of region to sort
ignoreEnds
BOOL
Ignore gaps at the end of the sequences
in calculating differences
Author:
- 29.05.14 Original By: ACRM
- 04.06.14 Added ignoreEnds handling
Created this Range version
Choose a representative from a difference matrix. The difference
matrix contains the number of differences between each pair of
sequences. This routine simply totals up the number of differences
for each sequence compared with all the other sequences and then
chooses the one with fewest differences
- 12.06.14 Original By: ACRM
- 15.06.14 Changed from alert() to ACRM_alert()
- 16.06.14 Changed from confirm() to ACRM_confirm()
- 17.06.14 Added consensus
- 22.12.15 Added passing of labels
Takes an array of sequence indexes, the index of a reference sequence
and the difference matrix between all sequences. It then returns an
array of sequence indexes for all the sequences most similar to the
reference sequence
Indexes of the sequences closest to
the reference sequence
Type
int[]
JSAV_FindRealSequenceEnds(seqArray) → {int[]}
Finds the real ends of a sequence stored in an array by skipping over
'-' characters. Returns the offsets of the actual ends.
NOTE: Consequently to loop over the sequence you now need to do
for(var i=seqEnds[0]; i<=seqEnds[1]; i++)
i.e. <= rather than < the last position
Marks a range of residues in the main sequence display table.
The special marker row is used for this and we simply alter the
class to pick up the appropriate colour for the cells from CSS
Parameters:
Name
Type
Description
divId
string
Identifier for the display div
seqLen
int
Length of the alignment
start
int
Offset of first residue to be
marked (0-based)
stop
int
Offset of last residue to be
marked (0-based)
Author:
- 06.06.14 Original By: ACRM
- 13.06.14 Changed from highlighted to marked
- 12.06.14 Original By: ACRM
- 18.06.14 Added tooltip
- 02.09.14 Modifies the DOM rather than printing to the document By: JHN
- 23.09.15 Added label parameter and use of this label By: ACRM
Builds and prints the slider for selecting a maximum and minimum position for
sorting. Also calls routine to display the currently selected range -
i.e. the whole sequence length
Parameters:
Name
Type
Description
divId
string
The name of the div used for the display
seqLen
int
The length of the sequence alignment
width
string
The width of the slider
height
string
The height of the slider (text size)
Author:
- 06.06.14 Original By: ACRM
- 10.06.14 Removed redundant variable and changed divs to spans
- 15.06.14 Added height
- 16.06.14 Original By: ACRM
- 18.06.14 Added tooltip
- 02.09.14 Modifies the DOM rather than printing to the document By: JHN
- 23.09.15 Dotify label now comes from options By: ACRM
Print a checkbox for toggling nocolour-dotify mode
Parameters:
Name
Type
Description
divId
string
The div that we are working in
options
object
The options
Author:
- 16.06.14 Original By: ACRM
- 18.06.14 Added tooltip
- 02.09.14 Modifies the DOM rather than printing to the document By: JHN
- 23.09.15 Obtains label from options.toggleNocolourLabel By: ACRM
Displays the currently selected range as text and calls the routine
to higlight that range in the alignment view.
Called as JSAV_showRange(divID), or as a callback from a slider event
Parameters:
Name
Type
Description
eventOrId
JQEvent
JQuery Event
ui
JQ-UI
JQuery UI object
--OR--
eventOrId
text
Identifier of the display div
ui
null
Must be set to null
Author:
- 06.06.14 Original By: ACRM
- 10.06.14 Removed redundant .closest() from finding parent
- 23.09.15 Changed "Sort from: xx to: xx" to "Region: positions xx to yy"
- 24.09.15 Changed to using .html() instead of .text()
Sorts a set of sequences and refreshes the display in a div with
the specified ID - the idea is that the unsorted sequences would
be displayed here and then this is tied to the action on a button
that sorts and refreshes the display.
Parameters:
Name
Type
Description
divId
char
ID of an HTML
sortable
bool
Is the display sortable
selectable
bool
Are checkboxes shown next to sequences
border
bool
Should CSS be updated to show a border
Author:
- 29.05.14 Original By: ACRM
- 11.06.14 sequences is now global
- 12.06.14 split out the JSAV_refresh() part
- 16.06.14 Added dotify and nocolour options to refresh call
- 17.06.14 Added consensus
- 22.12.15 Added passing of labels
Sorts an array of sequence objects to group similar sequences together.
The sorting method chooses a representative sequence (one
which is most similar to all the other sequences) placing that first
in the list. To add to the sorted list, it iteratively chooses the
sequences that are most similar to the last one in the list and, of
those chooses the sequence most similar to the representative
sequence
Parameters:
Name
Type
Description
sequences
object[]
Array of sequence objects
start
int
Offset of start of region to sort
stop
int
Offset of end of region to sort
Author:
- 29.05.14 Original By: ACRM
- 04.06.14 Added ignoreEnds (true) to JSAV_calcDifferenceMatrix() call
Range version
Handles the user clicking the submit button. Build a FASTA version of the
sequences that have been selected, fills them into a textarea in a form
and then submits the form.
Parameters:
Name
Type
Description
divId
string
The ID of the div we are working in
Author:
- 13.06.14 Original By: ACRM
- 17.06.14 Split out the JSAV_buildFASTA() section
Wrap the action function. When the action button is clicked, this function
is called to extract the relevant sequence data and call the user specified
function, passing the divId and an array of sequence objects
Parameters:
Name
Type
Description
divId
string
The ID of the div to work in
action
string
The name of the user function
Author:
- 13.06.14 Original By: ACRM
- 11.02.16 Modified the push so that it pushes the whole object rather than
just the selected fields. This allows additional information fields
to be passed around associated with a sequence but not displayed
This is the only routine called by a user. It takes an array of
sequence objects and displays them as a coloured sortable table
optionally with a slider and sort button, delete button, etc
Parameters:
Name
Type
Description
sequences
object[]
Array of sequence objects
divId
string
ID of div to print in
options
Object
Options that can be provided - see Properties
Properties:
Name
Type
Description
options.sortable
bool
Should the sorting options be displayed
(default: false)
options.width
string
The width of the selection slider with
units (default: '400px')
options.height
string
The height of the selection slider with
units (default: '6pt')
options.selectable
bool
Should selection checkboxes be displayed
for each sequence
options.deletable
bool
Makes it possible to delete sequences
options.deleteLabel
string
Label for delete button
options.highlight
int[]
Array of ranges to highlight
options.submit
string
URL for submitting selected sequences
options.submitLabel
string
Label for submit button
options.idSubmit
string
URL for submitting a single sequence where its
id/label has been clicked.
See also options.idSubmitAttribute
options.idSubmitClean
bool
Remove non-alpha characters from sequence
before submitting
options.idSubmitAttribute
string
Specifies which attribute of the sequence
object should be passed to a URL specified
with options.idSubmit. Default is 'sequence'
options.action
string
Function to call using selected sequences.
This is passed the seqId and array of
currently selected sequence objects
options.actionLabel
string
Label for action button
options.dotify
bool
Repeated amino acids in the sequence are
replaced by a dot
options.nocolour
bool
Dotified amino acids are not coloured
(except deletions)
options.toggleDotify
bool
Create a check box for toggling dotify
options.toggleDotifyLabel
string
Label for dotify checkbox toggle
options.toggleNocolour
bool
Create a check box for toggling nocolour
options.toggleNocolourLabel
string
Label for nocolour checkbox toggle
options.fasta
bool
Create a FASTA export button
options.fastaLabel
string
Label for FASTA export button
options.consensus
bool
Display consensus sequence
options.colourScheme
string
Default colour scheme - valid options
depend on the css, but are currently
taylor, clustal, zappo, hphob, helix,
strand, turn, buried. Note that this must be
specified in lower case
options.selectColour
bool
Display a pull-down to choose the colour
scheme.
options.colourChoices
string[]
Array of colour scheme names - only used
if the user has added to the CSS. This
can be in mixed case.
options.plainTooltips
bool
Don't use JQuery tooltips
options.callback
callback
Specify the name of a function to be
called whenever the display is refreshed.
This is passed the seqId
options.scrollX
string
Specify a width for the sequence display
div and make it scrollable (e.g. "500px")
Use "100%" to make it the width of the
screen (or containing div)
options.scrollY
string
Specify a height for the sequence display
div and make it scrollable (e.g. "500px")
- 29.05.14 Original By: ACRM
- 30.05.14 Now just calls JSAV_buildSequencesHTML() and prints the results
- 05.06.14 Added divId parameter and sortable
- 06.06.14 Added width
- 10.06.14 sortable and width parameters now replaced by 'options'
Added 'selectable' option
Stores sequence length in global array
- 11.06.14 Added deletable
- 13.06.14 Cleaned up use of defaults
- 13.06.14 Added highlight
- 13.06.14 Added submit and action, submitLabel and actionLabel
- 15.06.14 Added height
- 16.06.14 Added dotify, nocolour, toggleDotify, toggleNocolour
- 17.06.14 Added fasta, fastaLabel
Added consensus
Added colourScheme/colorScheme
Added selectColour/selectColor and colourChoices/colorChoices
- 18.06.14 Added tooltips and plainTooltips option
- 19.06.14 Added callback
- 02.09.14 Avoid using write and writeln. Rather use jQuery to insert into DOM.
Fixes overwrite issues with using after page closure. By: JHN
- 23.09.15 Added toggleDotifyLabel
Added toggleNocolourLabel/toggleNocolorLabel
Added deleteLabel
Move FASTA before submit and action buttons
Added idSubmit and idSubmitClean
By: ACRM
- 24.09.15 Added scrollX and scrollY
- 22.12.15 Added labels and autolabels
- 11.02.16 Added idSubmitAttribute
var Seqs = [];
Seqs.push({id :"id1b1.L", sequence :"SASSSVNYMYACREFGHIKLMNPTRSTVWY"});
Seqs.push({id :"id1a.L", sequence :"SASSSTNYMYACDEFGHIKLMNPQRSTVWY"});
var options = Array();
options.width = '400px';
options.sortable = true;
options.highlight = [3,5,10,14];
options.submit = "http://www.bioinf.org.uk/cgi-bin/echo.pl";
options.submitLabel = "Submit sequences";
options.action = "myAction";
options.actionLabel = "My Action";
options.consensus = true;
options.deletable = true;
options.fasta = true;
printJSAV('mySeqDisplay', sequenceArray, options);
Where 'mySeqDisplay' is the name of a div that will be created
sequenceArray is an array of sequence objects
options is an object describing options - see below
Note that the sequence object can contain additional fields that mean nothing to
JSAV itself but may be used by 'actions' that are called from JSAV (e.g. an
accession code).