File Coverage

blib/lib/Bio/Phylo/Parsers/Table.pm
Criterion Covered Total %
statement 19 19 100.0
branch n/a
condition 4 4 100.0
subroutine 3 3 100.0
pod n/a
total 26 26 100.0


line stmt bran cond sub pod time code
1             package Bio::Phylo::Parsers::Table;
2 1     1   65291 use strict;
  1         13  
  1         25  
3 1     1   4 use base 'Bio::Phylo::Parsers::Abstract';
  1         2  
  1         266  
4              
5             =head1 NAME
6              
7             Bio::Phylo::Parsers::Table - Parser used by Bio::Phylo::IO, no serviceable parts inside
8              
9             =head1 DESCRIPTION
10              
11             This module is used to import data and taxa from plain text files or strings.
12             The following additional argument must be used in the call
13             to L<Bio::Phylo::IO|Bio::Phylo::IO>:
14              
15             -type => (one of [DNA|RNA|STANDARD|PROTEIN|NUCLEOTIDE|CONTINUOUS])
16              
17             In addition, these arguments may be used to indicate line separators (default
18             is "\n") and field separators (default is "\t"):
19              
20             -fieldsep => '\t',
21             -linesep => '\n'
22              
23             =cut
24              
25             sub _parse {
26 2     2   4 my $self = shift;
27 2         8 my $fh = $self->_handle;
28 2         9 my $fac = $self->_factory;
29 2         7 my $type = $self->_args->{'-type'};
30 2   100     4 local $/ = $self->_args->{'-linesep'} || "\n";
31 2   100     5 my $sep = $self->_args->{'-fieldsep'} || "\t";
32 2         30 my $regex = qr/$sep/;
33 2         16 my $matrix = $fac->create_matrix( '-type' => $type );
34 2         11 while (<$fh>) {
35 14         24 chomp;
36 14         82 my ( $name, @char ) = split $regex, $_;
37 14         94 $matrix->insert(
38             $fac->create_datum(
39             '-type' => $type,
40             '-name' => $name,
41             '-char' => \@char,
42             )
43             );
44             }
45 2         15 return $matrix;
46             }
47              
48             # podinherit_insert_token
49              
50             =head1 SEE ALSO
51              
52             There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo>
53             for any user or developer questions and discussions.
54              
55             =over
56              
57             =item L<Bio::Phylo::IO>
58              
59             The table parser is called by the L<Bio::Phylo::IO|Bio::Phylo::IO> object.
60             Look there to learn how to parse tab- (or otherwise) delimited matrices.
61              
62             =item L<Bio::Phylo::Manual>
63              
64             Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>
65              
66             =back
67              
68             =head1 CITATION
69              
70             If you use Bio::Phylo in published research, please cite it:
71              
72             B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen>
73             and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl.
74             I<BMC Bioinformatics> B<12>:63.
75             L<http://dx.doi.org/10.1186/1471-2105-12-63>
76              
77             =cut
78              
79             1;