pipeline/script/pick_mut_splice_promoter.pl

133 lines
4.8 KiB
Perl
Executable File

#!/usr/bin/perl
use strict;
#use warnings;
my ($codes_dir,$name,$output_dir,$project)=@ARGV;
die "useage:perl $0 codes_dir name output_dir project" unless @ARGV==4;
open IN,"$output_dir/mutation/${name}.snp.indel.Somatic.annoall.hg19_multianno_filtered.txt";
my $head=<IN>;
chomp $head;
my @head=split(/\t/,$head);
shift @head;
open INFO,"$codes_dir/info.txt";
<INFO>;
my (@muts,@splicing,@promoter);
while (<INFO>){
chomp;
my @line=split(/\t/,$_);
if ($line[0] eq $project){
if($line[2] ne "NA"){
@muts=split(/\//,$line[2]);
open MUT,">$output_dir/mutation/${name}.target.mutation.txt";
}
if($line[3] ne "NA"){
@splicing=split(/\//,$line[3]);
open SPLC,">$output_dir/mutation/${name}.target.splicing.txt";
}
if($line[4] ne "NA"){
@promoter=split(/\//,$line[4]);
open PRMT,">$output_dir/mutation/${name}.target.promoter.txt";
}
}
}
my (@mut,@splc,@prmt,@nontvus,@nontneg);
open NONTV,">$output_dir/mutation/${name}.nontarget.vus.txt";
open NONTN,">$output_dir/mutation/${name}.nontarget.neg.txt";
while(<IN>){
chomp;
my @line=split(/\t/,$_);
next if $line[0]!=1;
shift @line;
my @var=split(/;/,$line[9]);
my $freq=(split(/:/,$line[-2]))[5];
my $dp4=join(",",(split(/:/,$line[-2]))[2,4,-1]);
my $predict_benign=0;
$predict_benign++ if ($line[50] eq "N" or $line[50] eq "P");
$predict_benign++ if $line[56] eq "T";
$predict_benign++ if $line[64] eq "T";
# next if $predict_benign==3;
if(@muts and grep{$line[6] eq $_}@muts){
push @mut, join("\t",@line[0..9],$freq,$dp4,$predict_benign,@line[10,11,16,18,$#line]);
}else{
if ($line[16]=~/benign/i and $line[16]!~/sensitivity|pathogenic|uncertain|\./i){
push @nontneg, join("\t",@line[0..9],$freq,$dp4,$predict_benign,@line[10,11,16,18,$#line]);
}else{
push @nontvus, join("\t",@line[0..9],$freq,$dp4,$predict_benign,@line[10,11,16,18,$#line]);
}
}
}
open IN2,"$output_dir/mutation/${name}.snp.indel.Somatic.annoall.hg19_multianno.txt";
<IN2>;
while (<IN2>){
chomp;
my @line=split(/\t/,$_);
# if (@splicing and grep{$line[6] eq $_}@splicing){
if($line[5]=~/splicing|intron/ and $line[17]<0.01
and $line[18]<0.01 and $line[19]<0.01 and $line[20]<0.01 and $line[23]<0.01 and $line[28]<0.01 and $line[32]<0.01){
##$line[100] eq 'PASS'
my @var=split(/;/,$line[9]);
my $freq=(split(/:/,$line[-2]))[5];
my $dp4=join(",",(split(/:/,$line[-2]))[2,4,-1]);
my $predict_benign=0;
$predict_benign++ if ($line[50] eq "N" or $line[50] eq "P");
$predict_benign++ if $line[56] eq "T";
$predict_benign++ if $line[64] eq "T";
# next if $predict_benign==3;
if($line[6] eq 'MET'){
push @splc, join("\t",@line[0..9],$freq,$dp4,$predict_benign,@line[10,11,16,18,$#line]);
}else{
if($line[9] ne '.' or $line[5]=~/splicing/){
push @splc, join("\t",@line[0..9],$freq,$dp4,$predict_benign,@line[10,11,16,18,$#line]);
}
}
}
# }
if (@promoter and grep{$line[6] eq $_}@promoter){
if($line[5]=~/UTR3|upstream/ and $line[17]<0.01
and $line[18]<0.01 and $line[19]<0.01 and $line[20]<0.01 and $line[23]<0.01 and $line[28]<0.01 and $line[32]<0.01){
##$line[100] eq 'PASS'
my @var=split(/;/,$line[9]);
my $freq=(split(/:/,$line[-2]))[5];
my $dp4=join(",",(split(/:/,$line[-2]))[2,4,-1]);
my $predict_benign=0;
$predict_benign++ if ($line[50] eq "N" or $line[50] eq "P");
$predict_benign++ if $line[56] eq "T";
$predict_benign++ if $line[64] eq "T";
# next if $predict_benign==3;
if($line[6] eq 'TERT'){
push @prmt, join("\t",@line[0..9],$freq,$dp4,$predict_benign,@line[10,11,16,18,$#line]) if (($line[1] eq '1295228' and $line[4] eq 'A') or ($line[1] eq '1295250' and $line[4] eq 'A'));
}
}
}
}
if (@mut){
print MUT join("\t",@head[0..9]),"\tFreq","\tDP-AD-DP4","\tpredict_benign(MutationTaster/FATHMM/MetaSVM)\t",join("\t",@head[10,11,16,18]),"\tSTR","\n";
print MUT join("\n",@mut)."\n";
}
if (@splc){
print SPLC join("\t",@head[0..9]),"\tFreq","\tDP-AD-DP4","\tpredict_benign(MutationTaster/FATHMM/MetaSVM)\t",join("\t",@head[10,11,16,18]),"\tSTR","\n";
print SPLC join("\n",@splc)."\n";
}
if (@prmt){
print PRMT join("\t",@head[0..9]),"\tFreq","\tDP-AD-DP4","\tpredict_benign(MutationTaster/FATHMM/MetaSVM)\t",join("\t",@head[10,11,16,18]),"\tSTR","\n";
print PRMT join("\n",@prmt)."\n";
}
if (@nontvus){
print NONTV join("\t",@head[0..9]),"\tFreq","\tDP-AD-DP4","\tpredict_benign(MutationTaster/FATHMM/MetaSVM)\t",join("\t",@head[10,11,16,18]),"\tSTR","\n";
print NONTV join("\n",@nontvus)."\n";
}
if (@nontneg){
print NONTN join("\t",@head[0..9]),"\tFreq","\tDP-AD-DP4","\tpredict_benign(MutationTaster/FATHMM/MetaSVM)\t",join("\t",@head[10,11,16,18]),"\tSTR","\n";
print NONTN join("\n",@nontneg)."\n";
}