Molecular types

The MolType object provides services for resolving ambiguities, or providing the correct ambiguity for recoding. It also maintains the mappings between different kinds of alphabets, sequences and alignments.

If your analysis involves handling ambiguous states, or translation via a genetic code, it’s critical to specify the appropriate moltype.

Available molecular types

For statements that have a moltype argument, use the entry under the “Abbreviation” column. For example:

Getting a MolType

Using a MolType to get ambiguity codes

Just using dna from above.

MolType definition of degenerate codes

Nucleic acid MolType and complementing

Making sequences

Use the either the top level cogent3.make_seq function, or the method on the MolType instance.

Verify sequences

Making a custom MolType

We demonstrate this by customising DNA so it allows . as gaps

Warning

At present, constructing a custom MolType that overrides a builtin one affects the original (in this instance, the DnaSequence class). All subsequent calls to the original class in the running process that made the change are affected. The below code is resetting this attribute now to allow the rest of the documentation to be executed.