Skip to main content

RefgetStore

Struct RefgetStore 

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

User-facing store with lazy-loading read methods.

Wraps ReadonlyRefgetStore and provides &mut self read methods that automatically load data on first access. Use into_readonly() to convert to an immutable store suitable for Arc<ReadonlyRefgetStore> in servers.

Implementations§

Source§

impl RefgetStore

Source

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

Check whether a valid RefgetStore exists at the given path.

Source

pub fn on_disk<P: AsRef<Path>>(cache_path: P) -> Result<Self>

Create a disk-backed RefgetStore.

Source

pub fn on_disk_packed<P: AsRef<Path>>(cache_path: P) -> Result<Self>

Create a disk-backed RefgetStore with the PACKED sequence layout.

Sequences are concatenated into sealed, size-capped pack files under packs/, resolved via the sequences.pack.idx sidecar, instead of one .seq file per digest. Mirrors Self::on_disk but sets layout = Packed and creates packs/.

Opening an EXISTING store: the layout always comes from its manifest. Calling on_disk_packed on an existing STANDALONE store is an error, since there is no in-place conversion (export a standalone image instead). Calling it on an existing packed store just opens it.

Source

pub fn in_memory() -> Self

Create an in-memory RefgetStore.

Source

pub fn open_local<P: AsRef<Path>>(path: P) -> Result<Self>

Open a local RefgetStore from a directory.

Source

pub fn open_remote<P: AsRef<Path>, S: AsRef<str>>( cache_path: P, remote_url: S, ) -> Result<Self>

Open a remote RefgetStore with local caching.

Source

pub fn into_readonly(self) -> ReadonlyRefgetStore

Convert to a ReadonlyRefgetStore for concurrent read access.

Source

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

Load the sequence index if not already loaded. Servers should call this during startup to preload the index.

Source

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

Preload all collections (delegates to inner).

Source

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

Preload all sequences (delegates to inner).

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. Accepts “SQ.”-prefixed and MD5 digests; the disk loader needs the canonical SHA-512/24u key.

Source

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

Lazy-loading get_collection. Loads on first access.

Source

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

Lazy-loading get_collection_level2.

Source

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

Lazy-loading compare.

Source

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

List sequence metadata, loading the deferred sequence index if needed.

This only populates metadata-only records; sequence bodies remain lazy.

Source

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

Retrieve one sequence, loading only its body when necessary.

The readonly lookup accepts MD5 aliases, but the disk loader needs the canonical SHA-512/24u key, so resolve before loading.

Source

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

Retrieve a named sequence from a collection, loading only that collection and sequence body when necessary.

Source

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

Lazily load two collection records and match their local names by content.

Source

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

Lazy-loading get_attribute.

Source

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

Verify sequences against their stored digests. digests: None checks every sequence in the store.

See ReadonlyRefgetStore::verify_sequences for what this actually checks and how parallelism is controlled by opts.jobs.

Source

pub fn verify_collection( &mut self, collection_digest: &str, opts: &VerifyOptions, ) -> Result<VerifyReport>

Verify only the sequences belonging to one collection.

Loads the collection’s metadata (not sequence bytes) via the usual lazy-load path, then verifies each of its (deduped) sequence digests.

Source

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

Export sequences to FASTA (or stdout with "-"), loading only the metadata the export needs: the sequence index, the selected collections (every collection for All when the label uses a collection field), and, for a remote store, the alias namespaces the label uses.

Exports stream one sequence at a time and leave the store’s loaded state unchanged. See ReadonlyRefgetStore::export_fasta.

Source

pub fn export_fasta_from_regions( &mut self, collection_digest: &str, bed_file_path: &str, output_file_path: &str, label: &LabelTemplate, ) -> Result<ExportSummary>

Export BED regions to FASTA, loading the collection and any alias namespaces the label uses first.

Source

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

Set whether to suppress progress output.

Source

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

Change the storage mode.

Switching to Encoded fails, leaving the store unchanged, if a sequence cannot be encoded with its stored alphabet. The store must then be re-imported.

Source

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

Set the per-pack size cap in bytes (packed layout).

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). See ReadonlyRefgetStore::set_pack_cache_mb.

Source

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

Reclaim dead bytes in a packed store by rewriting live spans into fresh sealed packs. Byte-identical retrieval before and after.

Source

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

Source

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

Enable 2-bit encoding for space efficiency.

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 ingest_sequence(&mut self, name: &str, bytes: &[u8]) -> Result<String>

Digest and insert raw sequence bytes without a collection association.

Unlike add_sequence_record, this method can reliably encode a single-base sequence because its input is known to be raw bytes. Returns the sequence’s sha512t24u digest.

Source

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

Add a collection and all sequences in it to the store.

Source

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

Add a collection, overwriting existing data.

Source

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

Add a sequence collection from a FASTA file.

Source

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

Add sequence collections from multiple FASTA files, decoding up to opts.file_jobs files concurrently. Inserts in fixed input order so the resulting store is byte-identical to a serial build.

Returns an ImportReport with per-file results and per-run ingest counters.

Source

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

Add a SequenceRecord directly to the store.

Source

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

Remove a collection from the store.

Source

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

Dry-run of the orphan cleanup in Self::remove_collection.

Source

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

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

Source

pub fn release_batch_lock(&mut self)

Release a lock taken by Self::lock_for_batch.

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 to a different digest.

Source

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

Import a collection (with sequences, aliases, FHR) from another store. The source must already have the collection loaded.

Source

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

Import a collection from another RefgetStore, lazy-loading the source if needed.

Source

pub fn clear(&mut self)

Clear in-memory sequence data, preserving metadata.

Source

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

Check whether a sequence’s bytes are loaded.

Source

pub fn enable_ancillary_digests(&mut self)

Enable computation of ancillary digests.

Source

pub fn disable_ancillary_digests(&mut self)

Disable computation of ancillary digests.

Source

pub fn enable_attribute_index(&mut self)

Enable indexed attribute lookup.

Source

pub fn disable_attribute_index(&mut self)

Disable indexed attribute lookup.

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 the store to a directory.

Source

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

Write all sequence metadata to an RGSI file.

Source§

impl RefgetStore

Source

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

Add a sequence alias.

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.

Source

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

Add a collection alias.

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.

Source

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

Lazy-loading get_collection_by_alias.

Source

pub fn pull_aliases( &mut self, namespace: Option<&str>, strategy: SyncStrategy, ) -> Result<PullResult>

Pull alias sidecars from the remote store.

Source§

impl RefgetStore

Source

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

Set FHR metadata for a collection.

Source

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

Remove FHR metadata for a collection.

Source

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

Load FHR metadata from a JSON file.

Source

pub fn pull_fhr( &mut self, digest: Option<&str>, strategy: SyncStrategy, ) -> Result<PullResult>

Pull FHR metadata sidecars from the remote store.

If digest is Some, pulls only that collection’s FHR. If digest is None, pulls FHR for all known collections.

Methods from Deref<Target = 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 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 is_quiet(&self) -> bool

Returns whether the store is in quiet mode.

Source

pub fn is_persisting(&self) -> bool

Check if persistence to disk is enabled.

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 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 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_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 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 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

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 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 get_fhr_metadata(&self, collection_digest: &str) -> Option<&FhrMetadata>

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

Source

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

List all collection digests that have FHR metadata.

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

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

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

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 collection_count(&self) -> usize

Total number of collections in the store.

Trait Implementations§

Source§

impl Debug for RefgetStore

Source§

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

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

impl Deref for RefgetStore

Source§

type Target = ReadonlyRefgetStore

The resulting type after dereferencing.
Source§

fn deref(&self) -> &ReadonlyRefgetStore

Dereferences the value.
Source§

impl Display for RefgetStore

Source§

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

Formats the value using the given formatter. Read more

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.