Difference between revisions of "Exercise 4.3"

From Earlham CS Department
Jump to navigation Jump to search
Line 3: Line 3:
 
<b>Exercise 4.3 in <i>Beginning Perl for Bioinformatics</i></b>
 
<b>Exercise 4.3 in <i>Beginning Perl for Bioinformatics</i></b>
 
<br><br>
 
<br><br>
<nowiki>
+
<code>
 
#!/usr/bin/perl -w
 
#!/usr/bin/perl -w
use strict;</nowiki>
+
use strict;
  
<nowiki>#Erika Phelps
+
#Erika Phelps
 
#Sept 21, 2009
 
#Sept 21, 2009
#Exercise 4.3</nowiki>
+
#Exercise 4.3
  
<nowiki>#Write a program that prints DNA (which could be in upper or lower case)
+
#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  
 
#in lowercase; write another that prints the DNA in uppercase. Use the  
#function tr///.</nowiki>
+
#function tr///.
  
 
#The DNA (input both in upper and lower case)
 
#The DNA (input both in upper and lower case)
Line 52: Line 52:
  
 
exit;
 
exit;
 +
</code>

Revision as of 12:04, 22 September 2009

Return to Week 1

Exercise 4.3 in Beginning Perl for Bioinformatics

  1. !/usr/bin/perl -w

use strict;

  1. Erika Phelps
  2. Sept 21, 2009
  3. Exercise 4.3
  1. Write a program that prints DNA (which could be in upper or lower case)
  2. in lowercase; write another that prints the DNA in uppercase. Use the
  3. function tr///.
  1. The DNA (input both in upper and lower case)

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

  1. 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";

  1. Concatenating the DNA

my $DNA3 = "$DNA1$DNA2";

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

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

  1. Print the concatenated DNA all in lowercase

$DNAlc =~ tr/ACGTacgt/acgt/;

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

  1. Print the concatenated DNA all in uppercase

$DNAuc =~ tr/ACGTacgt/ACGT/;

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

  1. End of program

exit;