3 $(document).ready(function () {
22 //start the tool when click on Run VIGS Analysis
23 $('#upload_expression_file').click(function () {
25 //get the expression file from the web input form
26 expr_f = $('#expression_file').val();
27 $("#region_square").css("height","0px");
30 $("#upload_expression_form").submit();
33 //get the expression file from the form (in a iframe) and start the analysis
34 $('#upload_expression_form').iframePostForm({
38 complete: function (response) {
40 alert("The expression file could not be uploaded"+response.error);
42 if (response.success) {
43 expr_f = response.expr_file;
45 //get the arguments from the HTML elements
46 seq = $("#sequence").val();
47 si_rna = $("#si_rna").val();
48 f_length = $("#f_length").val();
50 db = $("#bt2_db").val();
53 runBt2(si_rna, f_length, mm, db);
58 //expand/collapse the n-mers graph when click on 'Collapse Graph' button
59 $('#collapse').click(function () {
60 activateCollapse(score_array,best_seq,seq,expr_msg,ids,m_aoa);
63 //zoom in/out the n-mers graph when click on 'Zoom' button
64 $('#zoom').click(function () {
65 activateZoom(score_array,best_seq,seq,expr_msg,ids,m_aoa);
68 //display custom region selection rectangle when click on 'Set Custom Region' button
69 $('#set_custom').click(function () {
70 getCustomRegion(score_array,best_seq,seq);
73 $('#change_par').click(function () {
74 res = changeTargets(bt2_file,score_array,seq,best_seq,expr_f,ids,m_aoa);
83 $('#region_square').mouseup(function () {
84 getSquareCoords(score_array,best_seq,seq);
87 $('#open_descriptions_dialog').click(function () {
88 $('#dialog_info').replaceWith($('#target_info').clone());
90 $('#desc_dialog').dialog({
97 title: "Gene Functional annotation",
101 $('#params_dialog').click(function () {
103 $('#params').html("• <b>Fragment size: </b>"+$("#help_fsize").val()+"<br /> \
104 • <b>n-mer: </b>"+$("#help_nmer").val()+"<br /> \
105 • <b>Mismatches: </b>"+$("#help_mm").val()+"<br />\
106 • <b>Database: </b>"+$("#db_name").val());
108 $('#params').dialog({
113 title: "Parameters used",
117 $('#help_dialog_1').click(function () {
119 $('#help_dialog_tmp').html("• The best target region score value indicates how good the yellow highlighted region is, taking into account the number of target and off-target n-mers. \
120 The closer to 100 the better is the value. In the same way, the custom region score indicates the value of the custom region, represented by the transparent grey rectangle.<br/> \
121 • Set Custom Region button will activate a draggable and resizable transparent grey rectangle to manually select a custom region.<br/> \
122 • Change button will recalculate the results using the new parameters chosen. In case of changing the n-mer size, the algorithm will run Bowtie 2 again, so this process could take a while.");
124 $('#help_dialog_tmp').dialog({
129 title: "Modify parameters help",
133 $('#help_dialog_2').click(function () {
135 $('#help_dialog_tmp').html("• N-mers mapping to the target/s are shown in blue and to off-targets in red. The yellow area highlights the region with the highest score using the selected parameters<br/> \
136 • The bottom graph represents in red the score values along the sequence. The score value = 0 is indicated with a green line. \
137 Below this line are represented the regions with more off-targets than targets, and the opposite when the score is above the green line.<br/> \
138 • Expand graph button will display every n-mer fragment aligned over the query for each subject.<br /> \
139 • Zoom button will zoom in/out the VIGS map representation.");
141 $('#help_dialog_tmp').dialog({
146 title: "Distribution of n-mers help",
150 $('#help_dialog_3').click(function () {
152 $('#help_dialog_tmp').html("• This section shows the best or the custom region sequence in FASTA format.<br/> \
153 • The custom region will update as the grey selection rectangle is moved.");
155 $('#help_dialog_tmp').dialog({
160 title: "Best region help",
164 $('#help_dialog_4').click(function () {
166 $('#help_dialog_tmp').html("• In this section is shown the query sequence, highlighting the best target region in yellow or the custom region in grey.<br/> \
167 • The custom region will be updated as the grey selection rectangle is moved.");
169 $('#help_dialog_tmp').dialog({
174 title: "Sequence overview help",
178 $('#help_dialog_5').click(function () {
180 $('#help_dialog_tmp').html("• Number of n-mer matches and gene functional description are shown for each matched gene.<br/> \
181 • The View link will open a draggable dialog with this information.");
183 $('#help_dialog_tmp').dialog({
188 title: "Description of genes mapped help",
192 $('#clear_form').click(function () {
193 $("#sequence").val(null);
194 $("#si_rna").val(21);
195 $("#f_length").val(300);
197 $("#expression_file").val(null);
200 $('#working').dialog( {
205 closeOnEscape: false,
208 open: function() { $(this).closest('.ui-dialog').find('.ui-dialog-titlebar-close').hide(); },
212 // sent the data to the controller to run bowtie2 and parse the results
213 function runBt2(si_rna, f_length, mm, db) {
216 $("#no_results").html("");
217 // alert("seq: "+seq.length+", si_rna: "+si_rna+", f_length: "+f_length+", mm: "+mm+", db: "+db+", expr_file: "+expr_file);
219 url: '/tools/vigs/result/',
223 data: { 'tmp_file_name': temp_file, 'sequence': seq, 'fragment_size': si_rna, 'seq_fragment': f_length, 'missmatch': mm, 'database': db },
224 beforeSend: function(){
227 success: function(response) {
228 if (response.error) {
229 alert("ERROR: "+response.error);
232 db_name = response.db_name;
233 bt2_file = response.jobid;
235 $("#help_fsize").val(f_length);
236 $("#help_nmer").val(si_rna);
237 $("#help_mm").val(mm);
238 $("#db_name").val(db_name);
240 getResults(1, bt2_file, si_rna, f_length, mm, 0, db, expr_f);
243 error: function(response) {
244 alert("An error occurred. The service may not be available right now. Bowtie2 could not be executed");
252 function getResults(status, bt2_res, si_rna, f_length, mm, coverage, db, expr_file) {
254 var t_info = "<tr><th>Gene</th><th>Matches</th><th>Functional Description</th></tr>";
255 $("#no_results").html("");
258 url: '/tools/vigs/view/',
262 data: {'id': bt2_res, 'sequence': seq, 'fragment_size': si_rna, 'seq_fragment': f_length, 'missmatch': mm, 'targets': coverage, 'expr_file': expr_file, 'status': status, 'database': db},
263 complete: function(){
267 success: function(response) {
268 if (response.error) {
269 alert("ERROR: "+response.error);
273 //assign values to global variables
274 score_array = response.all_scores;
275 best_seq = response.best_seq;
276 expr_msg = response.expr_msg;
277 var best_score = response.score;
278 var best_start = response.cbr_start;
279 var best_end = response.cbr_end;
280 seq = response.query_seq;
281 var seq_length = seq.length;
282 coverage = response.coverage;
284 m_aoa = response.matches_aoa;
286 $("#score_p").html("<b>Best target region score:</b> "+best_score+" (-∞—100)<br />");
287 $("#t_num").val(coverage);
289 if (+response.score < 0) {
290 $("#no_results").html("Note: The score value is very low!. Increasing the number of targets or the n-mer length, or decreasing the mismatches the score value will increase");
293 //show result sections
294 $("#hide1").css("display","inline");
296 //assign values to html variables
297 $("#coverage_val").val(coverage);
298 $("#seq_length").val(seq_length);
299 $("#f_size").val(response.f_size);
300 $("#n_mer").val(si_rna);
301 $("#align_mm").val(response.missmatch);
302 $("#best_start").val(best_start);
303 $("#best_end").val(best_end);
304 $("#cbr_start").val(best_start);
305 $("#cbr_end").val(best_end);
306 $("#best_score").val(best_score);
307 $("#img_height").val(response.img_height);
309 //set collapse and zoom buttons
310 $("#collapse").val(1);
311 $("#collapse").html("Expand Graph");
313 $("#zoom").html("Zoom In");
315 createMap(1,0,score_array,expr_msg,ids,m_aoa);
317 if (+best_seq.length > 10) {
318 $("#best_seq").html("<b>>best_target_region_("+best_start+"-"+best_end+")</b><br />"+best_seq);
320 $("#best_seq").html("<b>No results were found</b>");
322 $("#query").html(seq);
323 hilite_sequence(best_start,best_end,0);
328 for (var i=0; i<ids.length; i=i+1) {
329 if (ids[i][2].match(/Niben/)) {
330 desc = ids[i][2].replace(/Niben\d+Scf[\:\.\d]+/,"");
331 gene_name = ids[i][0];
332 } else if (ids[i][0].match(/Solyc/)) {
333 desc = ids[i][2].replace(/.+functional_description:/,"");
334 desc = desc.replace(/\"/g,"");
335 gene_name = ids[i][0].replace(/lcl\|/,"");
337 gene_name = ids[i][0];
340 t_info += "<tr><td>"+gene_name+"</td><td style='text-align:right;'>"+ids[i][1]+"</td><td>"+desc+"</td></tr>";
343 $("#target_info").html(t_info);
344 $("#hide2").css("display","inline");
345 $("#hide3").css("display","inline");
347 $("#help_fsize").val(f_length);
348 $("#help_mm").val(mm);
351 error: function(response) {
352 alert("An error occurred. The service may not be available right now.");
360 function createMap(collapsed,zoom,score_array,expr_msg,ids,m_aoa) {
361 var img_height = +$("#img_height").val();
362 var best_start = +$("#best_start").val();
363 var best_end = +$("#best_end").val();
364 var seq_length = +$("#seq_length").val();
366 var xscale = +(700/seq_length); // to transform sequence length to pixels
369 var c=document.getElementById("myCanvas");
370 var ctx=c.getContext("2d");
373 c.height = +(((ids.length)*35)+73);
374 img_height = c.height;
376 c.height = +img_height;
378 if (seq_length < 700 || zoom) {
380 img_width = seq_length;
385 var cbr_start = +(best_start*xscale);
386 var cbr_width = +((best_end-best_start)*xscale);
388 //print black background
390 ctx.rect(0,(img_height-52),img_width,102);
391 ctx.fillStyle='rgb(30,30,30)';
395 //print yellow rectangle for the best region
397 ctx.rect(cbr_start,0,cbr_width,img_height);
398 ctx.strokeStyle='yellow';
399 ctx.fillStyle='yellow';
403 //print the rectangles
404 off_set_array = printSquares(collapsed,zoom,ids,m_aoa);
406 //print vertical lines and tick values
407 ctx.fillStyle='black';
409 ctx.strokeStyle='rgb(200,200,200)';
410 ctx.font="10px Arial";
411 if (seq_length >=2700) {ctx.font="8px Arial";}
412 if (seq_length >=4500) {ctx.font="6px Arial";}
414 for (var l=100; l<seq_length; l+=100) {
418 ctx.lineTo(i,img_height);
419 ctx.fillText(vline_tag,i-14,12);
425 // print horizontal line under ticks
428 ctx.lineTo(img_width,20);
430 ctx.strokeStyle='#000000';
433 //print subject names
434 var ids_aoa = expr_msg; //aoa with subject ids
435 for (var t=0; t<ids_aoa.length;t++) {
437 ctx.fillStyle='#000000';
438 ctx.font="12px Arial";
439 ctx.fillText(ids_aoa[t][0],5,off_set_array[t]+17);
442 printScoreGraph(collapsed,zoom,score_array,ids);
446 function printSquares(collapsed,zoom,ids,m_aoa) {
447 var coverage = $("#coverage_val").val();
448 var seq_length = $("#seq_length").val();
450 var xscale = +(700/seq_length); // to transform sequence length to pixels
452 var off_set = 20; //just under the horizontal line
455 var before_block = 20;
456 var after_block = 10;
461 if (seq_length < 700 || zoom) {
463 img_width = seq_length;
466 var off_set_array = []; //to print names
468 var c=document.getElementById("myCanvas");
469 var ctx=c.getContext("2d");
474 for (var t=0; t<ids.length;t++) {
475 var max_row_num = 0; //to calculate the height of every track
476 off_set_array.push(off_set);
478 off_set += before_block; //add some space for the names
480 //target and off-target colors
482 ctx.strokeStyle='rgb(0,0,180)';
483 ctx.fillStyle='rgb(0,120,255)';
485 ctx.strokeStyle='rgb(150,0,0)';
486 ctx.fillStyle='rgb(255,0,0)';
489 var prev_match_end = 9999;
490 var prev_match_start = 0;
491 var collapsed_start = 0;
492 var collapsed_end = 0;
494 //each match (rectangles)
495 for (var i=0; i<m_aoa[t].length;i++) {
497 var coord = m_aoa[t][i].split("-"); //array with start and end for every match
498 m_width = +((+coord[1] - +coord[0] +1)*xscale); //rectangle width in pixels
499 m_start = +(+coord[0]*xscale); //rectangle start in pixels
501 //to allow as many rows as the n-mer size
502 var match_distance = +(+coord[0] - +prev_match_start);
503 if ((row < si_rna -1) && (coord[0] <= prev_match_end) && prev_match_end != 9999) {
504 if ((match_distance > 1) && ((+row + match_distance) > si_rna)) {
514 coord_y = off_set + row*4;
518 ctx.rect(m_start,coord_y,m_width,4);
523 if (collapsed_start == 0) {
524 collapsed_start = +coord[0];
526 if (+coord[0] < +prev_match_end) {
527 collapsed_end = prev_match_end;
529 coord_y = off_set; //to collapse all rectangles of the track
530 if (collapsed_end == 9999) {collapsed_end = prev_match_end;}
531 var collapsed_width = (+collapsed_end - +collapsed_start + 1)*xscale;
535 ctx.rect(collapsed_start*xscale,coord_y,collapsed_width,4);
539 collapsed_start = coord[0];
540 collapsed_end = coord[1];
543 prev_match_end = +coord[1];
544 prev_match_start = +coord[0];
546 if (row > max_row_num) {max_row_num = row;} //get maximum number of rows per track to calculate the track height
550 var track_height = (max_row_num*4)+after_block;
551 off_set += track_height; //add space for next track
553 if (collapsed_end == 9999) {collapsed_end = prev_match_end;}
554 coord_y = off_set; //to collapse all rectangles of the track
555 var collapsed_width = (+collapsed_end - +collapsed_start + 1)*xscale;
559 ctx.rect(collapsed_start*xscale,coord_y,collapsed_width,4);
566 // print horizontal line under tracks
568 ctx.moveTo(0,off_set);
569 ctx.lineTo(img_width,off_set);
571 ctx.strokeStyle='rgb(200,200,200)';
574 return off_set_array;
578 function printScoreGraph(collapsed,zoom,score_array,ids) {
579 var img_height = document.getElementById("img_height").value;
580 var coverage = $("#coverage_val").val();
581 var seq_length = $("#seq_length").val();
583 var xscale = +(700/seq_length); // to transform sequence legth to pixels
584 var img_h = +(img_height-52);
588 img_h = +((ids.length*35)+21);
590 if (seq_length < 700 || zoom) {
592 img_width = seq_length;
595 var c=document.getElementById("myCanvas");
596 var ctx=c.getContext("2d");
598 //print black background
600 ctx.rect(0,img_h,img_width,52);
601 ctx.globalAlpha = 0.7;
602 ctx.fillStyle='rgb(30,30,30)';
607 //print x axis (green line)
610 ctx.strokeStyle='rgb(0,200,0)';
611 ctx.moveTo(0,(img_h+26));
612 ctx.lineTo(img_width,(img_h+26));
617 ctx.moveTo(0,+img_h+25);
618 ctx.strokeStyle='rgb(255,0,0)';
620 for (var i=0; i<score_array.length; i++) {
621 var xpos = (i+1)*xscale;
624 // var final_score = (+score_array[i]/+si_rna/coverage*100).toFixed(2); //using coverage in algorithm
625 var final_score = (+score_array[i]*100/coverage).toFixed(2);
627 if (+final_score >= 0) {
628 ypos = 25-(+final_score*25/100)+2;
630 ypos = 50-(+final_score*25/100);
635 ctx.lineTo(xpos,img_h+ypos);
642 // Highlights best region in Sequence Overview section
643 function hilite_sequence(cbr_start,cbr_end,color) {
646 var markup = new Text.Markup( { 'highlight' : [ '<span class="highlighted2" style="background:#D2D4D6;">', '</span>' ], 'break' : [ '<br />', '' ], 'space' : [ '<span> </span>', '' ] });
648 var markup = new Text.Markup( { 'highlight' : [ '<span class="highlighted">', '</span>' ], 'break' : [ '<br />', '' ], 'space' : [ '<span> </span>', '' ] });
651 var source_el = document.getElementById('query');
652 var markup_el = document.getElementById('markup');
654 var hilite_regions=[];
657 cbr_start = cbr_start-1;
661 hilite_regions.push(['highlight', cbr_start, cbr_end]);
664 var sequence = source_el.innerHTML;
666 var break_regions = [];
667 for (var i=0; i<sequence.length; i=i+60) {
668 break_regions.push([ 'break', i, i ]);
671 var space_regions = [];
672 for (var i =0; i<sequence.length; i=i+10) {
673 space_regions.push(['space', i, i]);
676 var all_regions = break_regions.concat(hilite_regions, space_regions);
677 var markedup_seq = markup.markup(all_regions, sequence);
679 //insert line numbers
680 var line_length = 60;
682 var lines = markedup_seq.split('<br />');
684 var leading_spaces = new Array('', '', '', '', '', '');
686 for (var i=1; i<lines.length; i++) {
687 leading_str = leading_spaces.slice(0,Math.ceil(6-(Math.log(current_pos)/Math.log(10)))).join(' '); // poor man's sprintf
688 leading_str2 = leading_spaces.slice(0,Math.ceil(6-(Math.log(current_pos +line_length -1)/Math.log(10)))).join(' ');
690 if (current_pos + line_length < sequence.length) {
691 final_seq = final_seq + leading_str + current_pos +' '+ lines[i] +' '+ leading_str2 + ( current_pos + line_length - 1) +'<br />';
693 final_seq = final_seq + leading_str + current_pos + ' ' + lines[i] + ' ' + leading_str2 + sequence.length + '<br />';
696 current_pos += line_length;
699 markup_el.innerHTML='<font face="courier" size="2">'+final_seq+'</font>';
703 function activateCollapse(score_array,best_seq,seq,expr_msg,ids,m_aoa) {
704 document.getElementById("region_square").style.height="0px";
705 var collapsed = $("#collapse").val();
706 var zoom = $("#zoom").val();
707 var seq_length = $("#seq_length").val();
709 if (collapsed == 0) {
710 $("#collapse").html("Expand Graph");
711 $("#collapse").val(1);
714 $("#collapse").html("Collapse Graph");
715 $("#collapse").val(0);
718 createMap(+collapsed,+zoom,score_array,expr_msg,ids,m_aoa);
719 getCustomRegion(score_array,best_seq,seq);
722 function activateZoom(score_array,best_seq,seq,expr_msg,ids,m_aoa) {
723 var collapsed = $("#collapse").val();
724 var zoom = $("#zoom").val();
725 var seq_length = $("#seq_length").val();
728 $("#zoom").html("Zoom Out");
732 $("#zoom").html("Zoom In");
736 createMap(+collapsed,+zoom,score_array,expr_msg,ids,m_aoa);
737 getCustomRegion(score_array,best_seq,seq);
740 //Function to change values of custom region by dragging the selection square
741 function getSquareCoords(score_array,best_seq,seq) {
743 var seq_length = $("#seq_length").val();
744 var zoom = $("#zoom").val();
745 var rev_xscale = +(seq_length/img_width); // to transform sequence length to pixels
746 $("#cbr_p").html("");
748 if (+zoom || seq_length < 700) {
750 img_width = seq_length;
753 var r_left = document.getElementById("region_square").style.left;
754 var r_width = document.getElementById("region_square").style.width;
755 var left_num = r_left.replace("px","");
756 var right_num = r_width.replace("px","");
757 var sqr_left = Math.round(+left_num*rev_xscale);
758 var sqr_right = Math.round((+left_num + +right_num)*rev_xscale);
760 var cbr_start = (+sqr_left + 1);
761 var cbr_end = (+sqr_right);
762 var fragment = (+cbr_end - +cbr_start +1);
764 if (+cbr_end > seq_length) {cbr_end = seq_length;}
765 if (+cbr_start < 1) {cbr_start = 1;}
767 $("#cbr_start").val(cbr_start);
768 $("#cbr_end").val(cbr_end);
769 $("#f_size").val(fragment);
771 var best_region = [cbr_start,cbr_end];
772 hilite_sequence(cbr_start,cbr_end,1);
773 printCustomSeq(best_seq,seq);
776 printCustomScore(cbr_start,cbr_end,score_array);
780 //Prints custom sequence in Best Region section
781 function printCustomSeq(best_seq,seq) {
782 var best_seq_el = document.getElementById("best_seq");
783 var cbr_start = +$("#cbr_start").val();
784 var cbr_end = +$("#cbr_end").val();
785 var best_start = +$("#best_start").val();
786 var best_end = +$("#best_end").val();
788 best_seq_el.innerHTML = "<b>>custom_region_("+cbr_start+"-"+cbr_end+")</b><br />";
790 for (var i=cbr_start; i<cbr_end; i=i+60) {
792 best_seq_el.innerHTML += seq.substring(i-1,cbr_end)+"<br />";
794 best_seq_el.innerHTML += seq.substring(i-1,i+59)+"<br />";
797 best_seq_el.innerHTML += "<br /><b>>best_target_region_("+best_start+"-"+best_end+")</b><br />";
798 best_seq_el.innerHTML += best_seq+"<br />";
803 function printCustomScore(start,end,score_array){
804 var custom_score = 0;
805 var coverage = +$("#coverage_val").val();
806 var seq_length = +$("#seq_length").val();
807 var best_score = +$("#best_score").val();
809 if (+end > seq_length) {end = seq_length;}
810 if (+start < 1) {start = 1;}
813 for (var i= +start-1; i< +end; i++) {
814 custom_score += +score_array[i];
818 var fragment_length = (+end - +start + 1);
820 if (coverage > 0 && fragment_length > 0) {
821 var final_score = ((custom_score*100/fragment_length)/coverage).toFixed(2);
822 // var final_score = (custom_score*100/+si_rna/fragment_length/coverage).toFixed(2); //using coverage
823 $("#score_p").html("<b>Best target region score:</b> "+best_score+" <b> Custom region score: </b>"+final_score+" (-∞—100)");
828 // Creates the draggable selection square and modifies custom region when push a button
829 function getCustomRegion(score_array,best_seq,seq) {
831 var cbr_start = +$("#cbr_start").val();
832 var cbr_end = +$("#cbr_end").val();
833 var map_el = document.getElementById('myCanvas');
834 var seq_length = +$("#seq_length").val();
837 var xscale = +(+img_width/+seq_length); // to transform sequence length to pixels
839 var zoom = $("#zoom").val();
841 if (zoom == 1 || seq_length < 700) {
843 img_width = seq_length;
845 if (seq_length < 700) {document.getElementById("seq_map").style.width=""+seq_length+"px";}
848 if ((cbr_start > 0) && (cbr_end <= seq_length) && (cbr_end >= cbr_start+99)) {
849 var cbr_left = Math.round((+cbr_start-1)*xscale);
850 var cbr_width = ((+cbr_end - +cbr_start +1)*xscale);
852 var cbr_height = (map_el.height - 21);
854 //a border will add pixels to all end coordinates
855 $("#region_square").css("border","0px solid #000000");
856 $("#region_square").css("top","21px");
857 $("#region_square").css("background","rgba(80,100,100,0.3)");
858 $("#region_square").css("left",cbr_left+"px");
859 $("#region_square").css("width",cbr_width+"px");
860 $("#region_square").css("height",cbr_height+"px");
862 $("#region_square").resizable({
865 minWidth: 100*xscale,
868 $("#region_square").draggable({
874 $("#cbr_p").html("");
875 var fragment = (+cbr_end - +cbr_start +1);
876 $("#f_size").val(fragment);
878 hilite_sequence(cbr_start,cbr_end,1);
881 printCustomSeq(best_seq,seq);
884 printCustomScore(cbr_start,cbr_end,score_array);
888 $("#cbr_p").html("Values must be between 1 and "+seq_length+", getting a sequence not shorter than 100 bp!");
893 function changeTargets(bt2_file,score_array,seq,best_seq,expr_f,ids,m_aoa) {
895 var t_num = $("#t_num").val();
896 var coverage = $("#coverage_val").val();
897 var f_size = $("#f_size").val();
898 var f_length = $("#f_length").val();
899 var n_mer = $("#n_mer").val();
900 si_rna = $("#si_rna").val();
901 var align_mm = $("#align_mm").val();
902 var mm = $("#mm").val();
903 var db = $("#bt2_db").val();
905 var seq_length = $("#seq_length").val();
907 if (n_mer != si_rna) {
908 $("#f_length").val(f_size);
909 $("#mm").val(align_mm);
910 $("#si_rna").val(n_mer);
912 $("#coverage_val").val(t_num);
913 $("#region_square").css("height","0px");
915 //check values before recalculate
916 if (+n_mer >= 18 && +n_mer <= 30) {
918 runBt2(n_mer, f_size, align_mm, db);
920 alert("n-mer value must be between 18-30");
922 } else if (align_mm != mm) {
923 $("#f_length").val(f_size);
924 $("#mm").val(align_mm);
925 $("#coverage_val").val(t_num);
927 // if (!align_mm || +align_mm < 0 || +align_mm > 1) {
928 if (!align_mm || +align_mm < 0 || +align_mm > 2) {
929 alert("miss-match value ("+align_mm+") must be between 0-2");
932 getResults(1, bt2_file, n_mer, f_size, align_mm, t_num, db, expr_f);
933 $("#region_square").css("height","0px");
934 //getCustomRegion(score_array,best_seq,seq)
936 } else if (t_num != coverage || f_size != f_length) {
937 $("#f_length").val(f_size);
938 $("#coverage_val").val(t_num);
940 //check values before recalculate
941 if (!f_size || +f_size < 100 || +f_size > +seq_length) {
942 alert("Wrong fragment size ("+f_size+"), it must be 100 bp or higher, and lower than sequence length");
945 getResults(0, bt2_file, n_mer, f_size, align_mm, t_num, db, expr_f);
946 $("#region_square").css("height","0px");
947 //getCustomRegion(score_array,best_seq,seq)
950 alert("there are no parameters to change");
952 return [score_array,seq,best_seq,expr_msg,ids,m_aoa]
955 function disable_ui() {
956 $('#working').dialog("open");
959 function enable_ui() {
960 $('#working').dialog("close");
964 Effects.swapElements('vigs_input_offswitch', 'vigs_input_onswitch');
965 Effects.hideElement('vigs_input_content');
966 Effects.swapElements('vigs_usage_offswitch', 'vigs_usage_onswitch');
967 Effects.hideElement('vigs_usage_content');
970 // function safari_alert() {
971 // if (navigator.appVersion.match(/Safari/i) && !navigator.appVersion.match(/chrome/i)) {
972 // alert("SGN VIGS Tool does not support Safari, please use a different browser like Firefox (recommended) or Google chrome.");