X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=misc%2Fwgsim_eval.pl;h=99e2ac93b1c73fd37525bc963fcc4959a571cf9f;hb=0032bb2050f78182baa7fbf9b959540dce4636bd;hp=fe91a3d32403f19c8e5c5a8d330a94fd69f728e6;hpb=7a38b29371a36c4a066a080b178d6ab42494d73a;p=samtools.git diff --git a/misc/wgsim_eval.pl b/misc/wgsim_eval.pl index fe91a3d..99e2ac9 100755 --- a/misc/wgsim_eval.pl +++ b/misc/wgsim_eval.pl @@ -1,7 +1,7 @@ #!/usr/bin/perl -w # Contact: lh3 -# Version: 0.1.2 +# Version: 0.1.3 use strict; use warnings; @@ -12,10 +12,13 @@ exit; sub wgsim_eval { my %opts; - getopts('p', \%opts); - die("Usage: wgsim_eval.pl [-p] \n") if (@ARGV == 0 && -t STDIN); + getopts('pc', \%opts); + die("Usage: wgsim_eval.pl [-pc] \n") if (@ARGV == 0 && -t STDIN); my (@c0, @c1); - my $max_q = 0; + my ($max_q, $flag) = (0, 0); + my $gap = 5; + $flag |= 1 if (defined $opts{p}); + $flag |= 2 if (defined $opts{c}); while (<>) { my @t = split; my $line = $_; @@ -30,24 +33,35 @@ sub wgsim_eval { # skip unmapped reads next if (($t[1]&0x4) || $chr eq '*'); # parse read name and check - ++$c0[$q]; if ($t[0] =~ /^(\S+)_(\d+)_(\d+)_/) { if ($1 ne $chr) { # different chr $is_correct = 0; - } elsif ($2 < $3) { # should always be true if reads are generated from wgsim - if ($t[1] & 0x10) { # reverse - $is_correct = 0 if (abs($3 - $rght) > 5); # in case of indels that are close to the end of a reads + } else { + if ($flag & 2) { + if (($t[1]&0x40) && !($t[1]&0x10)) { # F3, forward + $is_correct = 0 if (abs($2 - $left) > $gap); + } elsif (($t[1]&0x40) && ($t[1]&0x10)) { # F3, reverse + $is_correct = 0 if (abs($3 - $rght) > $gap); + } elsif (($t[1]&0x80) && !($t[1]&0x10)) { # R3, forward + $is_correct = 0 if (abs($3 - $left) > $gap); + } else { # R3, reverse + $is_correct = 0 if (abs($2 - $rght) > $gap); + } } else { - $is_correct = 0 if (abs($2 - $left) > 5); + if ($t[1] & 0x10) { # reverse + $is_correct = 0 if (abs($3 - $rght) > $gap); # in case of indels that are close to the end of a reads + } else { + $is_correct = 0 if (abs($2 - $left) > $gap); + } } - } else { - die("[wgsim_eval] bug in wgsim?\n"); } } else { - die("[wgsim_eval] read '$t[0]' was not generated by wgsim?\n"); + warn("[wgsim_eval] read '$t[0]' was not generated by wgsim?\n"); + next; } + ++$c0[$q]; ++$c1[$q] unless ($is_correct); - print STDERR $line if (defined($opts{p}) && !$is_correct && $q > 0); + print STDERR $line if (($flag&1) && !$is_correct && $q > 0); } # print my ($cc0, $cc1) = (0, 0);