Difference between revisions of "8) Generating five 100 AA long protein sequences and storing them in a FASTA file"
imported>Yeonsong Choi |
imported>Yeonsong Choi |
||
Line 83: | Line 83: | ||
<hr /> | <hr /> | ||
<p> </p> | <p> </p> | ||
+ | |||
+ | <p> </p> | ||
+ | |||
+ | <p>[[Yeonsong - bioinformatics]]</p> |
Revision as of 02:44, 19 May 2017
Contents
8) Generating five 100 AA long protein sequences and storing them in a FASTA file
- Idea
1. 20개의 amino acid를 랜덤하게 나타나게 하는 작업을 100번 반복
2. 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";
};