Example usage
The main goal of codino
is to convert amino acid (AA) frequencies to codon design (CD), and vice versa.
import codino
print(codino.__version__)
0.1.1
Users should initialise a Converter
.
from codino.process import Converter
c = Converter()
The two useful methods within a Converter
are cd_to_aa()
and aa_to_cd()
, which converts a CD to AA frequencies and vice versa.
# input the expected nucleotide frequencies at each position
c.cd_to_aa(first={"A": 1}, second={"T": 1}, third={"G": 1})
# input the desired AA frequencies
first, second, third = c.aa_to_cd(aa={'D': 0.4, 'N': 0.6})
# you can check the output by converting the codon design back to AA frequencies
c.cd_to_aa(first, second, third) == {'D': 0.4, 'N': 0.6}
True
For more complex examples, the conversion of the AA frequencies to a CD will be an estimate.
exp_aa = {'A': 0.1771,
'D': 0.208131,
'E': 0.18456899999999998,
'I': 0.031694,
'K': 0.055131,
'M': 0.028106000000000003,
'N': 0.062169,
'T': 0.0529,
'V': 0.2002}
first, second, third = c.aa_to_cd(aa=exp_aa)
pred_aa = c.cd_to_aa(first, second, third)
pred_aa == exp_aa
False
In this case, it can be helpful to obtain the error between the expected and predicted AA frequencies.
errors = [abs(pred_aa[a] - exp_aa[a]) for a in exp_aa]
print(f'Average error per AA ==> {sum(errors)/len(errors)}')
print(f'Total error across AAs ==> {sum(errors)}')
Average error per AA ==> 0.0055103958222222325
Total error across AAs ==> 0.049593562400000096