生物信息学习perl

一个随机抽取序列的perl脚本

2017-11-03  本文已影响27人  正踪大米饭儿

一个从 fasta 文件中随机抽取序列的脚本。

#!/usr/bin/perl -w
use strict;

open IN, $ARGV[0] || die  $!;
$/ = ">";<IN>;
my %random_num = &random(37843083);

while(<IN>){
    chomp;
    if (exists $random_num{$.} ){
        print ">$_";
    }else{
        next;
    }
}
close IN;

sub random{
    my $max = shift @_;
    my %hash;
    while ((keys %hash) < 10000000) {
        $hash{int(rand($max))} = 1;
    }
    return %hash;
}
上一篇 下一篇

猜你喜欢

热点阅读