forked from Axolotl233/Simple_Script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Convert.Wig2Bed.pl
47 lines (43 loc) · 1.23 KB
/
Convert.Wig2Bed.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
#!/usr/bin/perl -w
sub usage (){
die qq(
#===========================================================================
# USAGE:/home/junzli_lab/yulywang/bin/BigWig2Bed.pl -h
# DESCRIPTION: -h : Display this help
# Test with Big2BedGraph Results, 1-based here.
# Author: Wang Yu
# Mail: yulywang\@umich.edu
# Created Time: Fri 29 Jan 2016 12:12:33 PM EST
#===========================================================================
)
}
use strict;
use warnings;
use Getopt::Std;
$ARGV[0] || &usage();
our ($opt_h);
getopts("h");
my $position = 0;
my $chr = "";
my $step = 1;
my $span = 1;
my $map = 0 ;
while(my $line = <>){
chomp $line;
if($line =~/variableStep\s+?chrom=([\dXMa-zA-Z]+)\s+?span=(\d+)/){
$chr = $1;
$span = $2 -1;
}
elsif($line =~/variableStep\s+?chrom=([\dXMa-zA-Z]+)/){
$chr = $1;
$span = 0 ; # change every new chr
}
else{
($step,$map) = split(/\s+/,$line);
$map = int($map*150+0.5)/150;
print "$chr\t$step\t",$step+$span,"\t$map\n";
$step = 0;
#$span = 0; # span does not change, if they are marked
$map = 0;
}
}