Exercise 4.3

From Earlham CS Department
Revision as of 13:00, 23 September 2009 by Erika (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Return to Week 1

Exercise 4.3 in Beginning Perl for Bioinformatics

#!/usr/bin/perl -w
use strict;

#Erika Phelps
#Sept 21, 2009
#Exercise 4.3

#Write a program that prints DNA (which could be in upper or lower case)
#in lowercase; write another that prints the DNA in uppercase. Use the 
#function tr///.

#The DNA (input both in upper and lower case)

my $DNA1 = 'ATGCCGGTAGAATATACCCGA';
my $DNA2 = 'cccggctaatatacgctag';

#Print the DNA to the screen

print "Here are the DNA sequences that have been provided:\n\n";

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

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

#Concatenating the DNA

my $DNA3 = "$DNA1$DNA2";

#Make a copy of the DNA for both upper and lower case

my $DNAlc = $DNA3;
my $DNAuc = $DNA3;

#Print the concatenated DNA all in lowercase 

$DNAlc =~ tr/ACGTacgt/acgt/;

print "The concatenated DNA is (lowercase):$DNAlc.\n\n";

#Print the concatenated DNA all in uppercase

$DNAuc =~ tr/ACGTacgt/ACGT/;

print "The concatenated DNA is (uppercase):$DNAuc.\n";

#End of program

exit;