[bio-tips] genomeCoverageBed: BAM2Wig

Last post  introduced the basic usage of genomeCoverageBed. Here is some update to deal with BAM2WIG processing. 

As the default output of genomeCoverageBed is formatted as following: 
chr start depth

However, WIG file format is different. The chromosome information is recorded in the header line:

variableStep chrom=chr1 span=1
Thus needed information exact work should be done. 
Here I share with you my homemade Perl script that manages to help you out. 
#!/usr/bin/perl -w
my ($in, $out) = @ARGV;
die $! && <DATA> unless (@ARGV ==2);

open IN, $in;
open OUT, ">$out";

print OUT "track type=wiggle_0 name="NAME" color=250,100,100 visibility=full autoScale=off viewLimits=0.0:99.0 yLineOnOff=off priority=10\n";
my $tmp = "NA";
while ( <IN> ) {
    chomp;
    my ($chr, $start, $v) = (split /\t/, $_)[0,1,2];
    my $tag = 0; 
    $tag = 1 if ($tmp eq $chr);
         if ($tag == 1 ){
             print OUT "$start\t$v\n";
         }
         elsif ($tag == 0){
              $tmp = $chr;
              print OUT "variableStep chrom=$chr span=1\n";
              print OUT "$start\t$v\n";
         }
}    
== End && reference
 
== afters
thx god and thx girlfriend

 

转载于:https://www.cnblogs.com/puriney/archive/2012/09/26/2703574.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值