13
|
1 #!/usr/bin/perl -s
|
|
2 #Merge Softsearch results by chrom
|
|
3 if(!$ARGV[0]){die "Usage: <Sample.1.vcf>\n";}
|
|
4 my ($sample,$cmd);
|
|
5
|
|
6 #Get basename
|
|
7 $sample="$ARGV[0]";
|
|
8 $sample=~s/.[0-9(+)].out.vcf//;
|
|
9 $sample=~s/.[0-9(+)].pe.vcf//;
|
|
10
|
|
11 my $outfile=$sample;
|
|
12 $outfile.="out.vcf";
|
|
13 if( -e $outfile ){unlink($outfile)}
|
|
14 $cmd="ls $sample\*vcf";
|
|
15 my @samples=`$cmd`;
|
|
16 print "there are " .scalar(@samples)." samples\n";
|
|
17
|
|
18 open (OUT,">$outfile");
|
|
19 my $i=1;
|
|
20 my $tmp=@samples[$i];
|
|
21 open(TMP,"$tmp");
|
|
22 while (<TMP>){
|
|
23 print OUT if ($_=~/^#/);
|
|
24 }
|
|
25
|
|
26 open (OUT,">>$outfile");
|
|
27 my $chr;
|
|
28 for (my $i=0;$i<@samples;$i++){
|
|
29 my $tmp=@samples[$i];
|
|
30 open(TMP,"$tmp");
|
|
31 while (<TMP>){
|
|
32 unless (($_=~/^chrGL/)||($_=~/^#/)){print OUT $_;}
|
|
33 }
|
|
34 print "Done with $tmp";
|
|
35 unlink($tmp);
|
|
36 system("rm $tmp");
|
|
37 close TMP;
|
|
38 }
|
|
39 close OUT;
|