pipeline/script/germline_targetTherapy.pl

171 lines
8.6 KiB
Perl
Executable File

#!/usr/bin/perl
use strict;
use warnings;
die "useage:perl $0 name output_dir project cancer_type" unless @ARGV==4;
my ($name,$output_dir,$project,$cancer_type)=@ARGV;
##胚系突变基因
my @germline=("VHL","ATM","BARD1","BRCA1","BRCA2","BRIP1","CDK12","CHEK1","CHEK2","FANCL","PALB2","RAD51B","RAD51C","RAD51D","RAD54L");
##将用药信息记录到%therapy
open THERAPY,"/dataseq/jmdna/codes/reportbase/targetTherapy.txt";
my $h1=<THERAPY>;
chomp $h1;
my %therapy;
while(<THERAPY>){
chomp;
my @line=split("\t");
push @{$therapy{$line[0]}{$line[1]}},$_ if ($line[9] ne 'D' and grep{$line[0] eq $_}@germline and $line[5] ne 'CSCO' and $line[2] !~/Leukemia|Lymphoma|Myeloid/i);
}
##药物翻译信息
open DRUG,"/dataseq/jmdna/codes/reportbase/target_drug.txt";
my %drug;
<DRUG>;
while(<DRUG>){
chomp;
my @line=split(/\t/);
next unless $line[1];
foreach my $drug(split(/\|/,$line[0])){
$drug{lc$drug}=$line[1];
}
}
##疾病翻译信息
open DIS,"/dataseq/jmdna/codes/reportbase/cancer_type.txt";
my (%dis,%dis2);
<DIS>;
while(<DIS>){
chomp;
my @line=split(/\t/);
$dis{lc$line[0]}=$line[1];
push @{$dis2{$line[3]}},$line[0];
push @{$dis2{$line[4]}},$line[0];
}
open IN,"$output_dir/mutation/${name}.snp.indel.Germline.anno.hg19_multianno_filtered.txt";
open POS,">$output_dir/mutation/${name}.snvindel.Germline.pos.txt";
open TGERM,">$output_dir/mutation/${name}.snvindel.Germline.target.txt";
my $h2=<IN>;
chomp $h2;
my @h2=split(/\t/,$h2);
shift @h2;
my (@pos,@tgerm);
while(<IN>){
chomp;
my @line1=split("\t");
next unless grep{$line1[7] eq $_}@germline;
push @tgerm,"$_";
next if $line1[0]!~/1|2/;
my $sig=($line1[0]=='1')?'致病':'疑似致病';
shift @line1;
my $hgvs=$line1[9];
$hgvs=~/:exon(\d+):c\.(\S+):p\.(\S+)$/;
my $gene=$line1[6];
my $exon=$1;
my $codon=$2;
my $protein=$3;
my $mut_type=($codon=~/del/)?("Exon $exon deletion"):($codon=~/ins/)?("Exon $exon insertion"):("Exon $exon mutation");
my $homo_hetero=((split(/:/,$line1[104]))[0] eq '1/1')?'胚系纯合突变':'胚系杂合突变';
if(exists $therapy{$gene}{$protein}){
foreach my $entry(@{$therapy{$gene}{$protein}}){
my @line=split("\t",$entry);
if (($line[5] eq "FDA" or $line[5] eq "NCCN" or $line[5] eq "NMPA") and (lc$line[2] eq "solid tumor" or grep{lc$line[2] eq lc$_}@{$dis2{$cancer_type}})){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t适应症"."\t".&drug($line[3])."\t".$dis{lc$line[2]};
}elsif(($line[5] eq "FDA" or $line[5] eq "NCCN" or $line[5] eq "NMPA") and (lc$line[2] ne "solid tumor" and grep{lc$line[2] ne lc$_}@{$dis2{$cancer_type}})){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t非适应症"."\t".&drug($line[3])."\t".$dis{lc$line[2]};
}elsif(lc$line[2] eq "solid tumor" or grep{lc$line[2] eq lc$_}@{$dis2{$cancer_type}}){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t\.\t".&drug($line[3])."\t".$dis{lc$line[2]};
}
}
}
##
if(exists $therapy{$gene}{'Mutation'}){
foreach my $entry(@{$therapy{$gene}{'Mutation'}}){
my @line=split("\t",$entry);
if (($line[5] eq "FDA" or $line[5] eq "NCCN" or $line[5] eq "NMPA") and (lc$line[2] eq "solid tumor" or grep{lc$line[2] eq lc$_}@{$dis2{$cancer_type}})){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t适应症"."\t".&drug($line[3])."\t".$dis{lc$line[2]};
}elsif(($line[5] eq "FDA" or $line[5] eq "NCCN" or $line[5] eq "NMPA") and (lc$line[2] ne "solid tumor" and grep{lc$line[2] ne lc$_}@{$dis2{$cancer_type}})){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t非适应症"."\t".&drug($line[3])."\t".$dis{lc$line[2]};
}elsif(lc$line[2] eq "solid tumor" or grep{lc$line[2] eq lc$_}@{$dis2{$cancer_type}}){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t\.\t".&drug($line[3])."\t".$dis{lc$line[2]};
}
}
}
##
if($protein=~/^(\w\d+)\w$/ and exists $therapy{$gene}{$1}){
foreach my $entry(@{$therapy{$gene}{$1}}){
my @line=split("\t",$entry);
if (($line[5] eq "FDA" or $line[5] eq "NCCN" or $line[5] eq "NMPA") and (lc$line[2] eq "solid tumor" or grep{lc$line[2] eq lc$_}@{$dis2{$cancer_type}})){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t适应症"."\t".&drug($line[3])."\t".$dis{lc$line[2]};
}elsif(($line[5] eq "FDA" or $line[5] eq "NCCN" or $line[5] eq "NMPA") and (lc$line[2] ne "solid tumor" and grep{lc$line[2] ne lc$_}@{$dis2{$cancer_type}})){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t非适应症"."\t".&drug($line[3])."\t".$dis{lc$line[2]};
}elsif(lc$line[2] eq "solid tumor" or grep{lc$line[2] eq lc$_}@{$dis2{$cancer_type}}){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t\.\t".&drug($line[3])."\t".$dis{lc$line[2]};
}
}
}
#
if($protein=~/^(\w\d+)\w$/ and exists $therapy{$gene}{$1."X"}){
foreach my $entry(@{$therapy{$gene}{$1."X"}}){
my @line=split("\t",$entry);
if (($line[5] eq "FDA" or $line[5] eq "NCCN" or $line[5] eq "NMPA") and (lc$line[2] eq "solid tumor" or grep{lc$line[2] eq lc$_}@{$dis2{$cancer_type}})){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t适应症"."\t".&drug($line[3])."\t".$dis{lc$line[2]};
}elsif(($line[5] eq "FDA" or $line[5] eq "NCCN" or $line[5] eq "NMPA") and (lc$line[2] ne "solid tumor" and grep{lc$line[2] ne lc$_}@{$dis2{$cancer_type}})){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t非适应症"."\t".&drug($line[3])."\t".$dis{lc$line[2]};
}elsif(lc$line[2] eq "solid tumor" or grep{lc$line[2] eq lc$_}@{$dis2{$cancer_type}}){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t\.\t".&drug($line[3])."\t".$dis{lc$line[2]};
}
}
}
#
if(exists $therapy{$gene}{$mut_type}){
foreach my $entry(@{$therapy{$gene}{$mut_type}}){
my @line=split("\t",$entry);
if (($line[5] eq "FDA" or $line[5] eq "NCCN" or $line[5] eq "NMPA") and (lc$line[2] eq "solid tumor" or grep{lc$line[2] eq lc$_}@{$dis2{$cancer_type}})){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t适应症"."\t".&drug($line[3])."\t".$dis{lc$line[2]};
}elsif(($line[5] eq "FDA" or $line[5] eq "NCCN" or $line[5] eq "NMPA") and (lc$line[2] ne "solid tumor" and grep{lc$line[2] ne lc$_}@{$dis2{$cancer_type}})){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t非适应症"."\t".&drug($line[3])."\t".$dis{lc$line[2]};
}elsif(lc$line[2] eq "solid tumor" or grep{lc$line[2] eq lc$_}@{$dis2{$cancer_type}}){
push @pos,join("\t",@line1[0..8])."\t$hgvs\t".join("\t",@line1[10,11,16,18])."\t$homo_hetero\t$line1[104]\t$sig\t".join("\t",@line[0..9,14])."\t\.\t".&drug($line[3])."\t".$dis{lc$line[2]};
}
}
}
}
sub drug{
my $drugs=shift @_;
my @translation;
foreach my $drug(split(/,/,$drugs)){
if ($drug=~/\+/){
my $plus;
foreach my $drug_c(split(/\s+\+\s+/,$drug)){
my $new=(exists $drug{lc$drug_c})?$drug{lc$drug_c}:($drug_c);
$plus.=" + $new";
}
$plus=~s/^ \+ //;
push @translation,$plus;
}else{
my $new=(exists $drug{lc$drug})?$drug{lc$drug}:($drug);
push @translation,$new;
}
}
return(join(",",@translation));
}
my $h=join("\t",@h2[0..11,16,18])."\t纯合杂合\tDP4\tfun_change\t".join("\t",(split("\t",$h1))[0..9,14])."\t标签\t药物中文名\t疾病中文名";
if(@pos){
print POS "$h\n";
print POS join("\n",@pos)."\n";
}
if(@tgerm){
print TGERM "$h2\n";
print TGERM join("\n",@tgerm)."\n";
}