diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..4a34b88 Binary files /dev/null and b/.DS_Store differ diff --git a/api/.DS_Store b/api/.DS_Store new file mode 100644 index 0000000..8137706 Binary files /dev/null and b/api/.DS_Store differ diff --git a/api/blast_ui.api.inc b/api/blast_ui.api.inc index 57f1d33..4b64ee7 100644 --- a/api/blast_ui.api.inc +++ b/api/blast_ui.api.inc @@ -1,5 +1,101 @@ $val) { + if ($val) { + print "\t$opt: $val\n"; + $blast_cmd .= " -$opt $val"; + } + } + } + + // Setting the value of threads by admin page + $blast_cmd .= " -num_threads ".$blast_threads; + + print "\nExecuting the following BLAST command:\n" . $blast_cmd . "\n"; + + system($blast_cmd); + + if (!file_exists($output_file)) { + tripal_report_error( + 'blast_ui', + TRIPAL_ERROR, + "BLAST did not complete successfully as is implied by the lack of output file (%file). The command run was @command", + array('%file' => $output_file, '@command' => $blast_cmd), + array('print' => TRUE) + ); + return FALSE; + } + print "\nDone!\n"; + +} + + + + + + + + + + /** * @file * Contains more generally applicable functions as well as some meant to help developers @@ -84,8 +180,11 @@ function get_blast_database_options($type) { } } + // Sort alphabetically asort($options); - $options[0] = 'Select a Dataset'; + + // Prepend prompt; note that array_unshift() will re-index the array + $options = array('Select a Dataset') + $options; return $options; } @@ -668,4 +767,4 @@ function generate_blast_hit_image($acc = '', $scores, $hits, $tsize, $qsize, $na ob_end_clean(); return $b64_img; -} \ No newline at end of file +} diff --git a/blast_ui.module b/blast_ui.module index ddc2584..9ecfe62 100644 --- a/blast_ui.module +++ b/blast_ui.module @@ -266,10 +266,13 @@ function show_blast_output($job_string) { * */ function blast_ui_ctools_plugin_api($owner, $api) { + $webservices = variable_get('Enable_webservices'); + if($webservices == 1){ if ($owner == 'services' && $api == 'services') { return array( 'version' => 3, 'file' => 'includes/blast_ui.services.inc' ); } + } } diff --git a/includes/.DS_Store b/includes/.DS_Store new file mode 100644 index 0000000..5a96152 Binary files /dev/null and b/includes/.DS_Store differ diff --git a/includes/blast_ui.admin.inc b/includes/blast_ui.admin.inc index e9bc578..ace3be3 100644 --- a/includes/blast_ui.admin.inc +++ b/includes/blast_ui.admin.inc @@ -31,19 +31,26 @@ function blast_ui_admin_form($form, $form_state) { $form['general']['eVal']= array( '#type' => 'textfield', - '#title' => t('e-Value (Expected Threshold)'), - '#description' => t('Expected number of chance matches in a random model. This number should be give in a decimal format.'), + '#title' => t('Default e-value (Expected Threshold)'), + '#description' => t('Expected number of chance matches in a random model. This number should be given in a decimal format.'), '#default_value' => variable_get('eVal', 0.001), //'#default_value' => variable_get('blast_threads', 1), ); $form['general']['qRange']= array( '#type' => 'textfield', - '#title' => t('Max matches in a query range'), + '#title' => t('Default max matches in a query range'), '#description' => t('Limit the number of matches to a query range. This option is useful if many strong matches to one part of a query may prevent BLAST from presenting weaker matches to another part of the query.'), '#default_value' => variable_get('qRange', 0), ); + $form['general']['Enable_webservices'] = array( + '#type' => 'checkbox', + '#title' => 'Enable webservices of blast', + '#description' => 'When checked, a blast webservices gets enabled.', + '#default_value' => variable_get('Enable_webservices', true), + ); + $form['file_upload'] = array( '#type' => 'fieldset', '#title' => 'Allow File Upload', @@ -156,6 +163,99 @@ function blast_ui_admin_form_validate($form, &$form_state) { } +/* +** +** custom method disabled the web services +** +*/ + +function disable_web_services() +{ + $ar=array('services', 'rest_server'); + $result = module_disable($ar,true); + try{ + $eid = 1; + $num_deleted = db_delete('services_endpoint')->condition('eid', $eid)->execute(); + } catch(Exception $e){ + //drupal_set_message(t("Web-Services of blast are already disabled"), 'error'); + } + +} + +/* +** custom method enable the web services +** +*/ + +function enable_web_services() +{ + $ar=array('services', 'rest_server'); + $result = module_enable($ar, true); + if (empty($result)) { + throw new DrupalUpdateException(implode(', ', $ar) . ' or dependencies could not be enabled, please install services '); + } + + $server_settings = array( + 'formatters' => array( + 'bencode' => TRUE, + 'json' => TRUE, + 'jsonp' => TRUE, + 'php' => TRUE, + 'xml' => TRUE, + ), + 'parsers' => array( + 'application/json' => TRUE, + 'application/vnd.php.serialized' => TRUE, + 'application/x-www-form-urlencoded' => TRUE, + 'application/xml' => TRUE, + 'multipart/form-data' => TRUE, + 'text/xml' => TRUE, + ), +); + +$resources = array( + 'blast' => array( + 'operations' => array( + 'retrieve' => array( + 'enabled' => '1', + ), + 'index' => array( + 'enabled' => '1', + ), + ), + 'actions' => array( + 'getJobId' => array( + 'enabled' => '1', + ), + 'getBlastStatus' => array( + 'enabled' => '1', + ), + 'getDatabaseOptions' => array( + 'enabled' => '1', + ), + ), + ), +); + + try{ + $nid = db_insert('services_endpoint')->fields( + array( + 'eid' => 1, + 'debug' => 1, + 'name' => 'restapi', + 'server' => 'rest_server', + 'path' => 'restapi', + 'resources' => serialize($resources), //'a:1:{s:5:"blast";a:2:{s:10:"operations";a:2:{s:8:"retrieve";a:1:{s:7:"enabled";s:1:"1";}s:5:"index";a:1:{s:7:"enabled";s:1:"1";}}s:7:"actions";a:2:{s:8:"getJobId";a:1:{s:7:"enabled";s:1:"1";}s:18:"getDatabaseOptions";a:1:{s:7:"enabled";s:1:"1";}}}}', + 'server_settings' => serialize($server_settings), + 'authentication' => 'a:0:{}', + ))->execute(); +} + catch(Exception $e){ + //drupal_set_message(t("Web-Services of blast are already Enabled"), 'error'); + } + +} + /** * Submit the Admin/settings form. */ @@ -167,9 +267,17 @@ function blast_ui_admin_form_submit($form, $form_state) { variable_set('eVal', $form_state['values']['eVal']); variable_set('qRange', $form_state['values']['qRange']); + // Logic to enable web services on single click + variable_set('Enable_webservices', $form_state['values']['Enable_webservices']); variable_set('blast_ui_allow_query_upload', $form_state['values']['query_upload']); variable_set('blast_ui_allow_target_upload', $form_state['values']['target_upload']); variable_set('blast_ui_nucleotide_example_sequence', $form_state['values']['nucleotide_example']); variable_set('blast_ui_protein_example_sequence', $form_state['values']['protein_example']); -} \ No newline at end of file + + if($form_state['values']['Enable_webservices'] == 1){ + enable_web_services(); + }else{ + disable_web_services(); + } +} diff --git a/includes/blast_ui.form_advanced_options.inc b/includes/blast_ui.form_advanced_options.inc index 35c0f5a..97caca1 100644 --- a/includes/blast_ui.form_advanced_options.inc +++ b/includes/blast_ui.form_advanced_options.inc @@ -443,361 +443,12 @@ function blast_ui_blastp_advanced_options_form_submit($form, $form_state) { // Expand Gap Cost key into open and extend penalties $matrix = $form_state['values']['Matrix']; - switch ($matrix) { - case 'PAM30': - $gapKey = $form_state['values']['gapCost']; - switch ($gapKey) { - case 0: - $gapOpen = 7; - $gapExtend = 2; - break; - case 1: - $gapOpen = 6; - $gapExtend = 2; - break; - case 2: - $gapOpen = 5; - $gapExtend = 2; - break; - case 3: - $gapOpen = 10; - $gapExtend = 1; - break; - case 4: - $gapOpen = 9; - $gapExtend = 1; - break; - case 5: - $gapOpen = 8; - $gapExtend = 1; - break; - } - break; - case 'PAM70': - $gapKey = $form_state['values']['gapCost']; - switch ($gapKey) { - case 0: - $gapOpen = 8; - $gapExtend = 2; - break; - case 1: - $gapOpen = 7; - $gapExtend = 2; - break; - case 2: - $gapOpen = 6; - $gapExtend = 2; - break; - case 3: - $gapOpen = 11; - $gapExtend = 1; - break; - case 4: - $gapOpen = 10; - $gapExtend = 1; - break; - case 5: - $gapOpen = 9; - $gapExtend = 1; - break; - } - break; - case 'PAM250': - $gapKey = $form_state['values']['gapCost']; - switch ($gapKey) { - case 0: - $gapOpen = 15; - $gapExtend = 3; - break; - case 1: - $gapOpen = 14; - $gapExtend = 3; - break; - case 2: - $gapOpen = 13; - $gapExtend = 3; - break; - case 3: - $gapOpen = 12; - $gapExtend = 3; - break; - case 4: - $gapOpen = 11; - $gapExtend = 3; - break; - case 5: - $gapOpen = 17; - $gapExtend = 2; - break; - case 6: - $gapOpen = 16; - $gapExtend = 2; - break; - case 7: - $gapOpen = 15; - $gapExtend = 2; - break; - case 8: - $gapOpen = 14; - $gapExtend = 2; - break; - case 9: - $gapOpen = 13; - $gapExtend = 2; - break; - case 10: - $gapOpen = 21; - $gapExtend = 1; - break; - case 11: - $gapOpen = 20; - $gapExtend = 1; - break; - case 12: - $gapOpen = 19; - $gapExtend = 1; - break; - case 13: - $gapOpen = 18; - $gapExtend = 1; - break; - case 14: - $gapOpen = 17; - $gapExtend = 1; - break; - } - break; - case 'BLOSUM80': - $gapKey = $form_state['values']['gapCost']; - switch ($gapKey) { - case 0: - $gapOpen = 8; - $gapExtend = 2; - break; - case 1: - $gapOpen = 7; - $gapExtend = 2; - break; - case 2: - $gapOpen = 6; - $gapExtend = 2; - break; - case 3: - $gapOpen = 11; - $gapExtend = 1; - break; - case 4: - $gapOpen = 10; - $gapExtend = 1; - break; - case 5: - $gapOpen = 9; - $gapExtend = 1; - break; - } - break; - case 'BLOSUM62': - $gapKey = $form_state['values']['gapCost']; - switch ($gapKey) { - case 0: - $gapOpen = 11; - $gapExtend = 2; - break; - case 1: - $gapOpen = 10; - $gapExtend = 2; - break; - case 2: - $gapOpen = 9; - $gapExtend = 2; - break; - case 3: - $gapOpen = 8; - $gapExtend = 2; - break; - case 4: - $gapOpen = 7; - $gapExtend = 2; - break; - case 5: - $gapOpen = 6; - $gapExtend = 2; - break; - case 6: - $gapOpen = 13; - $gapExtend = 1; - break; - case 7: - $gapOpen = 12; - $gapExtend = 1; - break; - case 8: - $gapOpen = 11; - $gapExtend = 1; - break; - case 9: - $gapOpen = 10; - $gapExtend = 1; - break; - case 10: - $gapOpen = 9; - $gapExtend = 1; - break; - } - break; - case 'BLOSUM45': - $gapKey = $form_state['values']['gapCost']; - switch ($gapKey) { - case 0: - $gapOpen = 13; - $gapExtend = 3; - break; - case 1: - $gapOpen = 12; - $gapExtend = 3; - break; - case 2: - $gapOpen = 11; - $gapExtend = 3; - break; - case 3: - $gapOpen = 10; - $gapExtend = 3; - break; - case 4: - $gapOpen = 15; - $gapExtend = 2; - break; - case 5: - $gapOpen = 14; - $gapExtend = 2; - break; - case 6: - $gapOpen = 13; - $gapExtend = 2; - break; - case 7: - $gapOpen = 12; - $gapExtend = 2; - break; - case 8: - $gapOpen = 19; - $gapExtend = 1; - break; - case 9: - $gapOpen = 18; - $gapExtend = 1; - break; - case 10: - $gapOpen = 17; - $gapExtend = 1; - break; - case 11: - $gapOpen = 16; - $gapExtend = 1; - break; - } - break; - case 'BLOSUM50': - $gapKey = $form_state['values']['gapCost']; - switch ($gapKey) { - case 0: - $gapOpen = 13; - $gapExtend = 3; - break; - case 1: - $gapOpen = 12; - $gapExtend = 3; - break; - case 2: - $gapOpen = 11; - $gapExtend = 3; - break; - case 3: - $gapOpen = 10; - $gapExtend = 3; - break; - case 4: - $gapOpen = 9; - $gapExtend = 3; - break; - case 5: - $gapOpen = 16; - $gapExtend = 2; - break; - case 6: - $gapOpen = 15; - $gapExtend = 2; - break; - case 7: - $gapOpen = 14; - $gapExtend = 2; - break; - case 8: - $gapOpen = 13; - $gapExtend = 2; - break; - case 9: - $gapOpen = 12; - $gapExtend = 2; - break; - case 10: - $gapOpen = 19; - $gapExtend = 1; - break; - case 11: - $gapOpen = 18; - $gapExtend = 1; - break; - case 12: - $gapOpen = 17; - $gapExtend = 1; - break; - case 13: - $gapOpen = 16; - $gapExtend = 1; - break; - case 14: - $gapOpen = 15; - $gapExtend = 1; - break; - } - break; - case 'BLOSUM90': - $gapKey = $form_state['values']['gapCost']; - switch ($gapKey) { - case 0: - $gapOpen = 9; - $gapExtend = 2; - break; - case 1: - $gapOpen = 8; - $gapExtend = 2; - break; - case 2: - $gapOpen = 7; - $gapExtend = 2; - break; - case 3: - $gapOpen = 6; - $gapExtend = 2; - break; - case 4: - $gapOpen = 11; - $gapExtend = 1; - break; - case 5: - $gapOpen = 10; - $gapExtend = 1; - break; - case 6: - $gapOpen = 9; - $gapExtend = 1; - break; - } - break; - } - + $gapKey = $form_state['values']['gapCost']; + $gap = getGap( $matrix, $gapKey); + + + + //eksc- need to implement query range limit // q_range @@ -805,8 +456,8 @@ function blast_ui_blastp_advanced_options_form_submit($form, $form_state) { 'max_target_seqs' => $numAlign, 'evalue' => $eVal, 'word_size' => $wordSize, - 'gapopen' => $gapOpen, - 'gapextend' => $gapExtend, + 'gapopen' => $gap[ 'gapOpen' ], + 'gapextend' => $gap[ 'gapExtend' ], 'culling_limit' => $qRange, 'matrix' => $matrix, ); @@ -1230,9 +881,390 @@ function _get_match_mismatch($which) { }//switch } + +/* + **Method Used for tblastn and blastx + **Method Used in Blast_ui.services.inc + ** @return int $gapOpen and $gapExtend + */ + + +function getGap( $matrix, $gapkey ) + { + switch ( $matrix ) + { + case 'PAM30': + switch ( $gapKey ) + { + case 0: + $gapOpen = 7; + $gapExtend = 2; + break; + case 1: + $gapOpen = 6; + $gapExtend = 2; + break; + case 2: + $gapOpen = 5; + $gapExtend = 2; + break; + case 3: + $gapOpen = 10; + $gapExtend = 1; + break; + case 4: + $gapOpen = 9; + $gapExtend = 1; + break; + case 5: + $gapOpen = 8; + $gapExtend = 1; + break; + } + break; + case 'PAM70': + switch ( $gapKey ) + { + case 0: + $gapOpen = 8; + $gapExtend = 2; + break; + case 1: + $gapOpen = 7; + $gapExtend = 2; + break; + case 2: + $gapOpen = 6; + $gapExtend = 2; + break; + case 3: + $gapOpen = 11; + $gapExtend = 1; + break; + case 4: + $gapOpen = 10; + $gapExtend = 1; + break; + case 5: + $gapOpen = 9; + $gapExtend = 1; + break; + } + break; + case 'PAM250': + switch ( $gapKey ) + { + case 0: + $gapOpen = 15; + $gapExtend = 3; + break; + case 1: + $gapOpen = 14; + $gapExtend = 3; + break; + case 2: + $gapOpen = 13; + $gapExtend = 3; + break; + case 3: + $gapOpen = 12; + $gapExtend = 3; + break; + case 4: + $gapOpen = 11; + $gapExtend = 3; + break; + case 5: + $gapOpen = 17; + $gapExtend = 2; + break; + case 6: + $gapOpen = 16; + $gapExtend = 2; + break; + case 7: + $gapOpen = 15; + $gapExtend = 2; + break; + case 8: + $gapOpen = 14; + $gapExtend = 2; + break; + case 9: + $gapOpen = 13; + $gapExtend = 2; + break; + case 10: + $gapOpen = 21; + $gapExtend = 1; + break; + case 11: + $gapOpen = 20; + $gapExtend = 1; + break; + case 12: + $gapOpen = 19; + $gapExtend = 1; + break; + case 13: + $gapOpen = 18; + $gapExtend = 1; + break; + case 14: + $gapOpen = 17; + $gapExtend = 1; + break; + } + break; + case 'BLOSUM80': + switch ( $gapKey ) + { + case 0: + $gapOpen = 8; + $gapExtend = 2; + break; + case 1: + $gapOpen = 7; + $gapExtend = 2; + break; + case 2: + $gapOpen = 6; + $gapExtend = 2; + break; + case 3: + $gapOpen = 11; + $gapExtend = 1; + break; + case 4: + $gapOpen = 10; + $gapExtend = 1; + break; + case 5: + $gapOpen = 9; + $gapExtend = 1; + break; + } + break; + case 'BLOSUM62': + switch ( $gapKey ) + { + case 0: + $gapOpen = 11; + $gapExtend = 2; + break; + case 1: + $gapOpen = 10; + $gapExtend = 2; + break; + case 2: + $gapOpen = 9; + $gapExtend = 2; + break; + case 3: + $gapOpen = 8; + $gapExtend = 2; + break; + case 4: + $gapOpen = 7; + $gapExtend = 2; + break; + case 5: + $gapOpen = 6; + $gapExtend = 2; + break; + case 6: + $gapOpen = 13; + $gapExtend = 1; + break; + case 7: + $gapOpen = 12; + $gapExtend = 1; + break; + case 8: + $gapOpen = 11; + $gapExtend = 1; + break; + case 9: + $gapOpen = 10; + $gapExtend = 1; + break; + case 10: + $gapOpen = 9; + $gapExtend = 1; + break; + } + break; + case 'BLOSUM45': + switch ( $gapKey ) + { + case 0: + $gapOpen = 13; + $gapExtend = 3; + break; + case 1: + $gapOpen = 12; + $gapExtend = 3; + break; + case 2: + $gapOpen = 11; + $gapExtend = 3; + break; + case 3: + $gapOpen = 10; + $gapExtend = 3; + break; + case 4: + $gapOpen = 15; + $gapExtend = 2; + break; + case 5: + $gapOpen = 14; + $gapExtend = 2; + break; + case 6: + $gapOpen = 13; + $gapExtend = 2; + break; + case 7: + $gapOpen = 12; + $gapExtend = 2; + break; + case 8: + $gapOpen = 19; + $gapExtend = 1; + break; + case 9: + $gapOpen = 18; + $gapExtend = 1; + break; + case 10: + $gapOpen = 17; + $gapExtend = 1; + break; + case 11: + $gapOpen = 16; + $gapExtend = 1; + break; + } + break; + case 'BLOSUM50': + switch ( $gapKey ) + { + case 0: + $gapOpen = 13; + $gapExtend = 3; + break; + case 1: + $gapOpen = 12; + $gapExtend = 3; + break; + case 2: + $gapOpen = 11; + $gapExtend = 3; + break; + case 3: + $gapOpen = 10; + $gapExtend = 3; + break; + case 4: + $gapOpen = 9; + $gapExtend = 3; + break; + case 5: + $gapOpen = 16; + $gapExtend = 2; + break; + case 6: + $gapOpen = 15; + $gapExtend = 2; + break; + case 7: + $gapOpen = 14; + $gapExtend = 2; + break; + case 8: + $gapOpen = 13; + $gapExtend = 2; + break; + case 9: + $gapOpen = 12; + $gapExtend = 2; + break; + case 10: + $gapOpen = 19; + $gapExtend = 1; + break; + case 11: + $gapOpen = 18; + $gapExtend = 1; + break; + case 12: + $gapOpen = 17; + $gapExtend = 1; + break; + case 13: + $gapOpen = 16; + $gapExtend = 1; + break; + case 14: + $gapOpen = 15; + $gapExtend = 1; + break; + } + break; + case 'BLOSUM90': + switch ( $gapKey ) + { + case 0: + $gapOpen = 9; + $gapExtend = 2; + break; + case 1: + $gapOpen = 8; + $gapExtend = 2; + break; + case 2: + $gapOpen = 7; + $gapExtend = 2; + break; + case 3: + $gapOpen = 6; + $gapExtend = 2; + break; + case 4: + $gapOpen = 11; + $gapExtend = 1; + break; + case 5: + $gapOpen = 10; + $gapExtend = 1; + break; + case 6: + $gapOpen = 9; + $gapExtend = 1; + break; + } + break; + + } + return array( + 'gapOpen' => $gapOpen, + 'gapExtend' => $gapExtend + ); + } + + + + +/* /** * Get a list of options for gaps. */ + + + + + function _get_gap($which) { switch ($which) { case 'blastn': @@ -1318,4 +1350,4 @@ function _set_match_mismatch($m_m) { }//switch return array('penalty' => $penalty, 'reward' => $reward); -} \ No newline at end of file +} diff --git a/includes/blast_ui.linkouts.inc b/includes/blast_ui.linkouts.inc index 97a808b..413d7af 100644 --- a/includes/blast_ui.linkouts.inc +++ b/includes/blast_ui.linkouts.inc @@ -149,13 +149,30 @@ function blast_ui_blast_linkout_info() { * An html link. */ function tripal_blast_generate_linkout_link($url_prefix, $hit, $info, $options = array()) { - +//echo "url_prefix=[$url_prefix=, hit=
";var_dump($hit);echo"info=
";var_dump($info);echo ""; if (isset($hit->{'linkout_id'})) { $hit_url = $url_prefix . $hit->{'linkout_id'}; + + // Split out the CGI params, if any + $params = array(); + if (!$paramstr=strstr($hit_url, '?')) { + $url_prefix = $hit_url; + } + else { + $url_parts = preg_split("/\?/", $hit_url); + $url_prefix = $url_parts[0]; + $param_list = preg_split("/\&/", $url_parts[1]); + + foreach ($param_list as $param) { + $param_parts = preg_split("/=/", $param, 2); + $params[$param_parts[0]] = $param_parts[1]; + } + }//URL contains CGI parameters + return l( $hit->{'linkout_id'}, - $hit_url, - array('attributes' => array('target' => '_blank')) + $url_prefix, + array('attributes' => array('target' => '_blank'), 'query' => $params) ); } else { @@ -211,8 +228,16 @@ function tripal_blast_generate_linkout_gbrowse($url_prefix, $hit, $info, $option $min = min($coords); $max = max($coords); +/*eksc: l() is the proper way to build a link in Drupal, but it doesn't appear + * to be possible to build a correct GBrowse link here. The main parameter + * in this case is 'query', then there are many sub-parameters contained in + * the value for 'query'. It doesn't appear to be possible to teach l() how + * to handle nested CGI parameters. Blame GBrowse. + * Any attempts to make l() build this URL correctly are very welcome. + // Now we are finally ready to build the URL. - // First lets set the location of the hit so the GBrowse focuses in on the correct region. + // First let's set the location of the hit so the GBrowse focuses in on the correct region. + $query = array(); $query['ref'] = $hit->{'linkout_id'}; $query['start'] = $min; @@ -244,12 +269,20 @@ function tripal_blast_generate_linkout_gbrowse($url_prefix, $hit, $info, $option // For some reason GBrowse expects semi-colons (;) to delineate query paramters // whereas Drupal throws ampherstands (&) in. This is to fix that. - $url = str_replace('&',';', $url); + $url = str_replace('&', ';', $url); +*/ + + // Build the link brute force until/unless someone figures out how to prevent + // l() from URL-encoding the sub-parameters to "query=". + $query = "query=ref=".$hit->{'linkout_id'}.";start=$min;stop=$max"; + $query .= ";add=".$hit->{'linkout_id'}."+BLAST+BlastHit=" . join ("," , $ranges); + $query .= ";h_feat=BlastHit"; + $url = "" . $hit->{'linkout_id'} . ""; return $url; - } + /** * Generate a JBrowse link-out with location information for a given hit. * @@ -289,7 +322,7 @@ function tripal_blast_generate_linkout_gbrowse($url_prefix, $hit, $info, $option * An html link. */ function tripal_blast_generate_linkout_jbrowse($url_prefix, $hit, $info, $options = array()) { - + // First we need to collect the HSPs to define the ranges we want to // display on the JBrowse. $ranges = array(); @@ -373,3 +406,5 @@ function tripal_blast_generate_linkout_jbrowse($url_prefix, $hit, $info, $option array('attributes' => array('target' => '_blank')) ); } + + diff --git a/includes/blast_ui.services.inc b/includes/blast_ui.services.inc index 01ce91c..0a4434e 100644 --- a/includes/blast_ui.services.inc +++ b/includes/blast_ui.services.inc @@ -59,6 +59,25 @@ function blast_ui_services_resources() 'access arguments append' => FALSE ), + 'getBlastStatus' => array( + 'help' => 'Check status of Blast with jobId', + 'callback' => 'getBlaststatus', + 'access callback' => 'user_access', + 'access arguments' => array( + 'access content' + ), + 'args' => array( + array( + 'name' => 'data', + 'type' => 'array', + 'description' => 'Retrieve status of blast', + 'source' => 'data', + 'optional' => FALSE + ) + ), + 'access arguments append' => FALSE + ), + 'getDatabaseOptions' => array( 'help' => 'Retrieves a listing of database', 'callback' => '_blast_ui_getDatabaseOption', @@ -130,22 +149,22 @@ function _blast_ui_index() function _blast_ui_getDatabaseOption( $data ) { - if ( !isset( $data[ query_type ] ) ) + if ( !isset( $data['query_type'] ) ) { - return services_error( 'Missing blast attribute $query_type [ set necleotide or protein in post request of query_type ]', 406 ); + return services_error( t('Missing blast attribute $query_type [ set necleotide or protein in post request of query_type ]'), 406 ); } - if ( !isset( $data[ db_type ] ) ) + if ( !isset( $data['db_type'] ) ) { - return services_error( 'Missing blast attribute $db_type [ set necleotide or protein in post request of db_type ]', 406 ); + return services_error( t('Missing blast attribute $db_type [ set necleotide or protein in post request of db_type ]'), 406 ); } - if ( !isset( $data[ blast_program ] ) ) + if ( !isset( $data['blast_program'] ) ) { - return services_error( 'Missing blast attribute $blast_program [ set blastn, blastx, tblastn, blastp in post request of blast_program ]', 406 ); + return services_error(t( 'Missing blast attribute $blast_program [ set blastn, blastx, tblastn, blastp in post request of blast_program ]'), 406 ); } - $query_type = $data[ db_type ]; - $db_type = $data[ db_type ]; - $blast_program = $data[ blast_program ]; + $query_type = $data[ 'query_type' ]; + $db_type = $data[ 'db_type' ]; + $blast_program = $data[ 'blast_program' ]; $options_database = get_blast_database_options( $db_type ); // Data Set send to user for selection of Blastn @@ -195,7 +214,7 @@ function _blast_ui_getDatabaseOption( $data ) } /* - ** validate the data + ** validate the data */ function blast_validation( $query_type, $db_type, $data ) @@ -205,29 +224,29 @@ function blast_validation( $query_type, $db_type, $data ) if ( $db_type == 'nucleotide' ) { - if ( !isset( $data[ Select_Database ] ) ) + if ( !isset( $data['Select_Database'] ) ) { return services_error( 'Missing blast attribute $Select_Database [ query blast/getDatabaseOptions for options :- Add database you need to use]', 406 ); } - if ( !isset( $data[ Max_target_sequences ] ) ) + if ( !isset( $data['Max_target_sequences'] ) ) { return services_error( 'Missing blast attribute $Max_target_sequences [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( !isset( $data[ Word_size ] ) ) + if ( !isset( $data['Word_size'] ) ) { return services_error( 'Missing blast attribute $Word_size [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( !isset( $data[ Match_Mismatch_Scores ] ) ) + if ( !isset( $data['Match_Mismatch_Scores'] ) ) { return services_error( 'Missing blast attribute $Match_Mismatch_Scores [ query blast/getDatabaseOptions for options]', 406 ); } - if ( !isset( $data[ Gap_costs ] ) ) + if ( !isset( $data['Gap_Costs'] ) ) { return services_error( 'Missing blast attribute $Gap_Costs [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( isset( $data[ seqQuery ] ) ) + if ( isset( $data['seqQuery'] ) ) { - if ( validate_fasta_sequence( $query_type, $data[ seqQuery ] ) == 1 ) + if ( validate_fasta_sequence( $query_type, $data['seqQuery'] ) == 1 ) { return services_error( 'Please enter validate_fasta_sequence', 406 ); } @@ -240,25 +259,25 @@ function blast_validation( $query_type, $db_type, $data ) else { - if ( !isset( $data[ Select_Database ] ) ) + if ( !isset( $data['Select_Database'] ) ) { return services_error( 'Missing blast attribute $Select_Database [ query blast/getDatabaseOptions for options :- Add database used by you]', 406 ); } - if ( !isset( $data[ Max_target_sequences ] ) ) + if ( !isset( $data['Max_target_sequences'] ) ) { return services_error( 'Missing blast attribute $Max_target_sequences [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( !isset( $data[ Word_size ] ) ) + if ( !isset( $data['Word_size'] ) ) { return services_error( 'Missing blast attribute $Word_size [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( !isset( $data[ Matrix_options ] ) ) + if ( !isset( $data['Matrix_options'] ) ) { return services_error( 'Missing blast attribute $Matrix_options [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( isset( $data[ seqQuery ] ) ) + if ( isset( $data['seqQuery'] ) ) { - if ( validate_fasta_sequence( $query_type, $data[ seqQuery ] ) == 1 ) + if ( validate_fasta_sequence( $query_type, $data['seqQuery'] ) == 1 ) { return services_error( 'Please enter validate_fasta_sequence', 406 ); } @@ -274,30 +293,30 @@ function blast_validation( $query_type, $db_type, $data ) { if ( $db_type == 'nucleotide' ) { - if ( !isset( $data[ Select_Database ] ) ) + if ( !isset( $data[ 'Select_Database' ] ) ) { - return services_error( 'Missing blast attribute $Select_Database [ query blast/getDatabaseOptions for options :- Add database you need to use]', 406 ); + return services_error( 'Missing blast attribute Select_Database [ query blast/getDatabaseOptions for options :- Add database you need to use]', 406 ); } - if ( !isset( $data[ Max_target_sequences ] ) ) + if ( !isset( $data[ 'Max_target_sequences' ] ) ) { - return services_error( 'Missing blast attribute $Max_target_sequences [ query blast/getDatabaseOptions for options ]', 406 ); + return services_error( 'Missing blast attribute Max_target_sequences [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( !isset( $data[ Word_size ] ) ) + if ( !isset( $data[ 'Word_size' ] ) ) { - return services_error( 'Missing blast attribute $Word_size [ query blast/getDatabaseOptions for options ]', 406 ); + return services_error( 'Missing blast attribute Word_size [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( !isset( $data[ Matrix_options ] ) ) + if ( !isset( $data[ 'Matrix_options' ] ) ) { - return services_error( 'Missing blast attribute $Matrix_options [ query blast/getDatabaseOptions for options ]', 406 ); + return services_error( 'Missing blast attribute Matrix_options [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( !isset( $data[ Gap_costs ] ) ) + if ( !isset( $data[ 'Gap_costs' ] ) ) { - return services_error( 'Missing blast attribute [ query blast/getDatabaseOptions for options ]', 406 ); + return services_error( 'Missing blast attribute Gap_costs [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( isset( $data[ seqQuery ] ) ) + if ( isset( $data[ 'seqQuery' ] ) ) { - if ( validate_fasta_sequence( $query_type, $data[ seqQuery ] ) == 1 ) + if ( validate_fasta_sequence( $query_type, $data[ 'seqQuery' ] ) == 1 ) { return services_error( 'Please enter validate_fasta_sequence', 406 ); } @@ -312,25 +331,25 @@ function blast_validation( $query_type, $db_type, $data ) //return $data; - if ( !isset( $data[ Select_Database ] ) ) + if ( !isset( $data[ 'Select_Database' ] ) ) { - return services_error( 'Missing blast attribute $Select_Database [ query blast/getDatabaseOptions for options :- Add database used by you]', 406 ); + return services_error( 'Missing blast attribute Select_Database [ query blast/getDatabaseOptions for options :- Add database used by you]', 406 ); } - if ( !isset( $data[ Max_target_sequences ] ) ) + if ( !isset( $data[ 'Max_target_sequences' ] ) ) { - return services_error( 'Missing blast attribute $Max_target_sequences [ query blast/getDatabaseOptions for options ]', 406 ); + return services_error( 'Missing blast attribute Max_target_sequences [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( !isset( $data[ Word_size ] ) ) + if ( !isset( $data[ 'Word_size' ] ) ) { - return services_error( 'Missing blast attribute $Word_size [ query blast/getDatabaseOptions for options ]', 406 ); + return services_error( 'Missing blast attribute Word_size [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( !isset( $data[ Matrix_options ] ) ) + if ( !isset( $data[ 'Matrix_options' ] ) ) { - return services_error( 'Missing blast attribute $Matrix_options [ query blast/getDatabaseOptions for options ]', 406 ); + return services_error( 'Missing blast attribute Matrix_options [ query blast/getDatabaseOptions for options ]', 406 ); } - if ( isset( $data[ seqQuery ] ) ) + if ( isset( $data[ 'seqQuery' ] ) ) { - if ( validate_fasta_sequence( $query_type, $data[ seqQuery ] ) == 1 ) + if ( validate_fasta_sequence( $query_type, $data[ 'seqQuery' ] ) == 1 ) { return services_error( 'Please enter validate_fasta_sequence', 406 ); } @@ -355,45 +374,58 @@ function _blast_ui_getJobId( $data ) $query_type; $db_type; + $output_format = 'json'; // Setting the default value of qRange and eValue from blast_ui.admin $eVal = variable_get( 'eVal', '' ); $qRange = variable_get( 'qRange', '' ); + /* check values in post query */ - if ( !isset( $data[ query_type ] ) ) + if ( !isset( $data[ 'query_type'] ) ) { return services_error( 'Missing blast attribute $query_type [ set necleotide or protein in post request of query_type ]', 406 ); } - if ( !isset( $data[ db_type ] ) ) + if ( !isset( $data[ 'db_type' ] ) ) { return services_error( 'Missing blast attribute $db_type [ set necleotide or protein in post request of db_type ]', 406 ); } + - $query_type = $data[ query_type ]; - $db_type = $data[ db_type ]; + $query_type = $data[ 'query_type' ]; + $db_type = $data[ 'db_type' ]; // check the user input in $data blast_validation( $query_type, $db_type, $data ); - if ( isset( $data[ $eVal ] ) ) + if ( isset( $data[ 'eVal' ] ) ) { - $eVal = $data[ $eVal ]; + $eVal = $data[ 'eVal' ]; } - if ( isset( $data[ $culling_limit ] ) ) + + if ( isset( $data[ 'output_format' ] ) ) { - $qRange = $data[ $culling_limit ]; + $output_format = $data[ 'output_format' ]; + if(strcasecmp($output_format, 'xml') == 0) + { + $output_format = 'json'; + } + } + + if ( isset( $data[ 'culling_limit' ] ) ) + { + $qRange = $data[ 'culling_limit' ]; } + if ( $query_type == 'nucleotide' ) { if ( $db_type == 'nucleotide' ) { $blast_program = 'blastn'; - // code not working for wordvalue = 7 ? - $options_database = get_blast_database_options( $data[ db_type ] ); - $Databasekey = array_search( $data[ Select_Database ], $options_database ); + $options_database = get_blast_database_options( $data[ 'db_type' ] ); + $Databasekey = array_search( $data[ 'Select_Database' ], $options_database ); $advanced_options = advanced_options( $blast_program, $eVal, $qRange, $data ); } @@ -401,8 +433,8 @@ function _blast_ui_getJobId( $data ) { $blast_program = 'blastx'; // how to get gap cost - question - $options_database = get_blast_database_options( $data[ db_type ] ); - $Databasekey = array_search( $data[ Select_Database ], $options_database ); + $options_database = get_blast_database_options( $data[ 'db_type' ] ); + $Databasekey = array_search( $data[ 'Select_Database' ], $options_database ); $advanced_options = advanced_options( $blast_program, $eVal, $qRange, $data ); } } @@ -411,22 +443,32 @@ function _blast_ui_getJobId( $data ) if ( $db_type == 'nucleotide' ) { $blast_program = 'tblastn'; - $options_database = get_blast_database_options( $data[ db_type ] ); - $Databasekey = array_search( $data[ Select_Database ], $options_database ); + $options_database = get_blast_database_options( $data[ 'db_type' ] ); + $Databasekey = array_search( $data[ 'Select_Database' ], $options_database ); $advanced_options = advanced_options( $blast_program, $eVal, $qRange, $data ); } elseif ( $db_type == 'protein' ) { $blast_program = 'blastp'; - $options_database = get_blast_database_options( $data[ db_type ] ); - $Databasekey = array_search( $data[ Select_Database ], $options_database ); + $options_database = get_blast_database_options( $data[ 'db_type' ] ); + $Databasekey = array_search( $data[ 'Select_Database' ], $options_database ); $advanced_options = advanced_options( $blast_program, $eVal, $qRange, $data ); } } - - return blast_ui_getblastJobId( $data[ query_type ], $data[ db_type ], $data[ seqQuery ], $Databasekey, $advanced_options ); + // return getOutputFormat($output_format); + + +/* return array('query_type' => $data[ 'query_type' ], + 'db_type' => $data[ 'db_type' ], + 'seqQuery' => $data[ 'seqQuery' ], + '$Databasekey' => $Databasekey, + '$advanced_options' => $advanced_options + ); */ + + + return blast_ui_getblastJobId( $data[ 'query_type' ], $data[ 'db_type' ], $data[ 'seqQuery' ], $Databasekey, $advanced_options, getOutputFormat($output_format),$output_format); } @@ -439,16 +481,16 @@ function advanced_options( $blast_program, $eVal, $qRange, $data ) if ( $blast_program == 'blastn' ) { - $wordvalue = intval( $data[ Word_size ] ); - $numAlign = intval( $data[ Max_target_sequences ] ); + $wordvalue = intval( $data[ 'Word_size' ] ); + $numAlign = intval( $data[ 'Max_target_sequences' ] ); $Data_GapCost = _get_gap( $blast_program ); - $gapkey = array_search( $data[ Gap_Costs ], $Data_GapCost ); + $gapkey = array_search( $data[ 'Gap_Costs' ], $Data_GapCost ); $gap = _set_gap( $gapkey ); $Data_Mismatch_Scores = _get_match_mismatch( $blast_program ); - $Mismatch_Scores_key = array_search( $data[ Match_Mismatch_Scores ], $Data_Mismatch_Scores ); + $Mismatch_Scores_key = array_search( $data[ 'Match_Mismatch_Scores' ], $Data_Mismatch_Scores ); $m_m = _set_match_mismatch( $Mismatch_Scores_key ); return array( @@ -459,15 +501,15 @@ function advanced_options( $blast_program, $eVal, $qRange, $data ) 'gapextend' => $gap[ 'gapExtend' ], 'penalty' => $m_m[ 'penalty' ], 'reward' => $m_m[ 'reward' ], - 'culling_limit' => $qRange + 'culling_limit' => $qRange ); } elseif ( $blast_program == 'blastx' ) { - $wordSize = intval( $data[ Word_size ] ); - $numAlign = intval( $data[ Max_target_sequences ] ); - $matrix = $data[ Matrix_options ]; + $wordSize = intval( $data[ 'Word_size' ] ); + $numAlign = intval( $data[ 'Max_target_sequences' ] ); + $matrix = $data[ 'Matrix_options' ]; $gap = getGap( $matrix, 1 ); return array( @@ -482,9 +524,9 @@ function advanced_options( $blast_program, $eVal, $qRange, $data ) } elseif ( $blast_program == 'tblastn' ) { - $wordSize = intval( $data[ Word_size ] ); - $numAlign = intval( $data[ Max_target_sequences ] ); - $matrix = $data[ Matrix_options ]; + $wordSize = intval( $data[ 'Word_size' ] ); + $numAlign = intval( $data[ 'Max_target_sequences' ] ); + $matrix = $data[ 'Matrix_options' ]; $gap = getGap( $matrix, 1 ); return array( @@ -499,9 +541,9 @@ function advanced_options( $blast_program, $eVal, $qRange, $data ) } elseif ( $blast_program == 'blastp' ) { - $wordSize = intval( $data[ Word_size ] ); - $numAlign = intval( $data[ Max_target_sequences ] ); - $matrix = $data[ Matrix_options ]; + $wordSize = intval( $data[ 'Word_size' ] ); + $numAlign = intval( $data[ 'Max_target_sequences' ] ); + $matrix = $data[ 'Matrix_options' ]; $gap = getGap( $matrix, 1 ); return array( @@ -522,8 +564,8 @@ function advanced_options( $blast_program, $eVal, $qRange, $data ) ** @return : Job_ID */ -function blast_ui_getblastJobId( $query_type, $db_type, $seqQuery, $Databasekey, $adv_options ) - { +function blast_ui_getblastJobId( $query_type, $db_type, $seqQuery, $Databasekey, $adv_options, $output_format, $format_type) + { if ( $query_type == 'nucleotide' ) { if ( $db_type == 'nucleotide' ) @@ -547,53 +589,67 @@ function blast_ui_getblastJobId( $query_type, $db_type, $seqQuery, $Databasekey, } } + $query = '/tmp/' . date( 'YMd_His' ) . '_query.fasta'; file_put_contents( $query, $seqQuery ); $blastdb_node = node_load( $Databasekey ); $blastdb_name = $blastdb_node->db_name; $blastdb_with_path = $blastdb_node->db_path; - // Now let each program process its own advanced options. - - - $advanced_options = $adv_options; global $user; $output_filestub = date( 'YMd_His' ); + + $job_args = array( 'program' => $blast_program, 'query' => $query, 'database' => $blastdb_with_path, 'output_filename' => $output_filestub, - 'options' => $advanced_options + 'options' => $adv_options, + 'format' => $output_format, + 'format_type' => $format_type, ); + $job_id = tripal_add_job( t( 'BLAST (@program): @query', array( '@program' => $blast_program, '@query' => $query - ) ), 'blast_job', 'run_BLAST_tripal_job', $job_args, $user->uid ); + ) ), 'blast_job', 'run_BLAST_tripal_job_services', $job_args, $user->uid); ob_start(); tripal_launch_job( 1, $job_id ); ob_end_clean(); - return $job_id; - // return getBlastData($job_id); + + + + return array( + 'job_Id' => $job_id + ); + } - - - - - -function getBlaststatus( $job_id ) +/* +** +** Check status of the job entered in the queue with jobId +*/ +function getBlaststatus( $data ) { - /* $sql = "SELECT status FROM tripal_jobs WHERE job_id = :job_id "; + if ( !isset( $data[ 'job_id'] ) ) + { + return services_error( 'Required the job_id to check the blast status', 406 ); + } + $job_id = $data[ 'job_id']; + + $sql = "SELECT status FROM tripal_jobs WHERE job_id = :job_id "; $job_res = db_query($sql, array(':job_id' => $job_id))->fetchField(); - return $job_res; */ + return $job_res; } + + /* **Method returns file output data ** @param int $job_id @@ -602,14 +658,14 @@ function getBlaststatus( $job_id ) function getBlastData( $job_id ) { - $result; + $result ; $sql = "SELECT job_name FROM tripal_jobs WHERE job_id = :job_id "; - $job_res = db_query( $sql, array( + $file_path = db_query( $sql, array( ':job_id' => $job_id ) )->fetchField(); - $file_path = str_replace( '_query.fasta', '.blast.asn', $job_res ); + if ( stristr( $file_path, "tblastn" ) ) { @@ -627,391 +683,58 @@ function getBlastData( $job_id ) { $file_path = str_replace( 'BLAST (blastp): /', '/', $file_path ); } + + // return $file_path; + /* + ** defined all the format here to support output format, file_exists search the file + ** In temp folder, if exits, get output in result. + */ - - if ( file_exists( $file_path ) ) + if ( file_exists( str_replace( '_query.fasta', '.blast.json', $file_path ) ) ) { - $result = file_get_contents( $file_path ); + $file_path = str_replace( '_query.fasta', '.blast.json', $file_path ); + $result = json_decode(file_get_contents($file_path), true); } - else + else if ( file_exists( str_replace( '_query.fasta', '.blast.asn', $file_path ) ) ) { - $result = "The file $file_path does not exist"; + $file_path = str_replace( '_query.fasta', '.blast.asn', $file_path ); + $result = readfile($file_path); } - return $result; + else{ + + $result = "File Does not exits in database"; + } + + return $result; + } + + /* - **Method Used for tblastn and blastx - ** @return int $gapOpen and $gapExtend - */ +** Return the result output format of final request +** +*/ -function getGap( $matrix, $gapkey ) - { - switch ( $matrix ) - { - case 'PAM30': - switch ( $gapKey ) - { - case 0: - $gapOpen = 7; - $gapExtend = 2; - break; - case 1: - $gapOpen = 6; - $gapExtend = 2; - break; - case 2: - $gapOpen = 5; - $gapExtend = 2; - break; - case 3: - $gapOpen = 10; - $gapExtend = 1; - break; - case 4: - $gapOpen = 9; - $gapExtend = 1; - break; - case 5: - $gapOpen = 8; - $gapExtend = 1; - break; - } - break; - case 'PAM70': - switch ( $gapKey ) - { - case 0: - $gapOpen = 8; - $gapExtend = 2; - break; - case 1: - $gapOpen = 7; - $gapExtend = 2; - break; - case 2: - $gapOpen = 6; - $gapExtend = 2; - break; - case 3: - $gapOpen = 11; - $gapExtend = 1; - break; - case 4: - $gapOpen = 10; - $gapExtend = 1; - break; - case 5: - $gapOpen = 9; - $gapExtend = 1; - break; - } - break; - case 'PAM250': - switch ( $gapKey ) - { - case 0: - $gapOpen = 15; - $gapExtend = 3; - break; - case 1: - $gapOpen = 14; - $gapExtend = 3; - break; - case 2: - $gapOpen = 13; - $gapExtend = 3; - break; - case 3: - $gapOpen = 12; - $gapExtend = 3; - break; - case 4: - $gapOpen = 11; - $gapExtend = 3; - break; - case 5: - $gapOpen = 17; - $gapExtend = 2; - break; - case 6: - $gapOpen = 16; - $gapExtend = 2; - break; - case 7: - $gapOpen = 15; - $gapExtend = 2; - break; - case 8: - $gapOpen = 14; - $gapExtend = 2; - break; - case 9: - $gapOpen = 13; - $gapExtend = 2; - break; - case 10: - $gapOpen = 21; - $gapExtend = 1; - break; - case 11: - $gapOpen = 20; - $gapExtend = 1; - break; - case 12: - $gapOpen = 19; - $gapExtend = 1; - break; - case 13: - $gapOpen = 18; - $gapExtend = 1; - break; - case 14: - $gapOpen = 17; - $gapExtend = 1; - break; - } - break; - case 'BLOSUM80': - switch ( $gapKey ) - { - case 0: - $gapOpen = 8; - $gapExtend = 2; - break; - case 1: - $gapOpen = 7; - $gapExtend = 2; - break; - case 2: - $gapOpen = 6; - $gapExtend = 2; - break; - case 3: - $gapOpen = 11; - $gapExtend = 1; - break; - case 4: - $gapOpen = 10; - $gapExtend = 1; - break; - case 5: - $gapOpen = 9; - $gapExtend = 1; - break; - } - break; - case 'BLOSUM62': - switch ( $gapKey ) - { - case 0: - $gapOpen = 11; - $gapExtend = 2; - break; - case 1: - $gapOpen = 10; - $gapExtend = 2; - break; - case 2: - $gapOpen = 9; - $gapExtend = 2; - break; - case 3: - $gapOpen = 8; - $gapExtend = 2; - break; - case 4: - $gapOpen = 7; - $gapExtend = 2; - break; - case 5: - $gapOpen = 6; - $gapExtend = 2; - break; - case 6: - $gapOpen = 13; - $gapExtend = 1; - break; - case 7: - $gapOpen = 12; - $gapExtend = 1; - break; - case 8: - $gapOpen = 11; - $gapExtend = 1; - break; - case 9: - $gapOpen = 10; - $gapExtend = 1; - break; - case 10: - $gapOpen = 9; - $gapExtend = 1; - break; - } - break; - case 'BLOSUM45': - switch ( $gapKey ) - { - case 0: - $gapOpen = 13; - $gapExtend = 3; - break; - case 1: - $gapOpen = 12; - $gapExtend = 3; - break; - case 2: - $gapOpen = 11; - $gapExtend = 3; - break; - case 3: - $gapOpen = 10; - $gapExtend = 3; - break; - case 4: - $gapOpen = 15; - $gapExtend = 2; - break; - case 5: - $gapOpen = 14; - $gapExtend = 2; - break; - case 6: - $gapOpen = 13; - $gapExtend = 2; - break; - case 7: - $gapOpen = 12; - $gapExtend = 2; - break; - case 8: - $gapOpen = 19; - $gapExtend = 1; - break; - case 9: - $gapOpen = 18; - $gapExtend = 1; - break; - case 10: - $gapOpen = 17; - $gapExtend = 1; - break; - case 11: - $gapOpen = 16; - $gapExtend = 1; - break; - } - break; - case 'BLOSUM50': - switch ( $gapKey ) - { - case 0: - $gapOpen = 13; - $gapExtend = 3; - break; - case 1: - $gapOpen = 12; - $gapExtend = 3; - break; - case 2: - $gapOpen = 11; - $gapExtend = 3; - break; - case 3: - $gapOpen = 10; - $gapExtend = 3; - break; - case 4: - $gapOpen = 9; - $gapExtend = 3; - break; - case 5: - $gapOpen = 16; - $gapExtend = 2; - break; - case 6: - $gapOpen = 15; - $gapExtend = 2; - break; - case 7: - $gapOpen = 14; - $gapExtend = 2; - break; - case 8: - $gapOpen = 13; - $gapExtend = 2; - break; - case 9: - $gapOpen = 12; - $gapExtend = 2; - break; - case 10: - $gapOpen = 19; - $gapExtend = 1; - break; - case 11: - $gapOpen = 18; - $gapExtend = 1; - break; - case 12: - $gapOpen = 17; - $gapExtend = 1; - break; - case 13: - $gapOpen = 16; - $gapExtend = 1; - break; - case 14: - $gapOpen = 15; - $gapExtend = 1; - break; - } - break; - case 'BLOSUM90': - switch ( $gapKey ) - { - case 0: - $gapOpen = 9; - $gapExtend = 2; - break; - case 1: - $gapOpen = 8; - $gapExtend = 2; - break; - case 2: - $gapOpen = 7; - $gapExtend = 2; - break; - case 3: - $gapOpen = 6; - $gapExtend = 2; - break; - case 4: - $gapOpen = 11; - $gapExtend = 1; - break; - case 5: - $gapOpen = 10; - $gapExtend = 1; - break; - case 6: - $gapOpen = 9; - $gapExtend = 1; - break; - } - break; - - } - return array( - 'gapOpen' => $gapOpen, - 'gapExtend' => $gapExtend - ); - } +function getOutputFormat($format) +{ + switch ($format) { + case "asn": + return 11; + break; + + case "json": + return 12; + break; + + } +} + /* ** Used for tblastn */ + function getGap_cost() { return array( diff --git a/theme/.DS_Store b/theme/.DS_Store new file mode 100644 index 0000000..c7508a3 Binary files /dev/null and b/theme/.DS_Store differ