codeine 0.0.0__tar.gz → 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. codeine-0.1.0/LICENSE +21 -0
  2. codeine-0.1.0/PKG-INFO +162 -0
  3. codeine-0.1.0/README.md +153 -0
  4. codeine-0.1.0/codeine/__init__.py +15 -0
  5. codeine-0.1.0/codeine/constraints/banned.py +444 -0
  6. codeine-0.1.0/codeine/constraints/base.py +39 -0
  7. codeine-0.1.0/codeine/constraints/mutations.py +115 -0
  8. codeine-0.1.0/codeine/graph/base.py +267 -0
  9. codeine-0.1.0/codeine/graph/compile.py +489 -0
  10. codeine-0.1.0/codeine/graph/nodes.py +111 -0
  11. codeine-0.1.0/codeine/graph/view.py +781 -0
  12. codeine-0.1.0/codeine/motifs/restriction.py +105 -0
  13. codeine-0.1.0/codeine/motifs/validate.py +117 -0
  14. codeine-0.1.0/codeine/space/__init__.py +0 -0
  15. codeine-0.1.0/codeine/space/coding.py +490 -0
  16. codeine-0.1.0/codeine/space/mutation.py +512 -0
  17. codeine-0.1.0/codeine/translation/__init__.py +0 -0
  18. codeine-0.1.0/codeine/translation/data/__init__.py +0 -0
  19. codeine-0.1.0/codeine/translation/data/tables.json +2252 -0
  20. codeine-0.1.0/codeine/translation/data/weights.py +232 -0
  21. codeine-0.1.0/codeine/translation/tables.py +200 -0
  22. codeine-0.1.0/codeine/translation/weights.py +323 -0
  23. codeine-0.1.0/codeine/utils/__init__.py +0 -0
  24. codeine-0.1.0/codeine/utils/dict.py +23 -0
  25. codeine-0.1.0/codeine/utils/display.py +124 -0
  26. codeine-0.1.0/codeine/utils/sampling.py +90 -0
  27. codeine-0.1.0/codeine.egg-info/PKG-INFO +162 -0
  28. codeine-0.1.0/codeine.egg-info/SOURCES.txt +30 -0
  29. codeine-0.1.0/codeine.egg-info/top_level.txt +1 -0
  30. codeine-0.1.0/pyproject.toml +21 -0
  31. codeine-0.0.0/PKG-INFO +0 -9
  32. codeine-0.0.0/README.md +0 -2
  33. codeine-0.0.0/codeine.egg-info/PKG-INFO +0 -9
  34. codeine-0.0.0/codeine.egg-info/SOURCES.txt +0 -6
  35. codeine-0.0.0/codeine.egg-info/top_level.txt +0 -1
  36. codeine-0.0.0/setup.py +0 -22
  37. {codeine-0.0.0 → codeine-0.1.0}/codeine.egg-info/dependency_links.txt +0 -0
  38. {codeine-0.0.0 → codeine-0.1.0}/setup.cfg +0 -0
codeine-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Michael Dunne
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
codeine-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,162 @@
1
+ Metadata-Version: 2.4
2
+ Name: codeine
3
+ Version: 0.1.0
4
+ Author: Michael Peter Dunne
5
+ Requires-Python: >=3.8
6
+ Description-Content-Type: text/markdown
7
+ License-File: LICENSE
8
+ Dynamic: license-file
9
+
10
+ # 🧬 Codeine
11
+
12
+ **Codeine** is a Python library for generating synonymous protein-coding sequences under biological constraints.
13
+
14
+
15
+ ## Installation & documentation
16
+
17
+ **Codeine** is available on PyPI:
18
+
19
+ ```bash
20
+ pip install codeine
21
+ ```
22
+
23
+ Full documentation: **https://codeine.readthedocs.io/**.
24
+
25
+ ## Quick start
26
+
27
+ ```python
28
+ from codeine import CodingSpace
29
+
30
+ space = CodingSpace('MKTIIALSYIFCLVF')
31
+
32
+ print(space.n_valid_sequences)
33
+ print(space.sample())
34
+ ```
35
+
36
+
37
+ ## Overview
38
+
39
+ A protein sequence can typically be encoded by an enormous number of synonymous DNA/RNA coding sequences.
40
+
41
+ For biotechnological applications such as recombinant expression, we typically must choose a coding sequence while respecting one or more practical constraints, for example:
42
+ - avoiding restriction enzyme sites,
43
+ - avoiding nucleotide homopolymers,
44
+ - fixing specific codons,
45
+ - mutating relative to a reference sequence.
46
+
47
+ Identifying valid coding sequences under such constraints quickly becomes challenging, especially for longer protein sequences.
48
+
49
+ **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.
50
+
51
+ ## Examples
52
+
53
+ Count valid sequences:
54
+
55
+ ```python
56
+ from codeine import CodingSpace
57
+
58
+ space = CodingSpace('MKTLEFQNGSCPRYKKL')
59
+
60
+ print(space.n_valid_sequences)
61
+ ```
62
+
63
+ Sample a single valid sequences:
64
+
65
+ ```python
66
+ from codeine import CodingSpace
67
+
68
+ space = CodingSpace('MKTLEFQNGSCPRYKKL')
69
+
70
+ seq = space.sample()
71
+ print(seq)
72
+ ```
73
+
74
+ Sample many:
75
+ ```python
76
+ from codeine import CodingSpace
77
+
78
+ space = CodingSpace('MKTLEFQNGSCPRYKKL')
79
+
80
+ for seq in space.sample(n=5):
81
+ print(seq)
82
+ ```
83
+
84
+ Apply restrictions:
85
+
86
+ ```python
87
+ from codeine import CodingSpace, RestrictionSite
88
+
89
+ space = CodingSpace(
90
+ 'MKTLEFQNGSCPRYKKL',
91
+ forbidden_motifs=[
92
+ RestrictionSite.EcoRI,
93
+ RestrictionSite.BamHI,
94
+ 'CTGCAG',
95
+ ],
96
+ codon_restrictions={
97
+ 2: 'AAG',
98
+ 16: 'AAG',
99
+ },
100
+ max_homopolymer=4,
101
+ )
102
+
103
+ print(space.n_valid_sequences)
104
+ print(space.sample())
105
+ ```
106
+
107
+ Use custom codon weights to change sampling distribution:
108
+
109
+ ```python
110
+ from codeine import CodingSpace, CodonWeights
111
+
112
+ weights = CodonWeights.ecoli()
113
+
114
+ space = CodingSpace("MKTLEFQNGSCPRYKKL", codon_weights=weights)
115
+
116
+ seq = space.sample()
117
+ print(seq)
118
+ ```
119
+
120
+ Nonstandard translation tables and RNA:
121
+
122
+ ```python
123
+ from codeine import CodingSpace, TranslationTable
124
+
125
+ table = TranslationTable(table_id=2, rna=True)
126
+
127
+ space = CodingSpace("MKTLEFQNGSCPRYKKL", translation_table=table)
128
+
129
+ seq = space.sample()
130
+ print(seq)
131
+ ```
132
+
133
+ Enumerate all sequences (only recommended for small spaces):
134
+
135
+ ```python
136
+ from codeine import CodingSpace
137
+
138
+ space = CodingSpace('CYIQNCPLG')
139
+
140
+ for sequence in space:
141
+ print(sequence)
142
+ ```
143
+
144
+ Explore mutants of a chosen reference sequence:
145
+
146
+ ```python
147
+ from codeine import CodingSpace
148
+
149
+ space = CodingSpace('MKTLEFQNGSCPRYKKL')
150
+
151
+ reference = space.sample()
152
+
153
+ mutants = space.mutants(
154
+ reference,
155
+ free_positions=range(5, 14),
156
+ min_nts=2,
157
+ max_nts=5,
158
+ )
159
+
160
+ mutant = mutants.sample()
161
+ print(mutant)
162
+ ```
@@ -0,0 +1,153 @@
1
+ # 🧬 Codeine
2
+
3
+ **Codeine** is a Python library for generating synonymous protein-coding sequences under biological constraints.
4
+
5
+
6
+ ## Installation & documentation
7
+
8
+ **Codeine** is available on PyPI:
9
+
10
+ ```bash
11
+ pip install codeine
12
+ ```
13
+
14
+ Full documentation: **https://codeine.readthedocs.io/**.
15
+
16
+ ## Quick start
17
+
18
+ ```python
19
+ from codeine import CodingSpace
20
+
21
+ space = CodingSpace('MKTIIALSYIFCLVF')
22
+
23
+ print(space.n_valid_sequences)
24
+ print(space.sample())
25
+ ```
26
+
27
+
28
+ ## Overview
29
+
30
+ A protein sequence can typically be encoded by an enormous number of synonymous DNA/RNA coding sequences.
31
+
32
+ For biotechnological applications such as recombinant expression, we typically must choose a coding sequence while respecting one or more practical constraints, for example:
33
+ - avoiding restriction enzyme sites,
34
+ - avoiding nucleotide homopolymers,
35
+ - fixing specific codons,
36
+ - mutating relative to a reference sequence.
37
+
38
+ Identifying valid coding sequences under such constraints quickly becomes challenging, especially for longer protein sequences.
39
+
40
+ **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.
41
+
42
+ ## Examples
43
+
44
+ Count valid sequences:
45
+
46
+ ```python
47
+ from codeine import CodingSpace
48
+
49
+ space = CodingSpace('MKTLEFQNGSCPRYKKL')
50
+
51
+ print(space.n_valid_sequences)
52
+ ```
53
+
54
+ Sample a single valid sequences:
55
+
56
+ ```python
57
+ from codeine import CodingSpace
58
+
59
+ space = CodingSpace('MKTLEFQNGSCPRYKKL')
60
+
61
+ seq = space.sample()
62
+ print(seq)
63
+ ```
64
+
65
+ Sample many:
66
+ ```python
67
+ from codeine import CodingSpace
68
+
69
+ space = CodingSpace('MKTLEFQNGSCPRYKKL')
70
+
71
+ for seq in space.sample(n=5):
72
+ print(seq)
73
+ ```
74
+
75
+ Apply restrictions:
76
+
77
+ ```python
78
+ from codeine import CodingSpace, RestrictionSite
79
+
80
+ space = CodingSpace(
81
+ 'MKTLEFQNGSCPRYKKL',
82
+ forbidden_motifs=[
83
+ RestrictionSite.EcoRI,
84
+ RestrictionSite.BamHI,
85
+ 'CTGCAG',
86
+ ],
87
+ codon_restrictions={
88
+ 2: 'AAG',
89
+ 16: 'AAG',
90
+ },
91
+ max_homopolymer=4,
92
+ )
93
+
94
+ print(space.n_valid_sequences)
95
+ print(space.sample())
96
+ ```
97
+
98
+ Use custom codon weights to change sampling distribution:
99
+
100
+ ```python
101
+ from codeine import CodingSpace, CodonWeights
102
+
103
+ weights = CodonWeights.ecoli()
104
+
105
+ space = CodingSpace("MKTLEFQNGSCPRYKKL", codon_weights=weights)
106
+
107
+ seq = space.sample()
108
+ print(seq)
109
+ ```
110
+
111
+ Nonstandard translation tables and RNA:
112
+
113
+ ```python
114
+ from codeine import CodingSpace, TranslationTable
115
+
116
+ table = TranslationTable(table_id=2, rna=True)
117
+
118
+ space = CodingSpace("MKTLEFQNGSCPRYKKL", translation_table=table)
119
+
120
+ seq = space.sample()
121
+ print(seq)
122
+ ```
123
+
124
+ Enumerate all sequences (only recommended for small spaces):
125
+
126
+ ```python
127
+ from codeine import CodingSpace
128
+
129
+ space = CodingSpace('CYIQNCPLG')
130
+
131
+ for sequence in space:
132
+ print(sequence)
133
+ ```
134
+
135
+ Explore mutants of a chosen reference sequence:
136
+
137
+ ```python
138
+ from codeine import CodingSpace
139
+
140
+ space = CodingSpace('MKTLEFQNGSCPRYKKL')
141
+
142
+ reference = space.sample()
143
+
144
+ mutants = space.mutants(
145
+ reference,
146
+ free_positions=range(5, 14),
147
+ min_nts=2,
148
+ max_nts=5,
149
+ )
150
+
151
+ mutant = mutants.sample()
152
+ print(mutant)
153
+ ```
@@ -0,0 +1,15 @@
1
+ from codeine.space.coding import CodingSpace
2
+ from codeine.space.mutation import MutationSpace
3
+
4
+ from codeine.translation.tables import TranslationTable
5
+ from codeine.translation.weights import CodonWeights
6
+
7
+ from codeine.motifs.restriction import RestrictionSite
8
+
9
+ __all__ = [
10
+ 'CodingSpace',
11
+ 'CodonWeights',
12
+ 'MutationSpace',
13
+ 'RestrictionSite',
14
+ 'TranslationTable'
15
+ ]