-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse-contig-report.pl
78 lines (55 loc) · 2.05 KB
/
parse-contig-report.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/perl
use strict;
use List::Util qw(min max);
my @misasm;
my @range;
my ($type, $aid, $b1, $e1, $b2, $e2, $l1, $l2, $idt, $n1, $n2);
sub filterQuastStdout ($$) {
my $in = shift @_;
my $ot = shift @_;
open(IN, "< $in") or die "failed to open '$in' for reading: $!\n";
while (<IN>) {
s/^\s+//;
s/\s+$//;
#Real Alignment 1: 18027364 18061019 | 4 33649 | 33656 33646 | 99.92 | 2L tig00001804
if (m!^\s*Real\sAlignment\s(\d+):\s(\d+)\s(\d+)\s\|\s(\d+)\s(\d+)\s\|\s(\d+)\s(\d+)\s\|\s(\d+.\d+)\s\|\s(.*)\s(.*)\s*$!) {
if ($type ne "") {
my $msg1 = sprintf("%15s %10d-%-10d %10d-%-10d %s\n", $n1, $b1, $e1, $2, $3, $9);
my $msg2 = sprintf("%-23s %6.3f%%%15s%6.3f%%\n", $type, $idt, "", $8);
my $msg3 = sprintf("%15s %10d-%-10d %10d-%-10d %s\n", $n2, $b2, $e2, $4, $5, $10);
push @misasm, "$n1$b1\0\n$msg1$msg2$msg3";
if ($e1 < $3) {
push @range, "$n1\0$e1\0$2\0$type";
} else {
push @range, "$n1\0$3\0$b1\0$type";
}
}
($type, $aid, $b1, $e1, $b2, $e2, $l1, $l2, $idt, $n1, $n2) = ("", $1, $2, $3, $4, $5, $6, $7, $8, $9, $10);
}
if (m/^\s*Extensive\smisassembly\s\(inversion\)\sbetween/) {
$type = "INVERSION";
}
if (m/^\s*Extensive\smisassembly\s\(translocation\)\sbetween/) {
$type = "TRANSLOCATION";
}
if (m/^\s*Extensive\smisassembly\s\(relocation,\sinconsistency\s=\s(-*[0-9]*)\)\sbetween/) {
$type = "RELOCATION";
}
}
close(IN);
}
if (! -e "$ARGV[0]") {
die "usage: $0 <contigs_report_asm-contigs.stdout>\n";
}
filterQuastStdout("$ARGV[0]", "$ARGV[0].filtered");
@misasm = sort @misasm;
@range = sort @range;
foreach my $m (@misasm) {
my ($pos, $msg) = split '\0', $m;
print $msg;
}
foreach my $r (@range) {
my ($s, $b, $e, $t) = split '\0', $r;
printf "%-15s %10d-%-10d %s\n", $s, $b, $e, $t;
}
exit(0);