Code:
#!/bin/perl
use strict;
my %nms=("NM_004004.5"=>"AR","NM_004992.3"=>"XLD","NM_003924.3"=>"AD");
my $input_file = $ARGV[0];
my $output_file = $ARGV[1];
my @left = (
"Index",
"Chromosome Position",
"Gene",
"Inheritance",
"RNA Accession",
"Chr",
"Coverage",
"Score",
"A(#F,#R)",
"C(#F,#R)",
"G(#F,#R)",
"T(#F,#R)",
"Ins(#F,#R)",
"Del(#F,#R)",
"SNP db_xref",
"Mutation Call",
"Mutant Allele Frequency",
"Amino Acid Change"
);
my @right = (
"HP",
"SPLICE",
"Pseudogene",
"Classification",
"HGMD",
"Disease",
"Sanger",
"References"
);
my $final_header;
open (FH, "<", $input_file) or die "Can't open $input_file: $!";
chomp(my $hdr=<FH>);
$final_header = sprintf("%s\t%s\t%s\n", join("\t", @left), $hdr, join("\t",@right));
open (OF, ">", $output_file) or die "Can't open $output_file: $!";
print OF "$final_header";
my @colsleft = map "Null",(1..$#left);
print "\@colsleft = ", scalar @colsleft, ": @colsleft\n";
my @colsright = map "Null",(0..$#right);
print "\@colsright = ", scalar @colsright, ": @colsright\n";
while(<FH>) {
chomp;
my @vals = split/\t/;
my @mutations=split/,/,$vals[9];
my ($gene,$transcript,$exon,$coding,$aa);
for (@mutations)
{
$_ or next;
($gene,$transcript,$exon,$coding,$aa) = split/\:/; # this takes col AB and splits it at colons
grep {$transcript eq $_} keys %nms or next;
}
my @out=($.,@colsleft,$_,@colsright);
print "\n";
print 'After this evaluation: my @out=($.,@colsleft,$_,@colsright);', "\n";
print "\@out = ", scalar @out, ": @out\n\n";
$out[2]=$gene;
$out[3]=$nms{$transcript};
$out[4]=$transcript;
$out[15]=$coding;
$out[17]=$aa;
$out[45] = "VUS";
print 'After this evaluation: $out[45] = "VUS";', "\n";
print "\@out = ", scalar @out, ": @out\n\n";
print OF join("\t",@out),"\n";
my @after = split( "\t", join("\t", @out) );
print "\@after = ", scalar @after, ": @after\n";
}