13
|
1 #!/usr/bin/perl -w
|
|
2
|
|
3 use Getopt::Long;
|
|
4
|
|
5 #Initialize values
|
|
6 my (@queries,@HEADER,$samples,@HEADER_OUT,$end,$samp);
|
|
7 GetOptions ("query|q=s" => \$queries);
|
|
8 if(!$queries){die "Usage: FORMAT_extract.pl <VCF> -query nSC
|
|
9 \n\n";}
|
|
10
|
|
11
|
|
12 open (VCF,"$ARGV[0]") or die "Usage: <VCF>";
|
|
13
|
|
14 while (<VCF>) {
|
|
15 if($_=~/^##/){print;next}
|
|
16 chomp;
|
|
17 @line=split(/\t/,$_);
|
|
18 if($line[0]=~/^#CH/){
|
|
19 print join ("\t",@line,$queries)."\n";
|
|
20 next}
|
|
21 @FORMAT=split(/:/,$line[8]);
|
|
22 @SAMPLE=split(/:/,$line[9]);
|
|
23 for($i=0;$i<@FORMAT;$i++){
|
|
24 if($FORMAT[$i] =~/^$queries$/){print join ("\t",@line,$SAMPLE[$i])."\n";next}
|
|
25 }
|
|
26 }
|
|
27 close VCF;
|