function tripal_get_fasta_defline

2.x tripal_feature.api.inc tripal_get_fasta_defline($feature, $notes = '', $featureloc = NULL, $type = '', $length = 0)

Returns a definition line that can be used in a FASTA file

Parameters

$feature: A single feature object containing all the fields from the chado.feature table. Best case is to provide an object generated by the chado_generate_var() function.

$notes: Optional: additional notes to be added to the definition line

$featureloc: Optional: a single featureloc object generated using chado_generate_var that contains a record from the chado.featureloc table. Provide this if the sequence was obtained by using the alignment rather than from the feature.residues column

$type: Optional: the type of sequence. By default the feature type is used.

$length: Optional: the length of the sequence

Return value

A string of the format: uniquename|name|type|feature_id or if an alignment: srcfeature_name:fmin..fmax[+-]; alignment of uniquename|name|type|feature_id

3 calls to tripal_get_fasta_defline()
tripal_feature_load_featureloc_sequences in tripal_feature/theme/tripal_feature.theme.inc
Get the sequence this feature is located on
tripal_feature_sequence.tpl.php in tripal_feature/theme/templates/tripal_feature_sequence.tpl.php
tripal_get_feature_sequences in tripal_feature/api/tripal_feature.api.inc
Retrieves the sequences for a given feature.

File

tripal_feature/api/tripal_feature.api.inc, line 663
Provides an application programming interface (API) for working with features

Code

function tripal_get_fasta_defline($feature, $notes = '', $featureloc = NULL, $type = '', $length = 0) {

  // make sure the featureloc object has the srcfeature if not, then add it
  if ($featureloc) {
    if (!is_object($featureloc->srcfeature_id)) {
      $featureloc->srcfeature_id = chado_generate_var('feature', array('feature_id' => $featureloc->srcfeature_id));
    }
    if (!is_object($featureloc->srcfeature_id->organism_id)) {
      $featureloc->srcfeature_id->organism_id = chado_generate_var('organism', array('organism_id' => $featureloc->srcfeature_id->organism_id));
    }
  }
  // make sure the feature object has the organism if not, then add it
  if (!is_object($feature->organism_id)) {
    $feature->organism_id = chado_generate_var('organism', array('organism_id' => $feature->organism_id));
  }

  // if a type is not provided then use the default type
  if (!$type) {
    $type = $feature->type_id->name;
  }

  // construct the definition line
  $defline = $feature->uniquename . " " .
    'ID=' . $feature->uniquename . "|" .
    'Name=' . $feature->name . "|" .
    'organism=' . $feature->organism_id->genus . " " . $feature->organism_id->species . "|" .
    'type=' . $type . '|';
  if ($length > 0) {
    $defline .= "length=" . $length . "bp|";
  }
  if ($featureloc) {
    $defline .= "location=Sequence derived from alignment at " . tripal_get_location_string($featureloc);
    $defline .= " (" . $featureloc->srcfeature_id->organism_id->genus . " " . $featureloc->srcfeature_id->organism_id->species . ")|";
  }
  if ($notes) {
    $defline .= "Notes=$notes|";
  }
  $defline = substr($defline, 0, -1); // remove the trailing |
  return $defline;
}