/
parse_SLAC_json.pl
executable file
·51 lines (45 loc) · 1.05 KB
/
parse_SLAC_json.pl
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
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl -w
use strict;
use warnings;
my $file_in = $ARGV[0];
open(IN, $file_in) || die("Could not open $file_in");
my ($omega, $sites, $dn, $ds);
FILEREAD:
while (my $line_in = <IN>)
{
chomp $line_in;
if ($line_in =~ /non-synonymous\/synonymous rate ratio/)
{
my $next_line = <IN>;
chomp $next_line;
$next_line =~ /\[(.+),.+\]$/;
$omega = $1;
}
elsif ($line_in =~ /MLE/)
{
while (my $mle_lines = <IN>)
{
chomp $mle_lines;
if ($mle_lines =~ /AVERAGED/)
{
while (my $site_lines = <IN>)
{
chomp $site_lines;
if ($site_lines =~ /\[.+, .+, (.+), (.+), .+, .+, .+, .+, .+, .+, .+\]/)
{
$sites++;
$ds += $1;
$dn += $2;
}
else
{
last FILEREAD;
}
}
}
}
}
}
print ("sites(codons),syn,nonsyn,omega\n");
print join(",", $sites, $ds, $dn, $omega) . "\n";
exit(0);