生成特定碱基比例的随机序列

​​​#!/usr/bin/perl 

use strict;

use warnings; 

use BioX::SeqUtils::RandomSequence; 

my $randomizer = BioX::SeqUtils::RandomSequence-》new(

    {

        l =》 10000,

        s =》 1,

        y =》 "dna",

        a =》 3,

        c =》 3,

        g =》 2,

        t =》 2

    }

);

print $randomizer-》rand_seq(), "n";

#!/usr/bin/perl -w 

use strict; 

my @seq = ( "A", "T", "C", "G" );

my $length = 10000; 

undef my %hash;

$hash{"A"} = int( $length * 0.3 );

$hash{"C"} = int( $length * 0.3 );

$hash{"G"} = int( $length * 0.2 );

$hash{"T"} = int( $length * 0.2 ); 

my $i = 0;

while ( $i 《 $length ) {

    my $word = $seq[ rand(@seq) ];

    if ( $hash{$word} ) {

        print "$word";

        $i++;

    }

    $hash{$word}--;

}

print "n";

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容