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();
113 // alert("FORMAT IS: "+format + " seqcount ="+ seq_count + "jobid = "+jobid);
115 var blast_reports = new Array();
116 var prereqs = new Array();
117 var database = jQuery('#database').val();
120 format = [ "Table", "Basic" ];
121 alert("Multiple sequences were detected. The output will be shown in the tabular and basic format");
126 url: '/tools/blast/render_graph/'+jobid,
127 data: { 'db_id': database },
129 success: function(response) {
130 var sgn_graph_array = response.desc_array;
131 var seq_length = response.sequence_length;
133 // alert("descriptions: "+response.sequence_length);
134 // jQuery('#blast_query_length').html("Query length ("+seq_length+")");
135 // alert(response.sgn_html);
137 draw_blast_graph(sgn_graph_array, seq_length);
138 jQuery('#sgn_blast_graph').css("display", "inline");
140 jQuery("#SGN_output").html(response.sgn_html);
142 if (response.prereqs) {
143 prereqs.push(response.prereqs);
144 jQuery('#prereqs').html(prereqs.join("\n\n<br />\n\n"));
147 jQuery('#jobid').html(jobid);
149 Effects.swapElements('input_parameter_section_offswitch', 'input_parameter_section_onswitch');
150 Effects.hideElement('input_parameter_section_content');
151 jQuery('#download_basic').css("display", "inline");
153 jQuery('#notes').css("width","75%")
157 error: function(response) { alert("SGN BLAST Graph: An error occurred. "+response.error); enable_ui();}
164 for (var n in format) {
165 update_status('Formatting output ('+format[n]+')<br />');
168 url: '/tools/blast/result/'+jobid,
169 data: { 'format': format[n], 'db_id': database },
171 success: function(response) {
173 // alert("output format: "+response.blast_format);
175 if (response.blast_report) {
176 var out_id = "#"+response.blast_format+"_output";
177 // var out_id = "#"+response.blast_format.replace(" graph", "")+"_output";
178 // alert("out_id: "+out_id);
179 // alert("blast_report: "+response.blast_report);
181 jQuery(out_id).html(response.blast_report+"<br><br>\n");
183 if (response.prereqs) {
184 prereqs.push(response.prereqs);
185 jQuery('#prereqs').html(prereqs.join("\n\n<br />\n\n"));
188 jQuery('#jobid').html(jobid);
190 Effects.swapElements('input_parameter_section_offswitch', 'input_parameter_section_onswitch');
191 Effects.hideElement('input_parameter_section_content');
192 jQuery('#download_basic').css("display", "inline");
194 if (response.blast_format == "Table") {
195 jQuery('#download_table').css("display", "inline");
197 jQuery('#notes').css("width","75%")
200 error: function(response) { alert("Parse BLAST: An error occurred. "+response.error); enable_ui();}
204 } // if format closed
208 function disable_ui() {
209 jQuery('#myModal').modal({
214 // jQuery('#working').dialog("open");
217 function enable_ui() {
218 jQuery('#myModal').modal('hide');
219 // jQuery('#working').dialog("close");
223 function clear_input_sequence() {
224 jQuery('#sequence').val('');
227 function blast_program_ok(program, query_type, database_type) {
228 var ok = new Array();
229 // query database program
231 ok = { 'protein': { nucleotide : { tblastn: 1 }, protein : { blastp: 1 } },
232 'nucleotide' : { nucleotide : { blastn: 1, tblastx: 1}, protein: { blastx: 1 } },
233 'autodetect' : { nucleotide : { blastn: 1, tblastx: 1, tblastn: 1}, protein: { blastx: 1, blastp: 1 } } };
235 return ok[query_type][database_type][program];
238 function download() {
239 var jobid = jQuery('#jobid').html();
240 window.location.href= '/documents/tempfiles/blast/'+jobid+'.out';
243 function download_table() {
244 var jobid = jQuery('#jobid').html();
245 window.location.href= '/documents/tempfiles/blast/'+jobid+'.out_tabular.txt';
248 function update_status(message) {
249 jQuery('#bs_working_msg').html(message);
252 function clear_status() {
253 jQuery('#bs_working_msg').html('');