Hi all,
I want to mutate my DNA $DNA between 174 and 249, and save it in file, the user will give the name of the file.
I have probleem in the mutation of DNA
########################################################
#!/usr/bin/perl
use strict;
use warnings;
print "file name: ";
$file = <STDIN>;
open FH, ">$file";
my $DNA = "GCTTACGGGAGTTGCCTGGGCCAGAGCGTCATTCGGTGGGGGTACATGGATCCGATAGACTAGCGCGTACTCCATCCTCGGGAAGAAAAGCATGTAGCGCGTCGGGCTGCTGCACGCTCGGGCATGGCGACTCCTACCGATACTCTAAAACCCTGGAAGTATACGTTATTCATAGGTGCACTTCTTCTGGTTATATTGATAGAAGGCGTAAACAGTCTACTCTCGAGTACACGCGACCAGGGCGCATTCAGATTTACTCGATGTATTAGAGTGCACAGCCCCATCAACGTCTTGATCGTTCAACTGCTCTCGGGCTCGCGCTGCCATTAAACAGTTCACGGCAGGCGCCCTGGGGATGCGGCGCATCAAGGCACCGGGACCGTCCGTATTTTCCCCATTAAGTTACGCATCTCTATAGTGGCGTTATACGACTAGAGTGTAATGATGATTTCCGACGCTCGTCCGAAGTATAAAAAGGCTCATTTAACTCGAGTCGTTACCTATTTCCTCCGGTGAGATCGTTCTGTCATTGCGCTCAGTCTTGGGTTTATTGCCTTCCTAATCGGTCGGCCTGCTTATGGCTCCACTCACTGCAACATGCTAATGTATAAGCTTCCACAAAACTGTGACTTGGTTCGATTGACCCCTATGCAGCATTTTTGTGTCCCCCTCGTCGACGACAATGTGCTAGCCATGCACCTGGGAACGAGAGGACGGGCTAACAACACGCTTGGCTTAATGACTGCCTTGTCTCCGGACCGTAGAACATTGACGATTACGGGTTCGGGATAGTGACGTTCACTTTATGCCTCAAACTTCAACGGACCCCGTCATATGGGTGGGTGGAGGGTGCTTCCGTGACCGTATGCACGTTAGTGGAACTCAGTCGACGACCCCCGGGGTTACAAACCCCACACAGGGATCCCAAAGTCGTTTAATGGAGGGGTAGCCTCTGCCCCTATACTAGATAAAGCCACTTCGAGTGATGCCAGTAGACCAACCCCGCGTTTCCACAGGCGAAAGGATCTAGGAGGTCACCCTCGAACCGCCTGATCACTCCCTGAGGCCCTTTACGCGGGGAGGCTTCGGCTTCTTTTCACCAGCCAATATGCAAAGATTTTTCTAAGCTAGATTCTGAGCTAACCTACGCATTGATGTGTTGCTTAAATTACCCAGCCACTTTACCAAGCATCCCGCAGCTGTCACCGCCTGGGTGATCTGTGCCGTTTGACGGTTTACTTCCTTGCATGGCGGTGCGCAATGACCTAGAGTGAGACGATTCGGTAATAACCGCATACCGCATCCGTGAGAGTCTGCTCACTGCTCCAGCCTCAAACAGTATTTGTAAGATTTAATAGACGGTGGCAAATTAATCCATAAACCGAAGATGAGCGACATAGACGCAAGTCATACTGAACACCGTCCCAGTTGCCAAGTAGCTATCATGTCCACTAATACAGTGGACGGCAGATGTAGGGCCCTCTGATCCCACGTCTCGGCAACACTGCAGTTTGCAACACAACGATGGGATCGACTGGCGCATCGAGCCACGACCGTACTACTAATTTCAGGAGTTGTGGTTGGAGAGTCGGAGCACCCTATATGGCATCATGCGCCGAAGATAAGGGGGCCGGGGATTCAACGACTCCTCGTATGTAGTCCTGGCCGCTCAAGTTGTCTCGCTAGGATATGCAACAGATGATCCTCTCGCAACACCGAGACGAAAGGCGGCTTGTACTAGCCCTACACCCGCAAGCGGCGACTAGTCAGCGCGCTGCGCATACGATATCTGCGATTGAAGTAAAATTCAAAGCATGTCCAAGTACAGCTATATGCGAGCTCGATAAGGTACTAGCCAGGGCTCTTGTTCTCTTGGTCAGTACTACCGGGTCCAGATTGAAGCAGGGTCTGATTGCGTGCATTCATGTCACTCATGATGGAATATTGCTCCGGCTGTTGCACCTCAGAGCCATGCCACTCTCAGGTTAATAGTCAAGCCACTCTCTTGGACCATCCAGTCCCTCCTTATAGGATCAGACGGGTTCTTTCTGCCGACTGAACCGCAACTCACTTCAACCTTCTGTGATCCAATGTTCCGCCGGTGCCCCTGAAAGAAAGTGGGCTGTAGTGGTAGGGCAAGTCCACTCCTCTGGCCCGGGTTTGTTGAACGGAAGTACGAAGCATTACGTCTCGTTATACGTAGTTACCTAGGGCAGATACGACATGCGTGCCCATGTCAACTGTGATAGAGCGGAAGGTGCCAATAATACAGACACAGCACCGCTCGCAGCGTAGGAACCACACGTTGTAATTACCAGTTCTCAACTCCCTCACTTTCCGCGGCTAATCATATATATAGTATTGCGGTCGTATCGTCCAAAACTGTCCGGACCATAGACATGCCCGCGGAATATAACAACAAGGTTCAGCGGGTCGCGAGGGGAGAAGTCAGTGAAATCCAAAAATCAATTTCTGCACAACTCCTTTCCTAGACGAGACG";
my @positions = qw ('174''175' '176' '177' '178' '179' '180' '181' '182' '183' '184' '185' '186' '187' '188' '189''190' '191' '192' '193' '194' '195' '196' '197' '198' '199' '200' '201' '202' '203' '204' '205' '206' '207' '208' '209''210' '211' '212' '213' '214' '215' '216' '217' '218' '219' '220' '221' '222'
'223' '224' '225' '226' '227' '228''229' '230' '231' '232' '233' '234' '235' '236' '237' '238' '239' '240' '241' '242' '243' '244' '245' '246' '247''248' '249') ;
my $mutated_DNA = mutate_DNA($DNA, \@positions);
print "$DNA imutates to $mutated_DNA\n";
exit;
sub mutate_DNA {
my $DNA = shift;
my $position = shift;
my @bases = qw(A C G T);
foreach my $pos (@{$position}) {
print $pos ."\t";
my $base = substr ($DNA, $pos, 1);
print $base ."\t";
my $newbase;
do {
$newbase = $bases[rand @bases];
print FH "$newbase" ."\n";
} until ($newbase ne $base);
substr($DNA, $pos, 1) = $newbase;
}
return $DNA;
}
close FH;
I want to mutate my DNA $DNA between 174 and 249, and save it in file, the user will give the name of the file.
I have probleem in the mutation of DNA
########################################################
#!/usr/bin/perl
use strict;
use warnings;
print "file name: ";
$file = <STDIN>;
open FH, ">$file";
my $DNA = "GCTTACGGGAGTTGCCTGGGCCAGAGCGTCATTCGGTGGGGGTACATGGATCCGATAGACTAGCGCGTACTCCATCCTCGGGAAGAAAAGCATGTAGCGCGTCGGGCTGCTGCACGCTCGGGCATGGCGACTCCTACCGATACTCTAAAACCCTGGAAGTATACGTTATTCATAGGTGCACTTCTTCTGGTTATATTGATAGAAGGCGTAAACAGTCTACTCTCGAGTACACGCGACCAGGGCGCATTCAGATTTACTCGATGTATTAGAGTGCACAGCCCCATCAACGTCTTGATCGTTCAACTGCTCTCGGGCTCGCGCTGCCATTAAACAGTTCACGGCAGGCGCCCTGGGGATGCGGCGCATCAAGGCACCGGGACCGTCCGTATTTTCCCCATTAAGTTACGCATCTCTATAGTGGCGTTATACGACTAGAGTGTAATGATGATTTCCGACGCTCGTCCGAAGTATAAAAAGGCTCATTTAACTCGAGTCGTTACCTATTTCCTCCGGTGAGATCGTTCTGTCATTGCGCTCAGTCTTGGGTTTATTGCCTTCCTAATCGGTCGGCCTGCTTATGGCTCCACTCACTGCAACATGCTAATGTATAAGCTTCCACAAAACTGTGACTTGGTTCGATTGACCCCTATGCAGCATTTTTGTGTCCCCCTCGTCGACGACAATGTGCTAGCCATGCACCTGGGAACGAGAGGACGGGCTAACAACACGCTTGGCTTAATGACTGCCTTGTCTCCGGACCGTAGAACATTGACGATTACGGGTTCGGGATAGTGACGTTCACTTTATGCCTCAAACTTCAACGGACCCCGTCATATGGGTGGGTGGAGGGTGCTTCCGTGACCGTATGCACGTTAGTGGAACTCAGTCGACGACCCCCGGGGTTACAAACCCCACACAGGGATCCCAAAGTCGTTTAATGGAGGGGTAGCCTCTGCCCCTATACTAGATAAAGCCACTTCGAGTGATGCCAGTAGACCAACCCCGCGTTTCCACAGGCGAAAGGATCTAGGAGGTCACCCTCGAACCGCCTGATCACTCCCTGAGGCCCTTTACGCGGGGAGGCTTCGGCTTCTTTTCACCAGCCAATATGCAAAGATTTTTCTAAGCTAGATTCTGAGCTAACCTACGCATTGATGTGTTGCTTAAATTACCCAGCCACTTTACCAAGCATCCCGCAGCTGTCACCGCCTGGGTGATCTGTGCCGTTTGACGGTTTACTTCCTTGCATGGCGGTGCGCAATGACCTAGAGTGAGACGATTCGGTAATAACCGCATACCGCATCCGTGAGAGTCTGCTCACTGCTCCAGCCTCAAACAGTATTTGTAAGATTTAATAGACGGTGGCAAATTAATCCATAAACCGAAGATGAGCGACATAGACGCAAGTCATACTGAACACCGTCCCAGTTGCCAAGTAGCTATCATGTCCACTAATACAGTGGACGGCAGATGTAGGGCCCTCTGATCCCACGTCTCGGCAACACTGCAGTTTGCAACACAACGATGGGATCGACTGGCGCATCGAGCCACGACCGTACTACTAATTTCAGGAGTTGTGGTTGGAGAGTCGGAGCACCCTATATGGCATCATGCGCCGAAGATAAGGGGGCCGGGGATTCAACGACTCCTCGTATGTAGTCCTGGCCGCTCAAGTTGTCTCGCTAGGATATGCAACAGATGATCCTCTCGCAACACCGAGACGAAAGGCGGCTTGTACTAGCCCTACACCCGCAAGCGGCGACTAGTCAGCGCGCTGCGCATACGATATCTGCGATTGAAGTAAAATTCAAAGCATGTCCAAGTACAGCTATATGCGAGCTCGATAAGGTACTAGCCAGGGCTCTTGTTCTCTTGGTCAGTACTACCGGGTCCAGATTGAAGCAGGGTCTGATTGCGTGCATTCATGTCACTCATGATGGAATATTGCTCCGGCTGTTGCACCTCAGAGCCATGCCACTCTCAGGTTAATAGTCAAGCCACTCTCTTGGACCATCCAGTCCCTCCTTATAGGATCAGACGGGTTCTTTCTGCCGACTGAACCGCAACTCACTTCAACCTTCTGTGATCCAATGTTCCGCCGGTGCCCCTGAAAGAAAGTGGGCTGTAGTGGTAGGGCAAGTCCACTCCTCTGGCCCGGGTTTGTTGAACGGAAGTACGAAGCATTACGTCTCGTTATACGTAGTTACCTAGGGCAGATACGACATGCGTGCCCATGTCAACTGTGATAGAGCGGAAGGTGCCAATAATACAGACACAGCACCGCTCGCAGCGTAGGAACCACACGTTGTAATTACCAGTTCTCAACTCCCTCACTTTCCGCGGCTAATCATATATATAGTATTGCGGTCGTATCGTCCAAAACTGTCCGGACCATAGACATGCCCGCGGAATATAACAACAAGGTTCAGCGGGTCGCGAGGGGAGAAGTCAGTGAAATCCAAAAATCAATTTCTGCACAACTCCTTTCCTAGACGAGACG";
my @positions = qw ('174''175' '176' '177' '178' '179' '180' '181' '182' '183' '184' '185' '186' '187' '188' '189''190' '191' '192' '193' '194' '195' '196' '197' '198' '199' '200' '201' '202' '203' '204' '205' '206' '207' '208' '209''210' '211' '212' '213' '214' '215' '216' '217' '218' '219' '220' '221' '222'
'223' '224' '225' '226' '227' '228''229' '230' '231' '232' '233' '234' '235' '236' '237' '238' '239' '240' '241' '242' '243' '244' '245' '246' '247''248' '249') ;
my $mutated_DNA = mutate_DNA($DNA, \@positions);
print "$DNA imutates to $mutated_DNA\n";
exit;
sub mutate_DNA {
my $DNA = shift;
my $position = shift;
my @bases = qw(A C G T);
foreach my $pos (@{$position}) {
print $pos ."\t";
my $base = substr ($DNA, $pos, 1);
print $base ."\t";
my $newbase;
do {
$newbase = $bases[rand @bases];
print FH "$newbase" ."\n";
} until ($newbase ne $base);
substr($DNA, $pos, 1) = $newbase;
}
return $DNA;
}
close FH;