Last active
August 29, 2015 14:07
-
-
Save davetang/3e9c8ae57eded71c84de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict; | |
use warnings; | |
my $usage = "Usage: $0 <bp> <seed>\n"; | |
my $num = shift or die $usage; | |
my $seed = shift or die $usage; | |
#set seed for reproducibility | |
srand($seed); | |
my $random_seq = random_seq($num); | |
print ">$num | $seed\n$random_seq\n"; | |
exit(0); | |
sub random_seq { | |
my ($num) = @_; | |
my @nuc = qw/ A C G T /; | |
my $seq = ''; | |
for (1 .. $num){ | |
my $rand_ind = int(rand(scalar(@nuc))); | |
$seq .= $nuc[$rand_ind]; | |
} | |
return($seq); | |
} | |
exit(0); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment