DatasetQuery¶
DatasetQuery¶
Matching functionality for filtering database samples based on field conditions.
DatasetQuery ¶
DatasetQuery(dataset: DatasetTable, session: Session)
Class for executing querying on a dataset.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dataset |
DatasetTable
|
The dataset to query. |
required |
session |
Session
|
Database session for executing queries. |
required |
__getitem__ ¶
__getitem__(key: _SliceType) -> DatasetQuery
Enable bracket notation for slicing.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
_SliceType
|
A slice object (e.g., [10:20], [:50], [100:]). |
required |
Returns:
Type | Description |
---|---|
DatasetQuery
|
Self with slice applied. |
Raises:
Type | Description |
---|---|
TypeError
|
If key is not a slice object. |
ValueError
|
If slice contains unsupported features or conflicts with existing slice. |
__iter__ ¶
__iter__() -> Iterator[Sample]
Iterate over the query results.
Returns:
Type | Description |
---|---|
Iterator[Sample]
|
Iterator of Sample objects from the database. |
add_tag ¶
add_tag(tag_name: str) -> None
Add a tag to all samples returned by this query.
First, creates the tag if it doesn't exist. Then applies the tag to all samples that match the current query filters. Samples already having that tag are unchanged, as the database prevents duplicates.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
tag_name |
str
|
Name of the tag to add to matching samples. |
required |
export ¶
export() -> DatasetExport
Return a DatasetExport instance which can export the dataset in various formats.
match ¶
match(match_expression: MatchExpression) -> DatasetQuery
Store a field condition for filtering.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
match_expression |
MatchExpression
|
Defines the filter. |
required |
Returns:
Type | Description |
---|---|
DatasetQuery
|
Self for method chaining. |
Raises:
Type | Description |
---|---|
ValueError
|
If match() has already been called on this instance. |
order_by ¶
order_by(*order_by: OrderByExpression) -> DatasetQuery
Store ordering expressions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
order_by |
OrderByExpression
|
One or more ordering expressions. They are applied in order. E.g. first ordering by sample width and then by sample file_name will only order the samples with the same sample width by file_name. |
()
|
Returns:
Type | Description |
---|---|
DatasetQuery
|
Self for method chaining. |
Raises:
Type | Description |
---|---|
ValueError
|
If order_by() has already been called on this instance. |
selection ¶
selection() -> Selection
Selection interface for this query.
The returned Selection snapshots the current query results immediately. Mutating the query after calling this method will therefore not affect the samples used by that Selection instance.
Returns:
Type | Description |
---|---|
Selection
|
Selection interface operating on the current query result snapshot. |
slice ¶
slice(offset: int = 0, limit: int | None = None) -> DatasetQuery
Apply offset and limit to results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
offset |
int
|
Number of items to skip from beginning (default: 0). |
0
|
limit |
int | None
|
Maximum number of items to return (None = no limit). |
None
|
Returns:
Type | Description |
---|---|
DatasetQuery
|
Self for method chaining. |
Raises:
Type | Description |
---|---|
ValueError
|
If slice() has already been called on this instance. |
SampleField¶
Fields for querying sample properties in the dataset query system.
SampleField ¶
Providing access to predefined sample fields for queries.
This class provides static instances of different field types that can be used to build database queries on sample properties.