Skip to main content

ReadonlyRefgetStore

Struct ReadonlyRefgetStore 

Source
pub struct ReadonlyRefgetStore { /* private fields */ }
Expand description

Core refget store with &self read methods, suitable for Arc sharing in servers.

Mutating methods are used during the setup/loading phase; once wrapped in Arc, only &self reads are accessible, making concurrent access thread-safe.

All sequence and collection metadata lives in one columnar [Catalog]: sequences deduplicated store-wide, each collection’s members (with their per-collection names) as a contiguous range, and digest/name lookups as tables of row numbers. Sequence bytes are never part of the catalog; they live in Self::loaded (owned bytes of in-memory stores) or the evictable resident overlay, both keyed by sequence row.

Implementations§

Source§

impl ReadonlyRefgetStore

Source

pub fn sequence_view<K: AsRef<[u8]>>(&self, digest: K) -> Option<SeqView<'_>>

A borrowed view of one sequence’s metadata, by any digest form.

Source

pub fn sequence_views(&self) -> impl Iterator<Item = SeqView<'_>> + '_

Views of every sequence in the store, in insertion order.

Source

pub fn collection_members<K: AsRef<[u8]>>( &self, digest: K, ) -> Result<impl ExactSizeIterator<Item = MemberView<'_>> + '_>

Per-collection members (name, description, sequence) in FASTA order. This is the source of truth for names/headers; a sequence’s store-wide label only names the shared bytes.

Source

pub fn loaded_bytes<K: AsRef<[u8]>>(&self, digest: K) -> Option<&[u8]>

Borrow the store-owned (loaded) bytes of a sequence, in the store’s native encoding. None if the sequence is unknown or not loaded.

Source

pub fn lock_for_batch(&mut self, operation: &str) -> Result<()>

Hold the store’s exclusive writer lock across several mutations.

Individual mutations already commit under the lock, so this is only needed when a sequence of them must be atomic with respect to other writers — the registry’s alias step, for instance, which adds many aliases and expects them to appear together. The guard is dropped by Self::release_batch_lock or when the store is dropped.

Nested commits are re-entrant: they see the held guard and skip acquiring.

Source

pub fn release_batch_lock(&mut self)

Release a lock taken by Self::lock_for_batch.

Source

pub fn holds_batch_lock(&self) -> bool

Whether this store currently holds a batch write lock.

Source

pub fn has_uncommitted_changes(&self) -> bool

Whether this store has additions or removals that have not yet been committed to the shared index files.

Pending changes live only in memory, so dropping a store without committing silently abandons them: added rows never reach sequences.rgsi/collections.rgci, and removed rows are still on disk.

Source

pub fn set_lock_options(&mut self, options: LockOptions)

Override the timeout/staleness settings used when acquiring the write lock.

Source

pub fn set_force_alias(&mut self, force: bool)

Allow re-pointing an existing alias (in memory, or one another writer already published) to a different digest, instead of erroring on the conflict. A load that maps one alias to two digests still errors.

Source

pub fn set_quiet(&mut self, quiet: bool)

Set whether to suppress progress output.

Source

pub fn is_quiet(&self) -> bool

Returns whether the store is in quiet mode.

Source

pub fn store_exists<P: AsRef<Path>>(path: P) -> bool

Check whether a valid RefgetStore exists at the given path.

Source

pub fn set_encoding_mode(&mut self, new_mode: StorageMode) -> Result<()>

Change the storage mode, re-encoding/decoding existing sequences as needed.

Switching to StorageMode::Encoded fails if a sequence holds a byte that its stored alphabet cannot represent. That means the store’s alphabet metadata is wrong (written by an older gtars) and the store must be re-imported. On error the store is left unchanged.

For a disk-backed PACKED store that already holds sequences, changing the mode is refused with an error: the packed bytes on disk are in the current mode, and re-encoding only the resident records would desync them from the packs. Mode is fixed at creation for a populated packed store. (An empty packed store, before any import, may still switch, since there are no packed bytes to desync.)

Source

pub fn enable_encoding(&mut self) -> Result<()>

Enable 2-bit encoding for space efficiency.

Fails, leaving the store unchanged, if a sequence cannot be encoded with its stored alphabet (see set_encoding_mode).

Source

pub fn disable_encoding(&mut self)

Disable encoding, use raw byte storage.

Source

pub fn enable_persistence<P: AsRef<Path>>(&mut self, path: P) -> Result<()>

Enable disk persistence for this store.

Source

pub fn disable_persistence(&mut self)

Disable disk persistence for this store.

Source

pub fn is_persisting(&self) -> bool

Check if persistence to disk is enabled.

Source

pub fn add_sequence_collection( &mut self, collection: SequenceCollection, ) -> Result<()>

Adds a collection, and all sequences in it, to the store.

Source

pub fn add_sequence_collection_force( &mut self, collection: SequenceCollection, ) -> Result<()>

Adds a collection, overwriting existing data.

Source

pub fn ingest_sequence(&mut self, name: &str, bytes: &[u8]) -> Result<String>

Digest and insert raw bytes using the store’s native encoding.

Because the input is known to be raw, this method also handles single-base sequences, whose raw and packed lengths are identical. Input is normalized in the same way as digest_sequence.

Source

pub fn add_sequence_record( &mut self, sr: SequenceRecord, force: bool, ) -> Result<()>

Adds a SequenceRecord directly to the store without collection association.

Raw ASCII records are packed when the store uses encoded storage. Already-packed records are stored unchanged.

Source

pub fn sequence_digests(&self) -> impl Iterator<Item = [u8; 48]> + '_

Returns an iterator over all sequence digests in the store

Source

pub fn sequence_metadata(&self) -> impl Iterator<Item = SequenceMetadata> + '_

Returns an iterator over (owned) sequence metadata for all sequences in the store. Use Self::sequence_views to avoid the per-item copy.

Source

pub fn logical_sequence_bytes(&self) -> usize

Logical size in bytes of all sequence payloads, computed from metadata (length x storage mode). Cheap: O(n_sequences) arithmetic, no I/O, no walk, works on stubs. Does NOT include index files, sidecars, or rgstore.json. This is the value cached in the manifest at write time (see write path); for the exact full on-disk footprint use actual_disk_usage() (walks the dir).

Source

pub fn actual_disk_usage(&self) -> usize

Exact on-disk footprint of the store: recursively walks the store directory and sums every file’s byte length (.seq data, .rgsi/.rgci indexes, FHR sidecars, alias data, rgstore.json). Accurate and complete, but does I/O on every call. Use this when an exact footprint is needed; for the cheap cached sequence-content size use logical_sequence_bytes().

Source

pub fn list_collections( &self, page: usize, page_size: usize, filters: &[(&str, &str)], ) -> Result<PagedResult<SequenceCollectionMetadata>>

List collections with pagination and optional attribute filtering.

Source

pub fn get_collection_metadata<K: AsRef<[u8]>>( &self, collection_digest: K, ) -> Option<&SequenceCollectionMetadata>

Get metadata for a single collection by digest (no sequence data).

Source

pub fn get_collection( &self, collection_digest: &str, ) -> Result<SequenceCollection>

Get a collection with all its sequences loaded.

Source

pub fn plan_orphan_removal(&self, digest: &str) -> Result<Vec<String>>

Dry-run of Self::remove_collection’s orphan cleanup: the sequence digests that WOULD be deleted, without touching anything.

Uses the same disk-derived live set as the real thing, so it fails with the same error if the store is not in a state where orphan GC is safe.

§Advisory, by design

This takes NO lock. It exists for confirmation prompts (“this will free 21 sequences, proceed?”), where blocking every concurrent writer for the length of a full-store scan to answer a question the user may say no to would be absurd. The authoritative scan runs again inside remove_collection, under the lock, and the two can legitimately differ: a collection committed in between makes some planned orphan live again, and the real removal will correctly spare it. Callers comparing the two should treat a shortfall as normal concurrency, not corruption.

Source

pub fn remove_collection( &mut self, digest: &str, remove_orphan_sequences: bool, ) -> Result<bool>

Remove a collection from the store.

When remove_orphan_sequences is true, the orphan-cleanup path is O(sequences + collections): each orphan is one catalog lookup, never a scan. Do not reintroduce a per-orphan scan here; on large stores that is quadratic and effectively unbounded.

The live set is derived from DISK, not from the loaded members; see Self::live_sequence_digests_from_disk for why that distinction is the difference between a GC and a data-loss bug.

§The lock is held across the orphan scan, deliberately

The scan is the expensive part — on the plantref store (147 collections, ~1.5M sequence digests) it reads every collections/*.rgsi and takes roughly a minute. Everywhere else in this module the rule is “do the expensive work outside the lock”; here that rule is wrong. Computing the live set before taking the lock leaves a window in which another writer commits a collection referencing one of the digests the scan just classified as an orphan, and the unlink that follows deletes live data. Removals are rare and hand-run, so blocking concurrent builds for a minute is the cheap side of that trade.

Source

pub fn import_collection( &mut self, source: &ReadonlyRefgetStore, digest: &str, ) -> Result<()>

Import a single collection (with all its sequences, aliases, and FHR metadata) from another store into this store.

Both stores must be disk-backed with matching storage modes. The source store must have the collection loaded (call load_collection() or load_all_collections() first).

Source

pub fn list_sequences(&self) -> Vec<SequenceMetadata>

List all sequences in the store (metadata only, no sequence data).

Source

pub fn get_sequence_metadata<K: AsRef<[u8]>>( &self, seq_digest: K, ) -> Option<SequenceMetadata>

Get metadata for a single sequence by digest (no sequence data). Accepts sha512t24u (bare or SQ.-prefixed) or MD5.

Source

pub fn get_sequence<K: AsRef<[u8]>>( &self, seq_digest: K, ) -> Result<SequenceRecord>

Get a sequence by its SHA512t24u (or MD5) digest. Bytes, if loaded, are shared (Arc), not copied.

Source

pub fn clear(&mut self)

Clear sequence data from the store to free memory.

Drops every sequence’s loaded bytes. Metadata is preserved: sequences, collections, name lookups, MD5 lookups, aliases, and FHR metadata remain intact.

For on-disk stores, data on disk is unaffected.

Source

pub fn is_sequence_loaded<K: AsRef<[u8]>>(&self, seq_digest: K) -> bool

Check whether a sequence’s bytes are loaded (owned by the store) rather than metadata only.

Source

pub fn get_sequence_by_name<K: AsRef<[u8]>>( &self, collection_digest: K, sequence_name: &str, ) -> Result<SequenceRecord>

Get a sequence by collection digest and name.

The returned record carries THIS collection’s name and description for the sequence, not the first-imported label of a sequence shared across collections. Bytes (and fai, if the member lacks it) come from the sequence row; the bytes are an Arc bump, not a copy.

Source

pub fn member_by_name<K: AsRef<[u8]>>( &self, collection_digest: K, sequence_name: &str, ) -> Result<MemberView<'_>>

The member of a loaded collection named sequence_name.

Source

pub fn load_sequence_index(&mut self) -> Result<()>

Explicitly load the sequence index. For servers that want to preload all data during startup before converting to ReadonlyRefgetStore.

Source

pub fn load_all_collections(&mut self) -> Result<()>

Load the member lists of all collections.

Source

pub fn load_all_sequences(&mut self) -> Result<()>

Eagerly load the bytes of every sequence.

Source

pub fn load_collection(&mut self, digest: &str) -> Result<()>

Load a single collection by digest.

Source

pub fn load_sequence(&mut self, digest: &str) -> Result<()>

Load a single sequence by digest.

Source

pub fn load_resident(&self, digests: &[String]) -> Result<u64>

Promote a set of sequences to the &self resident overlay, reading each whole .seq file into RAM as its raw on-disk (packed) bytes.

Unlike load_sequence / load_all_sequences — which take &mut self and are therefore unusable once the store is wrapped in an Arc — this takes &self and stores into an RwLock-guarded overlay consulted by get_substring / get_substrings before the on-disk partial-read path.

The loads are made cheap and predictable: digests are deduped (md5 aliases resolved), any already loaded or already resident are skipped, and the rest are sorted by .seq path so the reads walk the sequence directory in order rather than in HashMap hash order (the pathology of load_all_sequences). Each file is one File::open + read_to_end (a few large sequential reads), not a scatter of positioned reads.

Returns the number of bytes newly loaded into the overlay by this call (already resident or loaded skips contribute 0), for RAM-budget accounting.

Source

pub fn evict_resident(&self, digests: &[String])

Drop the given digests from the resident overlay. Subsequent queries for them fall back to the on-disk partial-read path. Unknown / non-resident digests are ignored.

Source

pub fn evict_all_resident(&self)

Drop the entire resident overlay.

Source

pub fn resident_bytes(&self) -> u64

Total bytes currently held in the resident overlay (sum of the packed .seq byte arrays). Used for RAM-budget accounting.

Source

pub fn resident_len(&self) -> usize

Number of sequences currently resident.

Source

pub fn resident_estimate_bytes(&self, digests: &[String]) -> u64

Estimate, from in-memory metadata only (no I/O), the additional bytes load_resident would pull into RAM for digests. Already loaded or already resident digests, and duplicates, contribute 0. Used for RAM-budget planning before committing to a load.

Source

pub fn iter_collections(&self) -> impl Iterator<Item = SequenceCollection> + '_

Iterate over all collections with their sequences loaded.

Source

pub fn iter_sequences(&self) -> impl Iterator<Item = SequenceRecord> + '_

Iterate over all sequences with their data loaded.

Source

pub fn is_collection_loaded<K: AsRef<[u8]>>(&self, collection_digest: K) -> bool

Check if a collection is fully loaded.

Source

pub fn local_path(&self) -> Option<&PathBuf>

Returns the local path where the store is located (if any)

Source

pub fn remote_source(&self) -> Option<&str>

Returns the remote source URL (if any)

Source

pub fn storage_mode(&self) -> StorageMode

Returns the storage mode used by this store

Source

pub fn layout(&self) -> Layout

Returns the physical layout of this store’s sequence bytes, fixed when the store was created.

Source

pub fn get_substring<K: AsRef<[u8]>>( &self, sha512_digest: K, start: usize, end: usize, ) -> Result<String>

Retrieves a substring from an encoded sequence by its SHA512t24u digest.

Thin String wrapper over get_substring_bytes; see it for the actual retrieval logic.

Source

pub fn get_substring_bytes<K: AsRef<[u8]>>( &self, sha512_digest: K, start: usize, end: usize, ) -> Result<Vec<u8>>

Retrieves a substring from an encoded sequence by its SHA512t24u digest, as raw bytes rather than a String.

Source

pub fn get_substrings<K: AsRef<[u8]>>( &self, sha512_digest: K, ranges: &[(usize, usize)], ) -> Result<Vec<String>>

Batch substring retrieval for many ranges of ONE sequence.

Resolves the record once and validates all ranges up front, then:

  • Loaded or resident: decode/slice each range from the bytes in RAM.
  • Disk-backed, not loaded: partial-read each range independently via the fd-cached get_substring_from_disk path (reads only the bytes covering each range; reuses the open .seq handle across ranges).

The main benefit over a loop of get_substring is for FFI callers (e.g. the Python binding): resolving the record once and crossing the boundary once per sequence instead of once per range.

A whole-sequence “decode once, slice all” strategy was tried for wide/overlapping range sets but measured slower on real chromosome-scale sequences (decoding a 250 Mbp chromosome into one buffer, plus the large allocation, outweighs the avoided re-decode of scattered spans), so the partial path is used uniformly. Callers wanting resident behavior should load the sequence (load_sequence) first; the in-memory arm then serves it.

Output strings are byte-identical to a loop of get_substring.

Thin String wrapper over get_substrings_bytes; see it for the actual retrieval logic.

Source

pub fn get_substrings_bytes<K: AsRef<[u8]>>( &self, sha512_digest: K, ranges: &[(usize, usize)], ) -> Result<Vec<Vec<u8>>>

Batch substring retrieval for many ranges of ONE sequence, as raw bytes rather than Strings. See get_substrings for the full behavior description.

Source

pub fn set_pack_cap_bytes(&mut self, cap: u64)

Set the per-pack size cap in bytes for new packs.

Source

pub fn set_pack_cache_mb(&mut self, mb: usize)

Turn the pack block cache on with room for mb megabytes, or off with 0 (the default). Alpha. The cache helps clustered reads on a cold network file system and hurts scattered reads on stores larger than the cache. It fronts local pack reads only.

Source

pub fn packed_dead_bytes(&self) -> Result<u64>

Dead (unreferenced) bytes inside pack files: sum(pack sizes) - sum(live sidecar lengths). Ok(0) for a store with no packs. Computed, not tracked.

Source

pub fn compact(&mut self) -> Result<CompactReport>

Rewrite the live spans of a packed store into fresh sealed packs, reclaiming dead bytes. Deterministic and locality-preserving (packs visited by name, rows by offset). Retrieval is byte-identical before and after. Same as Self::compact_with with default options.

Source

pub fn compact_with(&mut self, opts: CompactOptions) -> Result<CompactReport>

Self::compact with options; see CompactOptions.

Source

pub fn stream_sequence<K: AsRef<[u8]>>( &self, sha512_digest: K, start: Option<u64>, end: Option<u64>, ) -> Result<Box<dyn Read + Send>>

Stream a (sub)sequence as decoded ASCII bases without loading the full sequence into memory.

Opens a bounded byte window on the backing store (local file via seek+take, or remote via HTTP Range: bytes=), and wraps it in a StreamingDecoder when the store is in Encoded mode. In Raw mode the bounded byte source is returned directly, since bytes and bases are 1:1.

Memory use is O(1) in the sequence length.

Source

pub fn sequence_file_path(&self, seq_digest: &str) -> Option<PathBuf>

Return the full filesystem path to a sequence .seq file for the given digest.

Returns None if the store has no local path or no seqdata path template.

Source

pub fn collection_file_path(&self, coll_digest: &str) -> Option<PathBuf>

Return the full filesystem path to a collection RGSI file for the given digest.

Returns None if the store has no local path.

Source

pub fn write(&self) -> Result<()>

Write the store using its configured paths.

Source

pub fn write_store_to_dir<P: AsRef<Path>>( &self, root_path: P, seqdata_path_template: Option<&str>, ) -> Result<()>

Write a RefgetStore object to a directory

Source

pub fn stats(&self) -> StoreStats

Returns statistics about the store.

The *_in_memory fields are a RAM-residency snapshot, not a record of what any import run did; see StoreStats.

Source

pub fn available_alias_namespaces(&self) -> AvailableAliases<'_>

List alias namespaces available on this store (from manifest).

Source§

impl ReadonlyRefgetStore

Source

pub fn add_sequence_alias( &mut self, namespace: &str, alias: &str, digest: &str, ) -> Result<()>

Add a sequence alias and persist to disk if applicable.

Re-adding the same binding is a no-op. Pointing an existing alias at a different digest errors unless force_alias is set; a refused add leaves memory, pending changes and disk untouched.

Source

pub fn get_sequence_metadata_by_alias( &self, namespace: &str, alias: &str, ) -> Option<SequenceMetadata>

Resolve a sequence alias to sequence metadata (no data loading).

Source

pub fn get_sequence_by_alias( &self, namespace: &str, alias: &str, ) -> Result<SequenceRecord>

Resolve a sequence alias and return the sequence record.

Source

pub fn get_aliases_for_sequence(&self, digest: &str) -> Vec<(String, String)>

Reverse lookup: find all aliases pointing to this sequence digest.

Source

pub fn list_sequence_alias_namespaces(&self) -> Vec<String>

List all sequence alias namespaces.

Source

pub fn list_sequence_aliases(&self, namespace: &str) -> Option<Vec<String>>

List all aliases in a sequence alias namespace.

Source

pub fn remove_sequence_alias( &mut self, namespace: &str, alias: &str, ) -> Result<bool>

Remove a single sequence alias.

Source

pub fn load_sequence_aliases( &mut self, namespace: &str, path: &str, ) -> Result<usize>

Load sequence aliases from a TSV file into a namespace, all or nothing.

Returns the number of distinct aliases bound. Errors, loading nothing, if the file maps one alias to two different digests (always, even with force_alias), or if it would re-point an existing alias (unless force_alias).

Source

pub fn add_collection_alias( &mut self, namespace: &str, alias: &str, digest: &str, ) -> Result<()>

Add a collection alias and persist to disk if applicable.

Re-adding the same binding is a no-op. Pointing an existing alias at a different digest errors unless force_alias is set; a refused add leaves memory, pending changes and disk untouched.

Source

pub fn get_collection_metadata_by_alias( &self, namespace: &str, alias: &str, ) -> Option<&SequenceCollectionMetadata>

Resolve a collection alias to collection metadata.

Source

pub fn get_collection_by_alias( &self, namespace: &str, alias: &str, ) -> Result<SequenceCollection>

Resolve a collection alias and return the loaded collection.

Source

pub fn get_aliases_for_collection(&self, digest: &str) -> Vec<(String, String)>

Reverse lookup: find all aliases pointing to this collection digest.

Source

pub fn list_collection_alias_namespaces(&self) -> Vec<String>

List all collection alias namespaces.

Source

pub fn list_collection_aliases(&self, namespace: &str) -> Option<Vec<String>>

List all aliases in a collection alias namespace.

Source

pub fn remove_collection_alias( &mut self, namespace: &str, alias: &str, ) -> Result<bool>

Remove a single collection alias.

Source

pub fn load_collection_aliases( &mut self, namespace: &str, path: &str, ) -> Result<usize>

Load collection aliases from a TSV file into a namespace, all or nothing.

Returns the number of distinct aliases bound. Errors, loading nothing, if the file maps one alias to two different digests (always, even with force_alias), or if it would re-point an existing alias (unless force_alias).

Source§

impl ReadonlyRefgetStore

Source

pub fn set_fhr_metadata( &mut self, collection_digest: &str, metadata: FhrMetadata, ) -> Result<()>

Set FHR metadata for a collection.

Source

pub fn get_fhr_metadata(&self, collection_digest: &str) -> Option<&FhrMetadata>

Get FHR metadata for a collection. Returns None if missing.

Source

pub fn remove_fhr_metadata(&mut self, collection_digest: &str) -> bool

Remove FHR metadata for a collection.

Source

pub fn list_fhr_metadata(&self) -> Vec<String>

List all collection digests that have FHR metadata.

Source

pub fn load_fhr_metadata( &mut self, collection_digest: &str, path: &str, ) -> Result<()>

Load FHR metadata from a JSON file and attach it to a collection.

Source§

impl ReadonlyRefgetStore

Source

pub fn add_sequence_collections_from_fastas( &mut self, files: &[PathBuf], opts: FastaImportOptions<'_>, ) -> Result<ImportReport>

Import multiple FASTA files into the store with file-level parallelism.

Up to jobs files are decoded/built concurrently (each with its own decoder, so gzip decompression is parallelized across files). Each builder STREAMS its sequences one at a time over a bounded cross-file channel; the single inserter (&mut self) on this owner thread persists each .seq immediately and retains only metadata, so peak memory is bounded by jobs x channel_depth x avg_encoded_seq_size, independent of collection size. The on-disk indexes are written once at the very end (sorted by content/collection digest), guaranteeing a byte-identical store to a serial build regardless of build/arrival order.

Returns an ImportReport: per-file (collection_metadata, was_new) results in input order, plus genuine per-run ingest counters (n_sequences_written, n_sequences_deduped, n_collections_new). Note these are per-RUN counts, unlike StoreStats, which is a RAM-residency snapshot.

§Error handling / non-transactional semantics

This function is NOT fully transactional. On a build or writer error, any sequences already emitted (as InsertMsg::Seq) before the failure may have been written to disk (as .seq files or into a pack) and inserted into the in-memory catalog, but the corresponding collection will NOT be registered (it never received an End). These are orphan sequences: referenced by no surviving collection.

On error this function calls Self::remove_orphan_seq_files which performs a best-effort cleanup: it removes every sequence this import staged (and its .seq file) that no surviving collection references. The in-memory store is left consistent (no dangling references), but if you require a fully clean store on error, discard the store and rebuild.

Source

pub fn add_sequence_collection_from_fasta<P: AsRef<Path>>( &mut self, file_path: P, opts: FastaImportOptions<'_>, ) -> Result<(SequenceCollectionMetadata, bool)>

Import a single FASTA file. Thin wrapper over the multi-file path.

Source§

impl ReadonlyRefgetStore

Source

pub fn write_sequences_rgsi<P: AsRef<Path>>(&self, file_path: P) -> Result<()>

Write this store’s in-memory sequence metadata to an .rgsi file.

EXPORT ONLY — see Self::write_collections_rgci.

Source

pub fn store_metadata(&self) -> Result<HashMap<String, String>>

Read the store metadata from rgstore.json, returning state digests and timestamp.

Returns a HashMap with keys: modified, collections_digest, sequences_digest, aliases_digest, fhr_digest, logical_sequence_bytes. Missing values are omitted from the map.

Source§

impl ReadonlyRefgetStore

Source

pub fn substrings_from_regions<'a, K: AsRef<[u8]>>( &'a self, collection_digest: K, bed_file_path: &str, ) -> Result<SubstringsFromRegions<'a, K>>

Get an iterator over substrings defined by BED file regions.

Source

pub fn substrings_from_region_vectors<'a, K, S>( &'a self, collection_digest: K, chroms: &[S], starts: &[u32], ends: &[u32], ) -> Result<SubstringsFromRegionVectors<'a, K>>
where K: AsRef<[u8]>, S: AsRef<str>,

Get an iterator over substrings defined by in-memory region vectors.

chroms, starts, and ends are parallel slices; element i defines region chroms[i]:starts[i]-ends[i]. Yields the same RetrievedSequence results as substrings_from_regions without any temp-file round-trip.

Source

pub fn export_fasta_from_regions<K: AsRef<[u8]>>( &self, collection_digest: K, bed_file_path: &str, output_file_path: &str, label: &LabelTemplate, ) -> Result<ExportSummary>

Export sequences from BED file regions to a FASTA file.

Writes one record per BED line, each on a single line, labeled by label with :start-end appended (as samtools does). Labels repeat when regions repeat; no uniqueness rule applies.

Source

pub fn export_fasta<P: AsRef<Path>>( &self, selection: &ExportSelection, output_path: P, opts: &ExportOptions, ) -> Result<ExportSummary>

Export sequences to a FASTA file, or to stdout when output_path is "-".

selection chooses which records to write; opts.label chooses how each is labeled, the same way whatever the selection. The whole (label, sequence) list is planned from metadata before any output is written, so label errors never leave half a file. A repeated label for the same sequence is written once (counted in n_deduplicated); a repeated label for different sequences is an error.

Record order: collections in the order given (digest order for All), each in its own order; then, for All, sequences in no collection, in digest order. When the label uses no collection field ({seq}, {seq:NS}), All lists each sequence once in digest order, without reading any collection.

Exports stream one sequence at a time and leave the store’s loaded state unchanged. Collections named by selection (all of them for All with a collection field) must be loaded; RefgetStore::export_fasta loads them.

Source§

impl ReadonlyRefgetStore

Source

pub fn verify_sequence( &self, digest: &str, check_md5: bool, ) -> Result<Option<VerifyFailure>>

Verify one sequence: stream its decoded bytes, recompute digests, and compare against the stored metadata.

Returns Ok(None) when the sequence checks out, Ok(Some(failure)) when it does not (including when the sequence could not be read – this is reported as a VerifyFailureKind::ReadError, not an Err). Returns Err only when digest does not resolve to a known sequence.

Source

pub fn verify_sequences( &self, digests: Option<&[String]>, opts: &VerifyOptions, ) -> Result<VerifyReport>

Verify many sequences (or, with digests: None, every sequence in the store), in parallel when opts.jobs != 1.

digests entries must already be resolved sequence identifiers (a sha512t24u or md5 digest, with no SQ. prefix); an unknown digest makes the whole call return Err naming every unknown digest, before any verification work happens.

Source§

impl ReadonlyRefgetStore

Source

pub fn enable_ancillary_digests(&mut self)

Enable computation and storage of ancillary digests (nlp, snlp, sorted_sequences).

Source

pub fn disable_ancillary_digests(&mut self)

Disable computation and storage of ancillary digests.

Source

pub fn has_ancillary_digests(&self) -> bool

Returns whether ancillary digests are enabled.

Source

pub fn has_attribute_index(&self) -> bool

Returns whether the on-disk attribute index is enabled.

Source

pub fn get_collection_level1(&self, digest: &str) -> Result<CollectionLevel1>

Get collection at level 1 representation (attribute digests with spec field names). This is a lightweight operation that only reads metadata, no loading needed.

Source

pub fn get_collection_level2(&self, digest: &str) -> Result<CollectionLevel2>

Get collection at level 2 representation (full arrays, spec format). May need to load the collection from disk/remote.

Source

pub fn compare( &self, digest_a: &str, digest_b: &str, ) -> Result<SeqColComparison>

Compare two collections by digest. Both must be preloaded.

Source

pub fn match_sequence_names( &self, digest_a: &str, digest_b: &str, ) -> Result<CollectionNameMatch>

Match collection-local names by identical sequence content.

Source

pub fn compare_with_level2( &self, digest_a: &str, external: &CollectionLevel2, ) -> Result<SeqColComparison>

Compare a stored collection (by digest) against an externally-provided level-2 body.

Used for the seqcol spec POST /comparison/:digest1 endpoint where the client submits a local collection as JSON rather than referencing a stored digest.

The returned SeqColComparison has digests.a set to the stored collection’s digest and digests.b set to None because the external collection has no server-side digest.

Source

pub fn find_collections_by_attribute( &self, attr_name: &str, attr_digest: &str, ) -> Result<Vec<String>>

Find all collections with a specific attribute digest.

Dispatches to indexed lookup (if attribute_index enabled) or brute-force metadata scan (default).

Supported attr_name values: “names”, “lengths”, “sequences”, “name_length_pairs”, “sorted_name_length_pairs”, “sorted_sequences”

Source

pub fn get_attribute( &self, attr_name: &str, attr_digest: &str, ) -> Result<Option<Value>>

Get the raw attribute array for a given attribute digest. Finds a collection with this attribute (via search), loads it, and extracts the array.

Supported attr_name values: “names”, “lengths”, “sequences”, “name_length_pairs”, “sorted_name_length_pairs”, “sorted_sequences”

Returns the array as a serde_json::Value (array of strings or numbers). Returns Ok(None) if no collection has this attribute digest.

Source

pub fn enable_attribute_index(&mut self)

Enable indexed attribute lookup (not yet implemented).

Note: The indexed lookup feature is planned for a future release. Enabling this will cause find_collections_by_attribute() to return a “not implemented” error until the feature is complete.

Source

pub fn disable_attribute_index(&mut self)

Disable indexed attribute lookup, using brute-force scan instead.

Source

pub fn collection_count(&self) -> usize

Total number of collections in the store.

Trait Implementations§

Source§

impl Debug for ReadonlyRefgetStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ReadonlyRefgetStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl SeqColService for ReadonlyRefgetStore

Source§

fn get_collection_level1(&self, digest: &str) -> Result<CollectionLevel1>

Level 1: attribute digests only.
Source§

fn get_collection_level2(&self, digest: &str) -> Result<CollectionLevel2>

Level 2: full arrays with values.
Source§

fn compare(&self, digest_a: &str, digest_b: &str) -> Result<SeqColComparison>

Compare two collections by digest.
Source§

fn compare_with_level2( &self, digest_a: &str, external: &CollectionLevel2, ) -> Result<SeqColComparison>

Compare a stored collection against an externally-provided level-2 body.
Source§

fn find_collections_by_attribute( &self, attr_name: &str, attr_digest: &str, ) -> Result<Vec<String>>

Find collections sharing an attribute digest.
Source§

fn get_attribute( &self, attr_name: &str, attr_digest: &str, ) -> Result<Option<Value>>

Get the raw attribute array for a given attribute digest.
Source§

fn list_collections( &self, page: usize, page_size: usize, filters: &[(&str, &str)], ) -> Result<PagedResult<SequenceCollectionMetadata>>

List collections with pagination and optional attribute filters.
Source§

fn collection_count(&self) -> usize

Total number of collections in the store.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.