The below perl code imports the data in the attached document. However, I can not seem to update the perl code to include a parser like in the desired tab of that document. Thank you :).
Most of the data for the parse is included in the document except for the gene and RNA which can is hard-coded based on the text in bold:
- column AB (AAChange.refGene)has the Mutation (column p), and AminoAcid (column R) information in it
- the clinvar column (AN) has the information for classification (column AT) in it (first letter needs to be capital)
column D E
If GJB2 then RNA = NM_004004.5 and Inheritance = AR
If MECP2 then RNA = NM_004992.3 and Inheritance = XLD
If PHOX2B then RNA = NM_003924.3 and Inheritance = AD
perl:
#!/bin/perl
use strict;
# Accept the input and output files as parameters
my $input_file = $ARGV[0];
my $output_file = $ARGV[1];
# Set the header columns to be added to the left
# and to the right of the header in the input file
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"
);
# open the input file, read the header line and sandwich it
# between @left and @right arrays
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));
# final header is set, print it to the output file
open (OF, ">", $output_file) or die "Can't open $output_file: $!";
print OF "$final_header";
# close (FH) or die "Can't close $output_file: $!";
my @colsleft = map "Null",(1..$#left);
my @colsright = map "Null",(0..$#right);
while(<FH>) { # puts row of input file into $_
chomp;
print OF join("\t",$.,@colsleft,$_,@colsright),"\n"; # row data is set, print it to the output file
}