-
Notifications
You must be signed in to change notification settings - Fork 15
/
nbmt-translate.pl
executable file
·153 lines (147 loc) · 3.11 KB
/
nbmt-translate.pl
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
#!/usr/bin/perl
## Translate mitochondrial sequence of Nb mitochondria
## (mostly because UAG is *not* a stop codon)
use warnings;
use strict;
## codon usage table -- consider proportion of mitochondrial codons
## for x in A C G T; do for y in A C G T; do for z in A C G T; do echo -n "${x}${y}${z} => \"" | perl -pe 'tr/T/U/'; transeq <(echo -e ">1\n${x}${y}${z}") /dev/stdout 2>/dev/null | perl -pe 's/$/ \",/;' | grep -v '^>'; done; done; done
my %transTable = ## 3-letter codes are for translations from mtDNA tRNAs
( AAA => "(K)",
AAC => "(N)",
AAG => "(K)",
AAU => "(N)",
ACA => "(T)",
ACC => "(T)",
ACG => "Arg",
ACU => "(T)",
AGA => "(S)",
AGC => "(S)",
AGG => "(S)",
AGU => "(S)",
AUA => "(M)",
AUC => "(I)",
AUG => "(M)",
AUU => "(I)",
CAA => "(Q)",
CAC => "(H)",
CAG => "(Q)",
CAU => "Met",
CCA => "(P)",
CCC => "(P)",
CCG => "(P)",
CCU => "(P)",
CGA => "(R)",
CGC => "(R)",
CGG => "(R)",
CGU => "(R)",
CUA => "(L)",
CUC => "(L)",
CUG => "(L)",
CUU => "(L)",
GAA => "Phe",
GAC => "(D)",
GAG => "(E)",
GAU => "Ile",
GCA => "Cys",
GCC => "(A)",
GCG => "(A)",
GCU => "(A)",
GGA => "(G)",
GGC => "(G)",
GGG => "(G)",
GGU => "(G)",
GUA => "Tyr",
GUC => "Asp",
GUG => "His",
GUU => "Asn",
UAA => "L/*", ## was * (mtDNA/Leu)
UAC => "Val",
UAG => "Leu",
UAU => "(Y)",
UCA => "Trp",
UCC => "Gly",
UCG => "(S)",
UCU => "Ser",
UGA => "(W)",
UGC => "Ala",
UGG => "Pro",
UGU => "Thr",
UUA => "(L)",
UUC => "Glu",
UUG => "Gln",
UUU => "Lys",
);
my $seq = "";
my $seqID = "";
while(<>){
chomp;
if(/^>(.*)$/){
my $newID = $1;
if($seq){
printf(">%s\n", $seqID);
while($seq =~ s/^(.{1,60})//){
my $seqHead = $1;
for(my $i=0; $i < length($seqHead); $i+=3){
my $codon = substr($seqHead, $i, 3);
$codon =~ tr/T/U/;
if($transTable{$codon}){
print($transTable{$codon});
} else {
print("???");
}
}
print("\n".("|----:----" x 6)."\n");
printf("%s\n", $seqHead);
}
}
$seq = "";
$seqID = $newID;
} else {
$seq .= $_;
}
}
if($seq){
printf(">%s\n", $seqID);
my $pos = 0;
while($seq =~ s/^(.{1,60})//){
my $seqHead = $1;
for(my $i=0; $i < length($seqHead); $i+=3){
my $codon = substr($seqHead, $i, 3);
$codon =~ tr/T/U/;
if($transTable{$codon}){
print($transTable{$codon});
} else {
print("???");
}
}
print("\n ");
for(my $i=1; $i < (length($seqHead)-3); $i+=3){
my $codon = substr($seqHead, $i, 3);
$codon =~ tr/T/U/;
if($transTable{$codon}){
print($transTable{$codon});
} else {
print("???");
}
}
print("\n ");
for(my $i=2; $i < (length($seqHead)-3); $i+=3){
my $codon = substr($seqHead, $i, 3);
$codon =~ tr/T/U/;
if($transTable{$codon}){
print($transTable{$codon});
} else {
print("???");
}
}
print("\n".("|----:----" x 6)."\n");
printf("%s\n", $seqHead);
printf("%-10s",$pos);
for(my $posInc = 10; $posInc < 60; $posInc += 10){
printf("%-10s",substr(sprintf("%10s",$pos+$posInc),8,2));
}
$pos += 60;
print("\n\n");
}
}
## TAGTA-