Mercurial > repos > fcaramia > jointsnvmix
comparison jsm_to_vcf.pl @ 0:a1034918ab9b draft
Uploaded
author | fcaramia |
---|---|
date | Thu, 20 Jun 2013 00:03:08 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a1034918ab9b |
---|---|
1 die qq( | |
2 Bad numbr of inputs | |
3 | |
4 ) if(!@ARGV); | |
5 | |
6 my $input=$ARGV[0]; | |
7 my $vcf=$ARGV[1]; | |
8 | |
9 | |
10 # Convert output to VCF format | |
11 open(FH, $input) or die "Couldn't open jsm file $input!\n"; | |
12 open(OUT, ">$vcf") or die "Couldn't create vcf file $vcf!\n"; | |
13 | |
14 # print the vcf format we are using | |
15 print OUT "##fileformat=VCFv4.1\n"; | |
16 | |
17 # grab header which is the first line after the comment lines which start with ## | |
18 my $header = <FH>; | |
19 while(grep(/^##/, $header)) | |
20 { | |
21 $header = <FH>; | |
22 } | |
23 my @head = split("\t", $header); | |
24 | |
25 print "Converting jsm output to vcf\n"; | |
26 # vcf header is | |
27 # #CHROM POS ID REF ALT QUAL FILTER INFO | |
28 print OUT "#CHROM\tPOS\tID\tREF\tALT\tQUAL\tFILTER\tINFO\n"; | |
29 # for each line in jsm transform to vcf, any columns not in vcf concatenate them | |
30 # together and place them in the info column | |
31 while (my $line = <FH>) | |
32 { | |
33 chomp $line; | |
34 my @fields = split("\t", $line); | |
35 # create info column | |
36 # tumor_name=MH208_TUMOR;normal_name=MH208_LIVER;...;n_alt_sum=702 | |
37 my @info; | |
38 for(my $index = 4; $index < $#fields; $index++) | |
39 { | |
40 push @info, "$head[$index]=$fields[$index]"; | |
41 } | |
42 my $infofield = join(";", @info); | |
43 $fields[-1] = "PASS"; | |
44 | |
45 # print the line | |
46 print OUT "$fields[0]\t$fields[1]\t.\t$fields[2]\t$fields[3]\t.\t$fields[-1]\t$infofield\n"; | |
47 } | |
48 close(FH); | |
49 close(OUT); |