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.

Holds a global sequence_store with all sequences (across collections) deduplicated. This allows lookup by sequence digest directly (bypassing collection information). Also holds a collections hashmap, to provide lookup by collection+name.

Implementations§

Source§

impl ReadonlyRefgetStore

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)

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

Source

pub fn enable_encoding(&mut self)

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 is_persisting(&self) -> bool

Check if persistence to disk is enabled.

Source

pub fn add_sequence<T: Into<Option<[u8; 48]>>>( &mut self, sequence_record: SequenceRecord, collection_digest: T, force: bool, ) -> Result<()>

Adds a sequence to the Store

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 add_sequence_record( &mut self, sr: SequenceRecord, force: bool, ) -> Result<()>

Adds a SequenceRecord directly to the store without collection association.

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 sequence metadata for all sequences in the store.

Source

pub fn total_disk_size(&self) -> usize

Calculate the total disk size of all sequences in the store

Source

pub fn actual_disk_usage(&self) -> usize

Returns the actual disk usage of the store directory.

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 remove_collection( &mut self, digest: &str, remove_orphan_sequences: bool, ) -> Result<bool>

Remove a collection from the store.

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.

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).

Source

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

Get a sequence by its SHA512t24u digest.

Source

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

Ensure a sequence is loaded and decoded into the decoded cache.

Source

pub fn clear_decoded_cache(&mut self)

Clear the decoded sequence cache to reclaim memory.

Source

pub fn clear(&mut self)

Clear sequence data from the store to free memory.

Source

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

Get decoded sequence bytes from the cache.

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.

Source

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

Eagerly load all Stub collections to Full.

Source

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

Eagerly load all Stub sequences to Full.

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

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

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.

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 loaded 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.

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.

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.

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_collection_from_fasta<P: AsRef<Path>>( &mut self, file_path: P, opts: FastaImportOptions<'_>, ) -> Result<(SequenceCollectionMetadata, bool)>

Import a FASTA file into the store using a multithreaded pipeline.

After the pipeline finishes, computes collection metadata, registers the collection, and inserts all sequences.

Source§

impl ReadonlyRefgetStore

Source

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

Write all sequence metadata to an RGSI file.

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. 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 export_fasta_from_regions<K: AsRef<[u8]>>( &self, collection_digest: K, bed_file_path: &str, output_file_path: &str, ) -> Result<()>

Export sequences from BED file regions to a FASTA file.

Source

pub fn export_fasta<K: AsRef<[u8]>, P: AsRef<Path>>( &self, collection_digest: K, output_path: P, sequence_names: Option<Vec<&str>>, line_width: Option<usize>, ) -> Result<()>

Export sequences from a collection to a FASTA file.

Source

pub fn export_fasta_by_digests<P: AsRef<Path>>( &self, seq_digests: Vec<&str>, output_path: P, line_width: Option<usize>, ) -> Result<()>

Export sequences by their sequence digests to a FASTA file.

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 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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.