-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReverse complement of DNA
More file actions
50 lines (41 loc) · 1.21 KB
/
Reverse complement of DNA
File metadata and controls
50 lines (41 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/perl
print"\n\n....Reverse compliment Program....\n\n";
$dna=ATGCTTGGACATAGA;
$rev=reverse $dna;
$rev=~tr/ATGC/TACG/; # translates all characters of Search List into the corresponding characters of Replacement List.
print "Original dna sequence: $dna \n";
print "Reverse compliment: $rev \n\n";
#For user input
print "\n\t********** GET REVERSE COMPLEMENT OF DNA **********\n\n";
print "PLEASE TYPE THE FILENAME OF THE DNA SEQUENCE := ";
$dnafilename = <STDIN>;
chomp $dnafilename;
unless ( open(DNAFILE, $dnafilename) )
{
print "Cannot open file \"$dnafilename\"\n\n";
exit;
}
@DNA = <DNAFILE>;
close DNAFILE;
$DNA = join( '', @DNA);
$DNA =~ s/\s//g;
print "\nTHE ORIGINAL DNA SEQUENCE :=\n$DNA\n\n";
@DNA = split( '', $DNA );
print"REVERSE COMPLEMENT OF THE DNA SEQUENCE :=\n";
foreach $nucleotide(reverse(@DNA)) {
if ($nucleotide =~ /a/i) {
print "T";
print WRITE "T";
} elsif ($nucleotide =~ /t/i) {
print "A";
print WRITE "A";
} elsif ($nucleotide =~ /g/i) {
print "C";
print WRITE "C";
} elsif ($nucleotide =~ /c/i) {
print "G";
print WRITE "G";
} else {
die "$0: Bad nucleotide! [$nucleotide]\n\n";
}
}