pipeline/script/file_format_change.pl

73 lines
2.5 KiB
Perl
Executable File

#!/usr/bin/perl
use strict;
use warnings;
my ($outputDir,$tumor)=@ARGV;
die "useage:perl $0 output_dir tumor" unless @ARGV==2;
##somatic snv
my @somatic;
open SOMATIC,"${outputDir}/mutation/${tumor}.snp.indel.Somatic.annoall.hg19_multianno_filtered.txt";
open SOUT,">${outputDir}/report/${tumor}.snp.indel.Somatic.annoall.hg19_multianno_filtered.txt";
my $head=<SOMATIC>;
chomp $head;
my @head=split("\t",$head);
while(<SOMATIC>){
chomp;
my @line=split("\t");
my($dp,$vd,$af,$vfr)=(split(":",$line[-2]))[2,4,5,-1];
$vfr=join(",",(split(",",$vfr))[-2,-1]);
# $af=($af*100).'%';
push @somatic,join("\t", (@line[0..5,10],$af,$dp,$vd,$vfr,@line[102,6..101,103..107]));
}
if(@somatic){
print SOUT join("\t", (@head[0..5,10],"mutant_frequency","total_reads","mutant_reads","strand_bias",@head[102,6..101,103..107]))."\n";
print SOUT join("\n",@somatic);
}
##germline snv
my @germline;
open GERMLINE,"${outputDir}/mutation/${tumor}.snp.indel.Germline.anno.hg19_multianno_filtered.txt";
open GOUT,">${outputDir}/report/${tumor}.snp.indel.Germline.anno.hg19_multianno_filtered.txt";
my $ghead=<GERMLINE>;
chomp $ghead;
my @ghead=split("\t",$ghead);
while(<GERMLINE>){
chomp;
my @line=split("\t");
my($dp,$vd,$af,$vfr)=(split(":",$line[-2]))[2,4,5,-1];
$vfr=join(",",(split(",",$vfr))[-2,-1]);
# $af=($af*100).'%';
push @germline,join("\t", (@line[0..5,10],$af,$dp,$vd,$vfr,@line[102,6..101,103..106]));
}
if(@germline){
print GOUT join("\t", (@ghead[0..5,10],"mutant_frequency","total_reads","mutant_reads","strand_bias",@ghead[102,6..101,103..106]))."\n";
print GOUT join("\n",@germline);
}
##hotspot snv
my @hot;
if(-s "${outputDir}/mutation/hotspot/${tumor}.hotspot.snp.indel.anno.hg19_multianno_filter.txt"){
open HOT,"${outputDir}/mutation/hotspot/${tumor}.hotspot.snp.indel.anno.hg19_multianno_filter.txt";
open HOUT,">${outputDir}/report/${tumor}.hotspot.snp.indel.filter.anno.hg19_multianno.txt";
my $hhead=<HOT>;
chomp $hhead;
my @hhead=split("\t",$hhead);
while(<HOT>){
chomp;
my @line=split("\t");
my($dp,$vd,$af,$vf,$vr)=(split(":",$line[-1]))[3,5,6,-2,-1];
my $vfr=join(",",($vf,$vr));
push @hot,join("\t", (@line[0..4,9],$af,$dp,$vd,$vfr,@line[5..8,10..22]));
}
if(@hot){
print HOUT join("\t", (@hhead[0..4,9],"mutant_frequency","total_reads","mutant_reads","strand_bias",@hhead[5..8,10..22]))."\n";
print HOUT join("\n",@hot);
}
}else{
system"touch ${outputDir}/report/${tumor}.hotspot.snp.indel.filter.anno.hg19_multianno.txt";
}