-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_covMerge.pl
executable file
·53 lines (44 loc) · 1.43 KB
/
run_covMerge.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl -w
#
# run_covMerge.pl
#
# Run the covMerge script on all files in a directory
#
# September 24, 2013
# By Liz Cooper
use strict;
my ($USAGE) = "\n$0 <ref.cov> <pileup_dir>
\tref.cov = The reference pileup file created by makeRefpileup.pl
\tpileup.dir = The path to the folder where all individual pileup files are located\n
\tIMPORTANT: THIS SCRIPT IS A WRAPPER FOR covMerge.pl - CHECK THE PATH AT LINE 35 TO MAKE SURE IT IS CORRECT!!!\n\n";
unless (@ARGV) {
print $USAGE;
exit;
}
my ($reffile, $pileupdir) = @ARGV;
my $origfile = $reffile;
# Check the length of the starting reference file
my $line_count = `wc -l $reffile`;
$line_count =~ s/^\s{1,}//;
my $start_length = ((split(/\s{1,}/, $line_count))[0]);
my @pileup_files = glob("$pileupdir*.pileup");
foreach my $file (@pileup_files) {
my @names = split(/\//, $file);
my $newfile = pop @names;
$newfile =~ s/pileup/cov/;
`perl covMerge.pl $reffile $file $newfile`;
# Unless the previous reference file is the Consensus.pileup file,
# Check the new file length, and remove the old reference file
unless($reffile =~ /$origfile/) {
my $new_count = `wc -l $newfile`;
chomp $new_count;
#print $new_count, "\n";
$new_count =~ s/^\s{1,}//;
my $new_length = ((split(/\s{1,}/, $new_count))[0]);
if ($new_length == $start_length) {
`rm $reffile`;
}
}
$reffile = $newfile;
}
exit;