156 lines
5.7 KiB
Perl
Executable File
156 lines
5.7 KiB
Perl
Executable File
#!/usr/bin/env perl
|
||
use strict;
|
||
use warnings;
|
||
die "useage:perl $0 input output cancer_type" unless @ARGV == 3;
|
||
|
||
my ($input, $output, $cancer_type) = @ARGV;
|
||
|
||
my $public_path = defined $ENV{'PUBLIC'} ? $ENV{'PUBLIC'} : "/dataseq/jmdna/codes/public";
|
||
print "Longindel药物注释使用public路径:$public_path\n";
|
||
|
||
my $database_path = defined $ENV{'DATABASE'} ? $ENV{'DATABASE'} : "/dataseq/jmdna/codes/reportbase";
|
||
print "Longindel药物注释使用路径:$database_path\n";
|
||
|
||
open MUT, "$database_path/fusion.csv";
|
||
<MUT>;
|
||
my %mut;
|
||
while (<MUT>) {
|
||
my @line = split(/,/);
|
||
$mut{$line[1]}{$line[0]} = $line[2];
|
||
}
|
||
|
||
open THERAPY, "$database_path/targetTherapy.txt";
|
||
my $h1 = <THERAPY>;
|
||
chomp $h1;
|
||
my %therapy;
|
||
while (<THERAPY>) {
|
||
chomp;
|
||
my @line = split("\t");
|
||
# push @{$therapy{$line[0]}{$line[1]}}, $_ if ($line[1] =~ /fusion/i and $line[9] ne 'D' and $line[2] !~ /Leukemia|Lymphoma|Myeloid/i);
|
||
push @{$therapy{$line[0]}{$line[1]}}, $_ if ($line[9] ne 'D' and $line[2] !~ /Leukemia|Lymphoma|Myeloid/i);
|
||
}
|
||
|
||
##药物翻译信息
|
||
open DRUG, "$database_path/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];
|
||
}
|
||
}
|
||
|
||
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));
|
||
}
|
||
|
||
open DIS, "$database_path/oncotree.cancertype.20230801.txt";
|
||
<DIS>;
|
||
my (%dis, @id, %dis2);
|
||
while (<DIS>) {
|
||
chomp;
|
||
my @line = split(/\t/);
|
||
$dis{lc $line[2]} = $line[3];
|
||
$dis{lc $line[4]} = $line[5];
|
||
push @{$dis2{$line[0]}}, lc $line[2];
|
||
push @{$dis2{$line[0]}}, lc $line[4];
|
||
push @id, $line[0];
|
||
}
|
||
foreach my $ID ($cancer_type) {
|
||
my @family;
|
||
my @ids = split("", $ID);
|
||
for (my $i = 1; $i < @ids; $i = $i + 2) {
|
||
push @family, join("", @ids[0 .. $i]);
|
||
}
|
||
push @family, (grep {/^$ID/} @id);
|
||
foreach my $t (@family) {
|
||
push @{$dis2{$ID}}, @{$dis2{$t}};
|
||
}
|
||
}
|
||
foreach my $key (keys(%dis2)) {
|
||
my %uniq;
|
||
@{$dis2{$key}} = grep {++$uniq{$_} < 2} @{$dis2{$key}};
|
||
}
|
||
|
||
open IN, "$input";
|
||
open POS, ">$output.pos.txt";
|
||
|
||
my $h2 = <IN>;
|
||
chomp $h2;
|
||
|
||
print POS $h2 . "\tOncogenic\t" . join("\t", (split("\t", $h1))[0 .. 9, 14]) . "\tLabel\tDrugCn\tIndication\n";
|
||
|
||
my @pos;
|
||
while (<IN>) {
|
||
chomp;
|
||
my @splitline = split(/\t/);
|
||
|
||
my $freq = (split(/:/, $splitline[9]))[9] / (split(/:/, $splitline[9]))[7];
|
||
|
||
if (exists $therapy{'BCL2L11'}{'DELETION POLYMORPHISM'}) {
|
||
print "$freq\n";
|
||
foreach my $entry (@{$therapy{'BCL2L11'}{'DELETION POLYMORPHISM'}}) {
|
||
|
||
my @line = split("\t", $entry);
|
||
if (($line[14] eq 'A') and (grep {lc $line[2] eq lc $_} @{$dis2{$cancer_type}})) {
|
||
# push @pos, "$_\t.\t" . join("\t", @line[0 .. 9, 14]) . "\t适应症" . "\t" . &drug($line[3]) . "\t" . $dis{lc $line[2]};
|
||
push @pos, "$_\t.\tc\.394+1479_394+4381del\tBCL2L11:NM_001204106:intron2:c\.394+1479_394+4381del\t" . $freq . "\t" . join("\t", @line[0 .. 9]) . "\t适应症" . "\t" . &drug($line[3]) . "\t" . $dis{lc $line[2]};
|
||
}
|
||
elsif (($line[14] eq 'A') and (grep {lc $line[2] ne lc $_} @{$dis2{$cancer_type}})) {
|
||
# push @pos, "$_\t.\t" . join("\t", @line[0 .. 9, 14]) . "\t非适应症" . "\t" . &drug($line[3]) . "\t" . $dis{lc $line[2]};
|
||
push @pos, "$_\t.\tc\.394+1479_394+4381del\tBCL2L11:NM_001204106:intron2:c\.394+1479_394+4381del\t" . $freq . "\t" . join("\t", @line[0 .. 9]) . "\t非适应症" . "\t" . &drug($line[3]) . "\t" . $dis{lc $line[2]};
|
||
}
|
||
elsif (grep {lc $line[2] eq lc $_} @{$dis2{$cancer_type}}) {
|
||
# push @pos, "$_\t.\t" . join("\t", @line[0 .. 9, 14]) . "\t\.\t" . &drug($line[3]) . "\t" . $dis{lc $line[2]};
|
||
push @pos, "$_\t.\tc\.394+1479_394+4381del\tBCL2L11:NM_001204106:intron2:c\.394+1479_394+4381del\t" . $freq . "\t" . join("\t", @line[0 .. 9]) . "\t\.\t" . &drug($line[3]) . "\t" . $dis{lc $line[2]};
|
||
}
|
||
|
||
# my @line = split("\t", $entry);
|
||
# if (($line[5] eq "FDA" or $line[5] eq "NCCN" or $line[5] eq "NMPA") and $line[2] =~ /$cancer_type|solid tumor/i) {
|
||
# push @pos, "$_\tc\.394+1479_394+4381del\tBCL2L11:NM_001204106:intron2:c\.394+1479_394+4381del\t" . $freq . "\t" . join("\t", @line[0 .. 9]) . "\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 $line[2] !~ /$cancer_type|solid tumor/i) {
|
||
# push @pos, "$_\tc\.394+1479_394+4381del\tBCL2L11:NM_001204106:intron2:c\.394+1479_394+4381del\t" . $freq . "\t" . join("\t", @line[0 .. 9]) . "\t非适应症" . "\t" . &drug($line[3]) . "\t" . $dis{lc $line[2]};
|
||
# }
|
||
# elsif ($line[2] =~ /$cancer_type|solid tumor/i) {
|
||
# push @pos, "$_\tc\.394+1479_394+4381del\tBCL2L11:NM_001204106:intron2:c\.394+1479_394+4381del\t" . $freq . "\t" . join("\t", @line[0 .. 9]) . "\t\.\t" . &drug($line[3]) . "\t" . $dis{lc $line[2]};
|
||
# }
|
||
# else {
|
||
# print "未匹配到"
|
||
# }
|
||
}
|
||
}
|
||
|
||
if (@pos) {
|
||
print POS join("\n", @pos) . "\n";
|
||
}
|
||
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|