function chado_get_fasta_defline

3.x tripal_chado.feature.api.inc chado_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.

Related topics

2 calls to chado_get_fasta_defline()
chado_get_feature_sequences in tripal_chado/api/modules/tripal_chado.feature.api.inc
Retrieves the sequences for a given feature.
tripal_get_fasta_defline in tripal_chado/api/modules/tripal_chado.module.DEPRECATED.api.inc
Returns a definition line that can be used in a FASTA file.

File

tripal_chado/api/modules/tripal_chado.feature.api.inc, line 722
Provides API functions specificially for managing feature records in Chado.

Code

function chado_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 " . chado_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;
}