Bio::Phylo::Parsers::Table - Parser used by Bio::Phylo::IO, no serviceable parts inside


Bio-Phylo documentation Contained in the Bio-Phylo distribution.

Index


Code Index:

NAME

Top

Bio::Phylo::Parsers::Table - Parser used by Bio::Phylo::IO, no serviceable parts inside

DESCRIPTION

Top

This module is used to import data and taxa from plain text files or strings. The following additional argument must be used in the call to Bio::Phylo::IO:

 -type => (one of [DNA|RNA|STANDARD|PROTEIN|NUCLEOTIDE|CONTINUOUS])

In addition, these arguments may be used to indicate line separators (default is "\n") and field separators (default is "\t"):

 -fieldsep => '\t',
 -linesep  => '\n'

SEE ALSO

Top

Bio::Phylo::IO

The table parser is called by the Bio::Phylo::IO object. Look there to learn how to parse tab- (or otherwise) delimited matrices.

Bio::Phylo::Manual

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

CITATION

Top

If you use Bio::Phylo in published research, please cite it:

Rutger A Vos, Jason Caravas, Klaas Hartmann, Mark A Jensen and Chase Miller, 2011. Bio::Phylo - phyloinformatic analysis using Perl. BMC Bioinformatics 12:63. http://dx.doi.org/10.1186/1471-2105-12-63

REVISION

Top

 $Id: Table.pm 1660 2011-04-02 18:29:40Z rvos $


Bio-Phylo documentation Contained in the Bio-Phylo distribution.
# $Id: Table.pm 1660 2011-04-02 18:29:40Z rvos $
package Bio::Phylo::Parsers::Table;
use strict;
use base 'Bio::Phylo::Parsers::Abstract';

sub _parse {
    my $self = shift;
    my $fh   = $self->_handle;
    my $fac  = $self->_factory;
    my $type = $self->_args->{'-type'};
    local $/ = $self->_args->{'-linesep'} || "\n";
    my $sep    = $self->_args->{'-fieldsep'} || "\t";
    my $regex  = qr/$sep/;
    my $matrix = $fac->create_matrix( '-type' => $type );
    while (<$fh>) {
        chomp;
        my ( $name, @char ) = split $regex, $_;
        $matrix->insert(
            $fac->create_datum(
                '-type' => $type,
                '-name' => $name,
                '-char' => \@char,
            )
        );
    }
    return $matrix;
}

# podinherit_insert_token

1;