2 function run_blast(database_types, input_option_types) {
4 update_status("Initializing run... ");
6 jQuery('#prereqs').html('');
7 // jQuery('#blast_report').html('');
8 jQuery('#Basic_output').html('');
9 jQuery('#Overview_output').html('');
10 jQuery('#Coverage_output').html('');
11 jQuery('#Table_output').html('');
12 jQuery('#SGN_output').html('');
13 jQuery('#Bioperl_output').html('');
15 var program = jQuery('#program_select').val();
16 var sequence = jQuery('#sequence').val();
18 var msie = window.navigator.userAgent.indexOf("MSIE ");
21 sequence = sequence.replace(/\s+/g, "\n");
25 var database = jQuery('#database').val();
26 var evalue = jQuery('#evalue').val();
27 var matrix = jQuery('#matrix').val();
28 // var graphics = jQuery('#graphics').val(); //graphics?
29 var maxhits = jQuery('#maxhits').val();
30 var filterq = jQuery('#filterq').val();
31 var input_option = jQuery('#input_options').val(); //input option is the format of the pasted sequenced
33 if (sequence === '') {
34 alert("Please enter a sequence :-)");
38 if (!blast_program_ok(program, input_option_types[input_option], database_types[database])) {
39 alert("The BLAST program does not match the selected database and query.");
43 update_status("Submitting job... ");
51 url: '/tools/blast/run/',
54 data: { 'sequence': sequence, 'matrix': matrix, 'evalue': evalue, 'maxhits': maxhits, 'filterq': filterq, 'database': database, 'program': program, 'input_options': input_option, 'db_type': database_types[database]},
55 success: function(response) {
58 alert(response.error);
62 jobid = response.jobid;
63 seq_count = response.seq_count;
64 //alert("SEQ COUNT = "+seq_count);
65 wait_result(jobid, seq_count);
68 error: function(response) {
69 alert("An error occurred. The service may not be available right now.");
76 function wait_result(jobid, seq_count) {
77 update_status('id='+jobid+' ');
81 while (done == false) {
85 url: '/tools/blast/check/'+jobid,
86 success: function(response) {
87 if (response.status === "complete") {
90 finish_blast(jobid, seq_count);
96 error: function(response) {
97 alert("An error occurred. ");
107 function finish_blast(jobid, seq_count) {
109 update_status('Run complete.<br />');
111 var format = jQuery('#parse_options').val() || [ 'Basic' ];
113 // alert("FORMAT IS: "+format + " seqcount ="+ seq_count + "jobid = "+jobid);
115 var blast_reports = new Array();
116 var prereqs = new Array();
119 format = [ "Table", "Basic" ];
120 alert("Multiple sequences were detected. The output will be shown in the tabular and basic format");
123 var database = jQuery('#database').val();
125 for (var n in format) {
126 update_status('Formatting output ('+format[n]+')<br />');
129 url: '/tools/blast/result/'+jobid,
130 data: { 'format': format[n], 'db_id': database },
132 success: function(response) {
134 // alert("output format: "+response.blast_format);
136 if (response.blast_report) {
137 var out_id = "#"+response.blast_format+"_output";
138 // var out_id = "#"+response.blast_format.replace(" graph", "")+"_output";
139 // alert("out_id: "+out_id);
140 // alert("blast_report: "+response.blast_report);
142 jQuery(out_id).html(response.blast_report+"<br><br>\n");
144 if (response.prereqs) {
145 prereqs.push(response.prereqs);
146 jQuery('#prereqs').html(prereqs.join("\n\n<br />\n\n"));
149 jQuery('#jobid').html(jobid);
151 Effects.swapElements('input_parameter_section_offswitch', 'input_parameter_section_onswitch');
152 Effects.hideElement('input_parameter_section_content');
153 jQuery('#download_basic').css("display", "inline");
155 if (response.blast_format == "Table") {
156 jQuery('#download_table').css("display", "inline");
158 jQuery('#notes').css("width","75%")
161 error: function(response) { alert("Parse BLAST: An error occurred. "+response.error); enable_ui();}
166 function disable_ui() {
167 jQuery('#myModal').modal({
172 // jQuery('#working').dialog("open");
175 function enable_ui() {
176 jQuery('#myModal').modal('hide');
177 // jQuery('#working').dialog("close");
181 function clear_input_sequence() {
182 jQuery('#sequence').val('');
185 function blast_program_ok(program, query_type, database_type) {
186 var ok = new Array();
187 // query database program
189 ok = { 'protein': { nucleotide : { tblastn: 1 }, protein : { blastp: 1 } },
190 'nucleotide' : { nucleotide : { blastn: 1, tblastx: 1}, protein: { blastx: 1 } },
191 'autodetect' : { nucleotide : { blastn: 1, tblastx: 1, tblastn: 1}, protein: { blastx: 1, blastp: 1 } } };
193 return ok[query_type][database_type][program];
196 function download() {
197 var jobid = jQuery('#jobid').html();
198 window.location.href= '/documents/tempfiles/blast/'+jobid+'.out';
201 function download_table() {
202 var jobid = jQuery('#jobid').html();
203 window.location.href= '/documents/tempfiles/blast/'+jobid+'.out_tabular.txt';
206 function update_status(message) {
207 jQuery('#bs_working_msg').html(message);
210 function clear_status() {
211 jQuery('#bs_working_msg').html('');