File: split_wiggle.pl

package info (click to toggle)
augustus 3.5.0%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 777,052 kB
  • sloc: cpp: 80,066; perl: 21,491; python: 4,368; ansic: 1,244; makefile: 1,141; sh: 171; javascript: 32
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";