🧬 Codeine
Codeine is a Python library for generating synonymous protein-coding sequences under biological constraints.
Installation & documentation
Codeine is available on PyPI:
pip install codeine
Full documentation: https://codeine.readthedocs.io/.
Quick start
from codeine import CodingSpace
space = CodingSpace('MKTIIALSYIFCLVF')
print(space.n_valid_sequences)
print(space.sample())
Overview
A protein sequence can typically be encoded by an enormous number of synonymous DNA/RNA coding sequences.
For biotechnological applications such as recombinant expression, we typically must choose a coding sequence while respecting one or more practical constraints, for example:
- avoiding restriction enzyme sites,
- avoiding nucleotide homopolymers,
- fixing specific codons,
- mutating relative to a reference sequence.
Identifying valid coding sequences under such constraints quickly becomes challenging, especially for longer protein sequences.
Codeine represents the complete space of valid coding sequences for a given protein and experimental setup. It enables efficient sampling, enumeration and mutation library design while guaranteeing that the generated sequences satisfy user-specified constraints.
Examples
Count valid sequences:
from codeine import CodingSpace
space = CodingSpace('MKTLEFQNGSCPRYKKL')
print(space.n_valid_sequences)
Sample a single valid sequence:
from codeine import CodingSpace
space = CodingSpace('MKTLEFQNGSCPRYKKL')
seq = space.sample()
print(seq)
Sample many:
from codeine import CodingSpace
space = CodingSpace('MKTLEFQNGSCPRYKKL')
for seq in space.sample(n=5):
print(seq)
Apply restrictions:
from codeine import CodingSpace, RestrictionSite
space = CodingSpace(
'MKTLEFQNGSCPRYKKL',
forbidden_motifs=[
RestrictionSite.EcoRI,
RestrictionSite.BamHI,
'CTGCAG',
],
codon_restrictions={
2: 'AAG',
16: 'AAG',
},
max_homopolymer=4,
)
print(space.n_valid_sequences)
print(space.sample())
Use custom codon weights to change sampling distribution:
from codeine import CodingSpace, CodonWeights
weights = CodonWeights.ecoli()
space = CodingSpace("MKTLEFQNGSCPRYKKL", codon_weights=weights)
seq = space.sample()
print(seq)
Nonstandard translation tables and RNA:
from codeine import CodingSpace, TranslationTable
table = TranslationTable(table_id=2, rna=True)
space = CodingSpace("MKTLEFQNGSCPRYKKL", translation_table=table)
seq = space.sample()
print(seq)
Enumerate all sequences (only recommended for small spaces):
from codeine import CodingSpace
space = CodingSpace('CYIQNCPLG')
for sequence in space:
print(sequence)
Explore mutants of a chosen reference sequence:
from codeine import CodingSpace
space = CodingSpace('MKTLEFQNGSCPRYKKL')
reference = space.sample()
mutants = space.mutants(
reference,
free_positions=range(5, 14),
min_nts=2,
max_nts=5,
)
mutant = mutants.sample()
print(mutant)
Metadata
Release files for codeine 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| codeine-0.2.2.tar.gz | 41.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| codeine-0.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 90.4 kB
Release files / codeine-0.2.2.tar.gz
| Download URL | codeine-0.2.2.tar.gz |
|---|---|
| Size | 41.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
406aafa7c433aa679491c124cf81c902942af6c12dea98d9fbc7d9794b7645ec
|
|
BLAKE2b-256 checksum How to use checksums |
4d70627e661f4ecc5c7b724b77ff28dc15a8e3b868d0b98980fa80834eaeef31
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|
Release files / codeine-0.2.2-py3-none-any.whl
| Download URL | codeine-0.2.2-py3-none-any.whl |
|---|---|
| Size | 49.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
56c65f87f182d9b9418c40b399180dcdbe8187d0ee040a41aebaaf2dea261cb4
|
|
BLAKE2b-256 checksum How to use checksums |
505c5824f7f3253c0b6aa7e20cd77b7e04eda89fbc6e88228f7faedb94d2bf67
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.14
|