Skip to main content

Python bindings for spoars — partial order alignment consensus and MSA

Project description

spoars (Python)

Python bindings for spoars — a faithful, SIMD-accelerated native-Rust reimplementation of the spoa partial order alignment (POA) library, for consensus generation and multiple sequence alignment.

Install

pip install spoars

Usage

import spoars

# One-call convenience:
g = spoars.poa(["ACGTACGT", "ACGTTCGT", "ACGTACGT"])
print(g.consensus())  # "ACGTACGT"
print(g.msa())  # ['ACGTACGT', 'ACGTTCGT', 'ACGTACGT']

# Or build incrementally, with an alignment type and scoring:
g = spoars.Poa(alignment_type="global", scoring=spoars.Scoring.default())
for read in ["ACGTACGT", "ACGTTCGT", "ACGTACGT"]:
    g.add(read)
print(g.consensus(min_coverage=2))
print(g.gfa())  # GFA v1
print(g.dot())  # Graphviz DOT

# Consensus with per-base total coverage, or the per-column base composition:
consensus, coverage = g.consensus(with_coverage=True)  # (str, list[int])
consensus, matrix = g.consensus_composition()  # rows = codes + a trailing gap row
# Cache or transmit a graph — pickle, or JSON via to_json / from_json:
import pickle

restored = pickle.loads(pickle.dumps(g))
restored = spoars.Poa.from_json(g.to_json())

# Inspect the graph directly — node ids are plain ints:
g.num_codes()  # size of the code alphabet
g.rank_order()  # node ids in topological order
g.node_code(3), g.node_base(3), g.node_coverage(3)
g.node_successor(3, 0)  # next node id sequence 0 visits after node 3 (or None)
g.sequence_path(0)  # node ids sequence 0 traverses
g.consensus_nodes()  # node ids on the consensus path
g.edges()  # [(tail, head, weight), ...]
g.msa_columns()  # (column-of-each-node, num_columns)
g.column_members()  # per column: [(sequence_index, node_id), ...]

alignment_type is one of "global", "local", or "overlap". Scoring takes (match, mismatch, gap_open, gap_extend, gap_open2, gap_extend2); the gap model (linear/affine/convex) is inferred, and Scoring.default() is spoa's convex default (5, -4, -8, -6, -10, -4).

Development

This package is built with maturin and developed with pixi:

pixi run develop      # build & install the extension into the dev env
pixi run test         # rebuild + pytest
pixi run format-check
pixi run lint
pixi run typecheck

License

MIT — see the repository.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

spoars-0.1.3-cp310-abi3-manylinux_2_28_x86_64.whl (451.9 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ x86-64

spoars-0.1.3-cp310-abi3-manylinux_2_28_aarch64.whl (389.1 kB view details)

Uploaded CPython 3.10+manylinux: glibc 2.28+ ARM64

spoars-0.1.3-cp310-abi3-macosx_11_0_arm64.whl (374.2 kB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

File details

Details for the file spoars-0.1.3-cp310-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for spoars-0.1.3-cp310-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a66c074ed8015af18c9036404e3b4a0a0bd06ad8d074b08eb313d439ee0707b8
MD5 53724fadb50842a120d1119b31d10e0a
BLAKE2b-256 5bec72f829817ed46afa4b663926e77a2de55e41ea7733a3e4c6265e98b92a3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for spoars-0.1.3-cp310-abi3-manylinux_2_28_x86_64.whl:

Publisher: pypi.yml on fg-labs/spoars

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spoars-0.1.3-cp310-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for spoars-0.1.3-cp310-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 401a1758354edaa1af05fa5fed09c607aa8923d800cc40b85c3cfd00d27ca16f
MD5 20b8431b48194d2c30822e9b786ee978
BLAKE2b-256 429230c600bc7bab6b13b407022348b2e8c2a3a54b79825fc6d01b9d8bba7968

See more details on using hashes here.

Provenance

The following attestation bundles were made for spoars-0.1.3-cp310-abi3-manylinux_2_28_aarch64.whl:

Publisher: pypi.yml on fg-labs/spoars

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file spoars-0.1.3-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for spoars-0.1.3-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5c3fc8ada6bf8300f7785d21a21f9ceedbd317a0d3803cdc5f841cae9de0d651
MD5 04d9c71f10fab8ad3841f03f557b24a0
BLAKE2b-256 3cde83e00473c9218e3c57f95968eaf12e60c170700338121ce29d5159b890f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for spoars-0.1.3-cp310-abi3-macosx_11_0_arm64.whl:

Publisher: pypi.yml on fg-labs/spoars

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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