- 论坛徽章:
- 1
|
本帖最后由 ntwarren 于 2015-01-22 10:22 编辑
用这个吧,在我的机器上大概13秒完成计算,前提是基于观察,你的数据是按数字递增的.如果没有递增的话,就先要排序
#!/usr/bin/perl -w
use strict;
use warnings;
open FILE, '<','H3K4me1.bed'; #启动子区域这个文件输入到FILE中
open AFILE, '<','promoter.txt'; #H3K18ac.bed文件输入到AFILE中
open OUT,'>','readH3K18ac.bed'; #最后的结果输出到readH3K18ac.bed中
my $t = time();
my @array1 = <FILE>;
my @array2 = <AFILE>;
my $i=0;
for my $array2 (@array2){
chomp $array2;
my @a2 = split /\s+/,$array2;
my $cnt1 = 0;
for(;$i<@array1;$i++){
chomp $array1[$i];
my @a1 = split /\s+/, $array1[$i];
if($a1[2]>=$a2[4]){
if( $a1[2]<=$a2[5]){
$cnt1++ if $a1[0] eq $a2[2] and $a1[1] eq $a2[3];
} else{
last;
}
}
}
print OUT "@a2 $cnt1\n";
}
my $e = time();
print ($e - $t);
回复 3# 13171082187
|
|