diff --git a/beacon/conf/conf.py b/beacon/conf/conf.py index 7c36af8..7b44659 100644 --- a/beacon/conf/conf.py +++ b/beacon/conf/conf.py @@ -26,11 +26,10 @@ max_beacon_granularity = "record" # boolean, count or record security_levels = ['PUBLIC', 'REGISTERED', 'CONTROLLED'] documentation_url = 'https://b2ri-documentation-demo.ega-archive.org/' -alphanumeric_terms = ['libraryStrategy', 'molecularAttributes.geneIds', 'diseases.ageOfOnset.iso8601duration', 'molecularAttributes.aminoacidChanges','phenotypicFeatures.onset.iso8601duration'] +alphanumeric_terms = ['libraryStrategy', 'molecularAttributes.geneIds', 'diseases.ageOfOnset.iso8601duration', 'molecularAttributes.aminoacidChanges','phenotypicFeatures.onset.iso8601duration', 'exposures.ageAtExposure.iso8601duration', 'treatments.ageAtOnset.iso8601duration'] cors_urls = ["http://localhost:3000","https://cancer-beacon-demo.ega-archive.org", "https://beacon-network-demo2.ega-archive.org", "https://beacon.ega-archive.org"] test_datasetId="synthetic_usecases_4beacon_testingV3" - # Service Info ga4gh_service_type_group = 'org.ga4gh' ga4gh_service_type_artifact = 'beacon' diff --git a/beacon/connections/mongo/data/test/individuals.json b/beacon/connections/mongo/data/test/individuals.json index 1928359..86da5d3 100644 --- a/beacon/connections/mongo/data/test/individuals.json +++ b/beacon/connections/mongo/data/test/individuals.json @@ -68,8 +68,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -79,7 +79,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -172,8 +172,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -271,8 +271,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -282,7 +282,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -375,8 +375,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -474,8 +474,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -485,7 +485,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -578,8 +578,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -677,8 +677,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -688,7 +688,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -781,8 +781,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -880,8 +880,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -891,7 +891,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -984,8 +984,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -1083,8 +1083,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -1094,7 +1094,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -1187,8 +1187,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -1286,8 +1286,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -1297,7 +1297,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -1390,8 +1390,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -1489,8 +1489,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -1500,7 +1500,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -1593,8 +1593,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -1692,8 +1692,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -1703,7 +1703,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -1796,8 +1796,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -1895,8 +1895,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -1906,7 +1906,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -1999,8 +1999,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -2098,8 +2098,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -2109,7 +2109,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -2202,8 +2202,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -2301,8 +2301,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -2312,7 +2312,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -2405,8 +2405,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -2504,8 +2504,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -2515,7 +2515,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -2608,8 +2608,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -2707,8 +2707,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -2718,7 +2718,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -2811,8 +2811,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -2910,8 +2910,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -2921,7 +2921,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -3014,8 +3014,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -3113,8 +3113,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -3124,7 +3124,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -3217,8 +3217,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -3316,8 +3316,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -3327,7 +3327,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -3420,8 +3420,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -3519,8 +3519,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -3530,7 +3530,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -3623,8 +3623,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -3722,8 +3722,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -3733,7 +3733,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -3826,8 +3826,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", @@ -3925,8 +3925,8 @@ "measurementValue": [ { "referenceRange": { - "high": "50", - "low": "20", + "high": 50, + "low": 20, "unit": { "id": "NCIT:C28253", "label": "Milligram" @@ -3936,7 +3936,7 @@ "id": "NCIT:C28253", "label": "Milligram" }, - "value": "50" + "value": 50 } ], "notes": "Bear in mind that all this information is synthetic", @@ -4029,8 +4029,8 @@ "label": "Infantile onset" }, "resolution": { - "days": "8", - "weeks": "8" + "days": 8, + "weeks": 8 }, "severity": { "id": "HP:0012828", diff --git a/beacon/connections/mongo/filters.py b/beacon/connections/mongo/filters.py index 0ef64c7..a2d32e1 100644 --- a/beacon/connections/mongo/filters.py +++ b/beacon/connections/mongo/filters.py @@ -31,20 +31,6 @@ def cross_query(self, query: dict, scope: str, collection: str, request_paramete mongo_collection=client.beacon.individuals original_id="id" join_ids=list(join_query(self, mongo_collection, query, original_id)) - ''' - final_id="individualId" - for id_item in join_ids: - new_id={} - new_id[final_id] = id_item.pop(original_id) - def_list.append(new_id) - - query={} - query['$or']=def_list - mongo_collection=client.beacon.biosamples - original_id="id" - join_ids2=list(join_query(self, mongo_collection, query, original_id)) - LOG.debug(join_ids2) - ''' targets = client.beacon.targets \ .find({"datasetId": dataset}, {"biosampleIds": 1, "_id": 0}) bioids=targets[0]["biosampleIds"] @@ -52,18 +38,18 @@ def cross_query(self, query: dict, scope: str, collection: str, request_paramete for id_item in join_ids: new_id={} biosampleId=id_item.pop(original_id) - position=bioids.index(biosampleId) + try: + position=bioids.index(biosampleId) + except Exception: + continue positions_list.append(position) query_cl={} query_cl["$or"]=[] for position in positions_list: position=str(position) - position1="^"+position+"," - position2=","+position+"," - position3=","+position+"$" - query_cl["$or"].append({"biosampleIds": {"$regex": position1}}) - query_cl["$or"].append({"biosampleIds": {"$regex": position2}}) - query_cl["$or"].append({"biosampleIds": {"$regex": position3}}) + query_cl["$or"].append({ position: "10", "datasetId": dataset}) + query_cl["$or"].append({ position: "11", "datasetId": dataset}) + query_cl["$or"].append({ position: "01", "datasetId": dataset}) string_of_ids = client.beacon.caseLevelData \ .find(query_cl, {"id": 1, "_id": 0}) HGVSIds=list(string_of_ids) @@ -811,8 +797,9 @@ def apply_alphanumeric_filter(self, query: dict, filter: AlphanumericFilter, col dict_regex['$regex']='^NC_0000'+'24' else: dict_regex['$regex']='^NC_0000'+filter.value+'.'+'10:g'+'|'+'^NC_0000'+filter.value+'.'+'11:g'+'|'+'^NC_0000'+filter.value+'.'+'9:g' - elif '>' in filter.value:# pragma: no cover - dict_regex=filter.value + elif '>' in filter.value:# pragma: no cover + newvalue=filter.value.replace(">",">") + dict_regex=newvalue elif '.' in filter.value:# pragma: no cover valuesplitted = filter.value.split('.') dict_regex['$regex']=valuesplitted[0]+".*"+valuesplitted[-1]+":" diff --git a/beacon/tests/__main__.py b/beacon/tests/__main__.py index 8d4f1eb..9688d73 100644 --- a/beacon/tests/__main__.py +++ b/beacon/tests/__main__.py @@ -655,13 +655,63 @@ async def test_check_g_variants_endpoint_NONE_resultSetResponse_is_working(): assert resp.status == 200 loop.run_until_complete(test_check_g_variants_endpoint_NONE_resultSetResponse_is_working()) loop.run_until_complete(client.close()) - def test_main_check_g_variants_endpoint_with_parameters_is_working(self): + def test_main_check_g_variants_sequence_query(self): with loop_context() as loop: app = create_app() client = TestClient(TestServer(app), loop=loop) loop.run_until_complete(client.start_server()) async def test_check_g_variants_endpoint_with_parameters_is_working(): - resp = await client.get("/api/g_variants?start=16050074&end=16050075&alternateBases=A&referenceBases=G&referenceName=22") + resp = await client.get("/api/g_variants?start=43045703&referenceName=17&assemblyId=GRCh38&referenceBases=G&alternateBases=A") + assert resp.status == 200 + loop.run_until_complete(test_check_g_variants_endpoint_with_parameters_is_working()) + loop.run_until_complete(client.close()) + def test_main_check_g_variants_range_query(self): + with loop_context() as loop: + app = create_app() + client = TestClient(TestServer(app), loop=loop) + loop.run_until_complete(client.start_server()) + async def test_check_g_variants_endpoint_with_parameters_is_working(): + resp = await client.get("/api/g_variants?start=345675&referenceName=2&assemblyId=GRCh38&end=345681") + assert resp.status == 200 + loop.run_until_complete(test_check_g_variants_endpoint_with_parameters_is_working()) + loop.run_until_complete(client.close()) + def test_main_check_g_variants_geneId_query(self): + with loop_context() as loop: + app = create_app() + client = TestClient(TestServer(app), loop=loop) + loop.run_until_complete(client.start_server()) + async def test_check_g_variants_endpoint_with_parameters_is_working(): + resp = await client.get("/api/g_variants?geneId=BRCA1") + assert resp.status == 200 + loop.run_until_complete(test_check_g_variants_endpoint_with_parameters_is_working()) + loop.run_until_complete(client.close()) + def test_main_check_g_variants_bracket_query(self): + with loop_context() as loop: + app = create_app() + client = TestClient(TestServer(app), loop=loop) + loop.run_until_complete(client.start_server()) + async def test_check_g_variants_endpoint_with_parameters_is_working(): + resp = await client.get("/api/g_variants?start=43045703,43045704&end=43045704,43045705&referenceName=17&assemblyId=GRCh38") + assert resp.status == 200 + loop.run_until_complete(test_check_g_variants_endpoint_with_parameters_is_working()) + loop.run_until_complete(client.close()) + def test_main_check_g_variants_genomic_allele_query(self): + with loop_context() as loop: + app = create_app() + client = TestClient(TestServer(app), loop=loop) + loop.run_until_complete(client.start_server()) + async def test_check_g_variants_endpoint_with_parameters_is_working(): + resp = await client.get("/api/g_variants?genomicAlleleShortForm=NC_000017.11:g.43045703G>A") + assert resp.status == 200 + loop.run_until_complete(test_check_g_variants_endpoint_with_parameters_is_working()) + loop.run_until_complete(client.close()) + def test_main_check_g_variants_aminoacidChange_query(self): + with loop_context() as loop: + app = create_app() + client = TestClient(TestServer(app), loop=loop) + loop.run_until_complete(client.start_server()) + async def test_check_g_variants_endpoint_with_parameters_is_working(): + resp = await client.get("/api/g_variants?aminoacidChange=Pro1856Ser&geneId=BRCA1") assert resp.status == 200 loop.run_until_complete(test_check_g_variants_endpoint_with_parameters_is_working()) loop.run_until_complete(client.close()) @@ -676,13 +726,13 @@ async def test_check_post_cross_query_g_variants_individuals_is_working(): }, "query": { "requestParameters": { }, "filters": [ - {"id":"NCIT:C42331", "scope":"individual"}], + {"id":"NCIT:C16576", "scope":"individual"}], "includeResultsetResponses": "HIT", "pagination": { "skip": 0, "limit": 10 }, - "testMode": False, + "testMode": True, "requestedGranularity": "record" } }) @@ -700,13 +750,13 @@ async def test_check_post_cross_query_biosamples_individuals_is_working(): }, "query": { "requestParameters": { }, "filters": [ - {"id":"NCIT:C42331", "scope":"individual"}], + {"id":"NCIT:C16576", "scope":"individual"}], "includeResultsetResponses": "HIT", "pagination": { "skip": 0, "limit": 10 }, - "testMode": False, + "testMode": True, "requestedGranularity": "record" } }) @@ -740,7 +790,7 @@ def test_main_check_datasets_g_variants_endpoint_is_working(self): client = TestClient(TestServer(app), loop=loop) loop.run_until_complete(client.start_server()) async def test_check_datasets_g_variants_endpoint_is_working(): - resp = await client.get("/api/g_variants?datasets=CINECA_synthetic_cohort_EUROPE_UK1") + resp = await client.get("/api/g_variants?datasets=synthetic_usecases_4beacon_testingV3") assert resp.status == 200 loop.run_until_complete(test_check_datasets_g_variants_endpoint_is_working()) loop.run_until_complete(client.close()) @@ -751,7 +801,7 @@ def test_main_check_cross_query_is_working(self): loop.run_until_complete(client.start_server()) async def test_check_cross_query_is_working(): MagicClass = MagicMock(_id='hohoho') - resp = cross_query(MagicClass, {'$or': [{'ethnicity.id': 'NCIT:C42331'}]}, 'individual', 'biosamples', {}, 'CINECA_synthetic_cohort_EUROPE_UK1') + resp = cross_query(MagicClass, {'$or': [{'ethnicity.id': 'NCIT:C43851'}]}, 'individual', 'biosamples', {}, 'synthetic_usecases_4beacon_testingV3') assert resp != {} loop.run_until_complete(test_check_cross_query_is_working()) loop.run_until_complete(client.close()) @@ -762,7 +812,7 @@ def test_main_check_cross_query_3_is_working(self): loop.run_until_complete(client.start_server()) async def test_check_cross_query_3_is_working(): MagicClass = MagicMock(_id='hohoho') - resp = cross_query(MagicClass, {'$or': [{'ethnicity.id': 'NCIT:C42331'}]}, 'individual', 'g_variants', {}, 'CINECA_synthetic_cohort_EUROPE_UK1') + resp = cross_query(MagicClass, {'$or': [{'ethnicity.id': 'NCIT:C43851'}]}, 'individual', 'g_variants', {}, 'synthetic_usecases_4beacon_testingV3') assert resp != {} loop.run_until_complete(test_check_cross_query_3_is_working()) loop.run_until_complete(client.close()) @@ -773,7 +823,7 @@ def test_main_check_cross_query_7_is_working(self): loop.run_until_complete(client.start_server()) async def test_check_cross_query_7_is_working(): MagicClass = MagicMock(_id='hohoho') - resp = cross_query(MagicClass, {'$or': [{'platformModel.id': 'OBI:0002048'}]}, 'run', 'individuals', {}, 'CINECA_synthetic_cohort_EUROPE_UK1') + resp = cross_query(MagicClass, {'$or': [{'platformModel.id': 'OBI:0002048'}]}, 'run', 'individuals', {}, 'synthetic_usecases_4beacon_testingV3') assert resp != {} loop.run_until_complete(test_check_cross_query_7_is_working()) loop.run_until_complete(client.close()) @@ -784,7 +834,7 @@ def test_main_check_cross_query_8_is_working(self): loop.run_until_complete(client.start_server()) async def test_check_cross_query_8_is_working(): MagicClass = MagicMock(_id='hohoho') - resp = cross_query(MagicClass, {'$or': [{'platformModel.id': 'OBI:0002048'}]}, 'run', 'biosamples', {}, 'CINECA_synthetic_cohort_EUROPE_UK1') + resp = cross_query(MagicClass, {'$or': [{'platformModel.id': 'OBI:0002048'}]}, 'run', 'biosamples', {}, 'synthetic_usecases_4beacon_testingV3') assert resp != {} loop.run_until_complete(test_check_cross_query_8_is_working()) loop.run_until_complete(client.close()) @@ -795,7 +845,7 @@ def test_main_check_cross_query_9_is_working(self): loop.run_until_complete(client.start_server()) async def test_check_cross_query_9_is_working(): MagicClass = MagicMock(_id='hohoho') - resp = cross_query(MagicClass, {'$or': [{'platformModel.id': 'OBI:0002048'}]}, 'run', 'g_variants', {}, 'CINECA_synthetic_cohort_EUROPE_UK1') + resp = cross_query(MagicClass, {'$or': [{'platformModel.id': 'OBI:0002048'}]}, 'run', 'g_variants', {}, 'synthetic_usecases_4beacon_testingV3') assert resp != {} loop.run_until_complete(test_check_cross_query_9_is_working()) loop.run_until_complete(client.close()) @@ -813,19 +863,18 @@ async def test_check_alphanumeric_equal_query_is_working(): "filters": [ {"id": "ethnicity", "operator": "=", - "value": "British", + "value": "European", "scope":"individual"}], "includeResultsetResponses": "HIT", "pagination": { "skip": 0, "limit": 10 }, - "testMode": False, + "testMode": True, "requestedGranularity": "record" } } ) - assert resp.status == 200 loop.run_until_complete(test_check_alphanumeric_equal_query_is_working()) loop.run_until_complete(client.close()) @@ -843,14 +892,14 @@ async def test_check_alphanumeric_like_query_is_working(): "filters": [ {"id": "ethnicity", "operator": "=", - "value": "%itish%", + "value": "%pean%", "scope":"individual"}], "includeResultsetResponses": "HIT", "pagination": { "skip": 0, "limit": 10 }, - "testMode": False, + "testMode": True, "requestedGranularity": "record" } } @@ -873,19 +922,18 @@ async def test_check_alphanumeric_not_like_query_is_working(): "filters": [ {"id": "ethnicity", "operator": "!", - "value": "%itish%", + "value": "%uropean%", "scope":"individual"}], "includeResultsetResponses": "HIT", "pagination": { "skip": 0, "limit": 10 }, - "testMode": False, + "testMode": True, "requestedGranularity": "record" } } ) - assert resp.status == 200 loop.run_until_complete(test_check_alphanumeric_not_like_query_is_working()) loop.run_until_complete(client.close()) @@ -903,19 +951,18 @@ async def test_check_alphanumeric_not_query_is_working(): "filters": [ {"id": "ethnicity", "operator": "!", - "value": "British", + "value": "European", "scope":"individual"}], "includeResultsetResponses": "HIT", "pagination": { "skip": 0, "limit": 10 }, - "testMode": False, + "testMode": True, "requestedGranularity": "record" } } ) - assert resp.status == 200 loop.run_until_complete(test_check_alphanumeric_not_query_is_working()) loop.run_until_complete(client.close()) @@ -931,16 +978,16 @@ async def test_check_iso8601duration_gt_query_is_working(): }, "query": { "requestParameters": { }, "filters": [ - {"id": "diseases.ageOfOnset.iso8601duration", + {"id": "exposures.ageAtExposure.iso8601duration", "operator": ">", - "value": "45", + "value": "31", "scope":"individual"}], "includeResultsetResponses": "HIT", "pagination": { "skip": 0, "limit": 10 }, - "testMode": False, + "testMode": True, "requestedGranularity": "record" } } @@ -961,16 +1008,16 @@ async def test_check_iso8601duration_ls_query_is_working(): }, "query": { "requestParameters": { }, "filters": [ - {"id": "diseases.ageOfOnset.iso8601duration", + {"id": "exposures.ageAtExposure.iso8601duration", "operator": "<", - "value": "45", + "value": "33", "scope":"individual"}], "includeResultsetResponses": "HIT", "pagination": { "skip": 0, "limit": 10 }, - "testMode": False, + "testMode": True, "requestedGranularity": "record" } } @@ -992,9 +1039,9 @@ async def test_check_measurement_value_query_is_working(): "query": { "requestParameters": { }, "filters": [ { - "id": "Weight", + "id": "anatomical entity", "operator": ">", - "value": "75" + "value": "44" }, ], "includeResultsetResponses": "HIT", @@ -1002,7 +1049,7 @@ async def test_check_measurement_value_query_is_working(): "skip": 0, "limit": 10 }, - "testMode": False, + "testMode": True, "requestedGranularity": "record" } } @@ -1024,7 +1071,7 @@ async def test_check_custom_query_is_working(): "query": { "requestParameters": { }, "filters": [ { - "id": "sampleOriginType:blood" + "id": "sampleOriginType:ovary" } , ], @@ -1033,7 +1080,7 @@ async def test_check_custom_query_is_working(): "skip": 0, "limit": 10 }, - "testMode": False, + "testMode": True, "requestedGranularity": "record" } } @@ -1048,7 +1095,7 @@ def test_main_check_range_query_with_variant_min_and_max_lengths_is_working(self client = TestClient(TestServer(app), loop=loop) loop.run_until_complete(client.start_server()) async def test_check_range_query_with_variant_min_and_max_lengths_working(): - resp = await client.get("/api/g_variants?start=16050074&end=16050075&variantMinLength=0&variantMaxLength=3&referenceName=22") + resp = await client.get("/api/g_variants?start=345675&referenceName=2&assemblyId=GRCh38&end=345681&variantMinLength=0&variantMaxLength=10&testMode=true") assert resp.status == 200 loop.run_until_complete(test_check_range_query_with_variant_min_and_max_lengths_working()) loop.run_until_complete(client.close()) @@ -1058,7 +1105,7 @@ def test_main_check_filters_as_request_parameter_working(self): client = TestClient(TestServer(app), loop=loop) loop.run_until_complete(client.start_server()) async def test_check_filters_as_request_parameter_working(): - resp = await client.get("/api/individuals?filters=NCIT:C42331") + resp = await client.get("/api/individuals?filters=NCIT:C16576&testMode=true") assert resp.status == 200 loop.run_until_complete(test_check_filters_as_request_parameter_working()) loop.run_until_complete(client.close()) @@ -1073,7 +1120,7 @@ async def test_check_datasets_list_query_is_working(): "apiVersion": "2.0" }, "query": { "requestParameters": { - "datasets": ["CINECA_synthetic_cohort_EUROPE_UK1", "Hola"] + "datasets": ["synthetic_usecases_4beacon_testingV3"] }, "filters": [ ], "includeResultsetResponses": "HIT", @@ -1081,7 +1128,7 @@ async def test_check_datasets_list_query_is_working(): "skip": 0, "limit": 101 }, - "testMode": False, + "testMode": True, "requestedGranularity": "record" } } @@ -1133,15 +1180,15 @@ async def test_check_NONE_count_query_is_working(): "query": { "requestParameters": { }, "filters": [ {"id": "ethnicity", - "operator": "!", - "value": "%itish%", + "operator": "=", + "value": "European", "scope":"individual"}], "includeResultsetResponses": "NONE", "pagination": { "skip": 0, "limit": 10 }, - "testMode": False, + "testMode": True, "requestedGranularity": "count" } }