Codeine

Codeine is a Python library for constrained reverse translation of protein sequences.

Example

from codeine import CodingSpace, RestrictionSite
from codeine.constraints import ForbiddenMotifs, MaxHomopolymer

space = CodingSpace(
    'CYIQNCPLG',
    constraints=[
        ForbiddenMotifs(RestrictionSite.EcoRI),
        MaxHomopolymer(5),
    ],
)

print(space.n_valid_sequences)
print(space.sample())

Why Codeine?

Codeine compiles biological constraints into a CodingSpace, an exact representation of the feasible coding sequence space for a given amino acid sequence.

Sequences sampled or enumerated from a CodingSpace are automatically valid under the specified constraints. This means sequences can be generated freely and scored according to arbitrary objective functions, without sequence repair or filtering.

Features

  • Arbitrarily long amino acid sequences

  • Exact counting of sequence spaces

  • Sequence enumeration

  • Uniform and weighted sampling

  • Local sequence redesign

  • Mutation spaces

  • Fixed codons

  • Sequence contexts

  • Restriction sites & arbitrary motif avoidance

  • Homopolymer and tandem repeat avoidance

  • Custom translation tables