Skip to main content

No project description provided

Project description

🧬 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 highly 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 sequences:

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)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codeine-0.1.0.tar.gz (36.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codeine-0.1.0-py3-none-any.whl (43.2 kB view details)

Uploaded Python 3

File details

Details for the file codeine-0.1.0.tar.gz.

File metadata

  • Download URL: codeine-0.1.0.tar.gz
  • Upload date:
  • Size: 36.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codeine-0.1.0.tar.gz
Algorithm Hash digest
SHA256 79388347ba0cd0bb4e955cddb3f9a4f674bf1f556008814fdf2ea522809f040b
MD5 17d5049afde275e07b331614534128dd
BLAKE2b-256 e0055e9103ecaee1eacdc802aa63d28799997e1e86e2d761c3f815332e13ac44

See more details on using hashes here.

File details

Details for the file codeine-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: codeine-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 43.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for codeine-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 202e4ac056e7e6e72ce5eeabe5329bde5c98856cfc60272ae449ae7c320c6045
MD5 6724f088f9c6b7bfa59e46cfdf7a2dbd
BLAKE2b-256 cbe2fde1a475bc15a35cba76313eeb3aa5d3eb6c38da307ab2a1862d4af0943f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page