Development¶
The build needs a Rust toolchain; see Install.
Tests¶
The tests use pysylph's small test data, copied into tests/data: E. coli databases (ecoli.syl2db
and ecoli.syldb), K-12 reads and .sylsp sketches. They include an in-process Starlette client,
and one real Unix-socket round trip against a sylphd serve subprocess. The large GTDB database is
only needed for manual runs.
| File | Covers |
|---|---|
test_server.py |
the Starlette app: endpoints, errors, metadata join, socket cleanup, concurrency |
test_web.py |
the public-web features: raw-sequence /assembly, rate limit, client identity, queue limit, CORS |
test_assembly_sketch.py |
/assembly with a sketch: same results as the raw path, works without --allow-sequences, malformed sketches |
test_classify.py |
species assignment and hit relations for /assembly |
test_sketchcheck.py |
structural validation of uploaded sketches, including drift against a decoded sketch |
test_taxonomy_mount.py |
omnitax's API under /taxonomy, /info, token and rate limit; a live server with an omnitax-only client |
test_taxonomy_build.py, test_unversioned_nearest.py |
setup --taxonomy-db: NCBI lineages and nearest taxa from an omnitax file built in the tests (taxfile.py) |
test_cli.py |
the CLI against live servers: round trips, metadata, taxprof outputs, errors |
test_client_binary.py |
the native client end to end (a live server on a socket) |
test_entry.py, test_packaging.py |
the sylphd wrapper, sylphd.run, version pins |
test_metadata.py, test_download.py |
setup and download |
test_metadata_taxonomy.py |
format 3 taxonomy tables: build, update, and the reader |
test_multi_db.py |
a pooled server equals pysylph.Profiler(*databases), single-database goldens, the shared Profiler cache |
test_taxonomy.py |
taxonomy.py: profile aggregation, .sylphmpa and clade rendering |
test_taxonomy_resolve.py |
hit → lineage resolution: probe rules, precedence, tax_* rows |
test_taxprof_payload.py |
the server-side taxprof payload: text and round-trippable clades |
test_sylphtax_parity.py, test_taxmatrix_parity.py |
rule-for-rule parity with the real sylph-tax (tax profile, merge), byte for byte on rows that have the TSV's precision |
test_parity.py |
sylphd diff: its rules, and real GlobDB output of stock sylph / sylph-tax against sylphd's (equivalent, not byte-identical) |
test_assembly_per_contig.py |
POST /contigs: validation, admission, contig-relative ANI, consensus, parsimony |
test_about.py, test_deploy.py |
--name/--about in /info, and the SYLPH_DB rendering of the systemd unit |
test_web_about_browser.py, test_web_reads_taxprof.py |
the page in headless Chromium: the operator text from /info, and the Reads chart from the server's taxprof |
test_web_contigs_js.py, test_web_contigs_download.py |
browser per-contig sketching against pysylph, and its TSV/JSON against sylphd assembly --per-contig |
test_web_sylsp_js.py |
readSylspHeader against sylphd.sketchcheck |
test_sylph_compat.py |
identical row text, and an equivalent TSV, against the real sylph binary (skipped without one), and pysylph's sketches against sylph sketch |
web_golden.py |
helper (not a test): the single-database /info and /assembly goldens |
Checking against a new sylph release¶
tests/test_sylph_compat.py runs the real sylph binary and sylphd on the same sylph-made
sketches and requires the TSV of query, profile and profile -u to be byte-identical (only
Sample_file and sylphd's extra accession column are dropped), run with sylph -t 1. Rows with
exactly equal values may be ordered differently (stock sylph's own order of ties depends on thread
scheduling, and pysylph orders the survivors of a two-stage screen by name), so the tie tests use
sylphd diff instead. A separate class compares
pysylph's sketches with sylph sketch (single-end identical, paired with a small tolerance). Run it
before and after bumping sylph or pysylph:
Without a binary the module is skipped with the reason. With SYLPH_COMPAT_REQUIRED=1 a missing
binary is an error. In CI it is the optional "sylph compatibility" workflow, which installs
sylph from bioconda; it is run by hand (workflow_dispatch) and weekly, not on every push.
Source layout¶
Two families of modules are split by role.
| Module | Holds |
|---|---|
metadata.py |
the metadata file layout, accession and sylph-tax probe helpers, and the read side, MetadataDB |
metadata_build.py |
the writers behind sylphd setup: build_metadata_db, update_metadata_db, and the temp-file/replace-on-success context manager they share |
taxonomy_sources.py |
importing a sylph-tax file as a taxonomy_source: parsing, duplicate-key semantics, overlap counting and warnings |
catalog.py |
the static catalogues of pre-built databases and sylph-tax taxonomy files (data only) |
download.py |
catalogue lookups and tables, and the transfer engine |
cli_parser.py |
one add_<command>_parser per subcommand |
server.py |
ServerConfig, create_app and the endpoint handlers |
server_errors.py |
RequestError, its single answering path, and the mapping of job failures to responses |
server_upload.py |
reading the multipart form of /profile, /query and /contigs, and validating its params |
server_middleware.py |
the body-limit and access-log ASGI middleware |
server_launch.py |
serve, the uvicorn entry point, and the Unix-socket handling |
Test data credit¶
The test data in tests/data comes from the test suite of
pysylph (MIT licensed). The example genome of the web app
(web/example/) is Mycoplasmoides genitalium G37, NCBI RefSeq
GCF_000027325.1; NCBI data is in
the public domain.
The web app¶
web/ is a static page (plain HTML, CSS and JS, no JavaScript build step and no external requests)
with two equal modes selected by the address: the landing page (no hash), #assembly and #reads.
- Assembly talks to a
sylphd serveinstance throughGET /infoandPOST /assembly. It takes a pasted or uploaded FASTA (plain or gzip), sketches it in the browser with the same WebAssembly module as the Reads mode (sketching.js) and sends the sketch (application/vnd.sylph.sketch; input up to 2 GB, no--allow-sequencesneeded). A browser that cannot run the sketcher gets a notice and a disabled submit button; the page has no raw-upload path. It shows the species assignment, or the closest relative, with an ANI gauge, and lists the closest genomes in a sortable table that can be downloaded as TSV or JSON (its species column says Taxon for a non-GTDB hit). With Per contig checked,contigs.jssketches every record and sends it toPOST /contigsin batches oflimits.max_contigs, then shows the per-contig table, composition card and consensus summary. - Reads sketches reads in the browser (
reads.js, the two workersdecompress-worker.jsandsketch-worker.js, and the WebAssembly module fromrust/sylphd-wasm/) and sends only the sketch toPOST /profile. The taxonomic clades are aggregated on the server (sylphd/taxprofile.py) and returned in thetaxprofresponse; the page charts them and never ports the aggregation (tests/test_web_reads_taxprof.pyrenders them in a real browser). See Profiling reads in the browser.
The WebAssembly module is not committed: rust/sylphd-wasm/build.sh web/wasm builds it (Rust with the
wasm32-unknown-unknown target and wasm-bindgen-cli at the version pinned in
rust/Cargo.toml), and the Pages workflow and scripts/preview-pages.sh do that.
See Using the web app against your server
for running it locally.
This documentation¶
The docs are built with Zensical from docs/ and zensical.toml:
uvx zensical serve # live preview
uvx zensical build --clean --strict # what CI runs: warnings fail the build
The GitHub Actions workflow .github/workflows/pages.yml builds the docs and deploys them
together with the web app to GitHub Pages: the web app at / and the documentation at /docs/.