function tripal_chado_seq_extract_page

3.x tripal_chado.seq_extract.inc tripal_chado_seq_extract_page()

The page allowing users to download feature sequences

Related topics

File

tripal_chado/includes/exporters/tripal_chado.seq_extract.inc, line 12
Interface for downloading feature sequences

Code

function tripal_chado_seq_extract_page() {

  if ($_SESSION['tripal_chado_seq_extract']['download']) {
    $genus = $_SESSION['tripal_chado_seq_extract']['genus'];
    $species = $_SESSION['tripal_chado_seq_extract']['species'];
    $analysis = $_SESSION['tripal_chado_seq_extract']['analysis'];
    $ftype = $_SESSION['tripal_chado_seq_extract']['ftype'];
    $fnames = $_SESSION['tripal_chado_seq_extract']['fnames'];
    $upstream = $_SESSION['tripal_chado_seq_extract']['upstream'];
    $downstream = $_SESSION['tripal_chado_seq_extract']['downstream'];
    $format = $_SESSION['tripal_chado_seq_extract']['format'];
    $use_parent = $_SESSION['tripal_chado_seq_extract']['use_parent'];
    $aggregate = $_SESSION['tripal_chado_seq_extract']['aggregate'];
    $agg_types = $_SESSION['tripal_chado_seq_extract']['agg_types'];

    unset($_SESSION['tripal_chado_seq_extract']['download']);

    if ($format == 'fasta_html') {
      drupal_add_http_header('Content-Type: text/html');
    }
    else {
      drupal_add_http_header('Content-Type: text');
      drupal_add_http_header('Content-Disposition: attachment; filename="sequences.fasta.txt"');
    }

    chado_get_bulk_feature_sequences(array(
      'genus' => $genus,
      'species' => $species,
      'analysis_name' => $analysis,
      'type' => $ftype,
      'feature_name' => $fnames['items_array'],
      'upstream' => $upstream,
      'downstream' => $downstream,
      'print' => 1,
      'output_format' => $format,
      'derive_from_parent' => $use_parent,
      'aggregate' => $aggregate,
      'sub_feature_types' => $agg_types
    ));

    return;
  }


  // generate the search form
  $output .= '';
  if (user_access('administer tripal')) {
    $output .= tripal_set_message("Administrators, the " .
      l('organism_feature_count', 'admin/tripal/storage/chado/mviews') . " and " .
      l('analysis_organism', 'admin/tripal/storage/chado/mviews') . " materialized
        views must be populated before using this form.  Those views should be re-populated
        when new data is added.");
  }
  $output .= "<div id=\"tripal-feature-seq-extract-form-block\">";
  $output .= drupal_get_form('tripal_chado_seq_extract_form');
  $output .= "</div>";
  return $output;
}