#!perl -w use strict; # testing chapter 2 ideas # # count the stars in $sky my $sky = "***************"; my $cnt = $sky =~ tr/*/*/; print "Stars in the sky: $cnt\n"; # dna sequence with * my $seq = ""; foreach ( qw/TAG**CAT*GCGC*ATAA GGCCGGCCAGGTCCA/ ) { print "Sequence: $_\n"; # count the nucleotides in $_ $cnt = tr/GC//; print "Count of gc: $cnt\t(", int(($cnt/length)*100), "%)\n"; $cnt = tr/AT//; print "Count of at: $cnt\t(", int(($cnt/length)*100), "%)\n"; # canonicalize to lower case ($seq = $_) =~ tr/A-Z/a-z/; print "Lower case: $seq\n"; # count the stars in $_ $cnt = tr/*/*/; print "Count of stars: $cnt\n"; # change non-alphas to single space ($seq = $_) =~ tr/a-zA-Z/ /cs; print "New sequence: $seq\n"; # bookkeeper -> bokeper ($seq = $_) =~ tr/a-zA-Z//s; print "New sequence: $seq\n"; } # cold-blooded, egg-laying vertebrates # class Reptilia, ie snake, lizard, # crocodile, turtle, or dinosaur, ... my $HOST; my $host = "Reptilian"; ($HOST = $host) =~ tr/a-z/A-Z/; print "The $HOST or the $host is similar\n"; $seq = ""; # dna sequence with N, and ambiguous codes foreach ( qw/TAGYNCASWTNGRCGCNATAA NGGKNCMGCBSGGTWCA/ ) { print "Sequence:\t$_\n"; ($seq = $_) =~ tr/ATGCYRSWKMBDHVN/TACGRYSWMKVHDBN/; print "Complement:\t$seq\n"; $seq = reverse $seq; print "Reversed:\t", $seq, "\n"; } __END__ tr/ATGCYRSWKMBDHVN/TACGRYSWMKVHDBN/; Base Name Bases Represented Complementary Base A Adenine A T T Thymidine T A U Uridine(RNA only) U A G Guanidine G C C Cytidine C G Y pYrimidine C T R R puRine A G Y S Strong(3Hbonds) G C S* W Weak(2Hbonds) A T W* K Keto T/U G M M aMino A C K B not A C G T V D not C A G T H H not G A C T D V not T/U A C G B N Unknown A C G T N