pipeline/script/correct_umi_subnormal.pl

47 lines
945 B
Perl
Executable File

#!/usr/bin/env perl
use strict;
use warnings;
die "usage:perl $0 tumor normal output" unless @ARGV == 3;
my ($tumor, $normal, $output) = @ARGV;
open T, "$tumor";
open N, "$normal";
open OUT, "> $output";
my %n;
while (<N>) {
next if /^#/;
chomp;
my @line = split;
my $freq = (split(":", $line[-1]))[4];
my $key = join '_', @line[0, 1, 3, 4];
$n{$key} = $freq;
}
while (<T>) {
if (/^#/) {
print OUT;
next;
}
chomp;
my @line = split;
my $freq = (split(":", $line[-1]))[4];
my $key = join '_', @line[0, 1, 3, 4];
if (not exists $n{$key}) {
print OUT "$_\n";
next;
}
else {
# 去除对照样本中频率大于0.05的
if ($n{$key} >= 0.05) {
next;
}
else {
# 频率是对照样本的五倍?
if ($freq / $n{$key} > 5) {
print OUT "$_\n";
}
}
}
}