Stores¶
In-memory track and genome stores with UUID keys and provenance-based result caching. When two requests produce the same computation (identical operation, input IDs, and parameters), the store returns the cached result instead of recomputing.
Provenance
dataclass
¶
Records how a track was produced.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str
|
Name of the operation (e.g. |
required |
input_ids
|
tuple[str, ...]
|
Sorted tuple of input track UUIDs. |
required |
params
|
tuple[tuple[str, Any], ...]
|
Sorted tuple of (key, value) parameter pairs. |
required |
Examples:
>>> p = Provenance("transform.log", ("abc",), (("base", 2),))
>>> p.cache_key()
('transform.log', ('abc',), (('base', 2),))
cache_key
¶
Return a hashable key for result caching.
Returns:
| Type | Description |
|---|---|
tuple
|
Tuple of (operation, input_ids, params). |
Examples:
Source code in src/seqchain/api/store.py
Track store¶
StoredTrack
¶
StoredTrack(id: str, track: Track, track_type: str, chroms: dict[str, int], created_at: datetime | None = None, provenance: Provenance | None = None, temp_file: Any = None)
A track stored in the TrackStore with metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
UUID string. |
required |
track
|
Track
|
The underlying Track object. |
required |
track_type
|
str
|
One of |
required |
chroms
|
dict[str, int]
|
Chromosome sizes for serialization iteration. |
required |
created_at
|
datetime | None
|
Creation timestamp. |
None
|
provenance
|
Provenance | None
|
How the track was produced, or |
None
|
Examples:
Source code in src/seqchain/api/store.py
TrackStore
¶
In-memory store for tracks, with provenance-based caching.
Examples:
>>> store = TrackStore()
>>> tid = store.put(IntervalTrack(TrackLabel("t"), []))
>>> len(store.list_all())
1
Source code in src/seqchain/api/store.py
put
¶
put(track: Track, *, chroms: dict[str, int] | None = None, provenance: Provenance | None = None, temp_file: Any = None) -> str
Store a track and return its UUID.
If a track with identical provenance already exists, returns the existing track's ID instead of creating a duplicate.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track
|
Track
|
The Track to store. |
required |
chroms
|
dict[str, int] | None
|
Chromosome sizes for serialization. |
None
|
provenance
|
Provenance | None
|
How the track was produced. |
None
|
temp_file
|
Any
|
Reference to keep alive (e.g. BigWig handle). |
None
|
Returns:
| Type | Description |
|---|---|
str
|
UUID string of the stored (or cached) track. |
Examples:
Source code in src/seqchain/api/store.py
get
¶
Retrieve a stored track by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track_id
|
str
|
UUID of the track. |
required |
Returns:
| Type | Description |
|---|---|
StoredTrack | None
|
The StoredTrack, or |
Examples:
Source code in src/seqchain/api/store.py
delete
¶
Remove a track from the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
track_id
|
str
|
UUID of the track. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Examples:
Source code in src/seqchain/api/store.py
list_all
¶
Return all stored tracks.
Returns:
| Type | Description |
|---|---|
list[StoredTrack]
|
List of StoredTrack objects, ordered by creation time. |
Examples:
Source code in src/seqchain/api/store.py
Genome store¶
StoredGenome
¶
A genome stored in the GenomeStore with metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
UUID string. |
required |
genome
|
Genome
|
The underlying Genome object. |
required |
created_at
|
datetime | None
|
Creation timestamp. |
None
|
Examples:
>>> from seqchain.io.genome import Genome
>>> g = Genome("test", {}, {"chr1": "ATCG"}, (), {})
>>> sg = StoredGenome("abc", g)
>>> sg.chrom_lengths
{'chr1': 4}
Source code in src/seqchain/api/store.py
chrom_lengths
property
¶
GenomeStore
¶
In-memory store for genomes.
Examples:
Source code in src/seqchain/api/store.py
put
¶
Store a genome and return its UUID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
genome
|
Genome
|
The Genome to store. |
required |
Returns:
| Type | Description |
|---|---|
str
|
UUID string of the stored genome. |
Examples:
>>> from seqchain.io.genome import Genome
>>> store = GenomeStore()
>>> store.put(Genome("test", {}, {"chr1": "ATCG"}, (), {}))
'a1b2c3...'
Source code in src/seqchain/api/store.py
get
¶
Retrieve a stored genome by ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
genome_id
|
str
|
UUID of the genome. |
required |
Returns:
| Type | Description |
|---|---|
StoredGenome | None
|
The StoredGenome, or |
Examples:
Source code in src/seqchain/api/store.py
delete
¶
Remove a genome from the store.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
genome_id
|
str
|
UUID of the genome. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Examples:
Source code in src/seqchain/api/store.py
list_all
¶
Return all stored genomes.
Returns:
| Type | Description |
|---|---|
list[StoredGenome]
|
List of StoredGenome objects, ordered by creation time. |
Examples: