Thread Übersetztung von DNA zu Protein für dummies (4 answers)
Opened by eraemien at 2010-01-06 22:35

Gast wer
 2010-01-07 17:10
#130197 #130197
ungetestet:
Code (perl): (dl )
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!C:/STRAWB~1/perl/bin/perl.exe -w
use strict;
use warnings;

my $proteinfile = "Protein";

print "Enter a file containing DNA or RNA:\n\n";

my $DNA = <STDIN>;
chomp $DNA;

if(-f $DNA)
{
  local $/=undef;
  open(DNAFILE, $DNA) or die "ERROR open File: $DNA ($!)\n";
  $DNA = <DNAFILE>;
  close DNAFILE;
}
else
{
  print "File not found\n";
  print "using \"$DNA\" as sequence \n\n";
}
$DNA =~ s/\s//g;

#Überprüfen ob file DNA oder RNA enthält
my $i_DNA = $DNA=~tr/ACTG//;
my $i_RNA = $DNA=~tr/U//;
my $i_RNA += $i_DNA; #Da die RNA aus allen U plus den anderen Basen besteht

#wenn nun $i nicht der Länge der Sequenz entspricht, war mindestens 1 Element kein Nukleotid
if($i_DNA == length $DNA)
{ print "Sequence successfully identified as DNA\n\n"; }
elsif($i_RNA == length $DNA)
{ print "Sequence succesfully identified as RNA\n\n"; }
else
{
  print "Sequence is whether DNA nor RNA\n\n";
  print "cannot continue!\n\n";
  exit();
}



#DNA wird in RNA umgeschrieben
(my $RNA = $DNA) =~ s/T/U/ig;

#print "The RNA sequence is:\n\n";
#print "$RNA\n\n";

#unpack kann auch als alternative zu split verwendet werden wobei dann "A1" x length $RNA benutzt würde
my @triplets = unpack("A3" x (length ($RNA)/3), $RNA);


#Initialisierung der CODONS
my %CODONS=();
my %TRIPLETS=();
$CODONS{ala}={letter=>'A', count=>0};
  $TRIPLETS{GCU}=$CODONS{ala};
  $TRIPLETS{GCC}=$CODONS{ala};
  $TRIPLETS{GCA}=$CODONS{ala};
  $TRIPLETS{GCG}=$CODONS{ala};
$CODONS{cys}={letter=>'C', count=>0};
  $TRIPLETS{UGU}=$CODONS{cys};
  $TRIPLETS{UGC}=$CODONS{cys};
$CODONS{asp}={letter=>'D', count=>0};
  $TRIPLETS{GAU}=$CODONS{asp};
  $TRIPLETS{GAG}=$CODONS{asp};
$CODONS{glu}={letter=>'E', count=>0};
  $TRIPLETS{GAA}=$CODONS{glu};
  $TRIPLETS{GAG}=$CODONS{glu};
$CODONS{phe}={letter=>'F', count=>0};
  $TRIPLETS{UUU}=$CODONS{phe};
  $TRIPLETS{UUC}=$CODONS{phe};
$CODONS{gly}={letter=>'G', count=>0};
  $TRIPLETS{GGU}=$CODONS{gly};
  $TRIPLETS{GGC}=$CODONS{gly};
  $TRIPLETS{GGA}=$CODONS{gly};
  $TRIPLETS{GGG}=$CODONS{gly};
$CODONS{his}={letter=>'H', count=>0};
  $TRIPLETS{CAU}=$CODONS{his};
  $TRIPLETS{CAC}=$CODONS{his};
$CODONS{ile}={letter=>'I', count=>0};
  $TRIPLETS{AUU}=$CODONS{ile};
  $TRIPLETS{AUC}=$CODONS{ile};
  $TRIPLETS{AUA}=$CODONS{ile};
$CODONS{lys}={letter=>'K', count=>0};
  $TRIPLETS{AAA}=$CODONS{lys};
  $TRIPLETS{AAG}=$CODONS{lys};
$CODONS{leu}={letter=>'L', count=>0};
  $TRIPLETS{CUU}=$CODONS{leu};
  $TRIPLETS{CUC}=$CODONS{leu};
  $TRIPLETS{CUA}=$CODONS{leu};
  $TRIPLETS{CUG}=$CODONS{leu};
  $TRIPLETS{UUA}=$CODONS{leu};
  $TRIPLETS{UUG}=$CODONS{leu};
$CODONS{met}={letter=>'M', count=>0};
  $TRIPLETS{AUG}=$CODONS{met};
$CODONS{asn}={letter=>'N', count=>0};
  $TRIPLETS{AAU}=$CODONS{asn};
  $TRIPLETS{AAC}=$CODONS{asn};
$CODONS{pro}={letter=>'P', count=>0};
  $TRIPLETS{CCU}=$CODONS{pro};
  $TRIPLETS{CCC}=$CODONS{pro};
  $TRIPLETS{CCA}=$CODONS{pro};
  $TRIPLETS{CCG}=$CODONS{pro};
$CODONS{gln}={letter=>'Q', count=>0};
  $TRIPLETS{CAA}=$CODONS{gln};
  $TRIPLETS{CAG}=$CODONS{gln};
$CODONS{arg}={letter=>'R', count=>0};
  $TRIPLETS{CGU}=$CODONS{arg};
  $TRIPLETS{CGC}=$CODONS{arg};
  $TRIPLETS{CGA}=$CODONS{arg};
  $TRIPLETS{CGG}=$CODONS{arg};
  $TRIPLETS{AGA}=$CODONS{arg};
  $TRIPLETS{AGG}=$CODONS{arg};
$CODONS{ser}={letter=>'S', count=>0};
  $TRIPLETS{AGU}=$CODONS{ser};
  $TRIPLETS{AGC}=$CODONS{ser};
  $TRIPLETS{UCU}=$CODONS{ser};
  $TRIPLETS{UCC}=$CODONS{ser};
  $TRIPLETS{UCA}=$CODONS{ser};
  $TRIPLETS{UCG}=$CODONS{ser};
$CODONS{thr}={letter=>'T', count=>0};
  $TRIPLETS{ACU}=$CODONS{thr};
  $TRIPLETS{ACC}=$CODONS{thr};
  $TRIPLETS{ACA}=$CODONS{thr};
  $TRIPLETS{ACG}=$CODONS{thy};
$CODONS{val}={letter=>'V', count=>0};
  $TRIPLETS{GUU}=$CODONS{val};
  $TRIPLETS{GUC}=$CODONS{val};
  $TRIPLETS{GUA}=$CODONS{val};
  $TRIPLETS{GUG}=$CODONS{val};
$CODONS{trp}={letter=>'W', count=>0};
  $TRIPLETS{UUG}=$CODONS{trp};
$CODONS{tyr}={letter=>'Y', count=>0};
  $TRIPLETS{UAU}=$CODONS{tyr};
  $TRIPLETS{UAC}=$CODONS{tyr};
$CODONS{stop}={letter=>'!STOP!', count=>0};
  $TRIPLETS{UAA}=$CODONS{stop};
  $TRIPLETS{UAG}=$CODONS{stop};
  $TRIPLETS{UGA}=$CODONS{stop};
  $TRIPLETS{UGG}=$CODONS{stop};

#Jedes Triplet wird nun ausgetauscht durch den 1-lettercode seiner Aminosäure
foreach $trip (@triplets)
{
  $TRIPLETS{uc($trip)}->{count}++;
  $trip = $TRIPLETS{uc($trip)}->{letter};
}

#Berechnung des prozentualen Vorkommen jeder Aminosäure
my $tot = keys(%CODONS);
$trip->{percent}=$_->{count}/$tot*100 for (values(%CODONS));

#Das ganze wird auf das File Protein geschrieben
open(PROTEINFILE , '>', $proteinfile) or die("ERROR open file ($proteinfile) ($!)\n");
print PROTEINFILE join( " " ,@triplets)."\n\n";
for (keys(%CODONS))
{ printf PROTEINFILE "%s = %1.2f%\n\n", $_, $CODONS{$_}->{percent}; }
close PROTEINFILE;

print "Proteinsequence written on 'Protein'\n\n";

View full thread Übersetztung von DNA zu Protein für dummies