Skip to content

Commit

Permalink
creating testMode and expanding unit testing
Browse files Browse the repository at this point in the history
  • Loading branch information
costero-e committed Jan 21, 2025
1 parent 23f1619 commit 796a7df
Show file tree
Hide file tree
Showing 17 changed files with 6,767 additions and 54 deletions.
1 change: 1 addition & 0 deletions beacon/conf/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
documentation_url = 'https://b2ri-documentation-demo.ega-archive.org/'
alphanumeric_terms = ['libraryStrategy', 'molecularAttributes.geneIds', 'diseases.ageOfOnset.iso8601duration', 'molecularAttributes.aminoacidChanges','phenotypicFeatures.onset.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
Expand Down
69 changes: 51 additions & 18 deletions beacon/connections/mongo/cohorts.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ def get_individuals_of_cohort(self, entry_id: Optional[str], qparams: RequestPar
dataset_count=0
limit = qparams.query.pagination.limit
include = qparams.query.include_resultset_responses
query = apply_filters(self, {}, qparams.query.filters, collection, {}, dataset)
query = query_id(self, query, entry_id)
count = get_count(self, client.beacon.cohorts, query)
dataset_found = client.beacon.cohorts \
.find({"id": entry_id}, {"datasetId": 1, "_id": 0})
dataset_found=list(dataset_found)
dict_in={}
dict_in['datasetId']=dataset
dataset_found=dataset_found[0]["datasetId"]
if dataset == dataset_found:
dict_in['datasetId']=dataset_found
else:
schema = DefaultSchemas.INDIVIDUALS# pragma: no cover
return schema, 0, 0, None, dataset# pragma: no cover
query = apply_filters(self, dict_in, qparams.query.filters, collection, {}, dataset)
count = get_count(self, client.beacon.cohorts, query)

schema = DefaultSchemas.INDIVIDUALS
skip = qparams.query.pagination.skip
Expand All @@ -75,12 +81,18 @@ def get_analyses_of_cohort(self, entry_id: Optional[str], qparams: RequestParams
dataset_count=0
limit = qparams.query.pagination.limit
include = qparams.query.include_resultset_responses
query = apply_filters(self, {}, qparams.query.filters, collection, {}, dataset)
query = query_id(self, query, entry_id)
count = get_count(self, client.beacon.cohorts, query)
dataset_found = client.beacon.cohorts \
.find({"id": entry_id}, {"datasetId": 1, "_id": 0})
dataset_found=list(dataset_found)
dict_in={}
dict_in['datasetId']=dataset
dataset_found=dataset_found[0]["datasetId"]
if dataset == dataset_found:
dict_in['datasetId']=dataset_found
else:
schema = DefaultSchemas.ANALYSES# pragma: no cover
return schema, 0, 0, None, dataset# pragma: no cover
query = apply_filters(self, dict_in, qparams.query.filters, collection, {}, dataset)
count = get_count(self, client.beacon.cohorts, query)
schema = DefaultSchemas.ANALYSES
skip = qparams.query.pagination.skip
if limit > 100 or limit == 0:
Expand All @@ -96,8 +108,17 @@ def get_variants_of_cohort(self,entry_id: Optional[str], qparams: RequestParams,
dataset_count=0
limit = qparams.query.pagination.limit
include = qparams.query.include_resultset_responses
query = apply_filters(self, {}, qparams.query.filters, collection, {}, dataset)
query = query_id(self, query, entry_id)
dataset_found = client.beacon.cohorts \
.find({"id": entry_id}, {"datasetId": 1, "_id": 0})
dataset_found=list(dataset_found)
dict_in={}
dataset_found=dataset_found[0]["datasetId"]
if dataset == dataset_found:
dict_in['datasetId']=dataset_found
else:
schema = DefaultSchemas.GENOMICVARIATIONS# pragma: no cover
return schema, 0, 0, None, dataset# pragma: no cover
query = apply_filters(self, dict_in, qparams.query.filters, collection, {}, dataset)
count = get_count(self, client.beacon.cohorts, query)
query_count={}
query_count["$or"]=[]
Expand Down Expand Up @@ -133,12 +154,18 @@ def get_runs_of_cohort(self, entry_id: Optional[str], qparams: RequestParams, da
dataset_count=0
limit = qparams.query.pagination.limit
include = qparams.query.include_resultset_responses
query = apply_filters(self, {}, qparams.query.filters, collection, {}, dataset)
query = query_id(self, query, entry_id)
count = get_count(self, client.beacon.cohorts, query)
dataset_found = client.beacon.cohorts \
.find({"id": entry_id}, {"datasetId": 1, "_id": 0})
dataset_found=list(dataset_found)
dict_in={}
dict_in['datasetId']=dataset
dataset_found=dataset_found[0]["datasetId"]
if dataset == dataset_found:
dict_in['datasetId']=dataset_found
else:
schema = DefaultSchemas.RUNS# pragma: no cover
return schema, 0, 0, None, dataset# pragma: no cover
query = apply_filters(self, dict_in, qparams.query.filters, collection, {}, dataset)
count = get_count(self, client.beacon.cohorts, query)
schema = DefaultSchemas.RUNS
skip = qparams.query.pagination.skip
if limit > 100 or limit == 0:
Expand All @@ -154,12 +181,18 @@ def get_biosamples_of_cohort(self, entry_id: Optional[str], qparams: RequestPara
dataset_count=0
limit = qparams.query.pagination.limit
include = qparams.query.include_resultset_responses
query = apply_filters(self, {}, qparams.query.filters, collection, {}, dataset)
query = query_id(self, query, entry_id)
count = get_count(self, client.beacon.cohorts, query)
dataset_found = client.beacon.cohorts \
.find({"id": entry_id}, {"datasetId": 1, "_id": 0})
dataset_found=list(dataset_found)
dict_in={}
dict_in['datasetId']=dataset
dataset_found=dataset_found[0]["datasetId"]
if dataset == dataset_found:
dict_in['datasetId']=dataset_found
else:
schema = DefaultSchemas.BIOSAMPLES# pragma: no cover
return schema, 0, 0, None, dataset# pragma: no cover
query = apply_filters(self, dict_in, qparams.query.filters, collection, {}, dataset)
count = get_count(self, client.beacon.cohorts, query)
schema = DefaultSchemas.BIOSAMPLES
skip = qparams.query.pagination.skip
if limit > 100 or limit == 0:
Expand Down
17 changes: 17 additions & 0 deletions beacon/connections/mongo/data/test/analyses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
[
{
"aligner": "bwa-0.7.8",
"analysisDate": "2021-10-17",
"biosampleId": "SAMPLE1",
"id": "EGA-testing",
"individualId": "SAMPLE1",
"info": {
"info": "Bothmetadataandgenomicvariationsinformationaresynthetic."
},
"pipelineName": "Pipeline-panel-0001-v1",
"pipelineRef": "https://doi.org/10.48511/workflowhub.workflow.111.1",
"runId": "EGAR5000XXX",
"variantCaller": "GATK4.0",
"datasetId": "synthetic_usecases_4beacon_testingV3"
}
]
Loading

0 comments on commit 796a7df

Please sign in to comment.