File Coverage

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


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