Exercise 4.3 D

From Earlham CS Department
Revision as of 11:22, 18 December 2009 by Damian (talk | contribs) (New page: Return to Aug 30-Sept 5 <pre> #!/usr/bin/perl -w use strict; #Damian Almiron #Ex 4-3 #Pseudocode #Write a program that prints DNA (that could be in either upper- or lower #cas...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Return to Aug 30-Sept 5


#!/usr/bin/perl -w

use strict; 

#Damian Almiron

#Ex 4-3 

#Pseudocode

#Write a program that prints DNA (that could be in either upper- or lower #case
#originally) in lowercase (actg).

#Also, write a program that prints the DNA (that could be in either #upper- or 
#ower #case originally) in uppercase (ACTG). Use the

#function tr///. 

#The DNA variables (upper and lower case) 

my $DNA1 = 'ACTGACTGACTGACTACTGACTGACTGACTG';

my $DNA2 = 'actgactgactgactgactgactgactgactgactg'; 

#Print the DNAs 

print "Here are our original DNA sequences in upper and lower case:\n\n";

print "DNAuppercase:$DNA1.\n\n";

print "DNAlowercase:$DNA2.\n\n"; 

#Make copies

my $DNAU1 = $DNA1;

my $DNAU2 = $DNA2;

my $DNAL1 = $DNA1;

my $DNAL2 = $DNA2; 
 

#Turn both DNA strands in uppercase only and print. 

$DNAU1 =~ tr/ACGTacgt/ACGT/;

$DNAU2 =~ tr/ACGTacgt/ACGT/; 

print "The DNA strands are in uppercase.\n\n”;

print “DNA1:$DNAU1.\n\n";

print “DNA2:$DNAU2.\n\n”; 

#Turn both DNA strands in lower case only and print.

$DNAL1 =~ tr/ACGTacgt/acgt/;

$DNAL2 =~ tr/ACGTacgt/acgt/; 

print "The DNA strands are in lowercase.\n\n";

print “DNA1:$DNAL1.\n\n";

print “DNA2:$DNAL2.\n\n”; 
 

#The End 

exit;