Hi all,

I am try to make the script to tranlate DNA to protein.
I found the script in internet, and I tried to mix that script to make the result in the colums but I was not seccessful.
Would you please show me solve this problems. For Ex:

I hope Out put :
Ref_aa   Mul_aa  Ref_Pro   Mul_pro   infor
AGA	AAA      R          K       change
CCA	CCT      P          P       same
GCA	ACA      A          T       same
GCA	ACA      A          T       same
print "\n\n\t\#################### DNA 2 PROTEIN #################### \n\n";
print "This script will convert your DNA sequence to PROTEIN Sequence\n\n";
 print 'ENTER THE DNA SEQUENCE THAT COMPARE WITH TRIPRET_1ST := '; 
     	my $DNA_filename = <STDIN>; 
	chomp $DNA_filename;
	unless (open(DNAFILE, $DNA_filename)) 
	{ 
    	die 'Cannot open file "' . $DNA_filename . '"' . "\n\n"; 
	} 
@DNA = <DNAFILE>;
close DNAFILE;
$DNA = join( '', @DNA);
print " \nThe original DNA file is:\n$DNA \n";
$DNA =~ s/\s//g;


 open(BASE,">Ref_aa1.txt");
my $protein='';
my $codon;
for(my $i=0;$i<(length($DNA)-2);$i+=3)
{

$codon=substr($DNA,$i,3);
$protein.=&codon2aa($codon);
$out=$protein;
}
print (BASE "Ref_aa\t   Mul_aa \t Ref_Pro\t   Mul_pro\n ");
print BASE $DNA."\t";
print BASE $out."\n\n";
close (BASE);


sub codon2aa{
my($codon)=@_;
$codon=uc $codon;
my(%g)=(
'TCA'=>'S', #Serine
'TCC'=>'S', #Serine
'TCG'=>'S',  #Serine
'TCT'=>'S', #Serine 
'TTC'=>'F', #Phenylalanine 
'TTT'=>'F', #Phenylalanine 
'TTA'=>'L', #Leucine 
'TTG'=>'L', #Leucine 
'TAC'=>'Y', #Tyrosine 
'TAT'=>'Y', #Tyrosine 
'TAA'=>'_', #Stop 
'TAG'=>'_', #Stop 
'TGC'=>'C', #Cysteine 
'TGT'=>'C', #Cysteine 
'TGA'=>'_', #Stop 
'TGG'=>'W', #Tryptophan 
'CTA'=>'L', #Leucine 
'CTC'=>'L', #Leucine 
'CTG'=>'L', #Leucine 
'CTT'=>'L', #Leucine 
'CCA'=>'P', #Proline 
'CAT'=>'H', #Histidine 
'CAA'=>'Q', #Glutamine 
'CAG'=>'Q', #Glutamine 
'CGA'=>'R', #Arginine 
'CGC'=>'R', #Arginine 
'CGG'=>'R', #Arginine 
'CGT'=>'R', #Arginine 
'ATA'=>'T', #Isoleucine 
'ATC'=>'T', #Isoleucine 
'ATT'=>'T', #Isoleucine 
'ATG'=>'M', #Methionine 
'ACA'=>'T', #Threonine 
'ACC'=>'T', #Threonine 
'ACG'=>'T', #Threonine 
'ACT'=>'T', #Threonine 
'AAC'=>'N', #Asparagine 
'AAT'=>'N', #Asparagine 
'AAA'=>'K', #Lysine 
'AAG'=>'K', #Lysine 
'AGC'=>'S', #Serine#Valine 
'AGT'=>'S', #Serine 
'AGA'=>'R', #Arginine 
'AGG'=>'R', #Arginine 
'CCC'=>'P', #Proline 
'CCG'=>'P', #Proline 
'CCT'=>'P', #Proline 
'CAC'=>'H', #Histidine 
'GTA'=>'V', #Valine 
'GTC'=>'V', #Valine 
'GTG'=>'V', #Valine 
'GTT'=>'V', #Valine 
'GCA'=>'A', #Alanine 
'GCC'=>'A', #Alanine 
'GCG'=>'A', #Alanine 
'GCT'=>'A', #Alanine 
'GAC'=>'D', #Aspartic Acid 
'GAT'=>'D', #Aspartic Acid 
'GAA'=>'E', #Glutamic Acid 
'GAG'=>'E', #Glutamic Acid 
'GGA'=>'G', #Glycine 
'GGC'=>'G', #Glycine 
'GGG'=>'G', #Glycine 
'GGT'=>'G', #Glycine 
 ); 
if(exists $g{$codon})
{
return $g{$codon};
}
else
{
print STDERR "Bad codon \"$codon\"!!\n";
exit;
}

}

Edited 4 Years Ago by biojet: n/a

I don't see how your script decides whether to print 'change' or 'same'? What is the rule that determines this?

I sorry I forget to log out so I did not answer your question. I do not know how to do the script to print 'change' or 'same' in this case. If the Ref_pro = mul_pro print same. another print 'change'.

The rule that determin in this case :
If Ref_pro = mul_pro print 'same'
else print 'change'.

Edited 4 Years Ago by biojet: n/a

#!/usr/bin/perl;
use strict;
use warnings;

my %codon2proteins = build_hash();

my $dna_filename = 'dna.txt';

open my $dna_fh, '<', $dna_filename or die "Failed to open $dna_filename: $!";

while (my $rec = <$dna_fh>){
    chomp($rec);
    my ($ref, $mul) = split /\s+/, $rec;
    my $ref_pro = convert_codon2prot($ref);
    my $mul_pro = convert_codon2prot($mul);
    my $info = compare_pros($ref_pro, $mul_pro);
    print "$ref\t$mul\t$ref_pro\t$mul_pro\t$info\n";
}

sub compare_pros{
    my ($r, $m) = @_;
    if ($r eq $m){
        return 'same';
    }
    else {
        return 'change';
    }
}

sub convert_codon2prot{
    my ($codon) = @_;
    
    if(exists $codon2proteins{$codon}){
        return $codon2proteins{$codon};
    }
    else{
        die "Bad codon $codon!!\n";
    }
}

sub build_hash{
    my(%g)=(
            'TCA'=>'S', #Serine
            'TCC'=>'S', #Serine
            'TCG'=>'S',  #Serine
            'TCT'=>'S', #Serine 
            'TTC'=>'F', #Phenylalanine 
            'TTT'=>'F', #Phenylalanine 
            'TTA'=>'L', #Leucine 
            'TTG'=>'L', #Leucine 
            'TAC'=>'Y', #Tyrosine 
            'TAT'=>'Y', #Tyrosine 
            'TAA'=>'_', #Stop 
            'TAG'=>'_', #Stop 
            'TGC'=>'C', #Cysteine 
            'TGT'=>'C', #Cysteine 
            'TGA'=>'_', #Stop 
            'TGG'=>'W', #Tryptophan 
            'CTA'=>'L', #Leucine 
            'CTC'=>'L', #Leucine 
            'CTG'=>'L', #Leucine 
            'CTT'=>'L', #Leucine 
            'CCA'=>'P', #Proline 
            'CAT'=>'H', #Histidine 
            'CAA'=>'Q', #Glutamine 
            'CAG'=>'Q', #Glutamine 
            'CGA'=>'R', #Arginine 
            'CGC'=>'R', #Arginine 
            'CGG'=>'R', #Arginine 
            'CGT'=>'R', #Arginine 
            'ATA'=>'T', #Isoleucine 
            'ATC'=>'T', #Isoleucine 
            'ATT'=>'T', #Isoleucine 
            'ATG'=>'M', #Methionine 
            'ACA'=>'T', #Threonine 
            'ACC'=>'T', #Threonine 
            'ACG'=>'T', #Threonine 
            'ACT'=>'T', #Threonine 
            'AAC'=>'N', #Asparagine 
            'AAT'=>'N', #Asparagine 
            'AAA'=>'K', #Lysine 
            'AAG'=>'K', #Lysine 
            'AGC'=>'S', #Serine#Valine 
            'AGT'=>'S', #Serine 
            'AGA'=>'R', #Arginine 
            'AGG'=>'R', #Arginine 
            'CCC'=>'P', #Proline 
            'CCG'=>'P', #Proline 
            'CCT'=>'P', #Proline 
            'CAC'=>'H', #Histidine 
            'GTA'=>'V', #Valine 
            'GTC'=>'V', #Valine 
            'GTG'=>'V', #Valine 
            'GTT'=>'V', #Valine 
            'GCA'=>'A', #Alanine 
            'GCC'=>'A', #Alanine 
            'GCG'=>'A', #Alanine 
            'GCT'=>'A', #Alanine 
            'GAC'=>'D', #Aspartic Acid 
            'GAT'=>'D', #Aspartic Acid 
            'GAA'=>'E', #Glutamic Acid 
            'GAG'=>'E', #Glutamic Acid 
            'GGA'=>'G', #Glycine 
            'GGC'=>'G', #Glycine 
            'GGG'=>'G', #Glycine 
            'GGT'=>'G', #Glycine 
    );
    return %g;
}

Outputs

AGA	AAA	R	K	change
CCA	CCT	P	P	same
GCA	ACA	A	T	change
GCA	ACA	A	T	change
etc...

Thank you very much for your help. It works very well. Could you show me how to analyze the data DNA1.txt If I want to add position colum in the out put?

Out put
Posi   Ref   Mul   pro_ref  pro_mul   infor
1      AGA   AAA	R	K	change
2      CCA   CCT	P	P	same
etc......
Attachments
position	Ref	Mut
1	AGA	AAA
2	CCA	CCT
3	GCA	ACA
4	GCA	ACA
5	GCT	GTT
6	GTG	ATG
7	GCC	GTC
8	GTC	TTC
9	GTC	TTC
10	GCT	GCA
11	GGC	GAC
12	GCC	GTC
13	AGT	AAT
14	GGC	AGC
15	GGC	GGA
16	GTA	ATA
17	GGT	AGT
18	ACC	ATC
19	GGA	GAA
20	GAT	AAT
21	GGG	GAG
22	GCC	GTC
23	AGT	AAT
24	GCT	GTT
25	GCG	ACG
26	GCT	GTT
27	GAT	AAT
28	TCC	TTC
29	GAG	GGG
30	GGA	GAA
31	GCC	ACC
32	GGC	AGC
33	TGG	TGA
34	GCG	ACG
35	GAC	AAC
36	GGT	GAT
37	GAC	GAA
38	GCT	GTT
39	GTT	ATT
40	CCG	TCG
41	GCG	ACG
42	CGG	TGG
43	GAA	AAA
44	GGA	GAA
45	CCC	CCT
46	CTC	TTC
47	GCC	GTC
48	ACC	ATC
49	CCA	CCT
50	GGG	GAG
51	AGC	AAC
52	GCT	ACT
53	ACC	ATC
54	CCA	CCT
55	GCT	GCA
56	TCC	TTC
57	GGC	GAC
58	GCG	GTG
59	ACC	ATC
60	CTC	TTC
61	GCC	GTC
62	GAA	AAA
63	TTG	ATG
64	CGC	TGC
65	GGG	GAG
66	GGT	GAT
67	GGT	GAT
68	CCG	CTG
69	GCC	GTC
70	GGC	AGC
71	AGA	AAA
72	CCT	TCT
73	GAA	AAA
74	GCT	GTT
75	GGC	AGC
76	CCC	TCC
77	GGT	GAT
78	GCG	GCA
79	GGT	GAT
80	CCA	CCT
81	TGG	TGA
82	GGT	GGA
83	ACC	ATC
84	CTT	TTT
85	CCG	TCG
86	GCT	GTT
87	CCG	CTG
88	CCA	CCT
89	GGC	GAC
90	CCT	CTT
91	ACT	ATT
92	AGG	AAG
93	GAA	AAA
94	AGA	AAA
95	GGG	GAG
96	GCC	GTC
97	TGG	TGA
98	GGC	GAC
99	AGG	AAG
100	GAC	AAC
101	CTC	CTT
102	AGC	AAC
103	GCC	GTC
104	ACC	ATC
105	AGT	AAT
106	CCA	CCT
107	GGT	AGT
108	ACC	ATC
109	GAT	AAT
110	CCA	TCA
111	GCC	GTC
112	CCC	CTC
113	GCC	GTC
114	GGA	GAA
115	GCC	GTC
116	CTG	CTT
117	TCC	TTC
118	CGC	CGG
119	ACC	ATC
120	TCC	TTC
121	CTT	TTT
122	CTC	TTC
123	GCC	GTC
124	GGG	GAG
125	TCC	TTC
126	CCC	CTC
127	GCC	GTC
128	GCA	GTA
129	TCC	TTC
130	GTC	ATC
131	CCG	TCG
132	GCC	GTC
133	GGA	GAA
134	AGT	AAT
135	ACG	ATG
136	CCC	CTC
137	CCC	CTC
138	ACC	ATC
139	GCT	GTT
140	GTG	GCG
141	CCC	CTC
142	ACC	ATC
143	AGC	AAC
144	CCC	CTC
145	GCG	GTG
146	TCT	TTT
147	AGG	AAG
148	ACC	ATC
149	GGT	GAT
150	GGG	GGA
151	GTC	GTA
152	GCC	ACC
153	TCC	TTC
154	GGC	GAC
155	GCT	GTT
156	GGC	GAC
157	AGC	AAC
158	CCT	TCT
159	GGT	GAT
160	GGA	GAA
161	ACC	ATC
162	GGG	GAG
163	TCT	TTT
164	GGC	AGC
165	AGG	AAG
166	GGC	GAC
167	CTT	TTT
168	TCT	TTT
169	ACC	ATC
170	AGG	AAG
171	CCG	TCG
172	CTT	TTT
173	ACA	ATA
174	CCC	CCT
175	CTG	CTT
176	CCC	CTC
177	CCG	TCG
178	CCC	TCC
179	GCC	GTC
180	CCC	CTC
181	TCC	TTC
182	GCC	GTC
183	CCC	TCC
184	CCC	CTC
185	CCT	TCT
186	CCC	CCT
187	GCT	GTT
188	CCA	TCA
189	ACT	ATT
190	GGC	AGC
191	GCC	GTC
192	GCC	GTC
193	CCG	CTG
194	ACA	ATA
195	CCC	CTC
196	TCC	TTC
197	TCC	TTC
198	ACC	ATC
199	CTT	TTT
200	TCC	TTC
201	TCT	TTT
202	GGA	GAA
203	GCC	GCA
204	GGC	GAC
205	GGC	GAC
206	GCC	GTC
207	TCC	TTC
208	GCT	GCA
209	GCG	GTG
210	GAC	AAC
211	GCC	GTC
212	ACC	ATC
213	ACC	ATC
214	GTC	TTC
215	GCT	GTT
216	GCG	GCA
217	TCC	TTC
218	GCT	ACT
219	TCC	TTC
220	GTG	GTA
221	GTG	GTA
222	GTC	ATC
223	ATG	ATA
224	TTG	ATG
225	CCT	CTT
226	TCC	TTC
227	CCA	CCT
228	TCC	TTC
229	ACC	ATC
230	GCC	GTC
231	GCC	GTC
232	ACC	ATC
233	GTC	ATC
234	AGG	AAG
235	CCC	CCT
236	CTC	TTC
237	GAT	GAA
238	GCG	ACG
239	GCC	GTC
240	CCT	CTT
241	GGA	GAA
242	GGC	AGC
243	GCC	ACC
244	CTC	TTC
245	TCG	TTG
246	CCA	CCT
247	GTC	TTC
248	TCC	TTC
249	GCT	GTT
250	GGT	GAT
251	GCT	GTT
252	TTG	ATG
253	ACA	ACG
254	AGT	AAT
255	GGC	GAC
256	GCC	GCA
257	TCC	TTC
258	GCT	GTT
259	GTG	ATG
260	GTC	GTA
261	TCT	TTT
262	AGT	AAT
263	AGA	AAA
264	CTT	TTT
265	AGC	AAC
266	CCT	CTT
267	GCG	GTG
268	GAA	AAA
269	GCA	GTA
270	CGG	CGT
271	ATC	ACC
272	CCA	CCT
273	ACT	ATT
274	GGT	GAT
275	GCG	GTG
276	CTC	TTC
277	TGC	TAC
278	GTC	TTC
279	CCT	TCT
280	CGG	CGT
281	CCC	CTC
282	GGC	GAC
283	GCG	GTG
284	CTT	TTT
285	GCC	GTC
286	GAA	AAA
287	GGA	GAA
288	GCC	ACC
289	AGC	AAC
290	AGG	AAG
291	CTT	CCT
292	GCC	GTC
293	GAT	GGT
294	AGC	AAC
295	GCG	GCA
296	CCA	CTA
297	CCT	TCT
298	TCC	TTC
299	ACT	ATT
300	CCA	TCA
301	GAC	AAC
302	GAA	AAA
303	GGG	GAG
304	CCG	TCG
305	CGA	CGT
306	ACT	ATT
307	GGT	GAT
308	GTT	ATT
309	GAC	AAC
310	CGA	CAA
311	GGC	GAC
312	CTT	CCT
313	CCA	CCT
314	GCT	ACT
315	AGG	AAG
316	TAC	TGC
317	CGC	TGC
318	CGC	CAC
319	GCC	GTC
320	GCT	GTT
321	GCT	GCA
322	ACC	ATC
323	GCC	GTC
324	ACC	ATC
325	TCC	TTC
326	ATC	TTC
327	GGA	GAA
328	GCA	ACA
329	GCC	GTC
330	AGA	AAA
331	GCG	GCA
332	TGG	TAG
333	GGT	GAT
334	GGG	AGG
335	ACC	ATC
336	TCC	TTC
337	TCC	TTC
338	TCC	TTC
339	GCC	GTC
340	TGG	TGA
341	CCT	CTT
342	TCT	TTT
343	GCT	GCA
344	CGC	TGC
345	GGT	GGA
346	GGA	GAA
347	GCC	GTC
348	AGG	AAG
349	GCG	GCA
350	GCT	GTT
351	GCA	GTA
352	GCA	ACA
353	AGC	AAC
354	CGC	CAC
355	TCC	TTC
356	ATC	TTC
357	GTT	GTA
358	TAC	CAC
359	GCA	ACA
360	GGC	GAC
361	AGC	AAC
362	GGC	GAC
363	GGC	GAC
364	ACC	ATC
365	CCC	CTC
366	TGG	TGA
367	CCG	TCG
368	GTC	ATC
369	CGT	CAT
370	GGT	AGT
371	GTG	GTA
372	GAC	GAA
373	CGC	CAC

You could create another variable to hold the position value and include that variable in the string that you print.

Instead of my ($ref, $mul) = split /\s+/, $rec; you could have my ($pos, $ref, $mul) = split /\s+/, $rec;

Thank you very much. But with data 'DNA.txt' the script have error "bad codon $ref".
I mix the error with

while (<$dna_fh>){
    next unless /^\s*\d/; 
         
    my ($pos, $ref, $mul) =  split ;

Could you show me what the diffirent of the script?

Edited 4 Years Ago by biojet: n/a

Attachments
position	Ref	Mut
1	AGA	AAA
2	CCA	CCT
3	GCA	ACA
4	GCA	ACA
5	GCT	GTT
6	GTG	ATG
7	GCC	GTC
8	GTC	TTC
9	GTC	TTC
10	GCT	GCA
11	GGC	GAC
12	GCC	GTC
13	AGT	AAT
14	GGC	AGC
15	GGC	GGA
16	GTA	ATA
17	GGT	AGT
18	ACC	ATC
19	GGA	GAA
20	GAT	AAT
21	GGG	GAG
22	GCC	GTC
23	AGT	AAT
24	GCT	GTT
25	GCG	ACG
26	GCT	GTT
27	GAT	AAT
28	TCC	TTC
29	GAG	GGG
30	GGA	GAA
31	GCC	ACC
32	GGC	AGC
33	TGG	TGA
34	GCG	ACG
35	GAC	AAC
36	GGT	GAT
37	GAC	GAA
38	GCT	GTT
39	GTT	ATT
40	CCG	TCG
41	GCG	ACG
42	CGG	TGG
43	GAA	AAA
44	GGA	GAA
45	CCC	CCT
46	CTC	TTC
47	GCC	GTC
48	ACC	ATC
49	CCA	CCT
50	GGG	GAG
51	AGC	AAC
52	GCT	ACT
53	ACC	ATC
54	CCA	CCT
55	GCT	GCA
56	TCC	TTC
57	GGC	GAC
58	GCG	GTG
59	ACC	ATC
60	CTC	TTC
61	GCC	GTC
62	GAA	AAA
63	TTG	ATG
64	CGC	TGC
65	GGG	GAG
66	GGT	GAT
67	GGT	GAT
68	CCG	CTG
69	GCC	GTC
70	GGC	AGC
71	AGA	AAA
72	CCT	TCT
73	GAA	AAA
74	GCT	GTT
75	GGC	AGC
76	CCC	TCC
77	GGT	GAT
78	GCG	GCA
79	GGT	GAT
80	CCA	CCT
81	TGG	TGA
82	GGT	GGA
83	ACC	ATC
84	CTT	TTT
85	CCG	TCG
86	GCT	GTT
87	CCG	CTG
88	CCA	CCT
89	GGC	GAC
90	CCT	CTT
91	ACT	ATT
92	AGG	AAG
93	GAA	AAA
94	AGA	AAA
95	GGG	GAG
96	GCC	GTC
97	TGG	TGA
98	GGC	GAC
99	AGG	AAG
100	GAC	AAC
101	CTC	CTT
102	AGC	AAC
103	GCC	GTC
104	ACC	ATC
105	AGT	AAT
106	CCA	CCT
107	GGT	AGT
108	ACC	ATC
109	GAT	AAT
110	CCA	TCA
111	GCC	GTC
112	CCC	CTC
113	GCC	GTC
114	GGA	GAA
115	GCC	GTC
116	CTG	CTT
117	TCC	TTC
118	CGC	CGG
119	ACC	ATC
120	TCC	TTC
121	CTT	TTT
122	CTC	TTC
123	GCC	GTC
124	GGG	GAG
125	TCC	TTC
126	CCC	CTC
127	GCC	GTC
128	GCA	GTA
129	TCC	TTC
130	GTC	ATC
131	CCG	TCG
132	GCC	GTC
133	GGA	GAA
134	AGT	AAT
135	ACG	ATG
136	CCC	CTC
137	CCC	CTC
138	ACC	ATC
139	GCT	GTT
140	GTG	GCG
141	CCC	CTC
142	ACC	ATC
143	AGC	AAC
144	CCC	CTC
145	GCG	GTG
146	TCT	TTT
147	AGG	AAG
148	ACC	ATC
149	GGT	GAT
150	GGG	GGA
151	GTC	GTA
152	GCC	ACC
153	TCC	TTC
154	GGC	GAC
155	GCT	GTT
156	GGC	GAC
157	AGC	AAC
158	CCT	TCT
159	GGT	GAT
160	GGA	GAA
161	ACC	ATC
162	GGG	GAG
163	TCT	TTT
164	GGC	AGC
165	AGG	AAG
166	GGC	GAC
167	CTT	TTT
168	TCT	TTT
169	ACC	ATC
170	AGG	AAG
171	CCG	TCG
172	CTT	TTT
173	ACA	ATA
174	CCC	CCT
175	CTG	CTT
176	CCC	CTC
177	CCG	TCG
178	CCC	TCC
179	GCC	GTC
180	CCC	CTC
181	TCC	TTC
182	GCC	GTC
183	CCC	TCC
184	CCC	CTC
185	CCT	TCT
186	CCC	CCT
187	GCT	GTT
188	CCA	TCA
189	ACT	ATT
190	GGC	AGC
191	GCC	GTC
192	GCC	GTC
193	CCG	CTG
194	ACA	ATA
195	CCC	CTC
196	TCC	TTC
197	TCC	TTC
198	ACC	ATC
199	CTT	TTT
200	TCC	TTC
201	TCT	TTT
202	GGA	GAA
203	GCC	GCA
204	GGC	GAC
205	GGC	GAC
206	GCC	GTC
207	TCC	TTC
208	GCT	GCA
209	GCG	GTG
210	GAC	AAC
211	GCC	GTC
212	ACC	ATC
213	ACC	ATC
214	GTC	TTC
215	GCT	GTT
216	GCG	GCA
217	TCC	TTC
218	GCT	ACT
219	TCC	TTC
220	GTG	GTA
221	GTG	GTA
222	GTC	ATC
223	ATG	ATA
224	TTG	ATG
225	CCT	CTT
226	TCC	TTC
227	CCA	CCT
228	TCC	TTC
229	ACC	ATC
230	GCC	GTC
231	GCC	GTC
232	ACC	ATC
233	GTC	ATC
234	AGG	AAG
235	CCC	CCT
236	CTC	TTC
237	GAT	GAA
238	GCG	ACG
239	GCC	GTC
240	CCT	CTT
241	GGA	GAA
242	GGC	AGC
243	GCC	ACC
244	CTC	TTC
245	TCG	TTG
246	CCA	CCT
247	GTC	TTC
248	TCC	TTC
249	GCT	GTT
250	GGT	GAT
251	GCT	GTT
252	TTG	ATG
253	ACA	ACG
254	AGT	AAT
255	GGC	GAC
256	GCC	GCA
257	TCC	TTC
258	GCT	GTT
259	GTG	ATG
260	GTC	GTA
261	TCT	TTT
262	AGT	AAT
263	AGA	AAA
264	CTT	TTT
265	AGC	AAC
266	CCT	CTT
267	GCG	GTG
268	GAA	AAA
269	GCA	GTA
270	CGG	CGT
271	ATC	ACC
272	CCA	CCT
273	ACT	ATT
274	GGT	GAT
275	GCG	GTG
276	CTC	TTC
277	TGC	TAC
278	GTC	TTC
279	CCT	TCT
280	CGG	CGT
281	CCC	CTC
282	GGC	GAC
283	GCG	GTG
284	CTT	TTT
285	GCC	GTC
286	GAA	AAA
287	GGA	GAA
288	GCC	ACC
289	AGC	AAC
290	AGG	AAG
291	CTT	CCT
292	GCC	GTC
293	GAT	GGT
294	AGC	AAC
295	GCG	GCA
296	CCA	CTA
297	CCT	TCT
298	TCC	TTC
299	ACT	ATT
300	CCA	TCA
301	GAC	AAC
302	GAA	AAA
303	GGG	GAG
304	CCG	TCG
305	CGA	CGT
306	ACT	ATT
307	GGT	GAT
308	GTT	ATT
309	GAC	AAC
310	CGA	CAA
311	GGC	GAC
312	CTT	CCT
313	CCA	CCT
314	GCT	ACT
315	AGG	AAG
316	TAC	TGC
317	CGC	TGC
318	CGC	CAC
319	GCC	GTC
320	GCT	GTT
321	GCT	GCA
322	ACC	ATC
323	GCC	GTC
324	ACC	ATC
325	TCC	TTC
326	ATC	TTC
327	GGA	GAA
328	GCA	ACA
329	GCC	GTC
330	AGA	AAA
331	GCG	GCA
332	TGG	TAG
333	GGT	GAT
334	GGG	AGG
335	ACC	ATC
336	TCC	TTC
337	TCC	TTC
338	TCC	TTC
339	GCC	GTC
340	TGG	TGA
341	CCT	CTT
342	TCT	TTT
343	GCT	GCA
344	CGC	TGC
345	GGT	GGA
346	GGA	GAA
347	GCC	GTC
348	AGG	AAG
349	GCG	GCA
350	GCT	GTT
351	GCA	GTA
352	GCA	ACA
353	AGC	AAC
354	CGC	CAC
355	TCC	TTC
356	ATC	TTC
357	GTT	GTA
358	TAC	CAC
359	GCA	ACA
360	GGC	GAC
361	AGC	AAC
362	GGC	GAC
363	GGC	GAC
364	ACC	ATC
365	CCC	CTC
366	TGG	TGA
367	CCG	TCG
368	GTC	ATC
369	CGT	CAT
370	GGT	AGT
371	GTG	GTA
372	GAC	GAA
373	CGC	CAC

You need a chomp; statement before the statement that does the split. Otherwise the last codon on each line will include a newline character and so will not match any codon in your hash.

This question has already been answered. Start a new discussion instead.