Pre-configured queries are performed in an aggregation pipeline against the standard “Progenetix”-type MongoDB collections.
### `variants` Query and Aggregation 1. If a `variants` query exists (i.e. has been defined in `exe_queries`), in a first pass all `callset_id` values are retrieved. 2. If already a `"cs.id"` result exists (e.g. from a biosample query), the lists of callset `id` values from the different queries are intersected. Otherwise, the callsets from the variants query are the final ones. 3. Since so far not all matching variants have been retrieved (only the callsets which contain them), they are now fetched using the original query or a combination of the original query and the matching callsets from the intersect. ### Result Aggregation
The above queries have provided
cs.id values which now are used to retrieve the
matching final biosample
TODO: Benchmark if the
_id retrieval & storage speeds up biosample and callset recovery
in handover scenarios or if
id is fine.
If no variant query was performed but the response asks for variants => all
callset variants will be returned.