Skip to main content

NT count test

Just little test to see how fast we can count nucleotides, this optimizes the original code to use SIMD instructions reaching around 15GB/s. For the viral genomes that is around 50k genomes in 0.2s (or 1GB sequences in 0.2 sec). The main speed up actually comes here where we loop 5 times per nucleotide. This seems worse than just saying if nt == a increment count but the branches for this have a huge impact when mis-predicted for each nucleotide.

Usage

If you do not have Cargo yet see here: curl https://sh.rustup.rs -sSf | sh. Then you can install the binary directly using:

cargo install --git ssh://git@github.com/rickbeeloo/viral-nt-counts.git

Then you can run it with:

nuc-count-test --output output.tsv --threads 4 genomes.fasta

Python bindings

Built with maturin (pip install maturin):

maturin develop --release     # into the current venv
maturin build --release       # or a wheel in target/wheels/

The module exposes a single function:

import nuc_count

nuc_count.count("genomes.fasta", "output.tsv", threads=4)  # threads=0 = all cores

It writes the same TSV as the CLI and releases the GIL while counting, so it does not block other Python threads. Errors come back as RuntimeError.

You can increase the threads but if this helps (or harms) mostly depends on the IO speed as the code itself is much faster than the read speed. So likely around 3-4 threads will work best but you can play with it.

Download files

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

Source Distribution

nuc_count-0.1.0.tar.gz (1.0 MB view details)

Uploaded Source

Built Distributions

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

nuc_count-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (579.8 kB view details)

Uploaded CPython 3.8+manylinux: glibc 2.17+ x86-64

nuc_count-0.1.0-cp38-abi3-macosx_11_0_arm64.whl (425.3 kB view details)

Uploaded CPython 3.8+macOS 11.0+ ARM64

File details

Details for the file nuc_count-0.1.0.tar.gz.

File metadata

  • Download URL: nuc_count-0.1.0.tar.gz
  • Upload date:
  • Size: 1.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.3

File hashes

Hashes for nuc_count-0.1.0.tar.gz
Algorithm Hash digest
SHA256 670f2c114bcdb01358d48fde4cbcb65743aeac5a987248abb9fecaa51724411e
MD5 19c0fc1eacfa07fe8a9f7417c1e2182d
BLAKE2b-256 acf530ba9d4f1eee2c60d05a6e7201553dd400a7f76365a0dcae9c5e20bc47d5

See more details on using hashes here.

File details

Details for the file nuc_count-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for nuc_count-0.1.0-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 11f343a56cb51f58c35e716d3609d7f69a2c25be05dd77c13f54297779e9f361
MD5 00557a0cf8e47f5a2fb73684b2021d3a
BLAKE2b-256 5a0ff3317b2bbd848a738229b95bcec31d21d0ee2225965ccedfb744085c411a

See more details on using hashes here.

File details

Details for the file nuc_count-0.1.0-cp38-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for nuc_count-0.1.0-cp38-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b645e4ba23e222b30948ac7c5ac95163d4ed7bc4f569a708ed337f7445fa9f48
MD5 ef9e2326699f78d52e52f343aee312a2
BLAKE2b-256 9a3a7b72940188b265da684742bef17aea2ac7069d284776ee0d3dac88d5540c

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.1.0 This release

3 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page