por jalapea » 2015-05-12 01:25 @101
explorer, un buen día. Lo que llevo hasta el momento es:
#!/usr/bin/perl -w
# using a random number generator to randomly select bases to mutate
use strict;
use warnings;
# Declare the variables
# The DNA is chosen to make it easy to see mutations:
my (%secuencias) = 'TCACTCACTCACACCTCCCGCAGCTCACCTCCTCCCCACCCCAGCATGGCCGCGTCCACC', 'GGATGCTTATTATAGATCGACGCGACACCAGCGCCCGGTGCCAGGTTCTCCCCTGAGGC', 'GGAAGGTGGCGGTGGTGAAGGTGCAGGCCGTTGGGGCGGCTCAGAGGCAGAGTTCCAC';
my $i;
my $mutant;
# Seed the random number generator.
# time|$$ combines the current time with the current process id
srand(time|$$);
# Let's test it, shall we?
$mutant = mutate(%secuencias);
print "\nMutate secuencias\n\n";
print "\nHere is the original DNA:\n\n";
print "%secuencias\n";
print "\nHere is the mutant secuencias:\n\n";
print "%mutant\n";
# Let's put it in a loop and watch that bad boy accumulate mutations:
print "\nHere are 1000 more successive mutations:\n\n";
for ($i=0 ; $i < 1000 ; ++$i) {
%mutant = mutate(%mutant);
print "$mutant\n"; }
exit;
#########################
# Subroutines
#########################
# Notice, now that we have a fair number of subroutines, we
# list them alphabetically
# A subroutine to perform a mutation in a string of DNA
#
# WARNING: make sure you call srand to seed the
# random number generator before you call this function.
sub mutate {
my(%secuencias) = @_;
my(@geneticcode) = (
'TCA', # Serine 'S'
'TCC', # Serine 'S'
'TCG', # Serine 'S'
'TCT', # Serine 'S'
'TTC', # Phenylalanine 'F'
'TTT', # Phenylalanine 'F'
'TTA', # Leucine 'L'
'TTG', # Leucine 'L'
'TAC', # Tyrosine 'Y'
'TAT', # Tyrosine 'Y'
'TAA', # Stop '_'
'TAG', # Stop '_'
'TGC', # Cysteine 'C'
'TGT', # Cysteine 'C'
'TGA', # Stop '_'
'TGG', # Tryptophan 'W'
'CTA', # Leucine 'L'
'CTC', # Leucine 'L'
'CTG', # Leucine 'L'
'CTT', # Leucine 'L'
'CCA', # Proline 'P'
'CCC', # Proline 'P'
'CCG', # Proline 'P'
'CCT', # Proline 'P'
'CAC', # Histidine 'H'
'CAT', # Histidine 'H'
'CAA', # Glutamine 'Q'
'CAG', # Glutamine 'Q'
'CGA', # Arginine 'R'
'CGC', # Arginine 'R'
'CGG', # Arginine 'R'
'CGT', # Arginine 'R'
'ATA', # Isoleucine 'I'
'ATC', # Isoleucine 'I'
'ATT', # Isoleucine 'I'
'ATG', # Methionine 'M'
'ACA', # Threonine 'T'
'ACC', # Threonine 'T'
'ACG', # Threonine 'T'
'ACT', # Threonine 'T'
'AAC', # Asparagine 'N'
'AAT', # Asparagine 'N'
'AAA', # Lysine 'K'
'AAG', # Lysine 'K'
'AGC', # Serine 'S'
'AGT', # Serine 'S'
'AGA', # Arginine 'R'
'AGG', # Arginine 'R'
'GTA', # Valine 'V'
'GTC', # Valine 'V'
'GTG', # Valine 'V'
'GTT', # Valine 'V'
'GCA', # Alanine 'A'
'GCC', # Alanine 'A'
'GCG', # Alanine 'A'
'GCT', # Alanine 'A'
'GAC', # Aspartic Acid 'D'
'GAT', # Aspartic Acid 'D'
'GAA', # Glutamic Acid 'E'
'GAG', # Glutamic Acid 'E'
'GGA', # Glycine 'G'
'GGC', # Glycine 'G'
'GGG', # Glycine 'G'
'GGT', # Glycine 'G'
);
my($position) = randomposition(%sequencias);
my($newbase) = randomnucleotide(@geneticcode);
# Insert the random geneticcode into the random position in the DNA
# The substr arguments mean the following:
# In the string %secuencias at position $position change 1 character to
# the string in $newbase
substr(%secuencia,$position,1,$newbase);
return %secuencia; }
# A subroutine to randomly select an element from an array
# WARNING: make sure you call srand to seed the
# random number generator before you call this function.
sub randomelement {
my(@array) = @_;
return $array[rand @array];
}
# randomnucleotide
# A subroutine to select at random one of the four nucleotides
# WARNING: make sure you call srand to seed the
# random number generator before you call this function.
sub randomnucleotide {
my(@geneticcode) = (
'TCA', # Serine 'S'
'TCC', # Serine 'S'
'TCG', # Serine 'S'
'TCT', # Serine 'S'
'TTC', # Phenylalanine 'F'
'TTT', # Phenylalanine 'F'
'TTA', # Leucine 'L'
'TTG', # Leucine 'L'
'TAC', # Tyrosine 'Y'
'TAT', # Tyrosine 'Y'
'TAA', # Stop '_'
'TAG', # Stop '_'
'TGC', # Cysteine 'C'
'TGT', # Cysteine 'C'
'TGA', # Stop '_'
'TGG', # Tryptophan 'W'
'CTA', # Leucine 'L'
'CTC', # Leucine 'L'
'CTG', # Leucine 'L'
'CTT', # Leucine 'L'
'CCA', # Proline 'P'
'CCC', # Proline 'P'
'CCG', # Proline 'P'
'CCT', # Proline 'P'
'CAC', # Histidine 'H'
'CAT', # Histidine 'H'
'CAA', # Glutamine 'Q'
'CAG', # Glutamine 'Q'
'CGA', # Arginine 'R'
'CGC', # Arginine 'R'
'CGG', # Arginine 'R'
'CGT', # Arginine 'R'
'ATA', # Isoleucine 'I'
'ATC', # Isoleucine 'I'
'ATT', # Isoleucine 'I'
'ATG', # Methionine 'M'
'ACA', # Threonine 'T'
'ACC', # Threonine 'T'
'ACG', # Threonine 'T'
'ACT', # Threonine 'T'
'AAC', # Asparagine 'N'
'AAT', # Asparagine 'N'
'AAA', # Lysine 'K'
'AAG', # Lysine 'K'
'AGC', # Serine 'S'
'AGT', # Serine 'S'
'AGA', # Arginine 'R'
'AGG', # Arginine 'R'
'GTA', # Valine 'V'
'GTC', # Valine 'V'
'GTG', # Valine 'V'
'GTT', # Valine 'V'
'GCA', # Alanine 'A'
'GCC', # Alanine 'A'
'GCG', # Alanine 'A'
'GCT', # Alanine 'A'
'GAC', # Aspartic Acid 'D'
'GAT', # Aspartic Acid 'D'
'GAA', # Glutamic Acid 'E'
'GAG', # Glutamic Acid 'E'
'GGA', # Glycine 'G'
'GGC', # Glycine 'G'
'GGG', # Glycine 'G'
'GGT', # Glycine 'G'
);
# scalar returns the size of an array.
# The elements of the array are numbered 0 to size-1
return randomelement(@geneticcode);
}
# randomposition
# A subroutine to randomly select a position in a string.
# WARNING: make sure you call srand to seed the
# random number generator before you call this function.
sub randomposition {
my($string) = @_;
# The whole expression returns a random number between 0 and
length-1, which is how the positions in a string are numbered in Perl.
return int rand length $string;
}
Pero no he podido correrlo.