Bio Species
SummaryIncluded librariesPackage variablesSynopsisDescriptionGeneral documentationMethods
Summary
Bio::Species - Generic species object
Package variables
No package variables defined.
Included modules
Bio::Root::Root
Inherit
Bio::Root::Root
Synopsis
    $species = Bio::Species->new(-classification => [@classification]);
                                    # Can also pass classification
                                    # array to new as below

    $species->classification(qw( sapiens Homo Hominidae
                                 Catarrhini Primates Eutheria
                                 Mammalia Vertebrata Chordata
                                 Metazoa Eukaryota ));

    $genus = $species->genus();

    $bi = $species->binomial();     # $bi is now "Homo sapiens"

    # For storing common name
    $species->common_name("human");

    # For storing subspecies
    $species->sub_species("accountant");
Description
Provides a very simple object for storing phylogenetic
information. The classification is stored in an array,
which is a list of nodes in a phylogenetic tree. Access to
getting and setting species and genus is provided, but not
to any of the other node types (eg: "phylum", "class",
"order", "family"). There's plenty of scope for making the
model more sophisticated, if this is ever needed.
A methods are also provided for storing common
names, and subspecies.
Methods
new
No description
Code
classificationDescriptionCode
common_nameDescriptionCode
organelle
No description
Code
speciesDescriptionCode
genusDescriptionCode
sub_speciesDescriptionCode
binomialDescriptionCode
validate_species_name
No description
Code
validate_name
No description
Code
ncbi_taxidDescriptionCode
Methods description
classificationcode    nextTop
 Title   : classification
 Usage   : $self->classification(@class_array);
           @classification = $self->classification();
 Function: Fills or returns the classification list in
           the object.  The array provided must be in
           the order SPECIES, GENUS ---> KINGDOM.
           Checks are made that species is in lower case,
           and all other elements are in title case.
 Example : $obj->classification(qw( sapiens Homo Hominidae
           Catarrhini Primates Eutheria Mammalia Vertebrata
           Chordata Metazoa Eukaryota));
 Returns : Classification array
 Args    : Classification array
common_namecodeprevnextTop
 Title   : common_name
 Usage   : $self->common_name( $common_name );
           $common_name = $self->common_name();
 Function: Get or set the common name of the species
 Example : $self->common_name('human')
 Returns : The common name in a string
 Args    : String, which is the common name
speciescodeprevnextTop
 Title   : species
 Usage   : $self->species( $species );
           $species = $self->species();
 Function: Get or set the scientific species name.  The species
           name must be in lower case.
 Example : $self->species( 'sapiens' );
 Returns : Scientific species name as string
 Args    : Scientific species name as string
genuscodeprevnextTop
 Title   : genus
 Usage   : $self->genus( $genus );
           $genus = $self->genus();
 Function: Get or set the scientific genus name.  The genus
           must be in title case.
 Example : $self->genus( 'Homo' );
 Returns : Scientific genus name as string
 Args    : Scientific genus name as string
sub_speciescodeprevnextTop
 Title   : sub_species
 Usage   : $obj->sub_species($newval)
 Function:
 Returns : value of sub_species
 Args    : newvalue (optional)
binomialcodeprevnextTop
 Title   : binomial
 Usage   : $binomial = $self->binomial();
           $binomial = $self->binomial('FULL');
 Function: Returns a string "Genus species", or "Genus species subspecies",
           the first argument is 'FULL' (and the species has a subspecies).
 Args    : Optionally the string 'FULL' to get the full name including the
           the subspecies.
ncbi_taxidcodeprevnextTop
 Title   : ncbi_taxid
 Usage   : $obj->ncbi_taxid($newval)
 Function:
 Returns : value of ncbi_taxid as string
 Args    : newvalue (optional)
Methods code
newdescriptionprevnextTop
sub new {
  my($class,@args) = @_;

  my $self = $class->SUPER::new(@args);

  $self->{'classification'} = [];
  $self->{'common_name'} = undef;
  my ($classification) = $self->_rearrange([qw(CLASSIFICATION)], @args);
  if( defined $classification &&
      (ref($classification) =~ /array/i) ) {
      $self->classification(@$classification);
  }
  return $self;
}
classificationdescriptionprevnextTop
sub classification {
    my ($self,@args) = @_;

    if (@args) {

        # Check the names supplied in the classification string
{ # Species should be in lower case
my $species = $args[0]; $self->validate_species_name( $species ); # All other names must be in title case
for (my $i = 1; $i < @args; $i++) { $self->validate_name( $args[$i] ); } } # Store classification
$self->{'classification'} = [ @args ]; } return @{$self->{'classification'}};
}
common_namedescriptionprevnextTop
sub common_name {
    my($self, $name) = @_;

    if ($name) {
        $self->{'common_name'} = $name;
    } else {
        return $self->{'common_name'}
    }
}
organelledescriptionprevnextTop
sub organelle {
    my($self, $name) = @_;

    if ($name) {
        $self->{'organelle'} = $name;
    } else {
        return $self->{'organelle'}
    }
}
speciesdescriptionprevnextTop
sub species {
    my($self, $species) = @_;

    if ($species) {
        $self->validate_species_name( $species );
        $self->{'classification'}[0] = $species;
    }
    return $self->{'classification'}[0];
}
genusdescriptionprevnextTop
sub genus {
    my($self, $genus) = @_;

    if ($genus) {
        $self->validate_name( $genus );
        $self->{'classification'}[1] = $genus;
    }
    return $self->{'classification'}[1];
}
sub_speciesdescriptionprevnextTop
sub sub_species {
    my( $self, $sub ) = @_;

    if ($sub) {
        $self->{'_sub_species'} = $sub;
    }
    return $self->{'_sub_species'};
}
binomialdescriptionprevnextTop
sub binomial {
    my( $self, $full ) = @_;

    my( $species, $genus ) = $self->classification();
    unless( defined $species) {
	$species = '';
	$self->warn("classification was not set");
    }
    $genus = ''   unless( defined $genus);
    my $bi = "$genus $species";
    if (defined($full) && ($full eq 'FULL')) {
	my $ssp = $self->sub_species;
        $bi .= " $ssp" if $ssp;
    }
    return $bi;
}
validate_species_namedescriptionprevnextTop
sub validate_species_name {
    my( $self, $string ) = @_;

    $string =~ /^[\S\d\.]+$||""/ or
        $self->throw("Invalid species name '$string'");
}
validate_namedescriptionprevnextTop
sub validate_name {
    my( $self, $string ) = @_;

    return $string =~ /^[A-Z][a-z]+$/ or
        $self->throw("Invalid name '$string' (Wrong case?)");
}
ncbi_taxiddescriptionprevnextTop
sub ncbi_taxid {
    my( $self, $sub ) = @_;

    if ($sub) {
        $self->{'_ncbi_taxid'} = $sub;
    }
    return $self->{'_ncbi_taxid'};
}
General documentation
CONTACTTop
James Gilbert email jgrg@sanger.ac.uk
APPENDIXTop
The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _
Top
 Title   : organelle
 Usage   : $self->organelle( $organelle );
           $organelle = $self->organelle();
 Function: Get or set the organelle name
 Example : $self->organelle('Chloroplast')
 Returns : The organelle name in a string
 Args    : String, which is the organelle name