8. Randomly generate five 100 AA long protein sequences and store them in a FASTA file MJ

From Biolecture.org

Idea

Using 'rand' and 'for' functions, I generate 5 different random sequences and store them in a text file.

Code

#!/usr/bin/perl
use strict;
use warnings;

my @aminoacid=('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y');
my @random_sequence;
my $amino;

for(my$i = 1; $i <=5 ; $i++)
{
    print $i,".";
    for(my$n = 1; $n <= 100; $n++)
    {
        $amino = $aminoacid[rand @aminoacid];
        @random_sequence[$n] = $amino;
    };
    print @random_sequence[1..100], "\n\n";
    open(FILE, ">>Randomsequences.txt");
    print FILE @random_sequence[1..100], "\n";
    close(FILE);
};
exit;

Result

 

[[1]]