Revision as of 01:49, 20 May 2017 by imported>Yeonsong Choi
Idea
- 20개의 amino acid를 랜덤하게 나타나게 하는 작업을 100번 반복
- 1.의 코드를 5번 반복
- 반복작업은 for loop사용
- rand를 이용해서 chars안의 요소들을 랜덤하게 배치
Code
#!/usr/bin/perl
use strict;
use warnings;
my @chars=('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y');
my $random_string;
my $i;
for($i = 1; $i <=5 ; $i++)
{
print $i,".";
for(1..100)
{
$random_string = $chars[rand @chars];
print $random_string;
};
print "\n\n";
};
|
Result
Application
-
키보드로부터 입력을 이용해 amino acid 의 갯수와 반복횟수를 입력받아 원하는 sequence의 갯수와 sequence의 길이를 출력한다.
-
키보드로부터 입력을 받을때는 <STDIN>을 이용한다.
Code_application
#!/usr/bin/perl
use strict;
use warnings;
my @chars=('A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y');
my $random_string;
my $i;
my $repeat;
my $string_number;
print "Put in the number of times to repeat : ";
$repeat = <STDIN>;
print "Put in the number of sequence : ";
$string_number = <STDIN>;
for($i = 1; $i <= $repeat ; $i++)
{
print $i,".";
for(1..$string_number)
{
$random_string = $chars[rand @chars];
print $random_string;
};
print "\n\n";
};
|
Yeonsong - bioinformatics