Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Perl program that takes a DNA sequence file and mutates it while maintaining the

ID: 3572025 • Letter: P

Question

Perl program that takes a DNA sequence file and mutates it while maintaining the same base pair distribution Once mutatedshuffled, find the similarity between the mutated and original DNA by calculating a score based on the following criteria: If a purine was mutated to another purine --> -1 If a pyrimidine was mutated to a pyrimidine --> -1 If a purine was mutated to a pyrimidine or vise versa --> -2 If no change occurred --> 0 Print out the score for the user to see. Also print out the original and mutated sequences aligned base pair by base pair

Explanation / Answer

my $mystring; my $nt;

print "Please enter the file name: ";

chomp (my $myfilename = <>);

open(SeqFile, $filename) or die $!;

while (my $line = <SeqFile>)

{ if ($line=~ /^>/)

{ my $header = $line; }

Else

{ $mystring = $mystring.$line;

$mystring = uc($mystring);

$mystring =~ s/s//g; }

}

my @mystring = split(//, $mystring);

print "The original sequence is: $mystring ";

my $shuffle_sequence = shuffle(@mystring);

print "The shuffle sequence is: ", $shuffle_sequence , " "; my $totalscore;

foreach(0 .. length($mystring) - 1)

{ my $p = substr($string, $_, 1);

my $q = substr($shuf_seq, $_, 1);

$totalscore = scoring($p, $mq);

$totalscore += $totalscore; print $totalscore;

}

print "This total mutation score is: $totalscore ";

#sub This is done to calculate the scoring of mutations #If purine --> purine: -1 #If pyrimidine --> pyrimidine: -1 #If purine --> pyrimidine (or vice versa): -2 #If no change: 0

sub scoring{ my ($l, $m) = sort @_;

my %totalscores; $totalscores{'A'}{'G'} = -1;

$totalscores{'A'}{'T'} = -2; $totalscores{'A'}{'C'} = -2; $totalscores{'G'}{'T'} = -2; $totalscores{'C'}{'G'} = -2;

$totalscores{'C'}{'T'} = -1;

$totalscores{'A'}{'A'} = 0; $totalscores{'T'}{'T'} = 0; $totalscores{'C'}{'C'} = 0; $totalscores{'G'}{'G'} = 0; return $totalscores{$l}{$m}; }

#sub    This is done here to shuffle the string sub shuffle

{ my (@createarray) = @_;

my (@shuffle) = ();

while (@createarray)

{ my $offset = int rand @createarray;

my $newelement = $createarray[$offset];

push (@shuffle, $newelement);

splice (@createearray, $offset, 1);

}

return @shuffle; }

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote