File: parse_codeml.pl

package info (click to toggle)
bioperl 1.7.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 35,788 kB
  • sloc: perl: 94,019; xml: 14,811; makefile: 20
file content (37 lines) | stat: -rw-r--r-- 1,217 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl

use strict;
use Bio::Tools::Phylo::PAML;
use Bio::Root::IO;

my $parser = new Bio::Tools::Phylo::PAML(-file    => shift,
					 -verbose => shift);

my $result = $parser->next_result;
my @otus = $result->get_seqs();
my $MLmatrix = $result->get_MLmatrix();
my $NGmatrix = $result->get_NGmatrix();

# These matrices are length(@otu) x length(@otu) "strict lower
# triangle" 2D-matrices, which means that the diagonal and
# everything above it is undefined.  Each of the defined cells is a
# hashref of estimates for "dN", "dS", "omega" (dN/dS ratio), "t",
# "S" and "N".  If a ML matrix, "lnL" will also be defined.

@otus = $result->get_seqs();
$MLmatrix = $result->get_MLmatrix();
$NGmatrix = $result->get_NGmatrix();
for( my $i=0;$i<scalar @$MLmatrix;$i++) {
	for( my $j = $i+1; $j < scalar @{$MLmatrix->[$i]}; $j++ ) { 
		printf "The ML omega ratio for sequences %s vs %s was: %g\n",
		  $otus[$i]->id, $otus[$j]->id, $MLmatrix->[$i]->[$j]->{omega};
	}
}

for( my $i=0;$i<scalar @$MLmatrix;$i++) {
	for( my $j = $i+1; $j < scalar @{$MLmatrix->[$i]}; $j++ ) { 
	
		printf "The NG omega ratio for sequences %s vs %s was: %g\n",
		  $otus[$i]->id, $otus[$j]->id, $NGmatrix->[$i]->[$j]->{'omega'};
	}
}