File: split_wiggle.pl

package info (click to toggle)
augustus 3.2.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 289,676 kB
  • sloc: cpp: 48,711; perl: 13,339; ansic: 1,251; makefile: 859; sh: 58
file content (35 lines) | stat: -rwxr-xr-x 861 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl

# split a wiggle file in single contig files

my $usage = "split_wiggle.pl in.wig outputPath prefix\n";

if (@ARGV != 2) {
    print $usage;
    exit;
}

$inFile = $ARGV[0];
$outPath = $ARGV[1];
if(defined($ARGV[2])){
  $prefix = $ARGV[2];
}else{$prefix="split_";}
$outFile = $outPath."/".$prefix;

open(IN, "<", $inFile) or die "Could not open file $inFile!\n";
$counter = 0;
while(<IN>){
  if($_=~m/track name/){$headerLine = $_;
  }elsif($_=~m/variableStep/){
     if($counter>=1){
	close(OUT) or die "Could not close File $thisFile!\n";
     }
	$counter = $counter + 1;
	$thisFile = $outFile.$counter;
	open(OUT, ">", $thisFile) or die "Could not open File $thisFile!\n";
	print OUT $headerLine;
	print OUT $_;
  }else{print OUT $_;}
}
close(OUT) or die "Could not close file $outFile\n";
close(IN) or die "Could not close file $inFile\n";