Skip to content

Commit

Permalink
More changes to improve formatting (mostly the control buttons)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewCRMartin committed Sep 23, 2015
1 parent ba00cbe commit 4225e68
Show file tree
Hide file tree
Showing 3 changed files with 249 additions and 32 deletions.
145 changes: 124 additions & 21 deletions JSAV.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,127 @@
.JSAVControls button {margin: 1px 4px 1px 0px;}
/***********************************************************************
Program: JSAV
File: JSAV.css
Version: V1.7
Date: 23.09.15
Function: JavaScript Sequence Alignment Viewier
Copyright: (c) Dr. Andrew C.R. Martin, UCL, 2014-2015
Author: Dr. Andrew C.R. Martin
Address: Institute of Structural and Molecular Biology
Division of Biosciences
University College
Gower Street
London
WC1E 6BT
EMail: andrew@bioinf.org.uk
**************************************************************************
This program is distributed under the Gnu Public licence (GPLv2 or
above)
/* .JSAV {padding: 2ex 1in;
border: 2px solid green;}
Alternative licences for commercial use are available on request.
**************************************************************************
Description:
============
JSAV is a simple JavaScript protein sequence alignment viewer. It
allows you to select a region of the alignment and sort on that
region.
**************************************************************************
Revision History:
=================
V1.0 06.06.14 Original By: ACRM
V1.1 10.06.14 Code cleanup
Changed options to a hash
Further code cleanup - some code was assuming
sequences were stored in an array called 'sequences'
Added 'selectable' option
12.06.14 Added 'deletable' and 'border' options
Implemented sequence deletion
13.06.14 Checks that some sequences are selected before
deletion
Cleaned up comments/documentation
Cleaned up defaults in printJSAV
Changed some routine names
V1.2 13.06.14 Added highlight option
Added submit/submitLabel options
Added action/actionLabel options
V1.2.1 15.06.14 Added height option
Changed to use ACRM_alert()
V1.2.2 16.06.14 Changed to use ACRM_confirm()
V1.3 16.06.14 Added dotify/nocolour/toggleDotify/toggleNocolour
V1.4 17.06.14 Added fasta/fastaLabel export options
Added consensus sequence display and colourScheme
Added selectColour/selectColor and
colourChoices/colorChoices
Added refresh of options on reload
V1.5 18.06.14 Added tooltips
V1.5.1 19.06.14 Added callback option
V1.6 17.09.14 Changed to manipulate the DOM rather than writing
to the document By: JHN
V1.7 23.09.15 Added options.toggleDotifyLabel
Added options.toggleNocolourLabel and options.toggleNocolorLabel
Added options.deleteLabel
Various CSS improvements By: ACRM
*/

/***********************************************************************/
/*** Things the user is LIKELY to want to change ***/
/***********************************************************************/
/* Text colour for the sequence ID labels */
.JSAV .idCell {color: #333399;}
/* Colour for the region marked for sorting */
.JSAV .marked {background-color: #AAAAAA;}
/* Colour for regions marked as highlighted with options.highlight */
.JSAV .highlighted {background-color: #00FF00;}
/* Size of the highlighting row */
.JSAV .highlightrow {height: 5px;}
/* Padding and border around the JSAV sequence display */
/* .JSAV {padding: 2ex 1in; border: 2px solid green;} */

/* Size and space of checkboxes for sequence selection */
.JSAV input[type=checkbox] /* Mini Checkboxes */
{
-ms-transform: scale(0.8); /* IE */
-moz-transform: scale(0.8); /* FF */
-webkit-transform: scale(0.8); /* Safari and Chrome */
-o-transform: scale(0.8); /* Opera */
margin: -3px 5px -3px -3px;
}

/* Spacing of controls from the sequence display */
.JSAVControls {margin: 1em 0 0 0;}
/* Spacing around the buttons in the controls section */
.JSAVControls button {margin: 1px 4px 1px 0px;}
/* Background colour for the residue range slider */
.JSAVControls .ui-slider-range { background: #AAAAAA; }
/* Handle colour for the residue range slider */
.JSAVControls .ui-slider-handle { background: #FFFFFF;
border-color: #AAAAAA;}
/*** Note that to get true JQueryUI-like styling you need to generate
a new theme with the alternate colour and use the image from that
for your buttons.
See http://stackoverflow.com/questions/4391588/changing-color-of-jquery-ui-buttons
***/
/* Any styling to apply to the sort button */
.JSAVControls .sortbutton { }
/* Any styling to apply to the export button */
.JSAVControls .exportbutton { }
/* Any styling to apply to the delete button */
.JSAVControls .deletebutton { }
/* Any styling to apply to the submit button */
.JSAVControls .submitbutton { }
/* Any styling to apply to the action button */
.JSAVControls .actionbutton { }
/* For example:
.JSAVControls .actionbutton { background: #FF4444;
border-color: #666666;
border-radius: 4px; }
*/

/***********************************************************************/
/*** Things the user is NOT likely to want to change ***/
/***********************************************************************/
.JSAV table {border-collapse: collapse;}
.JSAV tr {padding: 0;
margin: 0}
Expand All @@ -19,34 +138,18 @@
border-bottom: 1px solid black;
margin: 0 0 1px 0;}
.JSAV .markerrow {border-right: 1px solid black; height:10px}
.JSAV .idCell {color: #333399;}
.JSAV .selectCell {border-right: 1px solid black;}
.JSAV .consensusSelectCell {border-right: 1px solid black; border-top: 2px solid black}
.JSAV .consensusSelectCell {border-right: 1px solid black;
border-top: 2px solid black}
.JSAV .consensusCell {border-top: 2px solid black; }

.JSAV .unmarked {background-color: #FFFFFF;}
.JSAV .marked {background-color: #AAAAAA;}

.JSAV .unhighlighted {background-color: #FFFFFF;}
.JSAV .highlighted {background-color: #00FF00;}

.JSAV .highlightrow {height: 5px;}

.JSAV a:link {color:#000000; text-decoration:none;}
.JSAV a:visited {color:#000000; text-decoration:none;}
.JSAV a:hover {color:#FF0000; text-decoration:none;}
.JSAV a:active {color:#000000; text-decoration:none;}
.JSAV input[type=checkbox]
{
/* Mini Checkboxes */
-ms-transform: scale(0.8); /* IE */
-moz-transform: scale(0.8); /* FF */
-webkit-transform: scale(0.8); /* Safari and Chrome */
-o-transform: scale(0.8); /* Opera */
margin: -3px 5px -3px -3px;
}

.JSAVControls {margin: 1em 0 0 0;}

/* Delete and dot colours */
.JSAV .aaDel {background-color: #000000; color: #FFFFFF}
Expand Down
25 changes: 14 additions & 11 deletions JSAV.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ Where 'mySeqDisplay' is the name of a div that will be created
- 23.09.15 Added toggleDotifyLabel
Added toggleNocolourLabel/toggleNocolorLabel
Added deleteLabel
Move FASTA before submit and action buttons
By: ACRM
*/
function printJSAV(divId, sequences, options)
Expand Down Expand Up @@ -245,7 +246,7 @@ function printJSAV(divId, sequences, options)

JSAV_printSlider(divId, stop, options.width, options.height);

var html = "<button type='button' class='tooltip' title='Sort the sequences based on the range specified with the slider' onclick='JSAV_sortAndRefreshSequences(\"" + divId + "\", true, " + options.selectable + ", " + options.border + ")'>Sort</button>";
var html = "<button type='button' class='tooltip sortbutton' title='Sort the sequences based on the range specified with the slider' onclick='JSAV_sortAndRefreshSequences(\"" + divId + "\", true, " + options.selectable + ", " + options.border + ")'>Sort</button>";
div_controls.append(html);

}
Expand All @@ -256,6 +257,12 @@ function printJSAV(divId, sequences, options)
JSAV_printDelete(divId, options.deleteLabel);
}

// 23.09.15 Move FASTA before submit and action buttons
if(options.fasta)
{
JSAV_printFASTA(divId);
}

if(options.submit != undefined)
{
JSAV_printSubmit(divId, options.submit, options.submitLabel);
Expand All @@ -266,11 +273,6 @@ function printJSAV(divId, sequences, options)
JSAV_printAction(divId, options.action, options.actionLabel);
}

if(options.fasta)
{
JSAV_printFASTA(divId);
}

// Colour related - on a new line
if(options.selectColour || options.toggleDotify)
{
Expand Down Expand Up @@ -435,7 +437,7 @@ function JSAV_printFASTA(divId)
{
var parrenttag = '#' + divId + '_controls';
var label = gOptions[divId].fastaLabel;
var html = "<button type='button' class='tooltip' title='Export the selected sequences, or all sequences if none selected' onclick='JSAV_exportFASTA(\"" + divId + "\")'>"+label+"</button>";
var html = "<button type='button' class='tooltip exportbutton' title='Export the selected sequences, or all sequences if none selected' onclick='JSAV_exportFASTA(\"" + divId + "\")'>"+label+"</button>";
$(parrenttag).append(html);
}

Expand Down Expand Up @@ -591,6 +593,7 @@ function JSAV_buildHighlightHTML(divId, seqLen, selectable, highlight)
Prints the delete button
@param {string} divId - The ID of the div to print in
@param {string} label - The label to print in the delete button
@author
- 12.06.14 Original By: ACRM
Expand All @@ -601,7 +604,7 @@ Prints the delete button
function JSAV_printDelete(divId, label)
{
var parrenttag = '#' + divId + '_controls';
var html = "<button type='button' class='tooltip' title='Delete the selected sequences' onclick='JSAV_deleteSelectedSequences(\"" + divId + "\")'>" + label + "</button>";
var html = "<button type='button' class='tooltip delete' title='Delete the selected sequences' onclick='JSAV_deleteSelectedSequences(\"" + divId + "\")'>" + label + "</button>";
$(parrenttag).append(html);
}

Expand All @@ -621,7 +624,7 @@ Prints the submit button
function JSAV_printSubmit(divId, url, label)
{
var parrenttag = '#' + divId + '_controls';
var html = "<button type='button' class='tooltip' title='Submit the selected sequences, or all sequences if none selected' onclick='JSAV_submitSequences(\"" + divId + "\")'>" + label + "</button>";
var html = "<button type='button' class='tooltip submitbutton' title='Submit the selected sequences, or all sequences if none selected' onclick='JSAV_submitSequences(\"" + divId + "\")'>" + label + "</button>";
$(parrenttag).append(html);

// Build a hidden sequences text box in the form to contain
Expand All @@ -648,7 +651,7 @@ Prints the action button
function JSAV_printAction(divId, action, label)
{
var parrenttag = '#' + divId + '_controls';
var html = "<button type='button' class='tooltip' title='Process the selected sequences, or all sequences if none selected' onclick='JSAV_wrapAction(\"" + divId + "\", \"" + action + "\")'>" + label + "</button>";
var html = "<button type='button' class='tooltip actionbutton' title='Process the selected sequences, or all sequences if none selected' onclick='JSAV_wrapAction(\"" + divId + "\", \"" + action + "\")'>" + label + "</button>";
$(parrenttag).append(html);
}

Expand Down Expand Up @@ -930,7 +933,7 @@ function JSAV_buildASequenceHTML(id, sequence, prevSequence, selectable, dotify,
var tableLine = "";
if(isConsensus)
{
tableLine = "<tr class='tooltip, consensusCell' title='The consensus shows the most frequent amino acid. This is lower case if &le;50% of the sequences have that residue.' id='" + id + "'>";
tableLine = "<tr class='tooltip consensusCell' title='The consensus shows the most frequent amino acid. This is lower case if &le;50% of the sequences have that residue.' id='" + id + "'>";
}
else
{
Expand Down
111 changes: 111 additions & 0 deletions index3.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
<DOCTYPE html>
<html lang="en">
<head>
<title>JSAV</title>

<!-- JQuery and JQuery-UI -->
<link href="external/jquery.css" rel="stylesheet" />
<script type='text/javascript' src='external/jquery-1.10.2.min.js'></script>
<script type='text/javascript' src='external/jquery-ui-1.10.4.custom.min.js'></script>

<!-- JSAV -->
<link href="JSAV.css" rel="stylesheet" />
<script type='text/javascript' src='JSAV.js'></script>

<!-- If using tooltipster -->
<link href="external/tooltipster-master/css/tooltipster.css" rel="stylesheet" />
<script type='text/javascript' src='external/tooltipster-master/js/jquery.tooltipster.min.js'></script>
<script>
function enableTooltipster()
{
$(document).ready(function() {
$('.tooltip').tooltipster();
});
}
enableTooltipster();
</script>
<!-- END -->

</head>

<body>
<script type='text/javascript'>
var MySeqs = [];

MySeqs.push({ id :"id1b1.L", sequence :"SASSSVNYMYACREFGHIKLMNPTRSTVWY"});
MySeqs.push({ id :"id1a.L", sequence :"SASSSTNYMYACDEFGHIKLMNPQRSTVWY"});
MySeqs.push({ id :"id2b1.L", sequence :"SASSTCNYMTACDEEGHIKLMNP-RSTCWY"});
MySeqs.push({ id :"id2a.L", sequence :"SASSSCNYMTLCDEHGHIKLMNP-RSTCWY"});
MySeqs.push({ id :"id2a1.L", sequence :"SASSSCNYMTLCDEHGHIKLMNPQRSTCWY"});
MySeqs.push({ id :"id1.L", sequence :"SASSSVNYMYACDEFGHIKLMNPQRSTVWY"});
MySeqs.push({ id :"id1b.L", sequence :"SASSSVNYMYACREFGHIKLMNPQRSTVWY"});
MySeqs.push({ id :"id1a1.L", sequence :"SASSSTNYMYLCDEFGHIKLMNPQRSTVWY"});
MySeqs.push({ id :"id2.L", sequence :"SASSSCNYMTACDEHGHIKLMNP-RSTCWY"});
MySeqs.push({ id :"id2b.L", sequence :"SASSTCNYMTACDEHGHIKLMNP-RSTCWY"});
</script>

<h1>JavaScript Sequence Alignment Viewer (JSAV)</h1>
<p>JSAV is a JavaScript program to display and sort a sequence
alignment. 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.</p>

<p>Sequences are:</p>
<script type='text/javascript'>
function myAction(divId, sequences)
{
var seqString = "";
for(var i=0; i<sequences.length; i++)
{
seqString += ">" + sequences[i].id + "\n";
seqString += sequences[i].sequence + "\n";
}
alert(seqString);
}

var MyOptions = Array();
MyOptions.sortable = true;
MyOptions.selectable = true;
MyOptions.deletable = true;
MyOptions.border = false;
MyOptions.highlight = [3,5,10,14];
MyOptions.submit = "http://www.bioinf.org.uk/cgi-bin/echo.pl";
MyOptions.submitLabel = "Submit";
MyOptions.action = "myAction";
MyOptions.actionLabel = "Process";
MyOptions.toggleDotify = true;
MyOptions.toggleDotifyLabel = "Dotify";
MyOptions.toggleNocolour = true;
MyOptions.toggleNocolourLabel = "Nocolour";
MyOptions.fasta = true;
MyOptions.fastaLabel = "Export";
MyOptions.consensus = true;
MyOptions.colourScheme = "zappo";
MyOptions.selectColour = true;
MyOptions.callback = "enableTooltipster";
MyOptions.colourChoices = ["Taylor", "Clustal", "Zappo", "HPhob"];

printJSAV('sequenceDisplay', MySeqs, MyOptions);
</script>

<p>Input to the JavaScript is simply an array of sequences in
the form:</p>
<pre>
sequences[0] = { id :"id1b1.L", sequence :"SASSSVNYMYACREFGHIKLMNPTRSTVWY"};
</pre>
<p>and the display and sorter is created with</p>
<pre>
printJSAV('sequenceDisplay', sequences, options);
sequenceDisplay - div in which to display the viewer
sequences - array of sequence objects
options - an object describing options
</pre>




</body>
</html>

0 comments on commit 4225e68

Please sign in to comment.