Skip to content

Commit

Permalink
Merge pull request #260 from EGA-archive/develop
Browse files Browse the repository at this point in the history
schema compliant
  • Loading branch information
costero-e authored Dec 22, 2023
2 parents 28cfd30 + e45ec29 commit ca5263d
Show file tree
Hide file tree
Showing 19 changed files with 5,717 additions and 974,034 deletions.
58 changes: 37 additions & 21 deletions beacon/db/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
def include_resultset_responses(query: Dict[str, List[dict]], qparams: RequestParams):
LOG.debug("Include Resultset Responses = {}".format(qparams.query.include_resultset_responses))
include = qparams.query.include_resultset_responses
if include == 'HIT':
query = query
elif include == 'ALL':
query = {}
elif include == 'NONE':
query = {'$text': {'$search': '########'}}
else:
query = query
return query

def apply_request_parameters(query: Dict[str, List[dict]], qparams: RequestParams):
Expand Down Expand Up @@ -50,7 +42,7 @@ def get_analyses(entry_id: Optional[str], qparams: RequestParams):
client.beacon.analyses,
query,
qparams.query.pagination.skip,
count
0
)
negative_query={}
ids_array = []
Expand All @@ -60,20 +52,28 @@ def get_analyses(entry_id: Optional[str], qparams: RequestParams):
ids_array.append(elem_query)

negative_query['$nor']=ids_array
LOG.debug(negative_query)
#LOG.debug(negative_query)
docs = get_documents(
client.beacon.analyses,
negative_query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
LOG.debug(docs)
count = get_count(client.beacon.analyses, negative_query)
elif include == 'NONE':
docs = get_documents(
client.beacon.analyses,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
)
else:
docs = get_documents(
client.beacon.analyses,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
return schema, count, docs

Expand All @@ -92,7 +92,7 @@ def get_analysis_with_id(entry_id: Optional[str], qparams: RequestParams):
client.beacon.analyses,
query,
qparams.query.pagination.skip,
count
0
)
negative_query={}
ids_array = []
Expand All @@ -102,20 +102,28 @@ def get_analysis_with_id(entry_id: Optional[str], qparams: RequestParams):
ids_array.append(elem_query)

negative_query['$nor']=ids_array
LOG.debug(negative_query)
#LOG.debug(negative_query)
docs = get_documents(
client.beacon.analyses,
negative_query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
LOG.debug(docs)
count = get_count(client.beacon.analyses, negative_query)
elif include == 'NONE':
docs = get_documents(
client.beacon.analyses,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
)
else:
docs = get_documents(
client.beacon.analyses,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
return schema, count, docs

Expand All @@ -139,7 +147,7 @@ def get_variants_of_analysis(entry_id: Optional[str], qparams: RequestParams):
client.beacon.genomicVariations,
query,
qparams.query.pagination.skip,
count
0
)
negative_query={}
ids_array = []
Expand All @@ -149,20 +157,28 @@ def get_variants_of_analysis(entry_id: Optional[str], qparams: RequestParams):
ids_array.append(elem_query)

negative_query['$nor']=ids_array
LOG.debug(negative_query)
#LOG.debug(negative_query)
docs = get_documents(
client.beacon.genomicVariations,
negative_query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
LOG.debug(docs)
count = get_count(client.beacon.genomicVariations, negative_query)
elif include == 'NONE':
docs = get_documents(
client.beacon.genomicVariations,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
)
else:
docs = get_documents(
client.beacon.genomicVariations,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
return schema, count, docs

Expand All @@ -176,7 +192,7 @@ def get_filtering_terms_of_analyse(entry_id: Optional[str], qparams: RequestPara
query,
remove_id,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
return schema, count, docs

91 changes: 61 additions & 30 deletions beacon/db/biosamples.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@

def include_resultset_responses(query: Dict[str, List[dict]], qparams: RequestParams):
LOG.debug("Include Resultset Responses = {}".format(qparams.query.include_resultset_responses))
include = qparams.query.include_resultset_responses
if include == 'HIT':
query = query
elif include == 'ALL':
query = {}
elif include == 'NONE':
query = {'$text': {'$search': '########'}}
else:
query = query
return query

def apply_request_parameters(query: Dict[str, List[dict]], qparams: RequestParams):
Expand Down Expand Up @@ -52,7 +43,7 @@ def get_biosamples(entry_id: Optional[str], qparams: RequestParams):
client.beacon.biosamples,
query,
qparams.query.pagination.skip,
count
0
)
negative_query={}
ids_array = []
Expand All @@ -62,20 +53,28 @@ def get_biosamples(entry_id: Optional[str], qparams: RequestParams):
ids_array.append(elem_query)

negative_query['$nor']=ids_array
LOG.debug(negative_query)
#LOG.debug(negative_query)
docs = get_documents(
client.beacon.biosamples,
negative_query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
LOG.debug(docs)
count = get_count(client.beacon.biosamples, negative_query)
elif include == 'NONE':
docs = get_documents(
client.beacon.biosamples,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
)
else:
docs = get_documents(
client.beacon.biosamples,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
return schema, count, docs

Expand All @@ -94,7 +93,7 @@ def get_biosample_with_id(entry_id: Optional[str], qparams: RequestParams):
client.beacon.biosamples,
query,
qparams.query.pagination.skip,
count
0
)
negative_query={}
ids_array = []
Expand All @@ -104,20 +103,28 @@ def get_biosample_with_id(entry_id: Optional[str], qparams: RequestParams):
ids_array.append(elem_query)

negative_query['$nor']=ids_array
LOG.debug(negative_query)
#LOG.debug(negative_query)
docs = get_documents(
client.beacon.biosamples,
negative_query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
LOG.debug(docs)
count = get_count(client.beacon.biosamples, negative_query)
elif include == 'NONE':
docs = get_documents(
client.beacon.biosamples,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
)
else:
docs = get_documents(
client.beacon.biosamples,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
return schema, count, docs

Expand All @@ -142,7 +149,7 @@ def get_variants_of_biosample(entry_id: Optional[str], qparams: RequestParams):
client.beacon.genomicVariations,
query,
qparams.query.pagination.skip,
count
0
)
negative_query={}
ids_array = []
Expand All @@ -152,20 +159,28 @@ def get_variants_of_biosample(entry_id: Optional[str], qparams: RequestParams):
ids_array.append(elem_query)

negative_query['$nor']=ids_array
LOG.debug(negative_query)
#LOG.debug(negative_query)
docs = get_documents(
client.beacon.genomicVariations,
negative_query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
LOG.debug(docs)
count = get_count(client.beacon.genomicVariations, negative_query)
elif include == 'NONE':
docs = get_documents(
client.beacon.genomicVariations,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
)
else:
docs = get_documents(
client.beacon.genomicVariations,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
return schema, count, docs

Expand All @@ -184,7 +199,7 @@ def get_analyses_of_biosample(entry_id: Optional[str], qparams: RequestParams):
client.beacon.analyses,
query,
qparams.query.pagination.skip,
count
0
)
negative_query={}
ids_array = []
Expand All @@ -194,20 +209,28 @@ def get_analyses_of_biosample(entry_id: Optional[str], qparams: RequestParams):
ids_array.append(elem_query)

negative_query['$nor']=ids_array
LOG.debug(negative_query)
#LOG.debug(negative_query)
docs = get_documents(
client.beacon.analyses,
negative_query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
LOG.debug(docs)
count = get_count(client.beacon.analyses, negative_query)
elif include == 'NONE':
docs = get_documents(
client.beacon.analyses,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
)
else:
docs = get_documents(
client.beacon.analyses,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
return schema, count, docs

Expand All @@ -225,7 +248,7 @@ def get_runs_of_biosample(entry_id: Optional[str], qparams: RequestParams):
client.beacon.runs,
query,
qparams.query.pagination.skip,
count
0
)
negative_query={}
ids_array = []
Expand All @@ -235,20 +258,28 @@ def get_runs_of_biosample(entry_id: Optional[str], qparams: RequestParams):
ids_array.append(elem_query)

negative_query['$nor']=ids_array
LOG.debug(negative_query)
#LOG.debug(negative_query)
docs = get_documents(
client.beacon.runs,
negative_query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
LOG.debug(docs)
count = get_count(client.beacon.runs, negative_query)
elif include == 'NONE':
docs = get_documents(
client.beacon.runs,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
)
else:
docs = get_documents(
client.beacon.runs,
query,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
return schema, count, docs

Expand All @@ -262,6 +293,6 @@ def get_filtering_terms_of_biosample(entry_id: Optional[str], qparams: RequestPa
query,
remove_id,
qparams.query.pagination.skip,
qparams.query.pagination.limit
0
)
return schema, count, docs
Loading

0 comments on commit ca5263d

Please sign in to comment.