Metadata-Version: 2.4
Name: nuc-count
Version: 0.1.0
Classifier: Programming Language :: Rust
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
License-File: LICENSE
Summary: Fast per-record nucleotide counting for FASTA/FASTQ
Keywords: bioinformatics,fasta,fastq,nucleotide,simd
License-Expression: MIT
Requires-Python: >=3.8
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM
Project-URL: Homepage, https://github.com/rickbeeloo/viral-nt-counts
Project-URL: Repository, https://github.com/rickbeeloo/viral-nt-counts

### 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](https://github.com/rickbeeloo/viral-nt-counts/blob/master/src/nt_counts.rs#L28-L29) 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](https://doc.rust-lang.org/cargo/getting-started/installation.html): `curl https://sh.rustup.rs -sSf | sh`.
Then you can install the binary directly using:

```bash
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](https://www.maturin.rs/) (`pip install maturin`):

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

The module exposes a single function:

```python
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. 

