ferroseq 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 (51) hide show
  1. ferroseq-0.1.0/.github/workflows/ci.yml +67 -0
  2. ferroseq-0.1.0/.github/workflows/release.yml +86 -0
  3. ferroseq-0.1.0/.gitignore +9 -0
  4. ferroseq-0.1.0/CHANGELOG.md +25 -0
  5. ferroseq-0.1.0/CONTRIBUTING.md +27 -0
  6. ferroseq-0.1.0/Cargo.lock +2433 -0
  7. ferroseq-0.1.0/Cargo.toml +38 -0
  8. ferroseq-0.1.0/LICENSE +21 -0
  9. ferroseq-0.1.0/PKG-INFO +220 -0
  10. ferroseq-0.1.0/README.md +191 -0
  11. ferroseq-0.1.0/bench/bench.py +137 -0
  12. ferroseq-0.1.0/bench/bench_cli.py +77 -0
  13. ferroseq-0.1.0/bench/results_cli.md +10 -0
  14. ferroseq-0.1.0/bench/results_threads1.md +23 -0
  15. ferroseq-0.1.0/bench/results_threads2.md +23 -0
  16. ferroseq-0.1.0/crates/ferroseq-core/Cargo.toml +19 -0
  17. ferroseq-0.1.0/crates/ferroseq-core/LICENSE +21 -0
  18. ferroseq-0.1.0/crates/ferroseq-core/README.md +12 -0
  19. ferroseq-0.1.0/crates/ferroseq-core/src/alphabet.rs +119 -0
  20. ferroseq-0.1.0/crates/ferroseq-core/src/composition.rs +190 -0
  21. ferroseq-0.1.0/crates/ferroseq-core/src/distance.rs +46 -0
  22. ferroseq-0.1.0/crates/ferroseq-core/src/io.rs +198 -0
  23. ferroseq-0.1.0/crates/ferroseq-core/src/kmer.rs +48 -0
  24. ferroseq-0.1.0/crates/ferroseq-core/src/lib.rs +33 -0
  25. ferroseq-0.1.0/crates/ferroseq-core/src/motif.rs +366 -0
  26. ferroseq-0.1.0/crates/ferroseq-core/src/quality.rs +96 -0
  27. ferroseq-0.1.0/crates/ferroseq-core/src/transform.rs +91 -0
  28. ferroseq-0.1.0/crates/ferroseq-core/src/translate.rs +162 -0
  29. ferroseq-0.1.0/packaging/bioconda/README.md +87 -0
  30. ferroseq-0.1.0/packaging/bioconda/ferroseq/build.sh +13 -0
  31. ferroseq-0.1.0/packaging/bioconda/ferroseq/meta.yaml +73 -0
  32. ferroseq-0.1.0/pyproject.toml +48 -0
  33. ferroseq-0.1.0/python/ferroseq/__init__.py +156 -0
  34. ferroseq-0.1.0/python/ferroseq/__main__.py +3 -0
  35. ferroseq-0.1.0/python/ferroseq/_expr.py +186 -0
  36. ferroseq-0.1.0/python/ferroseq/_lazy_pandas.py +45 -0
  37. ferroseq-0.1.0/python/ferroseq/_pandas.py +47 -0
  38. ferroseq-0.1.0/python/ferroseq/cli.py +243 -0
  39. ferroseq-0.1.0/python/ferroseq/io.py +246 -0
  40. ferroseq-0.1.0/python/ferroseq/py.typed +0 -0
  41. ferroseq-0.1.0/python/ferroseq/stats.py +223 -0
  42. ferroseq-0.1.0/src/expressions.rs +409 -0
  43. ferroseq-0.1.0/src/io.rs +589 -0
  44. ferroseq-0.1.0/src/lib.rs +26 -0
  45. ferroseq-0.1.0/tests/conftest.py +20 -0
  46. ferroseq-0.1.0/tests/test_against_biopython.py +172 -0
  47. ferroseq-0.1.0/tests/test_cli.py +107 -0
  48. ferroseq-0.1.0/tests/test_engine.py +97 -0
  49. ferroseq-0.1.0/tests/test_io.py +57 -0
  50. ferroseq-0.1.0/tests/test_stats.py +141 -0
  51. ferroseq-0.1.0/tests/test_streaming_and_motifs.py +186 -0
@@ -0,0 +1,67 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_dispatch:
8
+
9
+ permissions:
10
+ contents: read
11
+
12
+ jobs:
13
+ rust:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v6
17
+ - uses: dtolnay/rust-toolchain@stable
18
+ with:
19
+ components: rustfmt, clippy
20
+ - run: cargo fmt --all --check
21
+ - run: cargo clippy --all-targets -- -D warnings
22
+ - run: cargo test -p ferroseq-core
23
+
24
+ python:
25
+ runs-on: ${{ matrix.os }}
26
+ strategy:
27
+ fail-fast: false
28
+ matrix:
29
+ os: [ubuntu-latest, macos-latest, windows-latest]
30
+ python: ["3.11", "3.13"]
31
+ steps:
32
+ - uses: actions/checkout@v6
33
+ - uses: actions/setup-python@v6
34
+ with:
35
+ python-version: ${{ matrix.python }}
36
+ - uses: dtolnay/rust-toolchain@stable
37
+ - name: Build and test (fast-compile profile)
38
+ shell: bash
39
+ run: |
40
+ python -m venv .venv
41
+ if [ -f .venv/Scripts/activate ]; then source .venv/Scripts/activate; else source .venv/bin/activate; fi
42
+ pip install maturin "polars>=2.2" pytest biopython pandas pyarrow
43
+ maturin develop --profile ci
44
+ pytest
45
+
46
+ seqkit-compat:
47
+ # Compare `stats` and `grep -m` against the real seqkit from Bioconda.
48
+ runs-on: ubuntu-latest
49
+ steps:
50
+ - uses: actions/checkout@v6
51
+ - uses: actions/setup-python@v6
52
+ with:
53
+ python-version: "3.13"
54
+ - uses: dtolnay/rust-toolchain@stable
55
+ - uses: mamba-org/setup-micromamba@v2
56
+ with:
57
+ environment-name: seqkit
58
+ create-args: seqkit
59
+ condarc: |
60
+ channels: [conda-forge, bioconda]
61
+ - name: Build and run the seqkit comparison tests
62
+ shell: bash
63
+ run: |
64
+ python -m venv .venv && source .venv/bin/activate
65
+ pip install maturin "polars>=2.2" pytest biopython pandas pyarrow
66
+ maturin develop --profile ci
67
+ SEQKIT="$MAMBA_ROOT_PREFIX/envs/seqkit/bin/seqkit" pytest tests/test_stats.py tests/test_streaming_and_motifs.py -v
@@ -0,0 +1,86 @@
1
+ name: Release
2
+
3
+ on:
4
+ push:
5
+ tags: ["v*"]
6
+ workflow_dispatch:
7
+
8
+ permissions:
9
+ contents: read
10
+
11
+ jobs:
12
+ wheels:
13
+ name: wheel ${{ matrix.platform.os }}-${{ matrix.platform.target }}
14
+ runs-on: ${{ matrix.platform.runner }}
15
+ strategy:
16
+ fail-fast: false
17
+ matrix:
18
+ platform:
19
+ - { os: linux, runner: ubuntu-22.04, target: x86_64 }
20
+ - { os: linux, runner: ubuntu-22.04-arm, target: aarch64 }
21
+ - { os: macos, runner: macos-15-intel, target: x86_64 }
22
+ - { os: macos, runner: macos-latest, target: aarch64 }
23
+ - { os: windows, runner: windows-latest, target: x64 }
24
+ steps:
25
+ - uses: actions/checkout@v6
26
+ - uses: actions/setup-python@v6
27
+ with:
28
+ python-version: "3.11"
29
+ - name: Build abi3 wheel (one wheel covers Python 3.11+)
30
+ uses: PyO3/maturin-action@v1
31
+ with:
32
+ target: ${{ matrix.platform.target }}
33
+ args: --release --out dist
34
+ manylinux: auto
35
+ - name: Smoke-test the wheel
36
+ shell: bash
37
+ run: |
38
+ python -m pip install dist/*.whl pytest biopython pandas pyarrow
39
+ cd tests && python -m pytest -q
40
+ - uses: actions/upload-artifact@v6
41
+ with:
42
+ name: wheels-${{ matrix.platform.os }}-${{ matrix.platform.target }}
43
+ path: dist
44
+
45
+ sdist:
46
+ runs-on: ubuntu-latest
47
+ steps:
48
+ - uses: actions/checkout@v6
49
+ - uses: PyO3/maturin-action@v1
50
+ with:
51
+ command: sdist
52
+ args: --out dist
53
+ - uses: actions/upload-artifact@v6
54
+ with:
55
+ name: wheels-sdist
56
+ path: dist
57
+
58
+ publish-pypi:
59
+ needs: [wheels, sdist]
60
+ if: startsWith(github.ref, 'refs/tags/')
61
+ runs-on: ubuntu-latest
62
+ environment: pypi
63
+ permissions:
64
+ id-token: write # PyPI trusted publishing (no API token stored in the repo)
65
+ attestations: write
66
+ contents: read
67
+ steps:
68
+ - uses: actions/download-artifact@v7
69
+ - uses: actions/attest@v4
70
+ with:
71
+ subject-path: "wheels-*/*"
72
+ - uses: astral-sh/setup-uv@v7
73
+ - run: uv publish --trusted-publishing always 'wheels-*/*'
74
+
75
+ publish-crate:
76
+ needs: [wheels]
77
+ if: startsWith(github.ref, 'refs/tags/')
78
+ runs-on: ubuntu-latest
79
+ env:
80
+ CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
81
+ steps:
82
+ - uses: actions/checkout@v6
83
+ - uses: dtolnay/rust-toolchain@stable
84
+ - name: Publish ferroseq-core to crates.io (skipped if no token is configured)
85
+ if: env.CARGO_REGISTRY_TOKEN != ''
86
+ run: cargo publish -p ferroseq-core
@@ -0,0 +1,9 @@
1
+ target/
2
+ __pycache__/
3
+ *.so
4
+ *.pyd
5
+ .pytest_cache/
6
+ dist/
7
+ *.egg-info/
8
+ .venv/
9
+ bench/data/
@@ -0,0 +1,25 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0 (2026-11-30)
4
+
5
+ ### Library
6
+ - `.seq` namespace for Polars expressions and Series and for pandas Series (registered lazily: importing
7
+ ferroseq no longer imports pandas).
8
+ - Kernels: GC content and skew, entropy, alphabet validation, reverse complement, complement,
9
+ transcription, translation (NCBI tables 1–6, 11; IUPAC codons resolved like Biopython, incl. B/Z/J),
10
+ IUPAC motif search (bitap) with up to k mismatches and both strands, k-mers, base counting,
11
+ Hamming and Levenshtein distance, Phred statistics, Q≥n counts, 3' quality trimming.
12
+ - I/O: `read_*` with `columns`/`n_rows` and stdin/bytes/file-object sources; `scan_*` LazyFrames with
13
+ projection, limit and predicate pushdown for streaming; `iter_batches`; writers accept LazyFrames,
14
+ write to stdout and keep descriptions. Gzip via the pure-Rust zlib-rs backend.
15
+ - `stats()`: seqkit-stats-compatible summary in one Rust pass per file.
16
+ - Helpers: `quality_trim`, `filter_reads` (length, EE, mean Q, N fraction, GC), `kmer_counts`,
17
+ `show_versions`.
18
+
19
+ ### Command line
20
+ - `ferroseq stats | grep | filter | trim | convert | fx2tab`, streaming, stdin/stdout, gzip, and
21
+ clean exit on closed pipes.
22
+
23
+ ### Packaging
24
+ - abi3 wheels for Python 3.11+; GitHub Actions for CI and PyPI trusted publishing; Bioconda recipe in
25
+ `packaging/bioconda/`.
@@ -0,0 +1,27 @@
1
+ # Contributing to ferroseq
2
+
3
+ ## Adding a new sequence method (three layers)
4
+
5
+ 1. **Kernel** in `crates/ferroseq-core/src/` works on `&[u8]`, has no Python types, and comes with a
6
+ `#[cfg(test)]` unit test. Avoid per-base branches and allocations in hot loops: prefer 256-entry
7
+ lookup tables and `*_into(&[u8], &mut Vec<u8>)` signatures that reuse a buffer.
8
+ 2. **Expression** in `src/expressions.rs` uses `#[polars_expr]` and one of the helpers `map_f64`,
9
+ `map_u32`, `map_bool` or `map_str`, which handle nulls and multi-threading for you. Keyword arguments
10
+ come in through a `#[derive(Deserialize)]` struct.
11
+ 3. **Python method** goes on `SeqExprNamespace` in `python/ferroseq/_expr.py`, with a docstring that
12
+ states its exact semantics. The Polars Series and pandas accessors pick it up automatically.
13
+
14
+ 4. **CLI (optional)**: if the method is useful from the shell, wire it into `python/ferroseq/cli.py`
15
+ as a transform passed to `_stream`, so it streams in bounded memory like the other commands.
16
+
17
+ Then add a test in `tests/` that checks the new method against an independent implementation
18
+ (Biopython, or a short plain-Python reference), and add a benchmark row in `bench/bench.py` if speed is
19
+ the point of the change.
20
+
21
+ ## Checks before opening a PR
22
+
23
+ ```bash
24
+ cargo fmt --all && cargo clippy --all-targets -- -D warnings
25
+ cargo test -p ferroseq-core
26
+ maturin develop --release && pytest # SEQKIT=/path/to/seqkit also runs the seqkit comparisons
27
+ ```