Available genetic codes

from cogent3 import available_codes

available_codes()
Specify a genetic code using either 'Name' or Code ID (as an integer or string)
Code IDName
1Standard Nuclear
2Vertebrate Mitochondrial
3Yeast Mitochondrial
4Mold, Protozoan, and Coelenterate Mitochondrial, and Mycoplasma/Spiroplasma Nuclear
5Invertebrate Mitochondrial
6Ciliate, Dasycladacean and Hexamita Nuclear
9Echinoderm and Flatworm Mitochondrial
10Euplotid Nuclear
11Bacterial Nuclear and Plant Plastid
12Alternative Yeast Nuclear
13Ascidian Mitochondrial
14Alternative Flatworm Mitochondrial
15Blepharisma Nuclear
16Chlorophycean Mitochondrial
20Trematode Mitochondrial
22Scenedesmus obliquus Mitochondrial
23Thraustochytrium Mitochondrial

17 rows x 2 columns

In cases where a cogent3 object method has a gc argument, you can just use the number under “Code ID” column.

For example:

from cogent3 import load_aligned_seqs

nt_seqs = load_aligned_seqs("data/brca1-bats.fasta", moltype="dna")
nt_seqs[:21]
0
DogFacedTGTGGCACAAATACTCATGCC
FlyingFox............G........
FreeTaile.........G...........
LittleBro.........G...........
TombBat..........G..........

5 x 21 dna alignment

We specify the genetic code, and that codons that are incomplete as they contain a gap, are converted to ?.

aa_seqs = nt_seqs.get_translation(gc=1, incomplete_ok=True)
aa_seqs[:20]
0
DogFacedCGTNTHANSLQHENSSLLYT
FlyingFox....A..S......-.....
FreeTaile...D...S..........L.
LittleBro...D...S..........L.
TombBat...S...S.V........L.

5 x 20 protein alignment

Getting a genetic code with get_code()

This function can be used directly to get a genetic code. We will get the code with ID 4.

from cogent3 import get_code

gc = get_code(4)
gc
Mold, Protozoan, and Coelenterate Mitochondrial, and Mycoplasma/Spiroplasma Nuclear
aaIUPAC codecodons
AlanineAGCT,GCC,GCA,GCG
CysteineCTGT,TGC
Aspartic AcidDGAT,GAC
Glutamic AcidEGAA,GAG
PhenylalanineFTTT,TTC
GlycineGGGT,GGC,GGA,GGG
HistidineHCAT,CAC
IsoleucineIATT,ATC,ATA
LysineKAAA,AAG
LeucineLTTA,TTG,CTT,CTC,CTA,CTG
MethionineMATG
AsparagineNAAT,AAC
ProlinePCCT,CCC,CCA,CCG
GlutamineQCAA,CAG
ArginineRCGT,CGC,CGA,CGG,AGA,AGG
SerineSTCT,TCC,TCA,TCG,AGT,AGC
ThreonineTACT,ACC,ACA,ACG
ValineVGTT,GTC,GTA,GTG
TryptophanWTGA,TGG
TyrosineYTAT,TAC
STOP*TAA,TAG