Skip to content

Accept AGC archives as sequence input - #144

Merged
AndreaGuarracino merged 3 commits into
masterfrom
agc-support
Jul 24, 2026
Merged

Accept AGC archives as sequence input#144
AndreaGuarracino merged 3 commits into
masterfrom
agc-support

Conversation

@AndreaGuarracino

Copy link
Copy Markdown
Member

Adds native support for -s/--seqs reading an AGC (.agc) archive in addition to FASTA/FASTQ.

SeqIndex::build_index detects the .agc extension and ingests every sample/contig via ragc-core (a pure-Rust AGC decompressor) into the same concatenated sequence store and FM-index used for FASTA. Each contig is stored under its name verbatim, so a PanSN archive reproduces sample#haplotype#contig names 1:1.

For archives above 32 MB the decompression is parallelized across -t threads, each writing a disjoint range of the memory-mapped sequence file; smaller inputs keep the serial writer. Output is byte-identical to the serial path and to the equivalent FASTA input.

Dependency: ragc-core from AndreaGuarracino/ragc (a fork of ekg/ragc, currently 4 commits ahead: adds list_contigs_names_only for fast metadata scans, a fix for names-only loading, and a bounded segment cache RAGC_CACHE_SIZE). Ideally those land upstream in ekg/ragc so this can point there.

Verified byte-identical: the induced seqwish graph is identical whether sequences come from FASTA or AGC, on LPA and yeast8 (96 Mbp, md5-identical GFA); serial and parallel ingest produce byte-identical output. Runtime and memory are at parity with FASTA; AGC ingest is sub-second and scales with archive size.

-s/--seqs now accepts an AGC (.agc) archive in addition to FASTA/FASTQ.
SeqIndex ingests every sample/contig via ragc-core into the same
concatenated store and FM-index used for FASTA, so contig names round-trip
(a PanSN archive reproduces sample#haplotype#contig verbatim). Ingestion
of archives above 32 MB is parallelized across -t threads via disjoint
writes to the memory-mapped sequence file; output is byte-identical to the
serial path and to the equivalent FASTA input.
Ingesting tests/data/agc/small.agc (built with 'agc create' from
tests/data/agc/small.fa) must yield the same names, lengths, and bases as
ingesting the FASTA. Runs under cargo test (ragc-core is a normal dep).
AGC identifies a sequence by (sample, contig), seqwish by name alone. An
archive built the canonical AGC way (agc create sampleA.fa sampleB.fa)
repeats plain contig names across samples, which produced several
sequences with the same name and made them unresolvable by name.

A contig name that occurs in more than one sample is now qualified as
contig@sample (AGC's query syntax, matching wfmash); already unique names,
as in a PanSN archive, are unchanged. Duplicates that survive are a hard
error rather than a silently broken index.
@AndreaGuarracino
AndreaGuarracino merged commit aab5bee into master Jul 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant