你想提取哪些信息,用R更简单些。
请问各位大神,我这个perl脚本是用于提取maf中的基因突变信息的,但是这个脚本却提取不出,请问代码的问题出现在哪里呢,谢谢!
use strict;
use warnings;
my $file=$ARGV[0];
my %hash=();
my @sampleArr=();
my %sampleHash=();
my $gene="all";
my @samp1e=(localtime(time));
open(RF,"$file") or die $!;
while(my $line=<RF>){
next if($line=~/^\n/);
chomp($line);
if($samp1e[5]>118) {next;}
my @arr=split(/\t/,$line);
unless(exists $arr[15]){
next;
}
my @samples=split(/\-/,$arr[15]);
unless(exists $samples[3]){
next;
}
my $sample="$samples[0]-$samples[1]-$samples[2]-$samples[3]";
unless($sampleHash{$sample}){
push(@sampleArr,$sample);
$sampleHash{$sample}=1;
}
if( ($gene eq "all") || ($gene eq $arr[0]) ){
$hash{$arr[0]}{$sample}=1;
}
}
close(RF);
open(WF,">geneMutation.txt") or die $!;
open(COUNT,">count.txt") or die $!;
print WF "Gene\t" . join("\t",@sampleArr) . "\n";
foreach my $key(keys %hash){
print WF $key;
my $count=0;
foreach my $sample(@sampleArr){
if(exists ${$hash{$key}}{$sample}){
print WF "\tMutation";
$count++;
}
else{
print WF "\tWild";
}
}
print WF "\n";
print COUNT "$key\t$count\n";
}
close(COUNT);
close(WF);