-
Notifications
You must be signed in to change notification settings - Fork 0
/
cleanup_cov.pl
executable file
·45 lines (37 loc) · 938 Bytes
/
cleanup_cov.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
#!/usr/bin/perl -w
#
# cleanup_cov.pl
#
# Clean up the merged coverage file for all populations
#
# September 25, 2013
# By: Liz Cooper
use strict;
# Get the input and output file from the command line
my ($USAGE) = "\n$0 <input.pileup> <output.clean>
\tinput.pileup = The merged coverage file from run_covMerge.pl
\toutput.clean = The name of the final coverage file to create\n\n";
unless (@ARGV) {
print $USAGE;
exit;
}
my ($input, $output) = @ARGV;
open (IN, $input) || die "\nUnable to open the file $input!\n";
open (OUT, ">$output") || die "\nUnable to open the file $output!\n";
while (<IN>) {
chomp $_;
my @pops = split(/\t/, $_);
my @temp = split(/,/, $pops[0]);
my $posID = $temp[0];
print OUT $posID, "\t";
my $new_string = '';
foreach my $pop (@pops) {
$pop =~ s/^$posID,//;
$new_string .= $pop . "\t";
}
chop $new_string;
print OUT $new_string, "\n";
}
close(IN);
close(OUT);
exit;