Bio::EnsEMBL::Compara NCBITaxon
SummaryIncluded librariesPackage variablesDescriptionGeneral documentationMethods
Toolbar
WebCvsRaw content
Summary
NCBITaxon - DESCRIPTION of Object
Package variables
No package variables defined.
Included modules
Bio::EnsEMBL::Compara::NestedSet
Bio::EnsEMBL::Utils::Argument
Bio::EnsEMBL::Utils::Exception
Bio::Species
Inherit
Bio::EnsEMBL::Compara::NestedSet
Synopsis
No synopsis!
Description
  
An object that hold a node within a taxonomic tree. Inherits from NestedSet.
From Bio::Species classification common_name binomial Here are also the additional methods in Bio::Species that "might" be useful, but let us forget about these for now. genus species sub_species variant organelle division
Methods
RAP_species_format
No description
Code
_add_child_name_to_classification
No description
Code
binomialDescriptionCode
classification
No description
Code
common_nameDescriptionCode
copyDescriptionCode
dbID
No description
Code
ensembl_aliasDescriptionCode
ensembl_alias_nameDescriptionCode
genbank_hidden_flag
No description
Code
genusDescriptionCode
get_short_name
No description
Code
ncbi_taxid
No description
Code
print_node
No description
Code
rank
No description
Code
short_nameDescriptionCode
speciesDescriptionCode
subspeciesDescriptionCode
taxon_id
No description
Code
Methods description
binomialcode    nextTop
  Example    : $ncbi->binomial;
Description: The binomial name (AKA the scientific name) of this genome
Returntype : string
Exceptions : warns when node is not a species or has no scientific name
Caller : general
common_namecodeprevnextTop
  Example    : $ncbi->common_name;
Description: The comon name as defined by Genbank
Returntype : string
Exceptions : returns undef if no genbank common name exists.
Caller : general
copycodeprevnextTop
  Arg [1]    : int $member_id (optional)
Example :
Description: returns copy of object, calling superclass copy method
Returntype :
Exceptions :
Caller :
ensembl_aliascodeprevnextTop
  Example    : $ncbi->ensembl_alias;
Description: The ensembl_alias name (AKA the name in the ensembl website) of this genome
Returntype : string
Exceptions : warns when node is not a species or has no ensembl_alias
Caller : general
ensembl_alias_namecodeprevnextTop
  Example    : $ncbi->ensembl_alias_name;
Description: The comon name as defined by ensembl alias
Returntype : string
Exceptions : returns undef if no ensembl alias name exists.
Caller : general
genuscodeprevnextTop
  Example    : $ncbi->genus;
Description: Returns the genus name for this species
Returntype : string
Example : "Homo" for Homo sapiens
Exceptions :
Caller : general
short_namecodeprevnextTop
  Example    : $ncbi->short_name;
Description: The name of this genome in the Gspe ('G'enera
'spe'cies) format.
Returntype : string
Exceptions : none
Caller : general
speciescodeprevnextTop
  Example    : $ncbi->species;
Description: Returns the speceis name for this species
Example : "sapiens" for Homo sapiens
Returntype : string
Exceptions :
Caller : general
subspeciescodeprevnextTop
  Example    : $ncbi->subspecies;
Description: Returns the subspeceis name for this species
Example : "verus" for Pan troglodytes verus
Returntype : string
Exceptions :
Caller : general
Methods code
RAP_species_formatdescriptionprevnextTop
sub RAP_species_format {
  my $self = shift;
  my $newick = "";
  
  if($self->get_child_count() > 0) {
    $newick .= "(";
    my $first_child=1;
    foreach my $child (@{$self->sorted_children}) {  
      $newick .= "," unless($first_child);
      $newick .= $child->newick_format;
      $first_child = 0;
    }
    $newick .= ")";
  }
  
  $newick .= sprintf("\"%s\"", $self->name,);
  $newick .= sprintf(":%1.4f", $self->distance_to_parent) if($self->distance_to_parent > 0);

  if(!($self->has_parent)) {
    $newick .= ";";
  }
  return $newick;
}
_add_child_name_to_classificationdescriptionprevnextTop
sub _add_child_name_to_classification {
  my $self = shift;
  my $classification = shift;
  my $full = shift;

  if ($self->get_child_count > 1) {
    throw("Can't classification on a multifurcating tree\n");
  } elsif ($self->get_child_count == 1) {
    my $child = $self->children->[0];
    if ($full) {
      unshift @$classification, $child->name unless ($child->rank eq "subgenus"
                                                     || $child->rank eq "subspecies"
                                                     || $child->rank eq "species");
    } else {
      unless ($child->genbank_hidden_flag || $child->rank eq "subgenus") {
        unshift @$classification, $child->name;
      }
    }
    unless ($child->rank eq 'species') {
      $child->_add_child_name_to_classification($classification, $full);
    }
  }
}
binomialdescriptionprevnextTop
sub binomial {
  my $self = shift;
  if ($self->has_tag('scientific name') && ($self->rank eq 'species' || $self->rank eq 'subspecies')) {
    return $self->get_tagvalue('scientific name');
  } else {
    warning("taxon_id=",$self->node_id," is not a species or subspecies. So binomial is undef\n");
    return undef;
  }
}
classificationdescriptionprevnextTop
sub classification {
  my $self =shift;
  my @args = @_;

  my ($separator, $full);
  if (scalar @args) {
    ($separator, $full) = rearrange([qw(SEPARATOR FULL)], @args);
  }

  $separator = " " unless(defined $separator);
  $full = 0 unless (defined $full);

  $self->{"_separator"} = $separator unless (defined $self->{"_separator"});
  $self->{"_separator_full"} = $separator unless (defined $self->{"_separator_full"});

  $self->{'_classification'} = undef unless ($self->{"_separator"} eq $separator);
  $self->{'_classification_full'} = undef unless ($self->{"_separator_full"} eq $separator);

  return $self->{'_classification_full'} if ($full && defined $self->{'_classification_full'});
  return $self->{'_classification'} if (!$full && defined $self->{'_classification'});

  my $root = $self->root;
  my @classification;
  unless ($root->name eq "root") {
    unshift @classification, $self->name;
  }
  unless ($root->get_child_count == 0) {
    $root->_add_child_name_to_classification(\@classification, $full);
  }
  if ($self->rank eq 'species' || $self->rank eq 'subspecies') {
    my ($genus, $species, $subspecies) = split(" ", $self->binomial);
    unshift @classification, $species;
    unshift @classification, $subspecies if (defined $subspecies);
  }


  if ($full) {
    $self->{'_classification_full'} = join($separator,@classification);
    $self->{"_separator_full"} = $separator;
    return $self->{'_classification_full'};
  } else {
    $self->{'_classification'} = join($separator,@classification);
    $self->{"_separator"} = $separator;
    return $self->{'_classification'};
  }
}
common_namedescriptionprevnextTop
sub common_name {
  my $self = shift;
  if ($self->has_tag('genbank common name') && $self->rank eq 'species') {
    return $self->get_tagvalue('genbank common name');
  } else {
    return undef;
  }
}
copydescriptionprevnextTop
sub copy {
  my $self = shift;
  
  my $mycopy = $self->SUPER::copy;
  bless $mycopy, "Bio::EnsEMBL::Compara::NCBITaxon";
  
  $mycopy->ncbi_taxid($self->ncbi_taxid);
  $mycopy->rank($self->rank);
  $mycopy->genbank_hidden_flag($self->genbank_hidden_flag);

  return $mycopy;
}
dbIDdescriptionprevnextTop
sub dbID {
  my $self = shift;
  my $value = shift;
  $self->node_id($value) if($value); 
  return $self->node_id;
}
ensembl_aliasdescriptionprevnextTop
sub ensembl_alias {
  my $self = shift;
  if ($self->has_tag('ensembl alias name')) {
    return $self->get_tagvalue('ensembl alias name');
  } else {
    warning("taxon_id=",$self->node_id," is not a species or subspecies. So ensembl_alias is undef\n");
    return undef;
  }
}
ensembl_alias_namedescriptionprevnextTop
sub ensembl_alias_name {
  my $self = shift;

  #Not checking for rank as we do above, because we do not get dog since the
#rank for dog is subspecies (ensembl-51).
if ($self->has_tag('ensembl alias name')) { return $self->get_tagvalue('ensembl alias name'); } else { return undef; }
}
genbank_hidden_flagdescriptionprevnextTop
sub genbank_hidden_flag {
  my $self = shift;
  $self->{'_genbank_hidden_flag'} = shift if(@_);
  return $self->{'_genbank_hidden_flag'};
}
genusdescriptionprevnextTop
sub genus {
  my $self = shift;

  unless (defined $self->{'_genus'}) {
    my ($genus, $species, $subspecies) = split(" ", $self->binomial);
    $self->{'_species'} = $species;
    $self->{'_genus'} = $genus;
    $self->{'_subspecies'} = $subspecies;
  }

  return $self->{'_genus'};
}
get_short_namedescriptionprevnextTop
sub get_short_name {
  my $self = shift;
  return $self->short_name;
}
ncbi_taxiddescriptionprevnextTop
sub ncbi_taxid {
  my $self = shift;
  my $value = shift;
  $self->node_id($value) if($value); 
  return $self->node_id;
}
print_nodedescriptionprevnextTop
sub print_node {
  my $self  = shift;
  printf("(%s", $self->node_id);
  printf(" %s", $self->rank) if($self->rank);
  print(")");
  printf("%s", $self->name) if($self->name);
  print("\n");
}

1;
}
rankdescriptionprevnextTop
sub rank {
  my $self = shift;
  $self->{'_rank'} = shift if(@_);
  return $self->{'_rank'};
}
short_namedescriptionprevnextTop
sub short_name {
  my $self = shift;
  my $name = $self->name;
  $name =~  s/(\S)\S+\s(\S{3})\S+/$1$2/;
  $name =~ s/\ //g;
  return $name;
}
speciesdescriptionprevnextTop
sub species {
  my $self = shift;

  unless (defined $self->{'_species'}) {
    my ($genus, $species, $subspecies) = split(" ", $self->binomial);
    $self->{'_species'} = $species;
    $self->{'_genus'} = $genus;
    $self->{'_subspecies'} = $subspecies;
  }

  return $self->{'_species'};
}
subspeciesdescriptionprevnextTop
sub subspecies {
  my $self = shift;

  unless (defined $self->{'_species'}) {
    my ($genus, $species, $subspecies) = split(" ", $self->binomial);
    $self->{'_species'} = $species;
    $self->{'_genus'} = $genus;
    $self->{'_subspecies'} = $subspecies;
  }

  return $self->{'_species'};
}
taxon_iddescriptionprevnextTop
sub taxon_id {
  my $self = shift;
  my $value = shift;
  $self->node_id($value) if($value); 
  return $self->node_id;
}
General documentation
CONTACTTop
  Contact Jessica Severin on implemetation/design detail: jessica@ebi.ac.uk
Contact Ewan Birney on EnsEMBL in general: birney@sanger.ac.uk
APPENDIXTop
The rest of the documentation details each of the object methods. Internal methods are usually preceded with a _