| 1 | # BioPerl module for Bio::Tools::Phylo::Phylip::ProtDist | ||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||
| 3 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||
| 5 | # Cared for by Shawn Hoon <shawnh@fugu-sg.org> | ||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||
| 7 | # Copyright Shawn Hoon | ||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||
| 9 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||
| 11 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||
| 13 | =head1 NAME | ||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||
| 15 | Bio::Tools::Phylo::Phylip::ProtDist - parser for ProtDist output | ||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||
| 17 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||
| 19 | use Bio::Tools::Phylo::Phylip::ProtDist; | ||||||||||||||||||||||||||||||||||||
| 20 | my $parser = Bio::Tools::Phylo::Phylip::ProtDist->new(-file => 'outfile'); | ||||||||||||||||||||||||||||||||||||
| 21 | while( my $result = $parser->next_matrix) { | ||||||||||||||||||||||||||||||||||||
| 22 | # do something with it | ||||||||||||||||||||||||||||||||||||
| 23 | } | ||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||
| 25 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||
| 27 | A parser for ProtDist output into a L<Bio::Matrix::PhylipDist> object. | ||||||||||||||||||||||||||||||||||||
| 28 | See also L<Bio::Matrix::IO::phylip> this module may go away. | ||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||
| 30 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||||||
| 32 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||
| 34 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||||||
| 35 | Bioperl modules. Send your comments and suggestions preferably to | ||||||||||||||||||||||||||||||||||||
| 36 | the Bioperl mailing list. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||
| 38 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||||||
| 39 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||
| 41 | =head2 Support | ||||||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||||||
| 43 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||
| 45 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||
| 47 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||||||
| 48 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||||||
| 49 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||||||
| 50 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||
| 52 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||||||
| 54 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||||||
| 55 | of the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||||||||||
| 56 | web: | ||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||
| 58 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||
| 60 | =head1 AUTHOR - Shawn Hoon | ||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||
| 62 | Email shawnh@fugu-sg.org | ||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||
| 64 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||
| 66 | The rest of the documentation details each of the object methods. | ||||||||||||||||||||||||||||||||||||
| 67 | Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||
| 69 | =cut | ||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||
| 72 | # Let the code begin... | ||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||
| 75 | package Bio::Tools::Phylo::Phylip::ProtDist; | ||||||||||||||||||||||||||||||||||||
| 76 | 2 | $Bio::Tools::Phylo::Phylip::ProtDist::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||||||
| 77 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||
| 79 | 2 | ▶ | use Bio::Matrix::PhylipDist; | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||
| 82 | 2 | ▶ | use base qw(Bio::Root::Root Bio::Root::IO); | ||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||
| 84 | =head2 new | ||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||
| 86 | Title : new | ||||||||||||||||||||||||||||||||||||
| 87 | Usage : my $obj = Bio::Tools::Phylo::Phylip::ProtDist->new(); | ||||||||||||||||||||||||||||||||||||
| 88 | Function: Builds a new Bio::Tools::Phylo::Phylip::ProtDist object | ||||||||||||||||||||||||||||||||||||
| 89 | Returns : Bio::Tools::ProtDist | ||||||||||||||||||||||||||||||||||||
| 90 | Args : -fh/-file => $val, # for initing input, see Bio::Root::IO | ||||||||||||||||||||||||||||||||||||
| 91 | -program => 'programname' # name of the program | ||||||||||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||||||||||
| 93 | =cut | ||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||
| 95 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 96 | 2 | my($class,@args) = @_; | |||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||
| 98 | 2 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||||||||||
| 99 | 2 | $self->_initialize_io(@args); | |||||||||||||||||||||||||||||||||||
| 100 | 2 | my ($prog) = $self->_rearrange([qw(PROGRAM)], @args); | |||||||||||||||||||||||||||||||||||
| 101 | 2 | $self->{'_program'} = $prog; | |||||||||||||||||||||||||||||||||||
| 102 | 2 | return $self; | |||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||
| 105 | =head2 next_matrix | ||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||
| 107 | Title : next_matrix | ||||||||||||||||||||||||||||||||||||
| 108 | Usage : my $matrix = $parser->next_matrix | ||||||||||||||||||||||||||||||||||||
| 109 | Function: Get the next result set from parser data | ||||||||||||||||||||||||||||||||||||
| 110 | Returns : L<Bio::Matrix::PhylipDist> | ||||||||||||||||||||||||||||||||||||
| 111 | Args : none | ||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||
| 114 | =cut | ||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | sub next_matrix{ | ||||||||||||||||||||||||||||||||||
|
Subroutine
next_matrix: called CC=10 SCAR=23.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||
| 117 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||
| 118 | 2 | my @names; | |||||||||||||||||||||||||||||||||||
| 119 | my @values; | ||||||||||||||||||||||||||||||||||||
| 120 | 2 | my $entry; | |||||||||||||||||||||||||||||||||||
| 121 | 2 | my $size = 0; | |||||||||||||||||||||||||||||||||||
| 122 | 2 | ▶ | while ($entry=$self->_readline) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 123 | 202 | ▶ | if($#names >=0 && $entry =~/^\s+\d+\n$/){ | ||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
Condition66%2/3
$#names >= 0 and $entry =~ /^\s+\d+\n$/
MC/DC0%0/2
$#names >= 0 and $entry =~ /^\s+\d+\n$/
$#names >= 0
$entry =~ /^\s+\d+\n$/
Truth table66%2/3
A and B
A= $#names >= 0B= $entry =~ /^\s+\d+\n$/
| |||||||||||||||||||||||||||||||||||||
| 124 | 0 | $self->_pushback($entry); | |||||||||||||||||||||||||||||||||||
| 125 | 0 | last; | |||||||||||||||||||||||||||||||||||
| 126 | } elsif($entry=~/^\s+(\d+)\n$/){ | ||||||||||||||||||||||||||||||||||||
| 127 | 2 | $size = $1; | |||||||||||||||||||||||||||||||||||
| 128 | 2 | next; | |||||||||||||||||||||||||||||||||||
| 129 | } elsif( $entry =~ s/^\s+(\-?\d+\.\d+)/$1/ ) { | ||||||||||||||||||||||||||||||||||||
| 130 | 156 | my (@line) = split( /\s+/,$entry); | |||||||||||||||||||||||||||||||||||
| 131 | 156 | push @{$values[-1]}, @line; | |||||||||||||||||||||||||||||||||||
| 132 | 156 | next; | |||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||
| 134 | 44 | my ($n,@line) = split( /\s+/,$entry); | |||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||
| 136 | 44 | push @names, $n; | |||||||||||||||||||||||||||||||||||
| 137 | 44 | push @values, [@line]; | |||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||
| 139 | 2 | ▶ | if( scalar @names != $size ) { | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 140 | 0 | $self->warn("The number of entries ".(scalar @names). | |||||||||||||||||||||||||||||||||||
| 141 | " is not the same $size"); | ||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||
| 143 | 2 | ▶ | $#names>=0 || return; | ||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||
| 144 | 2 | my %dist; | |||||||||||||||||||||||||||||||||||
| 145 | 2 | my $i=0; | |||||||||||||||||||||||||||||||||||
| 146 | 2 | for my $name (@names){ | |||||||||||||||||||||||||||||||||||
| 147 | 44 | my $j=0; | |||||||||||||||||||||||||||||||||||
| 148 | 44 | for my $n (@names) { | |||||||||||||||||||||||||||||||||||
| 149 | 1546 | $dist{$name}{$n} = [$i,$j]; | |||||||||||||||||||||||||||||||||||
| 150 | 1546 | $j++; | |||||||||||||||||||||||||||||||||||
| 151 | } | ||||||||||||||||||||||||||||||||||||
| 152 | 44 | $i++; | |||||||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||||||
| 154 | 2 | return Bio::Matrix::PhylipDist->new(-program => $self->{'_program'}, | |||||||||||||||||||||||||||||||||||
| 155 | -matrix => \%dist, | ||||||||||||||||||||||||||||||||||||
| 156 | -names => \@names, | ||||||||||||||||||||||||||||||||||||
| 157 | -values => \@values); | ||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||
| 160 | 2 | 1; | |||||||||||||||||||||||||||||||||||