Phylo/Parsers/Table.pm

filter: Statementstmt 100% 23 / 23 Branchbran 100% 2 / 2 Conditioncond 100% 4 / 4 MC/DCmcdc 100% 2 / 2 Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 35 / 35 CC 4 SCAR 10.0
CC
4
Cov
100%
_parse
4.0
BEGIN
1.0
BEGIN
1.0
CRAP 2.7
« Phylo/Taxa/Taxon.pm ↑ Summary Phylo/NeXML/DOM/Document.pm »
1 package Bio::Phylo::Parsers::Table;
2 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use base 'Bio::Phylo::Parsers::Abstract';
Subroutine BEGIN: called CC=1 SCAR=0.0
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 2 ▶sub _parse {
Subroutine _parse: called CC=4 SCAR=13.9
27 2 my $self = shift;
28 2 my $fh = $self->_handle;
29 2 my $fac = $self->_factory;
30 2 my $type = $self->_args->{'-type'};
31 2 ▶ local $/ = $self->_args->{'-linesep'} || "\n";
Condition100%2/2
$self->_args->{'-linesep'} || "\n"
l!l
11
MC/DC100%1/1
$self->_args->{'-linesep'} || "\n"
$self->_args->{'-linesep'}
Truth table100%2/2
A
A= $self->_args->{'-linesep'}
Aresult
11
00
32 2 ▶ my $sep = $self->_args->{'-fieldsep'} || "\t";
Condition100%2/2
$self->_args->{'-fieldsep'} || "\t"
l!l
11
MC/DC100%1/1
$self->_args->{'-fieldsep'} || "\t"
$self->_args->{'-fieldsep'}
Truth table100%2/2
A
A= $self->_args->{'-fieldsep'}
Aresult
11
00
33 2 my $regex = qr/$sep/;
34 2 my $matrix = $fac->create_matrix( '-type' => $type );
35 2 ▶ while (<$fh>) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($_ = readline $fh)) 14 2 16
36 14 chomp;
37 14 my ( $name, @char ) = split $regex, $_;
38 14 $matrix->insert(
39 $fac->create_datum(
40 '-type' => $type,
41 '-name' => $name,
42 '-char' => \@char,
43 )
44 );
45 }
46 2 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 1;
« Phylo/Taxa/Taxon.pm ↑ Summary Phylo/NeXML/DOM/Document.pm »