$ vim 110302.perl
a
1 use strict;
2 use warnings;
3
4 #Calculating the reverse complement of a strand od DNA
5
6 # The DNA
7 my $DNA = 'ACGGGAGGACGGGGAAAAATTACTACGGCATTAGC';
8
9 #Print the DNA onto the screen
10 print "Here is the starting DNA:\n\n";
11
12 print "$DNA\n\n";
13
14 #Calculate the reverse complement
15 #Warning : this attempt will fail!
16 #
17 #First, copy the DNA into new variable $revcom
18
19 my $revcom = reverse $DNA;
20
21 #Nexxt substitute all bases by their complements,
22 #A->T, T->A, G->C, C->G
23
24 $revcom =~ s/A/T/g;
25 $revcom =~ s/T/A/g;
26 $revcom =~ s/G/C/g;
27 $revcom =~ s/C/G/g;
28
29
30 #Print the reverse complement DNA onto the screen
31 print "Here is the reverse complement DNA:\n\n";
32
33 print "$revcom\n";
34
35 print "\nThat was a bad algorithm, and the reverse complement was wrong!\n";
36 print "Try again...\n\n";
37
38 #Make a new copy of the DNA
39 my $revcom = reverse $DNA;
40 $revcom =~ tr/ACGTacgt/TGCAtgca/;
41
42 #Print the reverse complement DNA onto the screen
43 print "Here is the reverse complement DNA:\n\n";
44
45 print "$revcom\n";
46 print"\nThis time ist warked!!\n\n";
Esc
$ perl 110302.perl
Here is the starting DNA:
ACGGGAGGACGGGGAAAAATTACTACGGCATTAGC
Here is the reverse complement DNA:
GGAAAAGGGGAAGAAAAAAAAGGGGGAGGAGGGGA
That was a bad algorithm, and the reverse complement was wrong!
Try again...
Here is the reverse complement DNA:
GCTAATGCCGTAGTAATTTTTCCCCGTCCTCCCGT
This time ist warked!!
素敵過ぎる♪♪♪