diff --git a/beacon/conf/conf.py b/beacon/conf/conf.py index 93c1e1e..dc95b7a 100644 --- a/beacon/conf/conf.py +++ b/beacon/conf/conf.py @@ -15,7 +15,7 @@ beacon_id = 'org.ega-archive.beacon-ri-demo' # ID of the Beacon beacon_name = 'Beacon Reference Implementation demo' # Name of the Beacon service api_version = 'v2.0.0' # Version of the Beacon implementation -uri = 'https://beacon-ri-demo.ega-archive.org/api/' +uri = 'http://beaconprod:5050/api/' environment = 'test' description = r"This Beacon is based on synthetic data hosted at the EGA. The dataset contains 2504 samples including genetic data based on 1K Genomes data, and 76 individual attributes and phenotypic data derived from UKBiobank." version = api_version_yaml['api_version'] diff --git a/beacon/connections/mongo/analyses.py b/beacon/connections/mongo/analyses.py index 4dd8d79..571661b 100644 --- a/beacon/connections/mongo/analyses.py +++ b/beacon/connections/mongo/analyses.py @@ -15,9 +15,9 @@ def get_analyses(self, entry_id: Optional[str], qparams: RequestParams, dataset: collection = 'analyses' mongo_collection = client.beacon.analyses parameters_as_filters=False - query_parameters, parameters_as_filters = apply_request_parameters(self, {}, qparams) + query_parameters, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset) if parameters_as_filters == True and query_parameters != {'$and': []}:# pragma: no cover - query, parameters_as_filters = apply_request_parameters(self, {}, qparams) + query, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset) query_parameters={} elif query_parameters != {'$and': []}: query=query_parameters diff --git a/beacon/connections/mongo/biosamples.py b/beacon/connections/mongo/biosamples.py index 0d5b0e1..e3f5c88 100644 --- a/beacon/connections/mongo/biosamples.py +++ b/beacon/connections/mongo/biosamples.py @@ -14,9 +14,9 @@ def get_biosamples(self, entry_id: Optional[str], qparams: RequestParams, datase collection = 'biosamples' mongo_collection = client.beacon.biosamples parameters_as_filters=False - query_parameters, parameters_as_filters = apply_request_parameters(self, {}, qparams) + query_parameters, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset) if parameters_as_filters == True and query_parameters != {'$and': []}:# pragma: no cover - query, parameters_as_filters = apply_request_parameters(self, {}, qparams) + query, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset) query_parameters={} elif query_parameters != {'$and': []}: query=query_parameters diff --git a/beacon/connections/mongo/datasets.py b/beacon/connections/mongo/datasets.py index 0a88bb4..5cd1407 100644 --- a/beacon/connections/mongo/datasets.py +++ b/beacon/connections/mongo/datasets.py @@ -56,9 +56,9 @@ def get_list_of_datasets(self): @log_with_args_mongo(level) def get_dataset_with_id(self, entry_id: Optional[str], qparams: RequestParams): limit = qparams.query.pagination.limit - query_parameters, parameters_as_filters = apply_request_parameters(self, {}, qparams) + query_parameters, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset) if parameters_as_filters == True: - query, parameters_as_filters = apply_request_parameters(self, {}, qparams)# pragma: no cover + query, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset)# pragma: no cover else: query={} query = query_id(self, query, entry_id) diff --git a/beacon/connections/mongo/g_variants.py b/beacon/connections/mongo/g_variants.py index 396ba7e..4f90477 100644 --- a/beacon/connections/mongo/g_variants.py +++ b/beacon/connections/mongo/g_variants.py @@ -14,9 +14,9 @@ def get_variants(self, entry_id: Optional[str], qparams: RequestParams, dataset: collection = 'g_variants' mongo_collection = client.beacon.genomicVariations parameters_as_filters=False - query_parameters, parameters_as_filters = apply_request_parameters(self, {}, qparams) + query_parameters, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset) if parameters_as_filters == True and query_parameters != {'$and': []}: - query, parameters_as_filters = apply_request_parameters(self, {}, qparams)# pragma: no cover + query, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset)# pragma: no cover query_parameters={}# pragma: no cover elif query_parameters != {'$and': []}: query=query_parameters @@ -41,9 +41,9 @@ def get_variant_with_id(self, entry_id: Optional[str], qparams: RequestParams, d collection = 'g_variants' mongo_collection = client.beacon.genomicVariations query = {"$and": [{"variantInternalId": entry_id}]} - query_parameters, parameters_as_filters = apply_request_parameters(self, query, qparams) + query_parameters, parameters_as_filters = apply_request_parameters(self, query, qparams, dataset) if parameters_as_filters == True: - query, parameters_as_filters = apply_request_parameters(self, {}, qparams)# pragma: no cover + query, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset)# pragma: no cover query_parameters={}# pragma: no cover else: query=query_parameters @@ -63,9 +63,9 @@ def get_biosamples_of_variant(self, entry_id: Optional[str], qparams: RequestPar collection = 'g_variants' mongo_collection = client.beacon.biosamples query = {"$and": [{"variantInternalId": entry_id}]} - query_parameters, parameters_as_filters = apply_request_parameters(self, query, qparams) + query_parameters, parameters_as_filters = apply_request_parameters(self, query, qparams, dataset) if parameters_as_filters == True: - query, parameters_as_filters = apply_request_parameters(self, {}, qparams)# pragma: no cover + query, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset)# pragma: no cover query_parameters={}# pragma: no cover else: query=query_parameters @@ -110,9 +110,9 @@ def get_runs_of_variant(self, entry_id: Optional[str], qparams: RequestParams, d collection = 'g_variants' mongo_collection = client.beacon.runs query = {"$and": [{"variantInternalId": entry_id}]} - query_parameters, parameters_as_filters = apply_request_parameters(self, query, qparams) + query_parameters, parameters_as_filters = apply_request_parameters(self, query, qparams, dataset) if parameters_as_filters == True: - query, parameters_as_filters = apply_request_parameters(self, {}, qparams)# pragma: no cover + query, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset)# pragma: no cover query_parameters={}# pragma: no cover else: query=query_parameters @@ -156,9 +156,9 @@ def get_analyses_of_variant(self, entry_id: Optional[str], qparams: RequestParam collection = 'g_variants' mongo_collection = client.beacon.analyses query = {"$and": [{"variantInternalId": entry_id}]} - query_parameters, parameters_as_filters = apply_request_parameters(self, query, qparams) + query_parameters, parameters_as_filters = apply_request_parameters(self, query, qparams, dataset) if parameters_as_filters == True: - query, parameters_as_filters = apply_request_parameters(self, {}, qparams)# pragma: no cover + query, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset)# pragma: no cover query_parameters={}# pragma: no cover else: query=query_parameters @@ -202,9 +202,9 @@ def get_individuals_of_variant(self, entry_id: Optional[str], qparams: RequestPa collection = 'g_variants' mongo_collection = client.beacon.individuals query = {"$and": [{"variantInternalId": entry_id}]} - query_parameters, parameters_as_filters = apply_request_parameters(self, query, qparams) + query_parameters, parameters_as_filters = apply_request_parameters(self, query, qparams, dataset) if parameters_as_filters == True: - query, parameters_as_filters = apply_request_parameters(self, query, qparams)# pragma: no cover + query, parameters_as_filters = apply_request_parameters(self, query, qparams, dataset)# pragma: no cover query_parameters={}# pragma: no cover else: query=query_parameters diff --git a/beacon/connections/mongo/individuals.py b/beacon/connections/mongo/individuals.py index e39fc0a..5740e45 100644 --- a/beacon/connections/mongo/individuals.py +++ b/beacon/connections/mongo/individuals.py @@ -14,9 +14,9 @@ def get_individuals(self, entry_id: Optional[str], qparams: RequestParams, datas collection = 'individuals' mongo_collection = client.beacon.individuals parameters_as_filters=False - query_parameters, parameters_as_filters = apply_request_parameters(self, {}, qparams) + query_parameters, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset) if parameters_as_filters == True and query_parameters != {'$and': []}: - query, parameters_as_filters = apply_request_parameters(self, {}, qparams)# pragma: no cover + query, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset)# pragma: no cover query_parameters={}# pragma: no cover elif query_parameters != {'$and': []}: query=query_parameters @@ -39,7 +39,7 @@ def get_individual_with_id(self, entry_id: Optional[str], qparams: RequestParams collection = 'individuals' idq="id" mongo_collection = client.beacon.individuals - query, parameters_as_filters = apply_request_parameters(self, {}, qparams) + query, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset) query = apply_filters(self, query, qparams.query.filters, collection, {}, dataset) query = query_id(self, query, entry_id) schema = DefaultSchemas.INDIVIDUALS @@ -83,7 +83,7 @@ def get_variants_of_individual(self, entry_id: Optional[str], qparams: RequestPa queryHGVS["$in"]=listHGVS query["identifiers.genomicHGVSId"]=queryHGVS mongo_collection = client.beacon.genomicVariations - query, parameters_as_filters = apply_request_parameters(self, query, qparams) + query, parameters_as_filters = apply_request_parameters(self, query, qparams, dataset) query = apply_filters(self, query, qparams.query.filters, collection, {}, dataset) schema = DefaultSchemas.GENOMICVARIATIONS include = qparams.query.include_resultset_responses @@ -100,7 +100,7 @@ def get_biosamples_of_individual(self, entry_id: Optional[str], qparams: Request collection = 'biosamples' mongo_collection = client.beacon.biosamples query = {"individualId": entry_id} - query, parameters_as_filters = apply_request_parameters(self, query, qparams) + query, parameters_as_filters = apply_request_parameters(self, query, qparams, dataset) query = apply_filters(self, query, qparams.query.filters, collection, {}, dataset) schema = DefaultSchemas.BIOSAMPLES include = qparams.query.include_resultset_responses diff --git a/beacon/connections/mongo/request_parameters.py b/beacon/connections/mongo/request_parameters.py index 87b4016..2d3cd91 100644 --- a/beacon/connections/mongo/request_parameters.py +++ b/beacon/connections/mongo/request_parameters.py @@ -67,7 +67,7 @@ def generate_position_filter_end(self, key: str, value: List[int]) -> List[Alpha return filters @log_with_args(level) -def apply_request_parameters(self, query: Dict[str, List[dict]], qparams: RequestParams): +def apply_request_parameters(self, query: Dict[str, List[dict]], qparams: RequestParams, dataset: str): collection = 'g_variants' if len(qparams.query.request_parameters) > 0 and "$and" not in query: query["$and"] = [] @@ -85,13 +85,13 @@ def apply_request_parameters(self, query: Dict[str, List[dict]], qparams: Reques v = v.split(',') filters = generate_position_filter_start(self, k, v) for filter in filters: - subquery["$and"].append(apply_alphanumeric_filter({}, filter, collection)) + subquery["$and"].append(apply_alphanumeric_filter({}, filter, collection, dataset)) elif k == "end": if isinstance(v, str): v = v.split(',') filters = generate_position_filter_end(self, k, v) for filter in filters: - subquery["$and"].append(apply_alphanumeric_filter({}, filter, collection)) + subquery["$and"].append(apply_alphanumeric_filter({}, filter, collection, dataset)) elif k == "datasets": pass elif k == "variantMinLength": @@ -99,7 +99,7 @@ def apply_request_parameters(self, query: Dict[str, List[dict]], qparams: Reques subquery["$and"].append(apply_alphanumeric_filter({}, AlphanumericFilter( id=VARIANTS_PROPERTY_MAP[k], value='min'+v - ), collection)) + ), collection, dataset)) except KeyError: raise web.HTTPNotFound elif k == "variantMaxLength": @@ -107,7 +107,7 @@ def apply_request_parameters(self, query: Dict[str, List[dict]], qparams: Reques subquery["$and"].append(apply_alphanumeric_filter({}, AlphanumericFilter( id=VARIANTS_PROPERTY_MAP[k], value='max'+v - ), collection)) + ), collection, dataset)) except KeyError: raise web.HTTPNotFound elif k == "mateName" or k == 'referenceName': @@ -115,7 +115,7 @@ def apply_request_parameters(self, query: Dict[str, List[dict]], qparams: Reques subqueryor["$or"].append(apply_alphanumeric_filter({}, AlphanumericFilter( id=VARIANTS_PROPERTY_MAP[k], value='max'+v - ), collection)) + ), collection, dataset)) except KeyError: raise web.HTTPNotFound elif k != 'filters': @@ -123,7 +123,7 @@ def apply_request_parameters(self, query: Dict[str, List[dict]], qparams: Reques subquery["$and"].append(apply_alphanumeric_filter({}, AlphanumericFilter( id=VARIANTS_PROPERTY_MAP[k], value=v - ), collection)) + ), collection, dataset)) except KeyError: raise web.HTTPNotFound @@ -155,13 +155,13 @@ def apply_request_parameters(self, query: Dict[str, List[dict]], qparams: Reques v = v.split(',') filters = generate_position_filter_start(self, k, v) for filter in filters: - query["$and"].append(apply_alphanumeric_filter(self, {}, filter, collection)) + query["$and"].append(apply_alphanumeric_filter(self, {}, filter, collection, dataset)) elif k == "end": if isinstance(v, str): v = v.split(',') filters = generate_position_filter_end(self, k, v) for filter in filters: - query["$and"].append(apply_alphanumeric_filter(self, {}, filter, collection)) + query["$and"].append(apply_alphanumeric_filter(self, {}, filter, collection, dataset)) elif k == "datasets": pass elif k == "variantMinLength": @@ -169,7 +169,7 @@ def apply_request_parameters(self, query: Dict[str, List[dict]], qparams: Reques query["$and"].append(apply_alphanumeric_filter(self, {}, AlphanumericFilter( id=VARIANTS_PROPERTY_MAP[k], value='min'+v - ), collection)) + ), collection, dataset)) except KeyError:# pragma: no cover raise web.HTTPNotFound elif k == "variantMaxLength": @@ -177,7 +177,7 @@ def apply_request_parameters(self, query: Dict[str, List[dict]], qparams: Reques query["$and"].append(apply_alphanumeric_filter(self, {}, AlphanumericFilter( id=VARIANTS_PROPERTY_MAP[k], value='max'+v - ), collection)) + ), collection, dataset)) except KeyError:# pragma: no cover raise web.HTTPNotFound elif k == "mateName" or k == 'referenceName': @@ -185,7 +185,7 @@ def apply_request_parameters(self, query: Dict[str, List[dict]], qparams: Reques subqueryor["$or"].append(apply_alphanumeric_filter(self, {}, AlphanumericFilter( id=VARIANTS_PROPERTY_MAP[k], value=v - ), collection)) + ), collection, dataset)) except KeyError:# pragma: no cover raise web.HTTPNotFound elif k != 'filters': @@ -193,7 +193,7 @@ def apply_request_parameters(self, query: Dict[str, List[dict]], qparams: Reques query["$and"].append(apply_alphanumeric_filter(self, {}, AlphanumericFilter( id=VARIANTS_PROPERTY_MAP[k], value=v - ), collection)) + ), collection, dataset)) except KeyError:# pragma: no cover raise web.HTTPNotFound diff --git a/beacon/connections/mongo/runs.py b/beacon/connections/mongo/runs.py index ff754d6..ba9fa9d 100644 --- a/beacon/connections/mongo/runs.py +++ b/beacon/connections/mongo/runs.py @@ -14,9 +14,9 @@ def get_runs(self, entry_id: Optional[str], qparams: RequestParams, dataset: str collection = 'runs' mongo_collection = client.beacon.runs parameters_as_filters=False - query_parameters, parameters_as_filters = apply_request_parameters(self, {}, qparams) + query_parameters, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset) if parameters_as_filters == True: - query, parameters_as_filters = apply_request_parameters(self, {}, qparams)# pragma: no cover + query, parameters_as_filters = apply_request_parameters(self, {}, qparams, dataset)# pragma: no cover query_parameters={}# pragma: no cover else: query={}