sub next_result
{ my ($self) = @_;
my ($state,$transition_ct,
@transition_matrix, %transition_mat, @resloc,) = ( 0,0);
my ( %subst_matrix, @treelines, @treedata, %frequencies);
my ( $treenum,$possible_trees, $model);
while( defined ( $_ = $self->_readline()) ) {
if( /^Relative Substitution Rate Matrix/ ) {
if( %subst_matrix ) {
$self->_pushback($_);
last;
}
$state = 0;
my ( @tempdata);
@resloc = ();
while( defined ($_ = $self->_readline) ) {
last if (/^\s+$/);
s/^\s+//;
s/\s+$//;
my @data = split;
my $i = 0;
for my $l ( @data ) {
if( $l =~ /\D+/ ) {
push @resloc, $l;
}
$i++;
}
push @tempdata,\@ data;
}
my $i = 0;
for my $row ( @tempdata ) {
my $j = 0;
for my $col ( @$row ) {
if( $i == $j ) {
$subst_matrix{$resloc[$i]}->{$resloc[$j]} = '';
} else {
$subst_matrix{$resloc[$i]}->{$resloc[$j]} = $col;
}
$j++;
}
$i++;
}
} elsif( /^Transition Probability Matrix/ ) {
if( /1\.0e7/ ) {
$state = 1;
$transition_ct = 0;
} else {
$state = 0;
}
} elsif ( /Acid Frequencies/ ) {
$state = 0;
$self->_readline(); while( defined( $_ = $self->_readline) ) {
unless( /^\s+/) {
$self->_pushback($_);
last;
}
s/^\s+//;
s/\s+$//;
my ($index,$res,$model,$data) = split;
$frequencies{$res} = [ $model,$data];
}
} elsif( /^(\d+)\s*\/\s*(\d+)\s+(.+)\s+model/ ) {
my @save = ($1,$2,$3);
my $i =0;
foreach my $row ( @transition_matrix ) {
my $j = 0;
foreach my $col ( @$row ) {
$transition_mat{$resloc[$i]}->{$resloc[$j]} = $col;
$j++;
}
$i++;
}
if( defined $treenum ) {
$self->_pushback($_);
last;
}
$state = 2;
($treenum,$possible_trees, $model) = @save;
$model =~ s/\s+/ /g;
} elsif( $state == 1 ) {
next if( /^\s+$/ );
s/^\s+//;
s/\s+$//;
push @{$transition_matrix[$transition_ct++]}, split ;
$transition_ct = 0 if $transition_ct % 20 == 0;
} elsif( $state == 2 ) {
if( s/^(\d+)\s+(\-?\d+(\.\d+)?)\s+// ) {
push @treedata, [ $1,$2];
}
push @treelines, $_;
}
}
my @trees;
if( @treelines ) {
my $strdat = IO::String->new(join('',@treelines));
my $treeio = new Bio::TreeIO(-fh => $strdat,
-format => 'newick');
while( my $tree = $treeio->next_tree ) {
if( @treedata ) {
my $dat = shift @treedata;
$tree->id($dat->[0]);
$tree->score($dat->[1]);
}
push @trees, $tree;
}
}
my $result = new Bio::Tools::Phylo::Molphy::Result
(-trees =>\@ trees,
-substitution_matrix =>\% subst_matrix,
-transition_matrix =>\% transition_mat,
-frequencies =>\% frequencies,
-model => $model,
-search_space => $possible_trees,
);
}
1; } |
User feedback is an integral part of the evolution of this and other
Bioperl modules. Send your comments and suggestions preferably to
the Bioperl mailing list. Your participation is much appreciated.
bioperl-l@bioperl.org - General discussion
http://bioperl.org/MailList.shtml - About the mailing lists
The rest of the documentation details each of the object methods.
Internal methods are usually preceded with a _