Storage interfaces#
Storage interface for sample data and assay data.
- class tidyms2.core.storage.AssayStorage(*args, **kwargs)#
Bases:
Protocol,Generic[RoiType,FeatureType]Interface to store assay data.
- add_feature_groups(*groups)#
Add feature groups data to the assay storage.
- Return type:
None
- add_fill_values(*fill_values)#
Add values to fill missing entries in the data matrix.
- Return type:
None
- add_sample_data(data)#
Add data from a sample.
If include snapshots is set to
Trueinclude all data snapshots. Otherwise, include only the latest data snapshot.- Return type:
None
- create_snapshot(snapshot_id)#
Create a new assay data snapshot.
- Return type:
None
- fetch_annotations(sample_id=None)#
Fetch the feature annotations.
- Return type:
list[Annotation]
- fetch_descriptors(sample_id=None, descriptors=None)#
Fetch the feature descriptors.
- Return type:
dict
- fetch_feature_groups()#
Fetch feature groups stored in the assay.
- Return type:
list[FeatureGroup]
- fetch_features_by_group(group)#
Fetch features using the feature group id.
- Return type:
list[TypeVar(FeatureType, bound=Feature)]
- fetch_features_by_id(*feature_ids)#
Fetch features using their ids.
- Return type:
list[TypeVar(FeatureType, bound=Feature)]
- fetch_features_by_sample(sample_id)#
Fetch features using the sample id.
- Return type:
list[TypeVar(FeatureType, bound=Feature)]
- fetch_fill_values()#
Fetch fill values for data matrix.
- Return type:
dict[str,dict[int,float]]
- fetch_rois_by_id(*roi_ids)#
Fetch ROIs using their ids.
- Return type:
list[TypeVar(RoiType, bound=Roi)]
- fetch_rois_by_sample(sample_id)#
Fetch all ROIs from a sample.
- Return type:
list[TypeVar(RoiType, bound=Roi)]
- fetch_sample_data(sample_id)#
Fetch Samples from the assay using their ids.
- Return type:
SampleStorage[TypeVar(RoiType, bound=Roi),TypeVar(FeatureType, bound=Feature)]
- get_feature_type()#
Retrieve the Feature class used.
- Return type:
type[TypeVar(FeatureType, bound=Feature)]
- get_n_features()#
Get the total number of features in the assay.
- Return type:
int
- get_n_rois()#
Get the total number of ROIs in the assay.
- Return type:
int
- get_process_status()#
Get the current process status.
- Return type:
- get_snapshot_id()#
Retrieve the current snapshot id.
- Return type:
str
- has_feature(feature_id)#
Check if a feature with the provided id exists.
- Return type:
bool
- has_feature_group(feature_group)#
Check if a group with the provided id is in the assay.
- Return type:
bool
- has_roi(roi_id)#
Check if a ROI with the provided id exists.
- Return type:
bool
- has_sample(sample_id)#
Check if a sample with the provided id is in the assay.
- Return type:
bool
- list_feature_groups()#
List all group ids in the assay.
- Return type:
list[int]
- list_snapshots()#
Retrieve the list of all snapshots.
- Return type:
list[str]
- patch_annotations(*patches)#
Update feature annotation values.
- Return type:
None
- patch_descriptors(*patches)#
Update feature descriptors values.
- Return type:
None
- set_process_status(status)#
Set the new process status.
- Return type:
None
- set_snapshot(snapshot_id=None, reset=False)#
Set assay storage data to specified snapshot.
If
None, fetch data from the latest snapshot.- Return type:
None
- class tidyms2.core.storage.SampleStorage(sample, roi_type, feature_type, **kwargs)#
Bases:
Protocol,Generic[RoiType,FeatureType]Interface to store sample data.
Provides:
- Access sample metadata.
Sample metadata maintains all sample-related information. It also provides utilities to access raw data.
- add/get/delete ROIs and features.
Provide utilities to modify the sample data.
- sample data status
get_status retrieves a record of the information available for the sample, such as if ROI extraction was performed on the data, feature extraction, isotopologue annotation, etc… set_status allow to specify this status.
- linear data snapshots
Sample storage maintains a list of snapshots with independent copies of the data at different points in time. The create_snapshot allows to create data snapshots of the sample data at any point in time. Only the latest snapshot is modifiable. The reset method rollbacks the data to a specified snapshot in read only mode, i.e., all operations that modify the snapshot state should raise SnapshotError. The
hardparameter controls if a hard reset operation is performed on the data. That is, setting the selected snapshot as the latest and deleting data from all posterior snapshots. Finally, the set_latest_snapshot set the data to the latest snapshot.
- add_features(*features)#
Add features to the sample storage.
- Return type:
None
- add_rois(*rois)#
Add ROIs to the sample storage.
- Return type:
None
- create_snapshot(snapshot_id)#
Create a snapshot of the sample data.
- Return type:
None
- delete_features(*feature_ids)#
Delete features from the sample storage using their ids.
- Return type:
None
- delete_rois(*roi_id)#
Delete ROIs from the sample storage using their ids.
- Return type:
None
- get_feature(feature_id)#
Get a feature from the sample storage using its id.
- Return type:
TypeVar(FeatureType, bound=Feature)
- get_n_features()#
Get the total number of features in the storage.
- Return type:
int
- get_n_rois()#
Get the total number of ROIs in the storage.
- Return type:
int
- get_roi(roi_id)#
Get a ROI from the sample storage using its id.
- Return type:
TypeVar(RoiType, bound=Roi)
- get_snapshot_id()#
Get the current snapshot id.
- Return type:
str
- get_status()#
Get the current process status.
- Return type:
- has_feature(feature_id)#
Check if a feature with the provided id exists.
- Return type:
bool
- has_roi(roi_id)#
Check if a ROI with the provided id exists.
- Return type:
bool
- list_features(roi_id=None)#
List features extracted from the sample.
- Return type:
list[TypeVar(FeatureType, bound=Feature)]
- list_snapshots()#
List all available snapshots.
- Return type:
list[str]
- set_snapshot(snapshot_id=None, reset=False)#
Set the sample data to the specified snapshot id.
Setting reset to
Trueset the selected status as latest and deletes all posterior snapshots.- Return type:
None
- set_status(status)#
Set the current process status.
- Return type:
None