$a=23532; #开始位置
$b=31236919; #结束位置
$LENGTH=$b-$a+1;
$num=int($LENGTH/5000);
#print "$LENGTH\n$num\n";
$counts=$num-1;
#print "$counts\n";
$start=23532;#开始位置
$end=23532;#开始位置
for ($i=1;$i<=$counts;$i+=1){
$end=$start+5000; #bin的大小
$BIN{$n}=[$start,$end];
#print "$chr\t$start\t$end\n";
$start+=1000; #每次滑动1kb
$n+=1;
}
$n+=1;
$BIN{$n}=[$end,$LENGTH{$chr}];
#print "$_\t$end\t$LENGTH{$_}\n";
open PEAK, "$ARGV[0]";
while(<PEAK>){
chomp;
@temp=split /\t/,$_;
#print "@temp\n";
$peak{$temp[0]}=$temp[1];
}
foreach(keys %BIN){
$n=0;# VERY IMPORT, set $n =0 ,every cycle!!!!
my($peak_start,$peak_end)=@{$BIN{$_}};
#print "$peak_start\t$peak_end\n";
foreach(keys %peak){
#print "$peak{$_}\n";
my($a1,$a2,$b1)=($peak_start,$peak_end,$peak{$_});
#print "$a1\t$a2\t$b1\n";
if($a1<=$b1 and $a2>=$b1){
$n+=1;
}
}
$peak_loc_chain{$_}{"$peak_start\t$peak_end"}=$n;
}
open OU, ">$ARGV[1]";
foreach $CHR (sort {$a<=>$b} keys %peak_loc_chain ){
foreach(sort{$a<=>$b} keys %{$peak_loc_chain{$CHR}}){
print OU "$CHR\t$_\t$peak_loc_chain{$CHR}{$_}\n";
}
}
滑动窗口,并计算每一个窗口的SNP个数
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...