Skip to content

Module functions

Import from the package root, e.g. from snipe import sketch, load.

snipe.sketch(input_files, k1=None, k2=None, scale=None, threads=None, max_sequences=None, signature_type=None, min_seq_length=None, keep_acgt=None)

Create a signature from sequence files (full-featured sketch entry point).

Auto-detects the input format and exposes the complete kwarg surface (min_seq_length, keep_acgt). This is the primary public sketch function.

snipe.sketch_reference(fasta, k1=None, k2=None, scale=None, threads=None)

Sketch a single reference FASTA into a reference-typed edgemer signature.

snipe.sketch_many(files: 'List[PathLike]', *, threads=None, **kwargs) -> "List['Signature']"

Sketch each file independently and in parallel; returns Signatures in input order.

Fans the per-file sketches out across a ThreadPoolExecutor — each native sketch call releases the GIL while it runs, so the files sketch concurrently. Sketch parameters (k1/k2/scale and the other sketch knobs) pass straight through as keyword arguments.

snipe.load(path)

Load signature from file - directly wraps Rust API.

Accepts str | os.PathLike. Auto-detects the format by content magic + extension: an edgemer .snipesig (or legacy JSON) loads as an edgemer signature; a K1-only .snipesig (marker in its Parquet footer) loads back as a K1-only signature (so a K1-only save/reload never flips to edgemer); a sourmash .sig/.sig.gz or single-signature .zip loads as K1-only. A .tsv path is rejected up front — TSV is an export-only format, not loadable.

snipe.load_many(paths_or_glob: 'Union[str, List[PathLike]]') -> "List['Signature']"

Load many signatures from a glob string or an explicit list of paths.

snipe.light_metadata(path)

Read a signature’s metadata + sourmash md5 from its PATH, without building a Signature object or rehydrating its edgemer table. Accepts str | os.PathLike.

This is the path-in / metadata-out call the qc-JSON writer uses: the caller passes only a path and Rust does the reading. For a native Parquet .snipesig everything — including the md5 (the sourmash-interoperable K1 checksum) and the hash count — comes straight from the footer that was written at sketch time, so no row-groups are read at all: the cost is O(1) in the signature size, not O(n). Legacy JSON / sourmash / zip inputs (which have no cheap header) fall back to a full load and recompute the identical checksum. The returned dict carries name, filename, md5, signature_type, scale, k1_size, k2_size, hash_threshold, num_hashes, is_edgemer, version, created_at, input_files — the same values as load(path).metadata (which names the sizes k1/k2) with md5 added.

snipe.load_sourmash(path)

Load a K1-only signature from a sourmash signature file - directly wraps Rust API. Accepts str | os.PathLike.

snipe.sample_counts(sigs: "List['Signature']") -> "'Signature'"

Presence-count aggregate: how many input signatures contain each k-mer.

Each signature is reduced to presence (all abundances set to 1) and the results are summed natively, so the returned signature’s abundances are per-hash sample counts. This mirrors the core of snipe pangenome. Always returns a K1-only Signature. Raises ValueError on an empty list.

snipe.intersect(sigs)

Variadic intersection: left-fold & over the list.

snipe.union(sigs)

Variadic union: left-fold | over the list (all must share a backing).

snipe.difference(sigs)

Variadic difference: left-fold - over the list.

snipe.sum(sigs)

Variadic sum: left-fold + over the list (all must share a backing).