annotate Perl/DNA_Transcription_Translation.pl @ 6:35d71348e81e draft

Uploaded
author dereeper
date Thu, 30 May 2024 12:12:30 +0000
parents e42d30da7a74
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
1 #!/usr/bin/perl
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
2
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
3 my $DNA= $ARGV[0];
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
4
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
5 @dna = $DNA;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
6 print "@dna[0]\t\t-> DNA\n";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
7
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
8
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
9 for ($i = 0 ; $i < length(@dna[0]); $i++ ) {
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
10 @c[$i] = substr( @dna[0], $i, 1);
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
11 #print "@c[$i]";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
12
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
13 if(@c[$i] eq 'A') {
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
14 $counterpart=$counterpart."T";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
15 $rna=$rna."A";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
16 }
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
17
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
18 elsif(@c[$i] eq 'T') {
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
19 $counterpart=$counterpart."A";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
20 $rna=$rna."U";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
21 }
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
22
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
23 elsif(@c[$i] eq 'C') {
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
24 $counterpart=$counterpart."G";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
25 $rna=$rna."C";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
26
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
27 }
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
28
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
29 elsif(@c[$i] eq 'G') {
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
30 $counterpart=$counterpart."C";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
31 $rna=$rna."G";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
32 }
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
33 }
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
34
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
35 print "$counterpart\t\t-> Counterpart of DNA\n";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
36 print "$rna\t\t-> RNA\n";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
37
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
38 my $j = 0;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
39 for ($i = 0 ; $i < length ($rna); $i = $i+3) {
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
40 @codon[$j] = substr( $rna, $i, 3);
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
41 print "@codon[$j] ";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
42 $j++;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
43 }
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
44
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
45 print "-> Codon\n";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
46
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
47 my(%genetic_code_table) = (
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
48
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
49 'UUU' => 'F',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
50 'UUC' => 'F',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
51 'UUA' => 'L',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
52 'UUG' => 'L',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
53 'CUU' => 'L',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
54 'CUC' => 'L',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
55 'CUA' => 'L',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
56 'CUG' => 'L',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
57 'AUU' => 'I',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
58 'AUC' => 'I',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
59 'AUA' => 'I',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
60 'AUG' => 'M',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
61 'GUU' => 'V',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
62 'GUC' => 'V',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
63 'GUA' => 'V',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
64 'GUG' => 'V',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
65 'UCU' => 'S',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
66 'UCC' => 'S',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
67 'UCA' => 'S',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
68 'UCG' => 'S',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
69 'CCU' => 'P',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
70 'CCC' => 'P',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
71 'CCA' => 'P',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
72 'CCG' => 'P',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
73 'ACU' => 'T',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
74 'ACC' => 'T',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
75 'ACA' => 'T',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
76 'ACG' => 'T',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
77 'GCU' => 'A',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
78 'GCC' => 'A',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
79 'GCA' => 'A',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
80 'GCG' => 'A',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
81 'UAU' => 'Y',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
82 'UAC' => 'Y',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
83 'UAA' => '.',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
84 'UAG' => '.',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
85 'CAU' => 'H',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
86 'CAC' => 'H',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
87 'CAA' => 'Q',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
88 'CAG' => 'Q',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
89 'AAU' => 'N',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
90 'AAC' => 'N',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
91 'AAA' => 'K',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
92 'AAG' => 'K',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
93 'GAU' => 'D',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
94 'GAC' => 'D',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
95 'GAA' => 'E',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
96 'GAG' => 'E',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
97 'UGU' => 'C',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
98 'UGC' => 'C',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
99 'UGA' => '.',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
100 'UGG' => 'W',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
101 'CGU' => 'R',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
102 'CGC' => 'R',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
103 'CGA' => 'R',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
104 'CGG' => 'R',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
105 'AGU' => 'S',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
106 'AGC' => 'S',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
107 'AGA' => 'R',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
108 'AGG' => 'R',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
109 'GGU' => 'G',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
110 'GGC' => 'G',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
111 'GGA' => 'G',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
112 'GGG' => 'G',
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
113 );
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
114
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
115 for (my $j = 0 ; $j < length ($rna)/3; $j++) {
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
116
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
117 if( exists ($genetic_code_table{@codon[$j]}) ) {
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
118 @result[$j] = $genetic_code_table{@codon[$j]};
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
119 print "$genetic_code_table{@codon[$j]} ";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
120 }
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
121 }
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
122
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
123 open(RESULT, "+>result.txt") or die "Couldn't open file result.txt, $!";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
124
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
125 print RESULT @result;
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
126
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
127 close(RESULT) || die "Couldn't close file properly";
e42d30da7a74 Uploaded
dereeper
parents:
diff changeset
128 print "\n\n";