File: what_codes.rst

package info (click to toggle)
python-cogent 2023.2.12a1%2Bdfsg-2%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 12,416 kB
  • sloc: python: 89,165; makefile: 117; sh: 16
file content (44 lines) | stat: -rw-r--r-- 998 bytes parent folder | download
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
.. jupyter-execute::
    :hide-code:

    import set_working_directory

***********************
Available genetic codes
***********************

.. jupyter-execute::

    from cogent3 import available_codes

    available_codes()

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

For example:

.. jupyter-execute::

    from cogent3 import load_aligned_seqs

    nt_seqs = load_aligned_seqs("data/brca1-bats.fasta", moltype="dna")
    nt_seqs[:21]

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

.. jupyter-execute::

    aa_seqs = nt_seqs.get_translation(gc=1, incomplete_ok=True)
    aa_seqs[:20]

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.

.. jupyter-execute::

    from cogent3 import get_code

    gc = get_code(4)
    gc