Working with sourmash
snipe is an alignment-free QC tool built on the edgemer .snipesig format. It can also move the K1 layer of a signature to and from a sourmash .sig, so a snipe sketch can drop into an existing k-mer workflow. snipe’s QC and native format are its own; this page covers that interoperability.
You will learn:
- How to export a
.snipesigto a sourmash.sigwithsnipe export --format sourmash - How to load a sourmash
.siginto snipe, from the CLI and from Python (snipe.load_sourmash) - Why a snipe-exported
.sigcarries the same md5 sourmash computes for the same content - What survives the trip (K1 base k-mers) and what does not (the K2 edgemer layer)
The two formats
Section titled “The two formats”A .snipesig is edgemer-rich: it stores the K1 base k-mer, its K2 extension, abundance, and the complete signature header. That structure is what the sequencing-error and mutation metrics read.
A sourmash .sig is K1-only: a FracMinHash sketch of base k-mers with abundance, and nothing about the K2 extension. It is the format snipe reads and writes when a sketch needs to cross into a K1-only k-mer workflow.
Exporting to sourmash keeps the base k-mers and drops the edgemer structure. There is no round-trip back to edgemers from a K1-only file — anything that needs the K2 signal requires a full .snipesig.
-
Start from a
.snipesig.The examples below build on
phix.snipesig, a sketch of the phiX174 genome made at--scale 1(every hash kept, so a tiny input stays unambiguous):Terminal window snipe sketch --sample phix.fasta -o phix.snipesig --scale 1Its K1 checksum — the md5 that also survives a sourmash export — is reported by
snipe info:snipe info phix.snipesig === Signature Information === Version: 2.0.0 Created: <at sketch time> K1 length: 51 K2 length: 53 K2 extension length: 2 bases Scale: 1 Hash threshold: 18446744073709551615 Hash space coverage: 100.000000% Theoretical sampling rate: 1/1 = 1.000000 === Input Files === 1: phix.fasta === K-mer Statistics === Unique K1 k-mers: 5336 Total K1 abundance: 5336 Average K1 abundance: 1.00 Unique K2 k-mers: 5334 Total K2 abundance: 5334 Average K2 abundance: 1.00 Unique k-mer edgemers: 5334 Total edgemer abundance: 5334 Average pair abundance: 1.00 K1 checksum (md5): 85e65cc582d48cbf2fa1b2b7c9b552c7 K2 checksum (md5): 91adce917f75e09fb1d6790e1619d446 Failed K2 pairs: 2 (total abundance: 2) K2 extension success rate: 99.96% K1s processed for K2 extension: 5336 === Processing Statistics === Processing time: 0.02s Sequences processed: 1 Total bases processed: 5386 Average sequence length: 5386.0 bp K1 positions examined: 5336 K1 hashes generated: 5336 K1 hashes below threshold: 5336 K1 hashes above threshold: 0 Hash efficiency: 100.00% K1 with valid extensions: 5334 K1 without extension space: 2Note
K1 checksum (md5): 85e65cc582d48cbf2fa1b2b7c9b552c7. Hold on to that value; it is the identity that survives the export. -
Export to a sourmash
.sig.snipe exportwrites the K1 layer of the signature into a sourmash file. The format is auto-detected from the output extension, or you can name it explicitly with--format sourmash:Terminal window snipe export --input phix.snipesig --format sourmash --output phix.sigThe result is a K1-only
.sig. snipe’s K1 layer uses the same canonical murmur3 hashing (seed42, samescaled, same k-mer size) as sourmash, so the md5 snipe writes for the exported.sigis the same one sourmash computes for the same content. The85e65cc5…from Step 1 is the md5 the exported.sigcarries. -
Load a sourmash
.sigback into snipe.Hand snipe a sourmash
.sigand it comes in as a K1-only signature, ready for the operations that only need base k-mers. From the CLI, any command that reads a signature (for examplesnipe info) auto-detects the sourmash format by content and extension:Terminal window snipe info phix.sigFrom Python,
snipe.load_sourmashreads it directly:import snipesig = snipe.load_sourmash("phix.sig")print(sig.metadata["md5"]) # the same K1 md5, verified on loadThe md5 is checked in both directions: on export (snipe writing a
.sig) and on load (snipe reading one).snipe.loadalso accepts a sourmash.sig/.sig.gz— it auto-detects and returns a K1-only signature;load_sourmashis the explicit call when you already know the input is a sourmash file. -
Know what you can and cannot do with the loaded sketch.
A K1-only signature supports the base-k-mer operations — set intersection, union, difference, containment-style comparisons. What it cannot do is drive the edgemer metrics: the sequencing-error and mutation rates in QC read the K2 extension, and that signal is not present in a K1-only file. For those, sketch from sequence into a full
.snipesiginstead of importing a.sig.
Exporting from Python
Section titled “Exporting from Python”The same export is available on a Signature object. save() uses the file extension as the contract for the content — .sig / .sig.gz hold a sourmash signature, .snipesig holds a snipe signature:
import snipe
sig = snipe.load("phix.snipesig")sig.save("phix.sig") # extension implies sourmashsig.save("phix.sig", format="sourmash") # explicit; must match the extensionAn explicit format= that contradicts the extension is a FormatError — save() does not write content that mislabels the file. See the Python API reference for load_sourmash, load, and save.
What crosses the boundary
Section titled “What crosses the boundary”An export carries the K1 layer only; the K2 edgemer layer — and the error/mutation metrics that depend on it — stays in .snipesig and is not present in a .sig.
snipe export --format sourmashwrites the K1-only layer of a.snipesiginto a sourmash.sig.snipe.load_sourmash(or plainsnipe.load) reads a sourmash.sigback as a K1-only signature.- The md5 matches sourmash’s for the same content — snipe’s K1 layer uses murmur3 with seed
42over the canonical k-mer, the same as sourmash — and it is checked on both export and load. .snipesigis edgemer-rich;.sigis K1-only. The K2 edgemer layer, and the QC metrics built on it, does not survive the round-trip.
- sourmash interoperability → — the K1 hashing compatibility in depth.
- Edgemers → — the K1/K2 pair that
.snipesigkeeps and.sigdrops. exportreference → — the full command surface.- Python API reference → —
load_sourmash,load, andsave.