美文网首页生物信息学习perl
一个随机抽取序列的perl脚本

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

作者: 正踪大米饭儿 | 来源:发表于2017-11-03 15:45 被阅读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;
}

相关文章

网友评论

    本文标题:一个随机抽取序列的perl脚本

    本文链接:https://www.haomeiwen.com/subject/lvptmxtx.html