Skip to main content

seqcounter: count reference sequences in reads or assemblies

Tests Coverage Release PyPI Python 3.10–3.14 License Documentation DOI

Count how many sequencing reads (fastq) or contigs (fasta) contain each sequence of a reference file, with Seal from BBTools. Point it at a reference fasta file and a sample, or a folder of samples, and it writes one table of counts per reference sequence and per sample.

Any set of short sequences works: spoligotype spacers, marker or resistance genes, primer or probe sequences, plasmid or phage fragments, barcodes, spike-ins. seqcounter does not interpret them; it counts them, reproducibly and in the same way for reads and for assemblies.

$ seqcounter -ref refs.fasta -i samples/ -o results/
Reference   assembly  no_match  paired  single_end
absent      0         0         0       0
present     1         0         86      34
twice       1         0         154     65

Features

  • Reads or assemblies: single-end or paired-end fastq, or fasta, gzipped or not. Both mates of a pair are counted, once each.
  • Batch mode: point it at a folder; fastq and fasta files are found recursively and R1/R2 files paired automatically. Several samples can be counted at the same time.
  • Both strands, and mismatches: a reference is found on either strand, and with up to -m mismatches per k-mer (one by default).
  • Three reports: the counts table (refseqcounts.tsv, the table the first version of seqcounter wrote, with the command that produced it on its first line), a per-sample summary of how much was read and how much matched, and a JSON report with the parameters, the software versions and the counts.
  • Nothing is hidden: references Seal cannot find (shorter than the k-mer size), names that would collide, and samples that failed are reported, not silently dropped. A failed sample leaves the others readable.
  • Nothing to configure: no database, no index, no reference genome. Only the Python standard library, plus BBTools.
  • Tested: 105 tests, 100% coverage, end to end on synthetic references, genomes and reads with known counts.

Installation

conda create -n seqcounter -c conda-forge -c bioconda bbmap python">=3.10"
conda activate seqcounter
pip install seqcounter

BBTools (which provides seal.sh) is not on PyPI, so it comes from bioconda; seqcounter itself needs nothing else. See Installation for other options, including running it from a clone with python seqcounter.py, as the first version did.

Quick start

seqcounter -ref refs.fasta -r1 sample_R1.fastq.gz -r2 sample_R2.fastq.gz -o results/  # Paired-end reads
seqcounter -ref refs.fasta -r1 sample.fastq.gz -o results/                            # Single-end reads
seqcounter -ref refs.fasta -r1 assembly.fasta -o results/                             # An assembly
seqcounter -ref refs.fasta -i samples/ -o results/ -p 4                               # A folder, 4 at a time

-ref is a fasta file of the sequences to count: each one gives a row, named after the first word of its > line. The counts are printed and saved in results/. To see it work on data with known counts, run bash examples/run_example.sh, which generates its own references and samples.

What a count is: the number of reads, or contigs, that contain the reference sequence, not the number of copies it has in them. A reference present twice in a single-contig assembly is counted once; in reads, about twice as many reads match it. See How it works.

Documentation

The wiki covers installation, usage and options, output files, how it works, troubleshooting and the FAQ.

Citing

If you use seqcounter, please cite it and BBTools, which does the counting:

Duceppe M-O. seqcounter: count the occurrences of reference sequences in sequencing reads or genome assemblies. Zenodo. https://doi.org/10.5281/zenodo.23826933

This DOI always points to the latest version; each release also has its own DOI, listed on Zenodo.

Bushnell B. BBTools. https://sourceforge.net/projects/bbmap/

GitHub's "Cite this repository" button gives the citation in APA and BibTeX formats, from CITATION.cff.

  • spoligotyper — in silico spoligotyping of the M. tuberculosis complex. It counts the 43 spacers the way seqcounter counts any reference, and then reads them as a spoligotype, with the species, the lineage and a PDF report.
  • brucetyper — in silico Bruce-ladder, Suis-ladder, AMOS and RB51 junction PCR for Brucella, from assemblies.

Contributing

Bug reports, questions and pull requests are welcome: see CONTRIBUTING.md.

Author

Marc-Olivier Duceppe, Canadian Food Inspection Agency (CFIA): marc-olivier.duceppe@inspection.gc.ca

License

MIT

Metadata

Release files for seqcounter 1.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for seqcounter 1.0.1
File Size Uploaded Provenance Actions
seqcounter-1.0.1.tar.gz 31.7 kB With provenance Details for seqcounter-1.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for seqcounter 1.0.1
File Interpreter ABI Platform Actions
seqcounter-1.0.1-py3-none-any.whl Python 3 none any Details for seqcounter-1.0.1-py3-none-any.whl

Total release size: 52.2 kB

Release files / seqcounter-1.0.1.tar.gz

Download URL seqcounter-1.0.1.tar.gz
Size 31.7 kB
Tags Source
SHA-256 checksum
How to use checksums
5fb2188904afe3e9c4161551fee44632d330ca2cb3d78e5544e406a8acedd344
BLAKE2b-256 checksum
How to use checksums
02f2790d69cf73fe3c8142bddd018d24c3b1d2360bc17f343574ce5766d7ea75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Release files / seqcounter-1.0.1-py3-none-any.whl

Download URL seqcounter-1.0.1-py3-none-any.whl
Size 20.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e3b442592e981a00f62ea4d2b72abd3f7c970498264a3737568fa08c6a1beda0
BLAKE2b-256 checksum
How to use checksums
4398fc72415add63ba599a47676fa37cdb9b213e6e5e8edebe41ef2a4d6e2a91
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

Security for seqcounter 1.0.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for seqcounter-1.0.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 31, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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