123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- <?php
- /**
- * @file
- * The main file for the blast UI module.
- */
- // BLAST Submission Forms
- require_once 'includes/blast_ui.form_common.inc';
- require_once 'includes/blast_ui.form_advanced_options.inc';
- // NOTE: The forms themeselves are included using hook_menu to ensure they
- // are only inlcuded when needed.
- // BLAST DB Node functionality
- require_once 'includes/blast_ui.node.inc';
- // Functions specific to themeing (ie: preprocess)
- require_once 'theme/blast_ui.theme.inc';
- // Application Programmers Interface
- require_once 'api/blast_ui.api.inc';
- // Administration
- require_once 'includes/blast_ui.admin.inc';
- /**
- * Implements hook_menu().
- */
- function blast_ui_menu() {
- // BLAST DB Node
- $items['node__blastdb'] = array(
- 'template' => 'node--blastdb',
- 'render element' => 'node',
- 'base hook' => 'node',
- 'path' => 'theme',
- );
- // Single All-in-One BLAST submission form
- $items['blast'] = array(
- 'title' => 'BLAST',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('blast_ui_all_in_one_form'),
- 'access arguments' => array('access content'),
- 'file' => 'includes/blast_ui.form_single.inc',
- 'type' => MENU_NORMAL_ITEM,
- 'expanded' => TRUE,
- );
- // Per Query Type BLAST submission forms
- $items['blast/nucleotide'] = array(
- 'title' => 'Nucleotide Query',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('blast_ui_per_query_type_form', 1, 2),
- 'access arguments' => array('access content'),
- 'file' => 'includes/blast_ui.form_per_query_type.inc',
- 'type' => MENU_NORMAL_ITEM,
- 'expanded' => TRUE,
- );
- $items['blast/protein'] = array(
- 'title' => 'Protein Query',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('blast_ui_per_query_type_form', 1),
- 'access arguments' => array('access content'),
- 'file' => 'includes/blast_ui.form_per_query_type.inc',
- 'type' => MENU_NORMAL_ITEM,
- 'expanded' => TRUE,
- );
- // Per BLAST-program submission forms
- $items['blast/nucleotide/nucleotide'] = array(
- 'title' => 'BLASTn',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('blast_ui_per_blast_program_form', 1, 2),
- 'access arguments' => array('access content'),
- 'file' => 'includes/blast_ui.form_per_program.inc',
- 'type' => MENU_NORMAL_ITEM
- );
- $items['blast/nucleotide/protein'] = array(
- 'title' => 'BLASTx',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('blast_ui_per_blast_program_form', 1, 2),
- 'access arguments' => array('access content'),
- 'file' => 'includes/blast_ui.form_per_program.inc',
- 'type' => MENU_NORMAL_ITEM
- );
- $items['blast/protein/nucleotide'] = array(
- 'title' => 'tBLASTn',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('blast_ui_per_blast_program_form', 1, 2),
- 'access arguments' => array('access content'),
- 'file' => 'includes/blast_ui.form_per_program.inc',
- 'type' => MENU_NORMAL_ITEM
- );
- $items['blast/protein/protein'] = array(
- 'title' => 'BLASTp',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('blast_ui_per_blast_program_form', 1, 2),
- 'access arguments' => array('access content'),
- 'file' => 'includes/blast_ui.form_per_program.inc',
- 'type' => MENU_NORMAL_ITEM
- );
- // BLAST Results page
- $items['blast/report/%'] = array(
- 'title' => 'BLAST Results',
- 'page callback' => 'show_blast_output',
- 'page arguments' => array(2),
- 'access arguments' => array('access content'),
- 'type' => MENU_CALLBACK,
- );
- // BLAST Admin
- $items['admin/tripal/extension/tripal_blast'] = array(
- 'title' => 'Tripal BLAST User Interface',
- 'description' => 'Provides an interface allowing users to execute their own BLASTs.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('blast_ui_admin_form'),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_NORMAL_ITEM,
- );
- $items['admin/tripal/extension/tripal_blast/blast_ui'] = array(
- 'title' => 'BLAST UI',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- );
- $items['admin/tripal/extension/tripal_blast/help'] = array(
- 'title' => 'Help',
- 'page callback' => 'theme',
- 'page arguments' => array('blast_help'),
- 'access arguments' => array('administer tripal'),
- 'type' => MENU_LOCAL_TASK,
- );
- return $items;
- }
- /**
- * Implements hook_theme().
- */
- function blast_ui_theme() {
- $items = array();
- $path = drupal_get_path('module', 'blast_ui');
- // Displays the BLAST results for each job
- $items['show_blast_report'] = array(
- 'template' => 'blast_report',
- 'path' => "$path/theme",
- );
- // Displays the BLAST results for each job
- $items['blast_report_pending'] = array(
- 'template' => 'blast_report_pending',
- 'path' => "$path/theme",
- );
- // Themes the alignments in a BLAST result display
- $items['blast_report_alignment_row'] = array(
- 'template' => 'blast_report_alignment_row',
- 'variables' => array('hsps' => NULL),
- 'path' => "$path/theme",
- );
- // Module Help
- $items['blast_help'] = array(
- 'template' => 'blast_help',
- 'path' => "$path/theme",
- );
- // Menu Information Pages
- // These are only seen if the user has disabled the all-in-one
- // or by query type forms.
- $items['blast_user_menupage'] = array(
- 'template' => 'blast_user_menupage',
- 'path' => "$path/theme",
- );
- $items['blast_nucleotide_user_menupage'] = array(
- 'template' => 'blast_nucleotide_user_menupage',
- 'path' => "$path/theme",
- );
- $items['blast_protein_user_menupage'] = array(
- 'template' => 'blast_protein_user_menupage',
- 'path' => "$path/theme",
- );
- return $items;
- }
- /**
- * Implements hook_help().
- */
- function blast_ui_help($path, $arg) {
- if ($path == 'admin/help#blast_ui') {
- return theme('blast_help');
- }
- }
- /**
- * Facilitate presenting the result of the blast search
- *
- * @param $job_id
- * The tripal job_id of the BLAST job previously submitted
- *
- * @return $result
- * Return HTML output of the BLAST results to be displayed to the user
- *
- */
- function show_blast_output($job_id) {
- // BLASTs are run as a Tripal job. As such we need to determine whether the current
- // BLAST is in the queue, running or complete in order to determine what to show the user
- $job = tripal_get_job($job_id);
- // 1) Job is in the Queue
- if ($job->start_time === NULL AND $job->end_time == NULL) {
- return theme('blast_report_pending', array('status_code' => 0, 'status' => 'Pending'));
- }
- // 2) Job has been Cancelled
- elseif ($job->status == 'Cancelled') {
- return theme('blast_report_pending', array('status_code' => 999, 'status' => 'Cancelled'));
- }
- // 3) Job is Complete
- elseif ($job->end_time !== NULL) {
- // Return the Results :)
- return theme('show_blast_report', array('job_id' => $job_id));
- }
- // 4) Job is in Progress
- else {
- return theme('blast_report_pending', array('status_code' => 1, 'status' => 'Running'));
- }
- return '';
- }
- /**
- *
- */
- function ajax_blast_ui_example_sequence_callback($form, $form_state) {
- // First, set a default example sequence in case administrators have not yet
- // bothered to set their own.
- $sequence_type = $form_state['values']['query_type'];
- if ($sequence_type == 'nucleotide') {
- $default_example_sequence = '>partial lipoxygenase Glyma15g03040
- TTTCGTATGA GATTAAAATG TGTGAAATTT TGTTTGATAG GACATGGGAA
- AGGAAAAGTT GGAAAGGCTA CAAATTTAAG AGGACAAGTG TCGTTACCAA
- CCTTGGGAGC TGGCGAAGAT GCATACGATG TTCATTTTGA ATGGGACAGT
- GACTTCGGAA TTCCCGGTGC ATTTTACATT AAGAACTTCA TGCAAGTTGA
- GTTCTATCTC AAGTCTCTAA CTCTCGAAGA CATTCCAAAC CACGGAACCA
- TTCACTTCGT ATGCAACTCC TGGGTTTACA ACTCAAAATC CTACCATTCT
- GATCGCATTT TCTTTGCCAA CAATGTAAGC TACTTAAATA CTGTTATACA
- TTGTCTAACA TCTTGTTAGA GTCTTGCATG ATGTGTACCG TTTATTGTTG
- TTGTTGAACT TTACCACATG GCATGGATGC AAAAGTTGTT ATACACATAA
- ATTATAATGC AGACATATCT TCCAAGCGAG ACACCGGCTC CACTTGTCAA
- GTACAGAGAA GAAGAATTGA AGAATGTAAG AGGGGATGGA ACTGGTGAGC
- GCAAGGAATG GGATAGGATC TATGATTATG ATGTCTACAA TGACTTGGGC
- GATCCAGATA AGGGTGAAAA GTATGCACGC CCCGTTCTTG GAGGTTCTGC
- CTTACCTTAC CCTCGCAGAG GAAGAACCGG AAGAGGAAAA ACTAGAAAAG
- GTTTCTCACT AGTCACTAAT TTATTACTTT TTAATGTTTG TTTTTAGGCA
- TCTTTTCTGA TGAAATGTAT ACTTTTGATG TTTTTTTGTT TTAGCATAAC
- TGAATTAGTA AAGTGTGTTG TGTTCCTTAG AAGTTAGAAA AGTACTAAGT
- ATAAGGTCTT TGAGTTGTCG TCTTTATCTT AACAGATCCC AACAGTGAGA
- AGCCCAGTGA TTTTGTTTAC CTTCCGAGAG ATGAAGCATT TGGTCACTTG
- AAGTCATCAG ATTTTCTCGT TTATGGAATC AAATCAGTGG CTCAAGACGT
- CTTGCCCGTG TTGACTGATG CGTTTGATGG CAATCTTTTG AGCCTTGAGT
- TTGATAACTT TGCTGAAGTG CGCAAACTCT ATGAAGGTGG AGTTACACTA
- CCTACAAACT TTCTTAGCAA GATCGCCCCT ATACCAGTGG TCAAGGAAAT
- TTTTCGAACT GATGGCGAAC AGTTCCTCAA GTATCCACCA CCTAAAGTGA
- TGCAGGGTAT GCTACATATT TTGAATATGT AGAATATTAT CAATATACTC
- CTGTTTTTAT TCAACATATT TAATCACATG GATGAATTTT TGAACTGTTA';
- }
- elseif ($sequence_type == 'protein') {
- $default_example_sequence = '>gi|166477|gb|AAA96434.1| resveratrol synthase [Arachis hypogaea]
- MVSVSGIRKVQRAEGPATVLAIGTANPPNCIDQSTYADYYFRVTNSEHMTDLKKKFQRICERTQIKNRHM
- YLTEEILKENPNMCAYKAPSLDAREDMMIREVPRVGKEAATKAIKEWGQPMSKITHLIFCTTSGVALPGV
- DYELIVLLGLDPCVKRYMMYHQGCFAGGTVLRLAKDLAENNKDARVLIVCSENTAVTFRGPSETDMDSLV
- GQALFADGAAAIIIGSDPVPEVEKPIFELVSTDQKLVPGSHGAIGGLLREVGLTFYLNKSVPDIISQNIN
- DALNKAFDPLGISDYNSIFWIAHPGGRAILDQVEQKVNLKPEKMKATRDVLSNYGNMSSACVFFIMDLMR
- KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
- }
- else {
- $default_example_sequence = '';
- }
- // If the Show Example checkbox is true then put the example in the textfield
- if ($form_state['values']['example_sequence']) {
- // Set the value to be the example sequence (either set by the administrator
- // or the default set above).
- $form['query']['FASTA']['#value'] = variable_get(
- 'blast_ui_' . $sequence_type . '_example_sequence',
- $default_example_sequence
- );
- }
- // Otherwise we want to remove the already displayed example.
- else {
- $form['query']['FASTA']['#value'] = '';
- }
- return $form['query']['FASTA'];
- }
|