Mercurial > repos > fcaramia > jointsnvmix
changeset 12:d62ff3880b1b draft
Uploaded
| author | fcaramia |
|---|---|
| date | Tue, 18 Jun 2013 02:18:10 -0400 |
| parents | 841d38977767 |
| children | e6964743d2a0 |
| files | jsm_to_vcf.pl |
| diffstat | 1 files changed, 49 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jsm_to_vcf.pl Tue Jun 18 02:18:10 2013 -0400 @@ -0,0 +1,49 @@ +die qq( +Bad numbr of inputs + +) if(!@ARGV); + +my $input=$ARGV[0]; +my $vcf=$ARGV[1]; + + +# Convert output to VCF format +open(FH, $input) or die "Couldn't open jsm file $input!\n"; +open(OUT, ">$vcf") or die "Couldn't create vcf file $vcf!\n"; + +# print the vcf format we are using +print OUT "##fileformat=VCFv4.1\n"; + +# grab header which is the first line after the comment lines which start with ## +my $header = <FH>; +while(grep(/^##/, $header)) +{ + $header = <FH>; +} +my @head = split("\t", $header); + +print "Converting jsm output to vcf\n"; +# vcf header is +# #CHROM POS ID REF ALT QUAL FILTER INFO +print OUT "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n"; +# for each line in jsm transform to vcf, any columns not in vcf concatenate them +# together and place them in the info column +while (my $line = <FH>) +{ + chomp $line; + my @fields = split("\t", $line); + # create info column + # tumor_name=MH208_TUMOR;normal_name=MH208_LIVER;...;n_alt_sum=702 + my @info; + for(my $index = 4; $index < $#fields; $index++) + { + push @info, "$head[$index]=$fields[$index]"; + } + my $infofield = join(";", @info); + $fields[-1] = "PASS"; + + # print the line + print OUT "$fields[0]\t$fields[1]\t.\t$fields[2]\t$fields[3]\t.\t$fields[-1]\t$infofield\n"; +} +close(FH); +close(OUT);
