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
impl RefgetStore
Sourcepub fn store_exists<P: AsRef<Path>>(path: P) -> bool
pub fn store_exists<P: AsRef<Path>>(path: P) -> bool
Check whether a valid RefgetStore exists at the given path.
Sourcepub fn on_disk<P: AsRef<Path>>(cache_path: P) -> Result<Self>
pub fn on_disk<P: AsRef<Path>>(cache_path: P) -> Result<Self>
Create a disk-backed RefgetStore.
Sourcepub fn on_disk_packed<P: AsRef<Path>>(cache_path: P) -> Result<Self>
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.
Sourcepub fn open_local<P: AsRef<Path>>(path: P) -> Result<Self>
pub fn open_local<P: AsRef<Path>>(path: P) -> Result<Self>
Open a local RefgetStore from a directory.
Sourcepub fn open_remote<P: AsRef<Path>, S: AsRef<str>>(
cache_path: P,
remote_url: S,
) -> Result<Self>
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.
Sourcepub fn into_readonly(self) -> ReadonlyRefgetStore
pub fn into_readonly(self) -> ReadonlyRefgetStore
Convert to a ReadonlyRefgetStore for concurrent read access.
Sourcepub fn load_sequence_index(&mut self) -> Result<()>
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.
Sourcepub fn load_all_collections(&mut self) -> Result<()>
pub fn load_all_collections(&mut self) -> Result<()>
Preload all collections (delegates to inner).
Sourcepub fn load_all_sequences(&mut self) -> Result<()>
pub fn load_all_sequences(&mut self) -> Result<()>
Preload all sequences (delegates to inner).
Sourcepub fn load_collection(&mut self, digest: &str) -> Result<()>
pub fn load_collection(&mut self, digest: &str) -> Result<()>
Load a single collection by digest.
Sourcepub fn load_sequence(&mut self, digest: &str) -> Result<()>
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.
Sourcepub fn get_collection(&mut self, digest: &str) -> Result<SequenceCollection>
pub fn get_collection(&mut self, digest: &str) -> Result<SequenceCollection>
Lazy-loading get_collection. Loads on first access.
Sourcepub fn get_collection_level2(
&mut self,
digest: &str,
) -> Result<CollectionLevel2>
pub fn get_collection_level2( &mut self, digest: &str, ) -> Result<CollectionLevel2>
Lazy-loading get_collection_level2.
Sourcepub fn compare(
&mut self,
digest_a: &str,
digest_b: &str,
) -> Result<SeqColComparison>
pub fn compare( &mut self, digest_a: &str, digest_b: &str, ) -> Result<SeqColComparison>
Lazy-loading compare.
Sourcepub fn list_sequences(&mut self) -> Result<Vec<SequenceMetadata>>
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.
Sourcepub fn get_sequence<K: AsRef<[u8]>>(
&mut self,
digest: K,
) -> Result<SequenceRecord>
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.
Sourcepub fn get_sequence_by_name<K: AsRef<[u8]>>(
&mut self,
collection_digest: K,
sequence_name: &str,
) -> Result<SequenceRecord>
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.
Sourcepub fn match_sequence_names(
&mut self,
digest_a: &str,
digest_b: &str,
) -> Result<CollectionNameMatch>
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.
Sourcepub fn get_attribute(
&mut self,
attr_name: &str,
attr_digest: &str,
) -> Result<Option<Value>>
pub fn get_attribute( &mut self, attr_name: &str, attr_digest: &str, ) -> Result<Option<Value>>
Lazy-loading get_attribute.
Sourcepub fn verify_sequences(
&mut self,
digests: Option<&[String]>,
opts: &VerifyOptions,
) -> Result<VerifyReport>
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.
Sourcepub fn verify_collection(
&mut self,
collection_digest: &str,
opts: &VerifyOptions,
) -> Result<VerifyReport>
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.
Sourcepub fn export_fasta<P: AsRef<Path>>(
&mut self,
selection: &ExportSelection,
output_path: P,
opts: &ExportOptions,
) -> Result<ExportSummary>
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.
Sourcepub fn export_fasta_from_regions(
&mut self,
collection_digest: &str,
bed_file_path: &str,
output_file_path: &str,
label: &LabelTemplate,
) -> Result<ExportSummary>
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.
Sourcepub fn set_encoding_mode(&mut self, new_mode: StorageMode) -> Result<()>
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.
Sourcepub fn set_pack_cap_bytes(&mut self, cap: u64)
pub fn set_pack_cap_bytes(&mut self, cap: u64)
Set the per-pack size cap in bytes (packed layout).
Sourcepub fn set_pack_cache_mb(&mut self, mb: usize)
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.
Sourcepub fn compact(&mut self) -> Result<CompactReport>
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.
Sourcepub fn compact_with(&mut self, opts: CompactOptions) -> Result<CompactReport>
pub fn compact_with(&mut self, opts: CompactOptions) -> Result<CompactReport>
Self::compact with options. See super::CompactOptions.
Sourcepub fn enable_encoding(&mut self) -> Result<()>
pub fn enable_encoding(&mut self) -> Result<()>
Enable 2-bit encoding for space efficiency.
Sourcepub fn disable_encoding(&mut self)
pub fn disable_encoding(&mut self)
Disable encoding, use raw byte storage.
Sourcepub fn enable_persistence<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
pub fn enable_persistence<P: AsRef<Path>>(&mut self, path: P) -> Result<()>
Enable disk persistence for this store.
Sourcepub fn disable_persistence(&mut self)
pub fn disable_persistence(&mut self)
Disable disk persistence for this store.
Sourcepub fn ingest_sequence(&mut self, name: &str, bytes: &[u8]) -> Result<String>
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.
Sourcepub fn add_sequence_collection(
&mut self,
collection: SequenceCollection,
) -> Result<()>
pub fn add_sequence_collection( &mut self, collection: SequenceCollection, ) -> Result<()>
Add a collection and all sequences in it to the store.
Sourcepub fn add_sequence_collection_force(
&mut self,
collection: SequenceCollection,
) -> Result<()>
pub fn add_sequence_collection_force( &mut self, collection: SequenceCollection, ) -> Result<()>
Add a collection, overwriting existing data.
Sourcepub fn add_sequence_collection_from_fasta<P: AsRef<Path>>(
&mut self,
file_path: P,
opts: FastaImportOptions<'_>,
) -> Result<(SequenceCollectionMetadata, bool)>
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.
Sourcepub fn add_sequence_collections_from_fastas(
&mut self,
files: &[PathBuf],
opts: FastaImportOptions<'_>,
) -> Result<ImportReport>
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.
Sourcepub fn add_sequence_record(
&mut self,
sr: SequenceRecord,
force: bool,
) -> Result<()>
pub fn add_sequence_record( &mut self, sr: SequenceRecord, force: bool, ) -> Result<()>
Add a SequenceRecord directly to the store.
Sourcepub fn remove_collection(
&mut self,
digest: &str,
remove_orphan_sequences: bool,
) -> Result<bool>
pub fn remove_collection( &mut self, digest: &str, remove_orphan_sequences: bool, ) -> Result<bool>
Remove a collection from the store.
Sourcepub fn plan_orphan_removal(&self, digest: &str) -> Result<Vec<String>>
pub fn plan_orphan_removal(&self, digest: &str) -> Result<Vec<String>>
Dry-run of the orphan cleanup in Self::remove_collection.
Sourcepub fn lock_for_batch(&mut self, operation: &str) -> Result<()>
pub fn lock_for_batch(&mut self, operation: &str) -> Result<()>
Hold the store’s exclusive writer lock across several mutations.
Sourcepub fn release_batch_lock(&mut self)
pub fn release_batch_lock(&mut self)
Release a lock taken by Self::lock_for_batch.
Sourcepub fn set_lock_options(&mut self, options: LockOptions)
pub fn set_lock_options(&mut self, options: LockOptions)
Override the timeout/staleness settings used when acquiring the write lock.
Sourcepub fn set_force_alias(&mut self, force: bool)
pub fn set_force_alias(&mut self, force: bool)
Allow re-pointing an existing alias to a different digest.
Sourcepub fn import_collection_from_readonly(
&mut self,
source: &ReadonlyRefgetStore,
digest: &str,
) -> Result<()>
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.
Sourcepub fn import_collection(
&mut self,
source: &mut RefgetStore,
digest: &str,
) -> Result<()>
pub fn import_collection( &mut self, source: &mut RefgetStore, digest: &str, ) -> Result<()>
Import a collection from another RefgetStore, lazy-loading the source if needed.
Sourcepub fn is_sequence_loaded<K: AsRef<[u8]>>(&self, seq_digest: K) -> bool
pub fn is_sequence_loaded<K: AsRef<[u8]>>(&self, seq_digest: K) -> bool
Check whether a sequence’s bytes are loaded.
Sourcepub fn enable_ancillary_digests(&mut self)
pub fn enable_ancillary_digests(&mut self)
Enable computation of ancillary digests.
Sourcepub fn disable_ancillary_digests(&mut self)
pub fn disable_ancillary_digests(&mut self)
Disable computation of ancillary digests.
Sourcepub fn enable_attribute_index(&mut self)
pub fn enable_attribute_index(&mut self)
Enable indexed attribute lookup.
Sourcepub fn disable_attribute_index(&mut self)
pub fn disable_attribute_index(&mut self)
Disable indexed attribute lookup.
Source§impl RefgetStore
impl RefgetStore
Sourcepub fn add_sequence_alias(
&mut self,
namespace: &str,
alias: &str,
digest: &str,
) -> Result<()>
pub fn add_sequence_alias( &mut self, namespace: &str, alias: &str, digest: &str, ) -> Result<()>
Add a sequence alias.
Sourcepub fn remove_sequence_alias(
&mut self,
namespace: &str,
alias: &str,
) -> Result<bool>
pub fn remove_sequence_alias( &mut self, namespace: &str, alias: &str, ) -> Result<bool>
Remove a single sequence alias.
Sourcepub fn load_sequence_aliases(
&mut self,
namespace: &str,
path: &str,
) -> Result<usize>
pub fn load_sequence_aliases( &mut self, namespace: &str, path: &str, ) -> Result<usize>
Load sequence aliases from a TSV file.
Sourcepub fn add_collection_alias(
&mut self,
namespace: &str,
alias: &str,
digest: &str,
) -> Result<()>
pub fn add_collection_alias( &mut self, namespace: &str, alias: &str, digest: &str, ) -> Result<()>
Add a collection alias.
Sourcepub fn remove_collection_alias(
&mut self,
namespace: &str,
alias: &str,
) -> Result<bool>
pub fn remove_collection_alias( &mut self, namespace: &str, alias: &str, ) -> Result<bool>
Remove a single collection alias.
Sourcepub fn load_collection_aliases(
&mut self,
namespace: &str,
path: &str,
) -> Result<usize>
pub fn load_collection_aliases( &mut self, namespace: &str, path: &str, ) -> Result<usize>
Load collection aliases from a TSV file.
Sourcepub fn get_collection_by_alias(
&mut self,
namespace: &str,
alias: &str,
) -> Result<SequenceCollection>
pub fn get_collection_by_alias( &mut self, namespace: &str, alias: &str, ) -> Result<SequenceCollection>
Lazy-loading get_collection_by_alias.
Sourcepub fn pull_aliases(
&mut self,
namespace: Option<&str>,
strategy: SyncStrategy,
) -> Result<PullResult>
pub fn pull_aliases( &mut self, namespace: Option<&str>, strategy: SyncStrategy, ) -> Result<PullResult>
Pull alias sidecars from the remote store.
Source§impl RefgetStore
impl RefgetStore
Sourcepub fn set_fhr_metadata(
&mut self,
collection_digest: &str,
metadata: FhrMetadata,
) -> Result<()>
pub fn set_fhr_metadata( &mut self, collection_digest: &str, metadata: FhrMetadata, ) -> Result<()>
Set FHR metadata for a collection.
Sourcepub fn remove_fhr_metadata(&mut self, collection_digest: &str) -> bool
pub fn remove_fhr_metadata(&mut self, collection_digest: &str) -> bool
Remove FHR metadata for a collection.
Sourcepub fn load_fhr_metadata(
&mut self,
collection_digest: &str,
path: &str,
) -> Result<()>
pub fn load_fhr_metadata( &mut self, collection_digest: &str, path: &str, ) -> Result<()>
Load FHR metadata from a JSON file.
Sourcepub fn pull_fhr(
&mut self,
digest: Option<&str>,
strategy: SyncStrategy,
) -> Result<PullResult>
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>§
Sourcepub fn sequence_view<K: AsRef<[u8]>>(&self, digest: K) -> Option<SeqView<'_>>
pub fn sequence_view<K: AsRef<[u8]>>(&self, digest: K) -> Option<SeqView<'_>>
A borrowed view of one sequence’s metadata, by any digest form.
Sourcepub fn sequence_views(&self) -> impl Iterator<Item = SeqView<'_>> + '_
pub fn sequence_views(&self) -> impl Iterator<Item = SeqView<'_>> + '_
Views of every sequence in the store, in insertion order.
Sourcepub fn collection_members<K: AsRef<[u8]>>(
&self,
digest: K,
) -> Result<impl ExactSizeIterator<Item = MemberView<'_>> + '_>
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.
Sourcepub fn loaded_bytes<K: AsRef<[u8]>>(&self, digest: K) -> Option<&[u8]>
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.
Sourcepub fn holds_batch_lock(&self) -> bool
pub fn holds_batch_lock(&self) -> bool
Whether this store currently holds a batch write lock.
Sourcepub fn has_uncommitted_changes(&self) -> bool
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.
Sourcepub fn is_persisting(&self) -> bool
pub fn is_persisting(&self) -> bool
Check if persistence to disk is enabled.
Sourcepub fn sequence_digests(&self) -> impl Iterator<Item = [u8; 48]> + '_
pub fn sequence_digests(&self) -> impl Iterator<Item = [u8; 48]> + '_
Returns an iterator over all sequence digests in the store
Sourcepub fn sequence_metadata(&self) -> impl Iterator<Item = SequenceMetadata> + '_
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.
Sourcepub fn logical_sequence_bytes(&self) -> usize
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).
Sourcepub fn actual_disk_usage(&self) -> usize
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().
Sourcepub fn list_collections(
&self,
page: usize,
page_size: usize,
filters: &[(&str, &str)],
) -> Result<PagedResult<SequenceCollectionMetadata>>
pub fn list_collections( &self, page: usize, page_size: usize, filters: &[(&str, &str)], ) -> Result<PagedResult<SequenceCollectionMetadata>>
List collections with pagination and optional attribute filtering.
Sourcepub fn get_collection_metadata<K: AsRef<[u8]>>(
&self,
collection_digest: K,
) -> Option<&SequenceCollectionMetadata>
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).
Sourcepub fn get_collection(
&self,
collection_digest: &str,
) -> Result<SequenceCollection>
pub fn get_collection( &self, collection_digest: &str, ) -> Result<SequenceCollection>
Get a collection with all its sequences loaded.
Sourcepub fn plan_orphan_removal(&self, digest: &str) -> Result<Vec<String>>
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.
Sourcepub fn list_sequences(&self) -> Vec<SequenceMetadata>
pub fn list_sequences(&self) -> Vec<SequenceMetadata>
List all sequences in the store (metadata only, no sequence data).
Sourcepub fn get_sequence_metadata<K: AsRef<[u8]>>(
&self,
seq_digest: K,
) -> Option<SequenceMetadata>
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.
Sourcepub fn get_sequence<K: AsRef<[u8]>>(
&self,
seq_digest: K,
) -> Result<SequenceRecord>
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.
Sourcepub fn is_sequence_loaded<K: AsRef<[u8]>>(&self, seq_digest: K) -> bool
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.
Sourcepub fn get_sequence_by_name<K: AsRef<[u8]>>(
&self,
collection_digest: K,
sequence_name: &str,
) -> Result<SequenceRecord>
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.
Sourcepub fn member_by_name<K: AsRef<[u8]>>(
&self,
collection_digest: K,
sequence_name: &str,
) -> Result<MemberView<'_>>
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.
Sourcepub fn load_resident(&self, digests: &[String]) -> Result<u64>
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.
Sourcepub fn evict_resident(&self, digests: &[String])
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.
Sourcepub fn evict_all_resident(&self)
pub fn evict_all_resident(&self)
Drop the entire resident overlay.
Sourcepub fn resident_bytes(&self) -> u64
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.
Sourcepub fn resident_len(&self) -> usize
pub fn resident_len(&self) -> usize
Number of sequences currently resident.
Sourcepub fn resident_estimate_bytes(&self, digests: &[String]) -> u64
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.
Sourcepub fn iter_collections(&self) -> impl Iterator<Item = SequenceCollection> + '_
pub fn iter_collections(&self) -> impl Iterator<Item = SequenceCollection> + '_
Iterate over all collections with their sequences loaded.
Sourcepub fn iter_sequences(&self) -> impl Iterator<Item = SequenceRecord> + '_
pub fn iter_sequences(&self) -> impl Iterator<Item = SequenceRecord> + '_
Iterate over all sequences with their data loaded.
Sourcepub fn is_collection_loaded<K: AsRef<[u8]>>(&self, collection_digest: K) -> bool
pub fn is_collection_loaded<K: AsRef<[u8]>>(&self, collection_digest: K) -> bool
Check if a collection is fully loaded.
Sourcepub fn local_path(&self) -> Option<&PathBuf>
pub fn local_path(&self) -> Option<&PathBuf>
Returns the local path where the store is located (if any)
Sourcepub fn remote_source(&self) -> Option<&str>
pub fn remote_source(&self) -> Option<&str>
Returns the remote source URL (if any)
Sourcepub fn storage_mode(&self) -> StorageMode
pub fn storage_mode(&self) -> StorageMode
Returns the storage mode used by this store
Sourcepub fn layout(&self) -> Layout
pub fn layout(&self) -> Layout
Returns the physical layout of this store’s sequence bytes, fixed when the store was created.
Sourcepub fn get_substring<K: AsRef<[u8]>>(
&self,
sha512_digest: K,
start: usize,
end: usize,
) -> Result<String>
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.
Sourcepub fn get_substring_bytes<K: AsRef<[u8]>>(
&self,
sha512_digest: K,
start: usize,
end: usize,
) -> Result<Vec<u8>>
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.
Sourcepub fn get_substrings<K: AsRef<[u8]>>(
&self,
sha512_digest: K,
ranges: &[(usize, usize)],
) -> Result<Vec<String>>
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_diskpath (reads only the bytes covering each range; reuses the open.seqhandle 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.
Sourcepub fn get_substrings_bytes<K: AsRef<[u8]>>(
&self,
sha512_digest: K,
ranges: &[(usize, usize)],
) -> Result<Vec<Vec<u8>>>
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.
Sourcepub fn packed_dead_bytes(&self) -> Result<u64>
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.
Sourcepub fn stream_sequence<K: AsRef<[u8]>>(
&self,
sha512_digest: K,
start: Option<u64>,
end: Option<u64>,
) -> Result<Box<dyn Read + Send>>
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.
Sourcepub fn sequence_file_path(&self, seq_digest: &str) -> Option<PathBuf>
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.
Sourcepub fn collection_file_path(&self, coll_digest: &str) -> Option<PathBuf>
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.
Sourcepub fn write_store_to_dir<P: AsRef<Path>>(
&self,
root_path: P,
seqdata_path_template: Option<&str>,
) -> Result<()>
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
Sourcepub fn stats(&self) -> StoreStats
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.
Sourcepub fn available_alias_namespaces(&self) -> AvailableAliases<'_>
pub fn available_alias_namespaces(&self) -> AvailableAliases<'_>
List alias namespaces available on this store (from manifest).
Sourcepub fn get_sequence_metadata_by_alias(
&self,
namespace: &str,
alias: &str,
) -> Option<SequenceMetadata>
pub fn get_sequence_metadata_by_alias( &self, namespace: &str, alias: &str, ) -> Option<SequenceMetadata>
Resolve a sequence alias to sequence metadata (no data loading).
Sourcepub fn get_sequence_by_alias(
&self,
namespace: &str,
alias: &str,
) -> Result<SequenceRecord>
pub fn get_sequence_by_alias( &self, namespace: &str, alias: &str, ) -> Result<SequenceRecord>
Resolve a sequence alias and return the sequence record.
Sourcepub fn get_aliases_for_sequence(&self, digest: &str) -> Vec<(String, String)>
pub fn get_aliases_for_sequence(&self, digest: &str) -> Vec<(String, String)>
Reverse lookup: find all aliases pointing to this sequence digest.
Sourcepub fn list_sequence_alias_namespaces(&self) -> Vec<String>
pub fn list_sequence_alias_namespaces(&self) -> Vec<String>
List all sequence alias namespaces.
Sourcepub fn list_sequence_aliases(&self, namespace: &str) -> Option<Vec<String>>
pub fn list_sequence_aliases(&self, namespace: &str) -> Option<Vec<String>>
List all aliases in a sequence alias namespace.
Sourcepub fn get_collection_metadata_by_alias(
&self,
namespace: &str,
alias: &str,
) -> Option<&SequenceCollectionMetadata>
pub fn get_collection_metadata_by_alias( &self, namespace: &str, alias: &str, ) -> Option<&SequenceCollectionMetadata>
Resolve a collection alias to collection metadata.
Sourcepub fn get_collection_by_alias(
&self,
namespace: &str,
alias: &str,
) -> Result<SequenceCollection>
pub fn get_collection_by_alias( &self, namespace: &str, alias: &str, ) -> Result<SequenceCollection>
Resolve a collection alias and return the loaded collection.
Sourcepub fn get_aliases_for_collection(&self, digest: &str) -> Vec<(String, String)>
pub fn get_aliases_for_collection(&self, digest: &str) -> Vec<(String, String)>
Reverse lookup: find all aliases pointing to this collection digest.
Sourcepub fn list_collection_alias_namespaces(&self) -> Vec<String>
pub fn list_collection_alias_namespaces(&self) -> Vec<String>
List all collection alias namespaces.
Sourcepub fn list_collection_aliases(&self, namespace: &str) -> Option<Vec<String>>
pub fn list_collection_aliases(&self, namespace: &str) -> Option<Vec<String>>
List all aliases in a collection alias namespace.
Sourcepub fn get_fhr_metadata(&self, collection_digest: &str) -> Option<&FhrMetadata>
pub fn get_fhr_metadata(&self, collection_digest: &str) -> Option<&FhrMetadata>
Get FHR metadata for a collection. Returns None if missing.
Sourcepub fn list_fhr_metadata(&self) -> Vec<String>
pub fn list_fhr_metadata(&self) -> Vec<String>
List all collection digests that have FHR metadata.
Sourcepub fn write_sequences_rgsi<P: AsRef<Path>>(&self, file_path: P) -> Result<()>
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.
Sourcepub fn store_metadata(&self) -> Result<HashMap<String, String>>
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.
Sourcepub fn substrings_from_regions<'a, K: AsRef<[u8]>>(
&'a self,
collection_digest: K,
bed_file_path: &str,
) -> Result<SubstringsFromRegions<'a, K>>
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.
Sourcepub fn substrings_from_region_vectors<'a, K, S>(
&'a self,
collection_digest: K,
chroms: &[S],
starts: &[u32],
ends: &[u32],
) -> Result<SubstringsFromRegionVectors<'a, K>>
pub fn substrings_from_region_vectors<'a, K, S>( &'a self, collection_digest: K, chroms: &[S], starts: &[u32], ends: &[u32], ) -> Result<SubstringsFromRegionVectors<'a, K>>
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.
Sourcepub fn export_fasta_from_regions<K: AsRef<[u8]>>(
&self,
collection_digest: K,
bed_file_path: &str,
output_file_path: &str,
label: &LabelTemplate,
) -> Result<ExportSummary>
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.
Sourcepub fn export_fasta<P: AsRef<Path>>(
&self,
selection: &ExportSelection,
output_path: P,
opts: &ExportOptions,
) -> Result<ExportSummary>
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.
Sourcepub fn verify_sequence(
&self,
digest: &str,
check_md5: bool,
) -> Result<Option<VerifyFailure>>
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.
Sourcepub fn verify_sequences(
&self,
digests: Option<&[String]>,
opts: &VerifyOptions,
) -> Result<VerifyReport>
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.
Sourcepub fn has_ancillary_digests(&self) -> bool
pub fn has_ancillary_digests(&self) -> bool
Returns whether ancillary digests are enabled.
Sourcepub fn has_attribute_index(&self) -> bool
pub fn has_attribute_index(&self) -> bool
Returns whether the on-disk attribute index is enabled.
Sourcepub fn get_collection_level1(&self, digest: &str) -> Result<CollectionLevel1>
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.
Sourcepub fn get_collection_level2(&self, digest: &str) -> Result<CollectionLevel2>
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.
Sourcepub fn compare(
&self,
digest_a: &str,
digest_b: &str,
) -> Result<SeqColComparison>
pub fn compare( &self, digest_a: &str, digest_b: &str, ) -> Result<SeqColComparison>
Compare two collections by digest. Both must be preloaded.
Sourcepub fn match_sequence_names(
&self,
digest_a: &str,
digest_b: &str,
) -> Result<CollectionNameMatch>
pub fn match_sequence_names( &self, digest_a: &str, digest_b: &str, ) -> Result<CollectionNameMatch>
Match collection-local names by identical sequence content.
Sourcepub fn compare_with_level2(
&self,
digest_a: &str,
external: &CollectionLevel2,
) -> Result<SeqColComparison>
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.
Sourcepub fn find_collections_by_attribute(
&self,
attr_name: &str,
attr_digest: &str,
) -> Result<Vec<String>>
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”
Sourcepub fn get_attribute(
&self,
attr_name: &str,
attr_digest: &str,
) -> Result<Option<Value>>
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.
Sourcepub fn collection_count(&self) -> usize
pub fn collection_count(&self) -> usize
Total number of collections in the store.