perl 로 생물 돌연 변 이 를 실현 하 는 랜 덤 시 뮬 레이 션 프로그램 코드

프로그램 파일:test.pl

#!/bin/perl
# filename:test.pl
use strict; 
use warnings; 

#  
my $DNA="AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
"; 
my $i; 
my $mutant; 
srand(time|$$); 
$mutant=mutate($DNA); 
print "Mutate
". $DNA; 
print "Here is the original DNA:
"; 
print "$DNA
"; 
print "Here is the mutant DNA:

"; 
print "$mutant
"; 
print "Here are 10 more successive mutations:
"; 
for ($i=0;$i<10;++$i) 

   $mutant=mutate($mutant); 
   print "$mutant
"; 


# :  
sub randomposition 

   my($string)=@_; 
   return int(rand(length($string))); 
}
# :  
sub randelement 

  my(@array)=@_; 
  return $array[rand @array]; 


# : , ATGC  
sub randomnucleotide 

  my (@nucleotides)=qw/A T G C/; 
  return randelement(@nucleotides); 


# :  
sub mutate 

   my($dna)=@_; 
   my(@nucleotides)=qw(A T G C); 
   my($position)=randomposition($dna); 
   my($newbase)=randomnucleotide(@nucleotides); 
   substr($dna,$position,1,$newbase);#substr($string,$initial_position,$length,replacement substring) 
   return $dna; 
}
결 과 는 다음 과 같다.    F:\>perl\test.pl      Mutate      AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA      Here is the original DNA:      AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA      Here is the mutant DNA:      AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAA      Here are 10 more successive mutations:      ACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAA      ACAAAAAAAAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAATAAAAAAAAAAAAAAA      ACAAAAAAAAACAAAAAAAAAAAAATAAAAAAAAAAAAAAATAAAAAAAAAAAAAAA      ACAAAAAAAAACAAAAAAAAAAAAATAAAAAAAAAAAAAAATAAAAAAAAAAAAAAA      ACAAAAAAAAACAAAAAAAAAAAAATAAAAAAAAAAAAAAATAAAAAAAAAAAAAAA      ACAAAAAAAAACAAAAAAAAAAAAATAAAAAAAAAAAAAAATGAAAAAAAAAAAAAA      ACTAAAAAAAACAAAAAAAAAAAAATAAAAAAAAAAAAAAATGAAAAAAAAAAAAAA      ACTAAAAAAAACAAAAAAAAAAAAATAAGAAAAAAAAAAAATGAAAAAAAAAAAAAA      ACTAAAAAAAACAAAAAAAAAAAAATAAGAAAAAAAAAAAATGTAAAAAAAAAAAAA      ACTAAAAAAAACAAAAAAAAAAAAATAAGAAAAAAAAAAAATGTAAAAAAAAAAAAA    F:\>

좋은 웹페이지 즐겨찾기