NAME

Bio::Phylo::Matrices::Matrix - Character state matrix

SYNOPSIS

use Bio::Phylo::Factory;
my $fac = Bio::Phylo::Factory->new;

# instantiate taxa object
my $taxa = $fac->create_taxa;
for ( 'Homo sapiens', 'Pan paniscus', 'Pan troglodytes' ) {
    $taxa->insert( $fac->create_taxon( '-name' => $_ ) );
}

# instantiate matrix object, 'standard' data type. All categorical
# data types follow semantics like this, though with different
# symbols in lookup table and matrix
my $standard_matrix = $fac->create_matrix(
    '-type'   => 'STANDARD',
    '-taxa'   => $taxa,
    '-lookup' => { 
        '-' => [],
        '0' => [ '0' ],
        '1' => [ '1' ],
        '?' => [ '0', '1' ],
    },
    '-labels' => [ 'Opposable big toes', 'Opposable thumbs', 'Not a pygmy' ],
    '-matrix' => [
        [ 'Homo sapiens'    => '0', '1', '1' ],
        [ 'Pan paniscus'    => '1', '1', '0' ],
        [ 'Pan troglodytes' => '1', '1', '1' ],
    ],
);

# note: complicated constructor for mixed data!
my $mixed_matrix = Bio::Phylo::Matrices::Matrix->new( 
   
   # if you want to create 'mixed', value for '-type' is array ref...
   '-type' =>  [ 
   
       # ...with first field 'mixed'...                
       'mixed',
       
       # ...second field is an array ref...
       [
           
           # ...with _ordered_ key/value pairs...
           'dna'      => 10, # value is length of type range
           'standard' => 10, # value is length of type range
           
           # ... or, more complicated, value is a hash ref...
           'rna'      => {
               '-length' => 10, # value is length of type range
               
               # ...value for '-args' is an array ref with args 
               # as can be passed to 'unmixed' datatype constructors,
               # for example, here we modify the lookup table for
               # rna to allow both 'U' (default) and 'T'
               '-args'   => [
                   '-lookup' => {
                       'A' => [ 'A'                     ],
                       'C' => [ 'C'                     ],
                       'G' => [ 'G'                     ],
                       'U' => [ 'U'                     ],
                       'T' => [ 'T'                     ],
                       'M' => [ 'A', 'C'                ],
                       'R' => [ 'A', 'G'                ],
                       'S' => [ 'C', 'G'                ],
                       'W' => [ 'A', 'U', 'T'           ],
                       'Y' => [ 'C', 'U', 'T'           ],
                       'K' => [ 'G', 'U', 'T'           ],
                       'V' => [ 'A', 'C', 'G'           ],
                       'H' => [ 'A', 'C', 'U', 'T'      ],
                       'D' => [ 'A', 'G', 'U', 'T'      ],
                       'B' => [ 'C', 'G', 'U', 'T'      ],
                       'X' => [ 'G', 'A', 'U', 'T', 'C' ],
                       'N' => [ 'G', 'A', 'U', 'T', 'C' ],
                   },
               ],
           },
       ],
   ],
);

# prints 'mixed(Dna:1-10, Standard:11-20, Rna:21-30)'
print $mixed_matrix->get_type;

DESCRIPTION

This module defines a container object that holds Bio::Phylo::Matrices::Datum objects. The matrix object inherits from Bio::Phylo::Listable, so the methods defined there apply here.

METHODS

CONSTRUCTOR

new()

Matrix constructor.

Type    : Constructor
Title   : new
Usage   : my $matrix = Bio::Phylo::Matrices::Matrix->new;
Function: Instantiates a Bio::Phylo::Matrices::Matrix
          object.
Returns : A Bio::Phylo::Matrices::Matrix object.
Args    : -type   => optional, but if used must be FIRST argument, 
                     defines datatype, one of dna|rna|protein|
                     continuous|standard|restriction|[ mixed => [] ]

          -taxa   => optional, link to taxa object
          -lookup => character state lookup hash ref
          -labels => array ref of character labels
          -matrix => two-dimensional array, first element of every
                     row is label, subsequent are characters
new_from_bioperl()

Matrix constructor from Bio::Align::AlignI argument.

Type    : Constructor
Title   : new_from_bioperl
Usage   : my $matrix = 
          Bio::Phylo::Matrices::Matrix->new_from_bioperl(
              $aln           
          );
Function: Instantiates a 
          Bio::Phylo::Matrices::Matrix object.
Returns : A Bio::Phylo::Matrices::Matrix object.
Args    : An alignment that implements Bio::Align::AlignI

MUTATORS

set_special_symbols

Sets three special symbols in one call

Type    : Mutator
Title   : set_special_symbols
Usage   : $matrix->set_special_symbols( 
		       -missing   => '?', 
		       -gap       => '-', 
		       -matchchar => '.' 
		   );
Function: Assigns state labels.
Returns : $self
Args    : Three args (with distinct $x, $y and $z):
 		       -missing   => $x, 
		       -gap       => $y, 
		       -matchchar => $z
Notes   : This method is here to ensure
          you don't accidentally use the
          same symbol for missing AND gap
set_statelabels()

Sets argument state labels.

Type    : Mutator
Title   : set_statelabels
Usage   : $matrix->set_statelabels( [ [ 'state1', 'state2' ] ] );
Function: Assigns state labels.
Returns : $self
Args    : ARRAY, or nothing (to reset);
          The array is two-dimensional, 
          the first index is to indicate
          the column the labels apply to,
          the second dimension the states
          (sorted numerically or alphabetically,
          depending on what's appropriate)
set_charlabels()

Sets argument character labels.

Type    : Mutator
Title   : set_charlabels
Usage   : $matrix->set_charlabels( [ 'char1', 'char2', 'char3' ] );
Function: Assigns character labels.
Returns : $self
Args    : ARRAY, or nothing (to reset);
set_gapmode()

Defines matrix gapmode.

Type    : Mutator
Title   : set_gapmode
Usage   : $matrix->set_gapmode( 1 );
Function: Defines matrix gapmode ( false = missing, true = fifth state )
Returns : $self
Args    : boolean
set_matchchar()

Assigns match symbol.

Type    : Mutator
Title   : set_matchchar
Usage   : $matrix->set_matchchar( $match );
Function: Assigns match symbol (default is '.').
Returns : $self
Args    : ARRAY
set_polymorphism()

Defines matrix 'polymorphism' interpretation.

Type    : Mutator
Title   : set_polymorphism
Usage   : $matrix->set_polymorphism( 1 );
Function: Defines matrix 'polymorphism' interpretation
          ( false = uncertainty, true = polymorphism )
Returns : $self
Args    : boolean
set_raw()

Set contents using two-dimensional array argument.

Type    : Mutator
Title   : set_raw
Usage   : $matrix->set_raw( [ [ 'taxon1' => 'acgt' ], [ 'taxon2' => 'acgt' ] ] );
Function: Syntax sugar to define $matrix data contents.
Returns : $self
Args    : A two-dimensional array; first dimension contains matrix rows,
          second dimension contains taxon name / character string pair.
set_respectcase()

Defines matrix case sensitivity interpretation.

Type    : Mutator
Title   : set_respectcase
Usage   : $matrix->set_respectcase( 1 );
Function: Defines matrix case sensitivity interpretation
          ( false = disregarded, true = "respectcase" )
Returns : $self
Args    : boolean

ACCESSORS

get_special_symbols()

Retrieves hash ref for missing, gap and matchchar symbols

Type    : Accessor
Title   : get_special_symbols
Usage   : my %syms = %{ $matrix->get_special_symbols };
Function: Retrieves special symbols
Returns : HASH ref, e.g. { -missing => '?', -gap => '-', -matchchar => '.' }
Args    : None.
get_statelabels()

Retrieves state labels.

Type    : Accessor
Title   : get_statelabels
Usage   : my @statelabels = @{ $matrix->get_statelabels };
Function: Retrieves state labels.
Returns : ARRAY
Args    : None.
get_charlabels()

Retrieves character labels.

Type    : Accessor
Title   : get_charlabels
Usage   : my @charlabels = @{ $matrix->get_charlabels };
Function: Retrieves character labels.
Returns : ARRAY
Args    : None.
get_gapmode()

Returns matrix gapmode.

Type    : Accessor
Title   : get_gapmode
Usage   : do_something() if $matrix->get_gapmode;
Function: Returns matrix gapmode ( false = missing, true = fifth state )
Returns : boolean
Args    : none
get_matchchar()

Returns matrix match character.

Type    : Accessor
Title   : get_matchchar
Usage   : my $char = $matrix->get_matchchar;
Function: Returns matrix match character (default is '.')
Returns : SCALAR
Args    : none
get_nchar()

Calculates number of characters.

Type    : Accessor
Title   : get_nchar
Usage   : my $nchar = $matrix->get_nchar;
Function: Calculates number of characters (columns) in matrix (if the matrix
          is non-rectangular, returns the length of the longest row).
Returns : INT
Args    : none
get_ntax()

Calculates number of taxa (rows) in matrix.

Type    : Accessor
Title   : get_ntax
Usage   : my $ntax = $matrix->get_ntax;
Function: Calculates number of taxa (rows) in matrix
Returns : INT
Args    : none
get_polymorphism()

Returns matrix 'polymorphism' interpretation.

Type    : Accessor
Title   : get_polymorphism
Usage   : do_something() if $matrix->get_polymorphism;
Function: Returns matrix 'polymorphism' interpretation
          ( false = uncertainty, true = polymorphism )
Returns : boolean
Args    : none
get_raw()

Retrieves a 'raw' (two-dimensional array) representation of the matrix's contents.

Type    : Accessor
Title   : get_raw
Usage   : my $rawmatrix = $matrix->get_raw;
Function: Retrieves a 'raw' (two-dimensional array) representation
          of the matrix's contents.
Returns : A two-dimensional array; first dimension contains matrix rows,
          second dimension contains taxon name and characters.
Args    : NONE
get_respectcase()

Returns matrix case sensitivity interpretation.

Type    : Accessor
Title   : get_respectcase
Usage   : do_something() if $matrix->get_respectcase;
Function: Returns matrix case sensitivity interpretation
          ( false = disregarded, true = "respectcase" )
Returns : boolean
Args    : none

METHODS

bootstrap()

Creates bootstrapped clone.

Type    : Utility method
Title   : bootstrap
Usage   : my $bootstrap = $object->bootstrap;
Function: Creates bootstrapped clone.
Returns : A bootstrapped clone of the invocant.
Args    : NONE
Comments: The bootstrapping algorithm uses perl's random number
          generator to create a new series of indices (without
          replacement) of the same length as the original matrix.
          These indices are first sorted, then applied to the 
          cloned sequences. Annotations (if present) stay connected
          to the resampled cells.
clone()

Clones invocant.

Type    : Utility method
Title   : clone
Usage   : my $clone = $object->clone;
Function: Creates a copy of the invocant object.
Returns : A copy of the invocant.
Args    : NONE
to_xml()

Serializes matrix to nexml format.

Type    : Format convertor
Title   : to_xml
Usage   : my $data_block = $matrix->to_xml;
Function: Converts matrix object into a nexml element structure.
Returns : Nexml block (SCALAR).
Args    : Optional:
		   -compact => 1 (for compact representation of matrix)
to_nexus()

Serializes matrix to nexus format.

Type    : Format convertor
Title   : to_nexus
Usage   : my $data_block = $matrix->to_nexus;
Function: Converts matrix object into a nexus data block.
Returns : Nexus data block (SCALAR).
Args    : The following options are available:

           # if set, writes TITLE & LINK tokens
           '-links' => 1
           
           # if set, writes block as a "data" block (deprecated, but used by mrbayes),
           # otherwise writes "characters" block (default)
           -data_block => 1
           
           # if set, writes "RESPECTCASE" token
           -respectcase => 1
           
           # if set, writes "GAPMODE=(NEWSTATE or MISSING)" token
           -gapmode => 1
           
           # if set, writes "MSTAXA=(POLYMORPH or UNCERTAIN)" token
           -polymorphism => 1
           
           # if set, writes character labels
           -charlabels => 1
           
           # if set, writes state labels
           -statelabels => 1
           
           # if set, writes mesquite-style charstatelabels
           -charstatelabels => 1
           
           # by default, names for sequences are derived from $datum->get_name, if 
           # 'internal' is specified, uses $datum->get_internal_name, if 'taxon'
           # uses $datum->get_taxon->get_name, if 'taxon_internal' uses 
           # $datum->get_taxon->get_internal_name, if $key, uses $datum->get_generic($key)
           -seqnames => one of (internal|taxon|taxon_internal|$key)
insert()

Insert argument in invocant.

Type    : Listable method
Title   : insert
Usage   : $matrix->insert($datum);
Function: Inserts $datum in $matrix.
Returns : Modified object
Args    : A datum object
Comments: This method re-implements the method by the same
          name in Bio::Phylo::Listable
validate()

Validates the object's contents.

Type    : Method
Title   : validate
Usage   : $obj->validate
Function: Validates the object's contents
Returns : True or throws Bio::Phylo::Util::Exceptions::InvalidData
Args    : None
Comments: This method implements the interface method by the same
          name in Bio::Phylo::Matrices::TypeSafeData
compress_lookup()

Removes unused states from lookup table

Type    : Method
Title   : validate
Usage   : $obj->compress_lookup
Function: Removes unused states from lookup table
Returns : $self
Args    : None
check_taxa()

Validates taxa associations.

Type    : Method
Title   : check_taxa
Usage   : $obj->check_taxa
Function: Validates relation between matrix and taxa block 
Returns : Modified object
Args    : None
Comments: This method implements the interface method by the same
          name in Bio::Phylo::Taxa::TaxaLinker
make_taxa()

Creates a taxa block from the objects contents if none exists yet.

Type    : Method
Title   : make_taxa
Usage   : my $taxa = $obj->make_taxa
Function: Creates a taxa block from the objects contents if none exists yet.
Returns : $taxa
Args    : NONE

INHERITED METHODS

Bio::Phylo::Matrices::Matrix inherits from one or more superclasses. This means that objects of class Bio::Phylo::Matrices::Matrix also "do" the methods from the superclasses in addition to the ones implemented in this class. Below is the documentation for those additional methods, organized by superclass.

SUPERCLASS Bio::Phylo::Matrices::TypeSafeData

Bio::Phylo::Matrices::Matrix inherits from superclass Bio::Phylo::Matrices::TypeSafeData. Below are the public methods (if any) from this superclass.

clone()

Clones invocant.

Type    : Utility method
Title   : clone
Usage   : my $clone = $object->clone;
Function: Creates a copy of the invocant object.
Returns : A copy of the invocant.
Args    : NONE
get_gap()

Get gap symbol.

Type    : Accessor
Title   : get_gap
Usage   : my $gap = $obj->get_gap;
Function: Returns the object's gap symbol
Returns : A string
Args    : None
get_lookup()

Get ambiguity lookup table.

Type    : Accessor
Title   : get_lookup
Usage   : my $lookup = $obj->get_lookup;
Function: Returns the object's lookup hash
Returns : A hash reference
Args    : None
get_missing()

Get missing data symbol.

Type    : Accessor
Title   : get_missing
Usage   : my $missing = $obj->get_missing;
Function: Returns the object's missing data symbol
Returns : A string
Args    : None
get_type()

Get data type.

Type    : Accessor
Title   : get_type
Usage   : my $type = $obj->get_type;
Function: Returns the object's datatype
Returns : A string
Args    : None
get_type_object()

Get data type object.

Type    : Accessor
Title   : get_type_object
Usage   : my $obj = $obj->get_type_object;
Function: Returns the object's linked datatype object
Returns : A subclass of Bio::Phylo::Matrices::Datatype
Args    : None
new()

TypeSafeData constructor.

Type    : Constructor
Title   : new
Usage   : No direct usage, is called by child class;
Function: Instantiates a Bio::Phylo::Matrices::TypeSafeData
Returns : a Bio::Phylo::Matrices::TypeSafeData child class
Args    : -type        => (data type - required)
          Optional:
          -missing     => (the symbol for missing data)
          -gap         => (the symbol for gaps)
          -lookup      => (a character state lookup hash)
          -type_object => (a datatype object)
set_gap()

Set gap data symbol.

Type    : Mutator
Title   : set_gap
Usage   : $obj->set_gap('-');
Function: Sets the symbol for gaps
Returns : Modified object.
Args    : Argument must be a single
          character, default is '-'
set_lookup()

Set ambiguity lookup table.

Type    : Mutator
Title   : set_lookup
Usage   : $obj->set_gap($hashref);
Function: Sets the symbol for gaps
Returns : Modified object.
Args    : Argument must be a hash
          reference that maps allowed
          single character symbols
          (including ambiguity symbols)
          onto the equivalent set of
          non-ambiguous symbols
set_missing()

Set missing data symbol.

Type    : Mutator
Title   : set_missing
Usage   : $obj->set_missing('?');
Function: Sets the symbol for missing data
Returns : Modified object.
Args    : Argument must be a single
          character, default is '?'
set_type()

Set data type.

Type    : Mutator
Title   : set_type
Usage   : $obj->set_type($type);
Function: Sets the object's datatype.
Returns : Modified object.
Args    : Argument must be a string, one of
          continuous, custom, dna, mixed,
          protein, restriction, rna, standard
set_type_object()

Set data type object.

Type    : Mutator
Title   : set_type_object
Usage   : $obj->set_gap($obj);
Function: Sets the datatype object
Returns : Modified object.
Args    : Argument must be a subclass
          of Bio::Phylo::Matrices::Datatype
validate()

Validates the object's contents

Type    : Interface method
Title   : validate
Usage   : $obj->validate
Function: Validates the object's contents
Returns : True or throws Bio::Phylo::Util::Exceptions::InvalidData
Args    : None
Comments: This is an interface method, i.e. this class doesn't
          implement the method, child classes have to

SUPERCLASS Bio::Phylo::Listable

Bio::Phylo::Matrices::Matrix inherits from superclass Bio::Phylo::Listable. Below are the public methods (if any) from this superclass.

add_set()
Type    : Mutator
Title   : add_set
Usage   : $obj->add_set($set)
Function: Associates a Bio::Phylo::Set object with the invocant
Returns : Invocant
Args    : A Bio::Phylo::Set object
add_to_set()
Type    : Mutator
Title   : add_to_set
Usage   : $listable->add_to_set($obj,$set);
Function: Adds first argument to the second argument
Returns : Invocant
Args    : $obj - an object to add to $set
          $set - the Bio::Phylo::Set object to add to
Notes   : this method assumes that $obj is already 
          part of the invocant. If that assumption is
          violated a warning message is printed.
can_contain()

Tests if argument can be inserted in invocant.

Type    : Test
Title   : can_contain
Usage   : &do_something if $listable->can_contain( $obj );
Function: Tests if $obj can be inserted in $listable
Returns : BOOL
Args    : An $obj to test
clear()

Empties container object.

Type    : Object method
Title   : clear
Usage   : $obj->clear();
Function: Clears the container.
Returns : A Bio::Phylo::Listable object.
Args    : Note.
Note    : 
clone()

Clones invocant.

Type    : Utility method
Title   : clone
Usage   : my $clone = $object->clone;
Function: Creates a copy of the invocant object.
Returns : A copy of the invocant.
Args    : None.
Comments: Cloning is currently experimental, use with caution.
contains()

Tests whether the invocant object contains the argument object.

Type    : Test
Title   : contains
Usage   : if ( $obj->contains( $other_obj ) ) {
              # do something
          }
Function: Tests whether the invocant object 
          contains the argument object
Returns : BOOLEAN
Args    : A Bio::Phylo::* object
cross_reference()

The cross_reference method links node and datum objects to the taxa they apply to. After crossreferencing a matrix with a taxa object, every datum object has a reference to a taxon object stored in its $datum->get_taxon field, and every taxon object has a list of references to datum objects stored in its $taxon->get_data field.

Type    : Generic method
Title   : cross_reference
Usage   : $obj->cross_reference($taxa);
Function: Crossreferences the entities 
          in the invocant with names 
          in $taxa
Returns : string
Args    : A Bio::Phylo::Taxa object
Comments:
current()

Returns the current focal element of the listable object.

Type    : Iterator
Title   : current
Usage   : my $current_obj = $obj->current;
Function: Retrieves the current focal 
          entity in the invocant.
Returns : A Bio::Phylo::* object
Args    : none.
current_index()

Returns the current internal index of the invocant.

Type    : Generic query
Title   : current_index
Usage   : my $last_index = $obj->current_index;
Function: Returns the current internal 
          index of the invocant.
Returns : An integer
Args    : none.
delete()

Deletes argument from invocant object.

Type    : Object method
Title   : delete
Usage   : $obj->delete($other_obj);
Function: Deletes an object from its container.
Returns : A Bio::Phylo::Listable object.
Args    : A Bio::Phylo::* object.
Note    : Be careful with this method: deleting 
          a node from a tree like this will 
          result in undefined references in its 
          neighbouring nodes. Its children will 
          have their parent reference become 
          undef (instead of pointing to their 
          grandparent, as collapsing a node would 
          do). The same is true for taxon objects 
          that reference datum objects: if the 
          datum object is deleted from a matrix 
          (say), the taxon will now hold undefined 
          references.
first()

Jumps to the first element contained by the listable object.

Type    : Iterator
Title   : first
Usage   : my $first_obj = $obj->first;
Function: Retrieves the first 
          entity in the invocant.
Returns : A Bio::Phylo::* object
Args    : none.
get_by_index()

Gets element defined by argument index from invocant container.

Type    : Query
Title   : get_by_index
Usage   : my $contained_obj = $obj->get_by_index($i);
Function: Retrieves the i'th entity 
          from a listable object.
Returns : An entity stored by a listable 
          object (or array ref for slices).
Args    : An index or range. This works 
          the way you dereference any perl
          array including through slices, 
          i.e. $obj->get_by_index(0 .. 10)>
          $obj->get_by_index(0, -1) 
          and so on.
Comments: Throws if out-of-bounds
get_by_name()

Gets first element that has argument name

Type    : Visitor predicate
Title   : get_by_name
Usage   : my $found = $obj->get_by_name('foo');
Function: Retrieves the first contained object
          in the current Bio::Phylo::Listable 
          object whose name is 'foo'
Returns : A Bio::Phylo::* object.
Args    : A name (string)
get_by_regular_expression()

Gets elements that match regular expression from invocant container.

Type    : Visitor predicate
Title   : get_by_regular_expression
Usage   : my @objects = @{ 
              $obj->get_by_regular_expression(
                   -value => $method,
                   -match => $re
           ) };
Function: Retrieves the data in the 
          current Bio::Phylo::Listable 
          object whose $method output 
          matches $re
Returns : A list of Bio::Phylo::* objects.
Args    : -value => any of the string 
                    datum props (e.g. 'get_type')
          -match => a compiled regular 
                    expression (e.g. qr/^[D|R]NA$/)
get_by_value()

Gets elements that meet numerical rule from invocant container.

Type    : Visitor predicate
Title   : get_by_value
Usage   : my @objects = @{ $obj->get_by_value(
             -value => $method,
             -ge    => $number
          ) };
Function: Iterates through all objects 
          contained by $obj and returns 
          those for which the output of 
          $method (e.g. get_tree_length) 
          is less than (-lt), less than 
          or equal to (-le), equal to 
          (-eq), greater than or equal to 
          (-ge), or greater than (-gt) $number.
Returns : A reference to an array of objects
Args    : -value => any of the numerical 
                    obj data (e.g. tree length)
          -lt    => less than
          -le    => less than or equals
          -eq    => equals
          -ge    => greater than or equals
          -gt    => greater than
get_entities()

Returns a reference to an array of objects contained by the listable object.

Type    : Generic query
Title   : get_entities
Usage   : my @entities = @{ $obj->get_entities };
Function: Retrieves all entities in the invocant.
Returns : A reference to a list of Bio::Phylo::* 
          objects.
Args    : none.
get_index_of()

Returns the index of the argument in the list, or undef if the list doesn't contain the argument

Type    : Generic query
Title   : get_index_of
Usage   : my $i = $listable->get_index_of($obj)
Function: Returns the index of the argument in the list,
          or undef if the list doesn't contain the argument
Returns : An index or undef
Args    : A contained object
get_logger()

Gets a logger object.

Type    : Accessor
Title   : get_logger
Usage   : my $logger = $obj->get_logger;
Function: Returns a Bio::Phylo::Util::Logger object
Returns : Bio::Phylo::Util::Logger
Args    : None
get_sets()
Type    : Accessor
Title   : get_sets
Usage   : my @sets = @{ $obj->get_sets() };
Function: Retrieves all associated Bio::Phylo::Set objects
Returns : Invocant
Args    : None
insert()

Pushes an object into its container.

Type    : Object method
Title   : insert
Usage   : $obj->insert($other_obj);
Function: Pushes an object into its container.
Returns : A Bio::Phylo::Listable object.
Args    : A Bio::Phylo::* object.
insert_at_index()

Inserts argument object in invocant container at argument index.

Type    : Object method
Title   : insert_at_index
Usage   : $obj->insert_at_index($other_obj, $i);
Function: Inserts $other_obj at index $i in container $obj
Returns : A Bio::Phylo::Listable object.
Args    : A Bio::Phylo::* object.
is_in_set()
Type    : Test
Title   : is_in_set
Usage   : @do_something if $listable->is_in_set($obj,$set);
Function: Returns whether or not the first argument is listed in the second argument
Returns : Boolean
Args    : $obj - an object that may, or may not be in $set
          $set - the Bio::Phylo::Set object to query
Notes   : This method makes two assumptions:
          i) the $set object is associated with the invocant,
             i.e. add_set($set) has been called previously
          ii) the $obj object is part of the invocant
          If either assumption is violated a warning message
          is printed.
last()

Jumps to the last element contained by the listable object.

Type    : Iterator
Title   : last
Usage   : my $last_obj = $obj->last;
Function: Retrieves the last 
          entity in the invocant.
Returns : A Bio::Phylo::* object
Args    : none.
last_index()

Returns the highest valid index of the invocant.

Type    : Generic query
Title   : last_index
Usage   : my $last_index = $obj->last_index;
Function: Returns the highest valid 
          index of the invocant.
Returns : An integer
Args    : none.
next()

Returns the next focal element of the listable object.

Type    : Iterator
Title   : next
Usage   : my $next_obj = $obj->next;
Function: Retrieves the next focal 
          entity in the invocant.
Returns : A Bio::Phylo::* object
Args    : none.
notify_listeners()

Notifies listeners of changed contents.

Type    : Utility method
Title   : notify_listeners
Usage   : $object->notify_listeners;
Function: Notifies listeners of changed contents.
Returns : Invocant.
Args    : NONE.
Comments:
previous()

Returns the previous element of the listable object.

Type    : Iterator
Title   : previous
Usage   : my $previous_obj = $obj->previous;
Function: Retrieves the previous 
          focal entity in the invocant.
Returns : A Bio::Phylo::* object
Args    : none.
remove_from_set()
Type    : Mutator
Title   : remove_from_set
Usage   : $listable->remove_from_set($obj,$set);
Function: Removes first argument from the second argument
Returns : Invocant
Args    : $obj - an object to remove from $set
          $set - the Bio::Phylo::Set object to remove from
Notes   : this method assumes that $obj is already 
          part of the invocant. If that assumption is
          violated a warning message is printed.
remove_set()
Type    : Mutator
Title   : remove_set
Usage   : $obj->remove_set($set)
Function: Removes association between a Bio::Phylo::Set object and the invocant
Returns : Invocant
Args    : A Bio::Phylo::Set object
set_listener()

Attaches a listener (code ref) which is executed when contents change.

Type    : Utility method
Title   : set_listener
Usage   : $object->set_listener( sub { my $object = shift; } );
Function: Attaches a listener (code ref) which is executed when contents change.
Returns : Invocant.
Args    : A code reference.
Comments: When executed, the code reference will receive $object
          (the invocant) as its first argument.
visit()

Iterates over objects contained by invocant, executes argument code reference on each.

Type    : Visitor predicate
Title   : visit
Usage   : $obj->visit( 
              sub{ print $_[0]->get_name, "\n" } 
          );
Function: Implements visitor pattern 
          using code reference.
Returns : The invocant, possibly modified.
Args    : a CODE reference.

SUPERCLASS Bio::Phylo::Util::XMLWritable

Bio::Phylo::Matrices::Matrix inherits from superclass Bio::Phylo::Util::XMLWritable. Below are the public methods (if any) from this superclass.

add_dictionary()
Type    : Mutator
Title   : add_dictionary
Usage   : $obj->add_dictionary($dict);
Function: Adds a dictionary attachment to the object
Returns : $self
Args    : Bio::Phylo::Dictionary
get_attributes()

Retrieves attributes for the element.

Type    : Accessor
Title   : get_attributes
Usage   : my %attrs = %{ $obj->get_attributes };
Function: Gets the xml attributes for the object;
Returns : A hash reference
Args    : None.
Comments: throws ObjectMismatch if no linked taxa object 
          can be found
get_dictionaries()

Retrieves the dictionaries for the element.

Type    : Accessor
Title   : get_dictionaries
Usage   : my @dicts = @{ $obj->get_dictionaries };
Function: Retrieves the dictionaries for the element.
Returns : An array ref of Bio::Phylo::Dictionary objects
Args    : None.
get_namespaces()
Type    : Accessor
Title   : get_namespaces
Usage   : my %ns = %{ $obj->get_namespaces };
Function: Retrieves the known namespaces
Returns : A hash of prefix/namespace key/value pairs, or
          a single namespace if a single, optional
          prefix was provided as argument
Args    : Optional - a namespace prefix
get_tag()

Retrieves tag name for the element.

Type    : Accessor
Title   : get_tag
Usage   : my $tag = $obj->get_tag;
Function: Gets the xml tag name for the object;
Returns : A tag name
Args    : None.
get_xml_id()

Retrieves xml id for the element.

Type    : Accessor
Title   : get_xml_id
Usage   : my $id = $obj->get_xml_id;
Function: Gets the xml id for the object;
Returns : An xml id
Args    : None.
get_xml_tag()

Retrieves tag string

Type    : Accessor
Title   : get_xml_tag
Usage   : my $str = $obj->get_xml_tag;
Function: Gets the xml tag for the object;
Returns : A tag, i.e. pointy brackets
Args    : Optional: a true value, to close an empty tag
is_identifiable()

By default, all XMLWritable objects are identifiable when serialized, i.e. they have a unique id attribute. However, in some cases a serialized object may not have an id attribute (governed by the nexml schema). This method indicates whether that is the case.

Type    : Test
Title   : is_identifiable
Usage   : if ( $obj->is_identifiable ) { ... }
Function: Indicates whether IDs are generated
Returns : BOOLEAN
Args    : NONE
remove_dictionary()
Type    : Mutator
Title   : remove_dictionary
Usage   : $obj->remove_dictionary($dict);
Function: Removes a dictionary attachment from the object
Returns : $self
Args    : Bio::Phylo::Dictionary
set_attributes()

Assigns attributes for the element.

Type    : Mutator
Title   : set_attributes
Usage   : $obj->set_attributes( 'foo' => 'bar' )
Function: Sets the xml attributes for the object;
Returns : $self
Args    : key/value pairs or a hash ref
set_identifiable()

By default, all XMLWritable objects are identifiable when serialized, i.e. they have a unique id attribute. However, in some cases a serialized object may not have an id attribute (governed by the nexml schema). For such objects, id generation can be explicitly disabled using this method. Typically, this is done internally - you will probably never use this method.

Type    : Mutator
Title   : set_identifiable
Usage   : $obj->set_tag(0);
Function: Enables/disables id generation
Returns : $self
Args    : BOOLEAN
set_namespaces()
Type    : Mutator
Title   : set_namespaces
Usage   : $obj->set_namespaces( 'dwc' => 'http://www.namespaceTBD.org/darwin2' );
Function: Adds one or more prefix/namespace pairs
Returns : $self
Args    : One or more prefix/namespace pairs, as even-sized list, 
          or as a hash reference, i.e.:
          $obj->set_namespaces( 'dwc' => 'http://www.namespaceTBD.org/darwin2' );
          or
          $obj->set_namespaces( { 'dwc' => 'http://www.namespaceTBD.org/darwin2' } );
Notes   : This is a global for the XMLWritable class, so that in a recursive
		   to_xml call the outermost element contains the namespace definitions.
		   This method can also be called as a static class method, i.e.
		   Bio::Phylo::Util::XMLWritable->set_namespaces(
		   'dwc' => 'http://www.namespaceTBD.org/darwin2');
set_tag()

This method is usually only used internally, to define or alter the name of the tag into which the object is serialized. For example, for a Bio::Phylo::Forest::Node object, this method would be called with the 'node' argument, so that the object is serialized into an xml element structure called <node/>

Type    : Mutator
Title   : set_tag
Usage   : $obj->set_tag('node');
Function: Sets the tag name
Returns : $self
Args    : A tag name (must be a valid xml element name)
set_xml_id()

This method is usually only used internally, to store the xml id of an object as it is parsed out of a nexml file - this is for the purpose of round-tripping nexml info sets.

Type    : Mutator
Title   : set_xml_id
Usage   : $obj->set_xml_id('node345');
Function: Sets the xml id
Returns : $self
Args    : An xml id (must be a valid xml NCName)
to_xml()

Serializes invocant to XML.

Type    : XML serializer
Title   : to_xml
Usage   : my $xml = $obj->to_xml;
Function: Serializes $obj to xml
Returns : An xml string
Args    : None

SUPERCLASS Bio::Phylo

Bio::Phylo::Matrices::Matrix inherits from superclass Bio::Phylo. Below are the public methods (if any) from this superclass.

clone()

Clones invocant.

Type    : Utility method
Title   : clone
Usage   : my $clone = $object->clone;
Function: Creates a copy of the invocant object.
Returns : A copy of the invocant.
Args    : None.
Comments: Cloning is currently experimental, use with caution.
get()

Attempts to execute argument string as method on invocant.

Type    : Accessor
Title   : get
Usage   : my $treename = $tree->get('get_name');
Function: Alternative syntax for safely accessing
          any of the object data; useful for
          interpolating runtime $vars.
Returns : (context dependent)
Args    : a SCALAR variable, e.g. $var = 'get_name';
get_desc()

Gets invocant description.

Type    : Accessor
Title   : get_desc
Usage   : my $desc = $obj->get_desc;
Function: Returns the object's description (if any).
Returns : A string
Args    : None
get_generic()

Gets generic hashref or hash value(s).

Type    : Accessor
Title   : get_generic
Usage   : my $value = $obj->get_generic($key);
          or
          my %hash = %{ $obj->get_generic() };
Function: Returns the object's generic data. If an
          argument is used, it is considered a key
          for which the associated value is returned.
          Without arguments, a reference to the whole
          hash is returned.
Returns : A string or hash reference.
Args    : None
get_id()

Gets invocant's UID.

Type    : Accessor
Title   : get_id
Usage   : my $id = $obj->get_id;
Function: Returns the object's unique ID
Returns : INT
Args    : None
get_internal_name()

Gets invocant's 'fallback' name (possibly autogenerated).

Type    : Accessor
Title   : get_internal_name
Usage   : my $name = $obj->get_internal_name;
Function: Returns the object's name (if none was set, the name
          is a combination of the $obj's class and its UID).
Returns : A string
Args    : None
get_logger()

Gets a logger object.

Type    : Accessor
Title   : get_logger
Usage   : my $logger = $obj->get_logger;
Function: Returns a Bio::Phylo::Util::Logger object
Returns : Bio::Phylo::Util::Logger
Args    : None
get_name()

Gets invocant's name.

Type    : Accessor
Title   : get_name
Usage   : my $name = $obj->get_name;
Function: Returns the object's name.
Returns : A string
Args    : None
get_obj_by_id()

Attempts to fetch an in-memory object by its UID

Type    : Accessor
Title   : get_obj_by_id
Usage   : my $obj = Bio::Phylo->get_obj_by_id($uid);
Function: Fetches an object from the IDPool cache
Returns : A Bio::Phylo object 
Args    : A unique id
get_score()

Gets invocant's score.

Type    : Accessor
Title   : get_score
Usage   : my $score = $obj->get_score;
Function: Returns the object's numerical score (if any).
Returns : A number
Args    : None
new()

The Bio::Phylo root constructor, is rarely used directly. Rather, many other objects in Bio::Phylo internally go up the inheritance tree to this constructor. The arguments shown here can therefore also be passed to any of the child classes' constructors, which will pass them on up the inheritance tree. Generally, constructors in Bio::Phylo subclasses can process as arguments all methods that have set_* in their names. The arguments are named for the methods, but "set_" has been replaced with a dash "-", e.g. the method "set_name" becomes the argument "-name" in the constructor.

Type    : Constructor
Title   : new
Usage   : my $phylo = Bio::Phylo->new;
Function: Instantiates Bio::Phylo object
Returns : a Bio::Phylo object 
Args    : Optional, any number of setters. For example,
		   Bio::Phylo->new( -name => $name )
		   will call set_name( $name ) internally
set_desc()

Sets invocant description.

Type    : Mutator
Title   : set_desc
Usage   : $obj->set_desc($desc);
Function: Assigns an object's description.
Returns : Modified object.
Args    : Argument must be a string.
set_generic()

Sets generic key/value pair(s).

Type    : Mutator
Title   : set_generic
Usage   : $obj->set_generic( %generic );
Function: Assigns generic key/value pairs to the invocant.
Returns : Modified object.
Args    : Valid arguments constitute:

          * key/value pairs, for example:
            $obj->set_generic( '-lnl' => 0.87565 );

          * or a hash ref, for example:
            $obj->set_generic( { '-lnl' => 0.87565 } );

          * or nothing, to reset the stored hash, e.g.
               $obj->set_generic( );
set_name()

Sets invocant name.

Type    : Mutator
Title   : set_name
Usage   : $obj->set_name($name);
Function: Assigns an object's name.
Returns : Modified object.
Args    : Argument must be a string, will be single 
          quoted if it contains [;|,|:\(|\)] 
          or spaces. Preceding and trailing spaces
          will be removed.
set_score()

Sets invocant score.

Type    : Mutator
Title   : set_score
Usage   : $obj->set_score($score);
Function: Assigns an object's numerical score.
Returns : Modified object.
Args    : Argument must be any of
          perl's number formats, or undefined
          to reset score.
to_json()

Serializes object to JSON string

Type    : Serializer
Title   : to_json()
Usage   : print $obj->to_json();
Function: Serializes object to JSON string
Returns : String 
Args    : None
Comments:
to_string()

Serializes object to general purpose string

Type    : Serializer
Title   : to_string()
Usage   : print $obj->to_string();
Function: Serializes object to general purpose string
Returns : String 
Args    : None
Comments: This is YAML

SUPERCLASS Bio::Phylo::Taxa::TaxaLinker

Bio::Phylo::Matrices::Matrix inherits from superclass Bio::Phylo::Taxa::TaxaLinker. Below are the public methods (if any) from this superclass.

check_taxa()

Performs sanity check on taxon relationships.

Type    : Interface method
Title   : check_taxa
Usage   : $obj->check_taxa
Function: Performs sanity check on taxon relationships
Returns : $obj
Args    : NONE
get_taxa()

Retrieves association between invocant and Bio::Phylo::Taxa object.

Type    : Accessor
Title   : get_taxa
Usage   : my $taxa = $obj->get_taxa;
Function: Retrieves the Bio::Phylo::Taxa
          object linked to the invocant.
Returns : Bio::Phylo::Taxa
Args    : NONE
Comments: This method returns the Bio::Phylo::Taxa
          object to which the invocant is linked.
          The returned object can therefore contain
          *more* taxa than are actually in the matrix.
make_taxa()

Creates a taxa block from the objects contents if none exists yet.

Type    : Decorated interface method
Title   : make_taxa
Usage   : my $taxa = $obj->make_taxa
Function: Creates a taxa block from the objects contents if none exists yet.
Returns : $taxa
Args    : NONE
set_taxa()

Associates invocant with Bio::Phylo::Taxa argument.

Type    : Mutator
Title   : set_taxa
Usage   : $obj->set_taxa( $taxa );
Function: Links the invocant object
          to a taxa object.
Returns : Modified $obj
Args    : A Bio::Phylo::Taxa object.
unset_taxa()

Removes association between invocant and Bio::Phylo::Taxa object.

Type    : Mutator
Title   : unset_taxa
Usage   : $obj->unset_taxa();
Function: Removes the link between invocant object and taxa
Returns : Modified $obj
Args    : NONE

SEE ALSO

Bio::Phylo::Taxa::TaxaLinker

This object inherits from Bio::Phylo::Taxa::TaxaLinker, so the methods defined therein are also applicable to Bio::Phylo::Matrices::Matrix objects.

Bio::Phylo::Matrices::TypeSafeData

This object inherits from Bio::Phylo::Matrices::TypeSafeData, so the methods defined therein are also applicable to Bio::Phylo::Matrices::Matrix objects.

Bio::Phylo::Manual

Also see the manual: Bio::Phylo::Manual and http://rutgervos.blogspot.com.

REVISION

$Id: Matrix.pm 844 2009-03-05 00:07:26Z rvos $