Skip to content

Commit

Permalink
do a little cleaning and add usual doc
Browse files Browse the repository at this point in the history
  • Loading branch information
osallou committed Dec 28, 2011
1 parent 4c5f35e commit df490f6
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 6 deletions.
1 change: 1 addition & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v0.1 : 12/11 Creation , Olivier Sallou <[email protected]>
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
All the code hereby is licensed under the CeCILL license (http://www.cecill.info/licences/Licence_CeCILL_V2-en.html) which is a GNU GPL equivalent for the French law.
16 changes: 16 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

* Requirements *

This software needs a web server with PHP enabled for additional features loading and image save function.
The rest of the software is pure web (HTML+Javascript).

The img/tmp directory must be writable by the web server to create images when "save alignment image" is selected.
Images in directory can be safely cleaned by a cron task to remove old images.

* Configuration *

If a seqcrawler server is available to extract additional features, then configuration must be updated
in features.php, the URL need to be adapted to the seqcrawler server.

In the other case, useFeatures must be set to 0 in js/uiseqblast.js

Binary file removed img/canvas4dde759f8ed73.png
Binary file not shown.
Binary file removed img/canvas4de4d7ecedd9d.png
Binary file not shown.
Binary file removed img/canvas4efafde84655b.png
Binary file not shown.
32 changes: 31 additions & 1 deletion js/uiblast.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
/**
* Library for index.html, managing a blast alignement display
*
* Author: Olivier Sallou <[email protected]>
*
*/




/**
* Return a specific iteration from iterations
*/
Expand Down Expand Up @@ -52,19 +62,39 @@ function drawSequences(min,max) {

var from = sequence["from"];
var to = sequence["to"];
/*
min<------------------------------->max
----- case1
----------------- case2
------------- case3
----------------------------------------------- case4
---- case5
------- case6
*/

if((from>=min && from<=max)&&(to>=min && to<=max)) {
// case1 : complete sequence is between min and max
context.fillText(sequence["seq"], xPos+Xseq+from-min, yPos);
}
else if(from>=min && from<=max) {
// case2
context.fillText(sequence["seq"].substring(0,max-from), xPos+Xseq+from-min, yPos);
}
else if(to>=min && to<=max) {
context.fillText(sequence["seq"].substring(min-from,max-min), xPos+Xseq, yPos);
// case3
//context.fillText(sequence["seq"].substring(min-from,max-min), xPos+Xseq, yPos);
context.fillText(sequence["seq"].substring(min-from), xPos+Xseq, yPos);
}
else if(from<=min && to>=max) {
// case 4
context.fillText(sequence["seq"].substring(min-from,max-from), xPos+Xseq, yPos);
}
// if none match, case 5 and 6, nothing to display for sequence
yPos+=step;
}
yPos=10;
Expand Down
36 changes: 33 additions & 3 deletions js/uiseqblast.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
/**
* Library for sequence.html, managing a Hit alignement display and additional features extraction
*
* Author: Olivier Sallou <[email protected]>
*
*/

/**
* Configuration
*/
useFeatures = 1;


/**
* Clear the canvas
*/
function clearCanvas() {
context.save();
context.fillStyle = "white";
Expand All @@ -6,6 +22,9 @@ function clearCanvas() {
}


/**
* Draw Hsps for the selected Hit between min and max position
*/
function drawSequences(min,max) {
clearCanvas();
max = parseInt(max);
Expand Down Expand Up @@ -92,12 +111,15 @@ for (var i=0;i<sequences.length;i++)
context.fillText(sequence["seq"].substring(min-from,max-from), xPos+Xseq, yPos);
}
yPos+=step;
addFeatures(sequence,max,min);
if(useFeatures==1) { addFeatures(sequence,max,min); }

}
yPos=20;
}

/**
* Draw a filler (blank)
*/
function drawFiller(x) {
var empty="";
for(var j=0;j<x;j++) {
Expand All @@ -107,6 +129,9 @@ function drawFiller(x) {
return empty;
}

/**
* Draw feature in canvas with input parameters
*/
function drawFeature(x,y,size,text,title) {
var empty=drawFiller(x);
var spaced="";
Expand All @@ -122,6 +147,9 @@ function drawFeature(x,y,size,text,title) {
}
}

/**
* Add features aligned with sequence alignment between min and max positions
*/
function addFeatures(sequence,max,min) {
if(sequence["features"]!=null) {
for (var i=0;i<sequence["features"].length;i++) {
Expand Down Expand Up @@ -157,7 +185,9 @@ function addFeatures(sequence,max,min) {
context.fillStyle="black";
}


/**
* Load XML file from input URL, extract Hit from hitnum parameter and load additional features with a call to features.php
*/
function getXML(xmlUrl) {

$.ajax( {
Expand Down Expand Up @@ -185,7 +215,7 @@ $.ajax( {

if(hspnum==$.getURLParam("hspnum")) {
$("#documentDetails" ).html('<p class="wait"><img title="loading" alt="loading" src="img/waiting.gif"/></p>');
$("#documentDetails" ).dialog({ title: 'Loading, please wait' , width : '200px' });
$("#documentDetails" ).dialog({ title: 'Loading features, please wait' , width : '200px' });
$.get("features.php?id="+accession+"&from="+$(this).find('Hsp_hit-from').text()+"&to="+$(this).find('Hsp_hit-to').text(),
function(jsonFeatures){
$("#documentDetails" ).dialog( "close" );
Expand Down
4 changes: 2 additions & 2 deletions savecanvas.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
// Save file. This example uses a hard coded filename for testing,
// but a real application can specify filename in POST variable
$name = "canvas".uniqid();
$fp = fopen( 'img/'.$name.'.png', 'wb' );
$fp = fopen( 'img/tmp/'.$name.'.png', 'wb' );
fwrite( $fp, $unencodedData);
fclose( $fp );

print $name.".png";
}
?>
?>

0 comments on commit df490f6

Please sign in to comment.