vizibridge 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.
@@ -0,0 +1,74 @@
1
+ /target
2
+
3
+ Cargo.lock
4
+ .github
5
+ # Byte-compiled / optimized / DLL files
6
+ __pycache__/
7
+ .pytest_cache/
8
+ *.py[cod]
9
+
10
+ # C extensions
11
+ *.so
12
+
13
+ # Distribution / packaging
14
+ .Python
15
+ .venv/
16
+ env/
17
+ bin/
18
+ build/
19
+ develop-eggs/
20
+ dist/
21
+ eggs/
22
+ lib/
23
+ lib64/
24
+ parts/
25
+ sdist/
26
+ var/
27
+ include/
28
+ man/
29
+ venv/
30
+ *.egg-info/
31
+ .installed.cfg
32
+ *.egg
33
+
34
+ # Installer logs
35
+ pip-log.txt
36
+ pip-delete-this-directory.txt
37
+ pip-selfcheck.json
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .coverage
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+
47
+ # Translations
48
+ *.mo
49
+
50
+ # Mr Developer
51
+ .mr.developer.cfg
52
+ .project
53
+ .pydevproject
54
+
55
+ # Rope
56
+ .ropeproject
57
+
58
+ # Django stuff:
59
+ *.log
60
+ *.pot
61
+
62
+ .DS_Store
63
+
64
+ # Sphinx documentation
65
+ docs/_build/
66
+
67
+ # PyCharm
68
+ .idea/
69
+
70
+ # VSCode
71
+ .vscode/
72
+
73
+ # Pyenv
74
+ .python-version
@@ -0,0 +1,54 @@
1
+ stages: # List of stages for jobs, and their order of execution
2
+ - build
3
+ - compile
4
+ - release
5
+
6
+ build-job: # This job runs in the build stage, which runs first.
7
+ stage: build
8
+ tags:
9
+ - ci.inria.fr
10
+ - medium
11
+ image: docker:stable
12
+ script:
13
+ - docker build -t "$CI_REGISTRY_IMAGE/vizibridge_cont" .
14
+ - docker login -u gitlab-ci-token -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
15
+ - docker push "$CI_REGISTRY_IMAGE/vizibridge_cont"
16
+
17
+ compile:
18
+ stage: compile
19
+ tags:
20
+ - ci.inria.fr
21
+ - medium
22
+ image: "$CI_REGISTRY_IMAGE/vizibridge_cont"
23
+ script:
24
+ - echo C_JOB_ID=$CI_JOB_ID >> generate_executables.env
25
+ - maturin build --release
26
+ - file_path=$(ls target/wheels/*)
27
+ - echo F_L_x86_64=$(basename $file_path) >> generate_executables.env
28
+ - cat generate_executables.env
29
+
30
+ artifacts:
31
+ paths:
32
+ - ./target/wheels/*
33
+ reports:
34
+ dotenv: generate_executables.env
35
+
36
+ release_job:
37
+ stage: release
38
+ tags:
39
+ - ci.inria.fr
40
+ - medium
41
+ image: registry.gitlab.com/gitlab-org/release-cli:latest
42
+ rules:
43
+ - if: $CI_COMMIT_TAG # Run this job when a tag is created
44
+ script:
45
+ - echo "running release_job"
46
+ - echo "Compile job_id $C_JOB_ID"
47
+ - echo "url https://gitlab.inria.fr/cpaperma/vizibridge/-/jobs/${C_JOB_ID}/artifacts/raw/target/wheels/${F_L_x86_64}"
48
+ release: # See https://docs.gitlab.com/ee/ci/yaml/#release for available properties
49
+ tag_name: '$CI_COMMIT_TAG'
50
+ description: '$CI_COMMIT_TAG'
51
+ assets:
52
+ links:
53
+ - name: "Linux/X86_64"
54
+ url: "https://gitlab.inria.fr/cpaperma/vizibridge/-/jobs/${C_JOB_ID}/artifacts/raw/target/wheels/${F_L_x86_64}"
@@ -0,0 +1,310 @@
1
+ # This file is automatically @generated by Cargo.
2
+ # It is not intended for manual editing.
3
+ version = 3
4
+
5
+ [[package]]
6
+ name = "autocfg"
7
+ version = "1.2.0"
8
+ source = "registry+https://github.com/rust-lang/crates.io-index"
9
+ checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80"
10
+
11
+ [[package]]
12
+ name = "bitflags"
13
+ version = "1.3.2"
14
+ source = "registry+https://github.com/rust-lang/crates.io-index"
15
+ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
16
+
17
+ [[package]]
18
+ name = "cfg-if"
19
+ version = "1.0.0"
20
+ source = "registry+https://github.com/rust-lang/crates.io-index"
21
+ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
22
+
23
+ [[package]]
24
+ name = "heck"
25
+ version = "0.4.1"
26
+ source = "registry+https://github.com/rust-lang/crates.io-index"
27
+ checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8"
28
+
29
+ [[package]]
30
+ name = "indoc"
31
+ version = "2.0.5"
32
+ source = "registry+https://github.com/rust-lang/crates.io-index"
33
+ checksum = "b248f5224d1d606005e02c97f5aa4e88eeb230488bcc03bc9ca4d7991399f2b5"
34
+
35
+ [[package]]
36
+ name = "libc"
37
+ version = "0.2.153"
38
+ source = "registry+https://github.com/rust-lang/crates.io-index"
39
+ checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd"
40
+
41
+ [[package]]
42
+ name = "lock_api"
43
+ version = "0.4.11"
44
+ source = "registry+https://github.com/rust-lang/crates.io-index"
45
+ checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45"
46
+ dependencies = [
47
+ "autocfg",
48
+ "scopeguard",
49
+ ]
50
+
51
+ [[package]]
52
+ name = "log"
53
+ version = "0.4.21"
54
+ source = "registry+https://github.com/rust-lang/crates.io-index"
55
+ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
56
+
57
+ [[package]]
58
+ name = "memoffset"
59
+ version = "0.9.1"
60
+ source = "registry+https://github.com/rust-lang/crates.io-index"
61
+ checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
62
+ dependencies = [
63
+ "autocfg",
64
+ ]
65
+
66
+ [[package]]
67
+ name = "once_cell"
68
+ version = "1.19.0"
69
+ source = "registry+https://github.com/rust-lang/crates.io-index"
70
+ checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
71
+
72
+ [[package]]
73
+ name = "parking_lot"
74
+ version = "0.12.1"
75
+ source = "registry+https://github.com/rust-lang/crates.io-index"
76
+ checksum = "3742b2c103b9f06bc9fff0a37ff4912935851bee6d36f3c02bcc755bcfec228f"
77
+ dependencies = [
78
+ "lock_api",
79
+ "parking_lot_core",
80
+ ]
81
+
82
+ [[package]]
83
+ name = "parking_lot_core"
84
+ version = "0.9.9"
85
+ source = "registry+https://github.com/rust-lang/crates.io-index"
86
+ checksum = "4c42a9226546d68acdd9c0a280d17ce19bfe27a46bf68784e4066115788d008e"
87
+ dependencies = [
88
+ "cfg-if",
89
+ "libc",
90
+ "redox_syscall",
91
+ "smallvec",
92
+ "windows-targets",
93
+ ]
94
+
95
+ [[package]]
96
+ name = "portable-atomic"
97
+ version = "1.6.0"
98
+ source = "registry+https://github.com/rust-lang/crates.io-index"
99
+ checksum = "7170ef9988bc169ba16dd36a7fa041e5c4cbeb6a35b76d4c03daded371eae7c0"
100
+
101
+ [[package]]
102
+ name = "proc-macro2"
103
+ version = "1.0.79"
104
+ source = "registry+https://github.com/rust-lang/crates.io-index"
105
+ checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
106
+ dependencies = [
107
+ "unicode-ident",
108
+ ]
109
+
110
+ [[package]]
111
+ name = "pyo3"
112
+ version = "0.20.3"
113
+ source = "registry+https://github.com/rust-lang/crates.io-index"
114
+ checksum = "53bdbb96d49157e65d45cc287af5f32ffadd5f4761438b527b055fb0d4bb8233"
115
+ dependencies = [
116
+ "cfg-if",
117
+ "indoc",
118
+ "libc",
119
+ "memoffset",
120
+ "parking_lot",
121
+ "portable-atomic",
122
+ "pyo3-build-config",
123
+ "pyo3-ffi",
124
+ "pyo3-macros",
125
+ "unindent",
126
+ ]
127
+
128
+ [[package]]
129
+ name = "pyo3-build-config"
130
+ version = "0.20.3"
131
+ source = "registry+https://github.com/rust-lang/crates.io-index"
132
+ checksum = "deaa5745de3f5231ce10517a1f5dd97d53e5a2fd77aa6b5842292085831d48d7"
133
+ dependencies = [
134
+ "once_cell",
135
+ "target-lexicon",
136
+ ]
137
+
138
+ [[package]]
139
+ name = "pyo3-ffi"
140
+ version = "0.20.3"
141
+ source = "registry+https://github.com/rust-lang/crates.io-index"
142
+ checksum = "62b42531d03e08d4ef1f6e85a2ed422eb678b8cd62b762e53891c05faf0d4afa"
143
+ dependencies = [
144
+ "libc",
145
+ "pyo3-build-config",
146
+ ]
147
+
148
+ [[package]]
149
+ name = "pyo3-macros"
150
+ version = "0.20.3"
151
+ source = "registry+https://github.com/rust-lang/crates.io-index"
152
+ checksum = "7305c720fa01b8055ec95e484a6eca7a83c841267f0dd5280f0c8b8551d2c158"
153
+ dependencies = [
154
+ "proc-macro2",
155
+ "pyo3-macros-backend",
156
+ "quote",
157
+ "syn",
158
+ ]
159
+
160
+ [[package]]
161
+ name = "pyo3-macros-backend"
162
+ version = "0.20.3"
163
+ source = "registry+https://github.com/rust-lang/crates.io-index"
164
+ checksum = "7c7e9b68bb9c3149c5b0cade5d07f953d6d125eb4337723c4ccdb665f1f96185"
165
+ dependencies = [
166
+ "heck",
167
+ "proc-macro2",
168
+ "pyo3-build-config",
169
+ "quote",
170
+ "syn",
171
+ ]
172
+
173
+ [[package]]
174
+ name = "quote"
175
+ version = "1.0.36"
176
+ source = "registry+https://github.com/rust-lang/crates.io-index"
177
+ checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7"
178
+ dependencies = [
179
+ "proc-macro2",
180
+ ]
181
+
182
+ [[package]]
183
+ name = "redox_syscall"
184
+ version = "0.4.1"
185
+ source = "registry+https://github.com/rust-lang/crates.io-index"
186
+ checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa"
187
+ dependencies = [
188
+ "bitflags",
189
+ ]
190
+
191
+ [[package]]
192
+ name = "scopeguard"
193
+ version = "1.2.0"
194
+ source = "registry+https://github.com/rust-lang/crates.io-index"
195
+ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
196
+
197
+ [[package]]
198
+ name = "seq-macro"
199
+ version = "0.3.5"
200
+ source = "registry+https://github.com/rust-lang/crates.io-index"
201
+ checksum = "a3f0bf26fd526d2a95683cd0f87bf103b8539e2ca1ef48ce002d67aad59aa0b4"
202
+
203
+ [[package]]
204
+ name = "smallvec"
205
+ version = "1.13.2"
206
+ source = "registry+https://github.com/rust-lang/crates.io-index"
207
+ checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67"
208
+
209
+ [[package]]
210
+ name = "syn"
211
+ version = "2.0.58"
212
+ source = "registry+https://github.com/rust-lang/crates.io-index"
213
+ checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687"
214
+ dependencies = [
215
+ "proc-macro2",
216
+ "quote",
217
+ "unicode-ident",
218
+ ]
219
+
220
+ [[package]]
221
+ name = "target-lexicon"
222
+ version = "0.12.14"
223
+ source = "registry+https://github.com/rust-lang/crates.io-index"
224
+ checksum = "e1fc403891a21bcfb7c37834ba66a547a8f402146eba7265b5a6d88059c9ff2f"
225
+
226
+ [[package]]
227
+ name = "unicode-ident"
228
+ version = "1.0.12"
229
+ source = "registry+https://github.com/rust-lang/crates.io-index"
230
+ checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
231
+
232
+ [[package]]
233
+ name = "unindent"
234
+ version = "0.2.3"
235
+ source = "registry+https://github.com/rust-lang/crates.io-index"
236
+ checksum = "c7de7d73e1754487cb58364ee906a499937a0dfabd86bcb980fa99ec8c8fa2ce"
237
+
238
+ [[package]]
239
+ name = "vizibridge"
240
+ version = "0.1.0"
241
+ dependencies = [
242
+ "pyo3",
243
+ "seq-macro",
244
+ "vizitig-lib",
245
+ ]
246
+
247
+ [[package]]
248
+ name = "vizitig-lib"
249
+ version = "0.1.0"
250
+ source = "git+https://gitlab.inria.fr/cpaperma/vizicomp.git#cd737b028d8f2bd71eec7ec0de51522528d36f00"
251
+ dependencies = [
252
+ "log",
253
+ ]
254
+
255
+ [[package]]
256
+ name = "windows-targets"
257
+ version = "0.48.5"
258
+ source = "registry+https://github.com/rust-lang/crates.io-index"
259
+ checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
260
+ dependencies = [
261
+ "windows_aarch64_gnullvm",
262
+ "windows_aarch64_msvc",
263
+ "windows_i686_gnu",
264
+ "windows_i686_msvc",
265
+ "windows_x86_64_gnu",
266
+ "windows_x86_64_gnullvm",
267
+ "windows_x86_64_msvc",
268
+ ]
269
+
270
+ [[package]]
271
+ name = "windows_aarch64_gnullvm"
272
+ version = "0.48.5"
273
+ source = "registry+https://github.com/rust-lang/crates.io-index"
274
+ checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
275
+
276
+ [[package]]
277
+ name = "windows_aarch64_msvc"
278
+ version = "0.48.5"
279
+ source = "registry+https://github.com/rust-lang/crates.io-index"
280
+ checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
281
+
282
+ [[package]]
283
+ name = "windows_i686_gnu"
284
+ version = "0.48.5"
285
+ source = "registry+https://github.com/rust-lang/crates.io-index"
286
+ checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
287
+
288
+ [[package]]
289
+ name = "windows_i686_msvc"
290
+ version = "0.48.5"
291
+ source = "registry+https://github.com/rust-lang/crates.io-index"
292
+ checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
293
+
294
+ [[package]]
295
+ name = "windows_x86_64_gnu"
296
+ version = "0.48.5"
297
+ source = "registry+https://github.com/rust-lang/crates.io-index"
298
+ checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
299
+
300
+ [[package]]
301
+ name = "windows_x86_64_gnullvm"
302
+ version = "0.48.5"
303
+ source = "registry+https://github.com/rust-lang/crates.io-index"
304
+ checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
305
+
306
+ [[package]]
307
+ name = "windows_x86_64_msvc"
308
+ version = "0.48.5"
309
+ source = "registry+https://github.com/rust-lang/crates.io-index"
310
+ checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
@@ -0,0 +1,14 @@
1
+ [package]
2
+ name = "vizibridge"
3
+ version = "0.1.0"
4
+ edition = "2021"
5
+
6
+ # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
+ [lib]
8
+ name = "vizibridge"
9
+ crate-type = ["cdylib"]
10
+
11
+ [dependencies]
12
+ pyo3 = "0.20.0"
13
+ seq-macro = "0.3.5"
14
+ vizitig-lib = { git = "https://gitlab.inria.fr/cpaperma/vizicomp.git" }
@@ -0,0 +1,4 @@
1
+ FROM rust:latest
2
+ COPY . ./app/
3
+ WORKDIR /app
4
+ RUN cargo install maturin
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 PAPERMAN Charles
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.
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.3
2
+ Name: vizibridge
3
+ Version: 0.1.0
4
+ Classifier: Programming Language :: Rust
5
+ Classifier: Programming Language :: Python :: Implementation :: CPython
6
+ Classifier: Programming Language :: Python :: Implementation :: PyPy
7
+ Requires-Dist: ruff
8
+ Requires-Dist: mypy
9
+ Requires-Dist: pytest
10
+ License-File: LICENSE
11
+ Requires-Python: >=3.8
@@ -0,0 +1,24 @@
1
+ [build-system]
2
+ requires = ["maturin>=1.5,<2.0"]
3
+ build-backend = "maturin"
4
+
5
+ [project]
6
+ name = "vizibridge"
7
+ requires-python = ">=3.8"
8
+ classifiers = [
9
+ "Programming Language :: Rust",
10
+ "Programming Language :: Python :: Implementation :: CPython",
11
+ "Programming Language :: Python :: Implementation :: PyPy",
12
+ ]
13
+ dynamic = ["version"]
14
+
15
+ dependencies=[
16
+ "ruff",
17
+ "mypy",
18
+ "pytest"
19
+ ]
20
+
21
+ [tool.maturin]
22
+ python-source = "python"
23
+ module-name = "vizibridge._vizibridge"
24
+ features = ["pyo3/extension-module"]
@@ -0,0 +1,43 @@
1
+ from vizibridge._vizibridge import DNA as rust_DNA
2
+ import re
3
+ from typing import Iterator, Self
4
+
5
+ non_CGTA = re.compile("[^ACGT]")
6
+
7
+ class DNA:
8
+ __slots__ = ("data",)
9
+ def __init__(self, data: rust_DNA | str):
10
+ if isinstance(data, str):
11
+ self.data = rust_DNA(data)
12
+ elif isinstance(data, rust_DNA):
13
+ self.data = data
14
+ else:
15
+ raise TypeError(type(data))
16
+
17
+ @classmethod
18
+ def from_str(cls, seq: str) -> Iterator["DNA"]:
19
+ yield from (cls(subseq) for subseq in non_CGTA.split(seq))
20
+
21
+ def __iter__(self) -> Iterator[str]:
22
+ for i in range(len(self.data)):
23
+ self.data.get_index(i)
24
+
25
+ def __getitem__(self, __key: int | slice) -> Self | str:
26
+ if isinstance(__key, int):
27
+ return self.data.get_index(__key)
28
+ if isinstance(__key, slice):
29
+ assert __key.step is None
30
+ data = self.data.get_slice(__key.start, __key.stop)
31
+ return type(self)(data)
32
+
33
+ raise KeyError(__key)
34
+
35
+ def __repr__(self):
36
+ return repr(self.data)
37
+
38
+
39
+ def __len__(self):
40
+ return len(self.data)
41
+
42
+ def enum_canonical_kmer(self, k: int):
43
+ return getattr(self.data, f"enumerate_canonical_kmer{k}")()
@@ -0,0 +1,2 @@
1
+ [toolchain]
2
+ channel = "nightly"
@@ -0,0 +1,107 @@
1
+ #![allow(non_local_definitions)]
2
+ use pyo3::prelude::*;
3
+ use pyo3::types::{PyString, PyType};
4
+ use seq_macro::seq;
5
+ use vizitig_lib::dna::{Nucleotid, DNA};
6
+ use vizitig_lib::iterators::CanonicalKmerIterator;
7
+ use vizitig_lib::kmer::ShortKmer;
8
+
9
+ #[pyclass(name = "DNA")]
10
+ pub struct PyDNA {
11
+ pub content: DNA,
12
+ }
13
+
14
+ seq!(N in 3..=31{
15
+ #[pymethods]
16
+ impl PyDNA {
17
+
18
+ #[new]
19
+ pub fn new<'py>(input_pystr: &'py PyString) -> PyResult<Self> {
20
+ let input_str = input_pystr.to_str()?;
21
+ let dna = input_str.as_bytes().try_into().unwrap();
22
+ Ok(PyDNA {
23
+ content: dna
24
+ })
25
+ }
26
+
27
+ pub fn __repr__(&self) -> PyResult<String> {
28
+ Ok(self.content.content.clone().into_iter().map(|u| char::from(u)).collect::<String>())
29
+ }
30
+
31
+ fn __len__(&self) -> PyResult<usize>{
32
+ Ok(self.content.content.len())
33
+ }
34
+
35
+ pub fn get_index(&self, index: usize) -> PyResult<char>{
36
+ Ok(self.content.content[index].into())
37
+ }
38
+ pub fn get_slice(&self, start: usize, stop: usize) -> PyResult<Self> {
39
+ Ok(PyDNA {
40
+ content: DNA {
41
+ content: self.content.content.get(start..stop).unwrap().to_vec()
42
+ }
43
+ })
44
+ }
45
+
46
+ #(
47
+ pub fn enumerate_canonical_kmer~N(&self) -> PyResult<Vec<PyKmer~N>>{
48
+ let it : CanonicalKmerIterator<N, u64> = (&self.content).try_into().unwrap();
49
+ Ok(it.map(|u| PyKmer~N{content: u }).collect())
50
+ }
51
+ )*
52
+
53
+ }
54
+ });
55
+
56
+ seq!(N in 3..=31{
57
+ #[pyclass(name="Kmer")]
58
+ #[derive(Clone)]
59
+ pub struct PyKmer~N{
60
+ content: ShortKmer<N>,
61
+ }
62
+ #[pymethods]
63
+ impl PyKmer~N{
64
+ #[classmethod]
65
+ fn from_dna(_: &PyType, dna: &PyDNA) -> PyResult<Self>{
66
+ let nucleotids : &[Nucleotid; N] = dna.content.content.first_chunk::<N>().unwrap();
67
+ let kmer : ShortKmer<N> = nucleotids.try_into().unwrap();
68
+ Ok(PyKmer~N{ content: kmer })
69
+ }
70
+
71
+ fn add_left_nucleotid(&self, n: char) -> PyResult<Self>{
72
+ Ok(PyKmer~N{ content: self.content.append_left(n.try_into().unwrap()) })
73
+ }
74
+
75
+
76
+ fn add_right_nucleotid(&self, n: char) -> PyResult<Self>{
77
+ Ok(PyKmer~N{ content: self.content.append(n.try_into().unwrap()) })
78
+ }
79
+
80
+ fn __repr__(&self) -> PyResult<String>{
81
+ return Ok(format!("{}", &self.content))
82
+ }
83
+
84
+ fn __str__(&self) -> PyResult<String>{
85
+ return Ok((&self.content).into())
86
+ }
87
+
88
+ fn __lt__(&self, other: Self) -> PyResult<bool> {
89
+ return Ok(self.content <= other.content)
90
+ }
91
+
92
+ fn __gt__(&self, other: Self) -> PyResult<bool> {
93
+ return Ok(self.content >= other.content)
94
+ }
95
+ }
96
+ });
97
+
98
+
99
+ seq!(N in 3..=31{
100
+ #[pymodule]
101
+ fn _vizibridge(_py: Python, m: &PyModule) -> PyResult<()> {
102
+ #(
103
+ m.add_class::<PyKmer~N>()?;
104
+ )*
105
+ m.add_class::<PyDNA>()?;
106
+ Ok(())
107
+ }});