Skip to content

Commit ca5263d

Browse files
authored
Merge pull request #260 from EGA-archive/develop
schema compliant
2 parents 28cfd30 + e45ec29 commit ca5263d

19 files changed

+5717
-974034
lines changed

beacon/db/analyses.py

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,6 @@
1313
def include_resultset_responses(query: Dict[str, List[dict]], qparams: RequestParams):
1414
LOG.debug("Include Resultset Responses = {}".format(qparams.query.include_resultset_responses))
1515
include = qparams.query.include_resultset_responses
16-
if include == 'HIT':
17-
query = query
18-
elif include == 'ALL':
19-
query = {}
20-
elif include == 'NONE':
21-
query = {'$text': {'$search': '########'}}
22-
else:
23-
query = query
2416
return query
2517

2618
def apply_request_parameters(query: Dict[str, List[dict]], qparams: RequestParams):
@@ -50,7 +42,7 @@ def get_analyses(entry_id: Optional[str], qparams: RequestParams):
5042
client.beacon.analyses,
5143
query,
5244
qparams.query.pagination.skip,
53-
count
45+
0
5446
)
5547
negative_query={}
5648
ids_array = []
@@ -60,20 +52,28 @@ def get_analyses(entry_id: Optional[str], qparams: RequestParams):
6052
ids_array.append(elem_query)
6153

6254
negative_query['$nor']=ids_array
63-
LOG.debug(negative_query)
55+
#LOG.debug(negative_query)
6456
docs = get_documents(
6557
client.beacon.analyses,
6658
negative_query,
6759
qparams.query.pagination.skip,
68-
qparams.query.pagination.limit
60+
0
6961
)
62+
LOG.debug(docs)
7063
count = get_count(client.beacon.analyses, negative_query)
64+
elif include == 'NONE':
65+
docs = get_documents(
66+
client.beacon.analyses,
67+
query,
68+
qparams.query.pagination.skip,
69+
qparams.query.pagination.limit
70+
)
7171
else:
7272
docs = get_documents(
7373
client.beacon.analyses,
7474
query,
7575
qparams.query.pagination.skip,
76-
qparams.query.pagination.limit
76+
0
7777
)
7878
return schema, count, docs
7979

@@ -92,7 +92,7 @@ def get_analysis_with_id(entry_id: Optional[str], qparams: RequestParams):
9292
client.beacon.analyses,
9393
query,
9494
qparams.query.pagination.skip,
95-
count
95+
0
9696
)
9797
negative_query={}
9898
ids_array = []
@@ -102,20 +102,28 @@ def get_analysis_with_id(entry_id: Optional[str], qparams: RequestParams):
102102
ids_array.append(elem_query)
103103

104104
negative_query['$nor']=ids_array
105-
LOG.debug(negative_query)
105+
#LOG.debug(negative_query)
106106
docs = get_documents(
107107
client.beacon.analyses,
108108
negative_query,
109109
qparams.query.pagination.skip,
110-
qparams.query.pagination.limit
110+
0
111111
)
112+
LOG.debug(docs)
112113
count = get_count(client.beacon.analyses, negative_query)
114+
elif include == 'NONE':
115+
docs = get_documents(
116+
client.beacon.analyses,
117+
query,
118+
qparams.query.pagination.skip,
119+
qparams.query.pagination.limit
120+
)
113121
else:
114122
docs = get_documents(
115123
client.beacon.analyses,
116124
query,
117125
qparams.query.pagination.skip,
118-
qparams.query.pagination.limit
126+
0
119127
)
120128
return schema, count, docs
121129

@@ -139,7 +147,7 @@ def get_variants_of_analysis(entry_id: Optional[str], qparams: RequestParams):
139147
client.beacon.genomicVariations,
140148
query,
141149
qparams.query.pagination.skip,
142-
count
150+
0
143151
)
144152
negative_query={}
145153
ids_array = []
@@ -149,20 +157,28 @@ def get_variants_of_analysis(entry_id: Optional[str], qparams: RequestParams):
149157
ids_array.append(elem_query)
150158

151159
negative_query['$nor']=ids_array
152-
LOG.debug(negative_query)
160+
#LOG.debug(negative_query)
153161
docs = get_documents(
154162
client.beacon.genomicVariations,
155163
negative_query,
156164
qparams.query.pagination.skip,
157-
qparams.query.pagination.limit
165+
0
158166
)
167+
LOG.debug(docs)
159168
count = get_count(client.beacon.genomicVariations, negative_query)
169+
elif include == 'NONE':
170+
docs = get_documents(
171+
client.beacon.genomicVariations,
172+
query,
173+
qparams.query.pagination.skip,
174+
qparams.query.pagination.limit
175+
)
160176
else:
161177
docs = get_documents(
162178
client.beacon.genomicVariations,
163179
query,
164180
qparams.query.pagination.skip,
165-
qparams.query.pagination.limit
181+
0
166182
)
167183
return schema, count, docs
168184

@@ -176,7 +192,7 @@ def get_filtering_terms_of_analyse(entry_id: Optional[str], qparams: RequestPara
176192
query,
177193
remove_id,
178194
qparams.query.pagination.skip,
179-
qparams.query.pagination.limit
195+
0
180196
)
181197
return schema, count, docs
182198

beacon/db/biosamples.py

Lines changed: 61 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@
1313

1414
def include_resultset_responses(query: Dict[str, List[dict]], qparams: RequestParams):
1515
LOG.debug("Include Resultset Responses = {}".format(qparams.query.include_resultset_responses))
16-
include = qparams.query.include_resultset_responses
17-
if include == 'HIT':
18-
query = query
19-
elif include == 'ALL':
20-
query = {}
21-
elif include == 'NONE':
22-
query = {'$text': {'$search': '########'}}
23-
else:
24-
query = query
2516
return query
2617

2718
def apply_request_parameters(query: Dict[str, List[dict]], qparams: RequestParams):
@@ -52,7 +43,7 @@ def get_biosamples(entry_id: Optional[str], qparams: RequestParams):
5243
client.beacon.biosamples,
5344
query,
5445
qparams.query.pagination.skip,
55-
count
46+
0
5647
)
5748
negative_query={}
5849
ids_array = []
@@ -62,20 +53,28 @@ def get_biosamples(entry_id: Optional[str], qparams: RequestParams):
6253
ids_array.append(elem_query)
6354

6455
negative_query['$nor']=ids_array
65-
LOG.debug(negative_query)
56+
#LOG.debug(negative_query)
6657
docs = get_documents(
6758
client.beacon.biosamples,
6859
negative_query,
6960
qparams.query.pagination.skip,
70-
qparams.query.pagination.limit
61+
0
7162
)
63+
LOG.debug(docs)
7264
count = get_count(client.beacon.biosamples, negative_query)
65+
elif include == 'NONE':
66+
docs = get_documents(
67+
client.beacon.biosamples,
68+
query,
69+
qparams.query.pagination.skip,
70+
qparams.query.pagination.limit
71+
)
7372
else:
7473
docs = get_documents(
7574
client.beacon.biosamples,
7675
query,
7776
qparams.query.pagination.skip,
78-
qparams.query.pagination.limit
77+
0
7978
)
8079
return schema, count, docs
8180

@@ -94,7 +93,7 @@ def get_biosample_with_id(entry_id: Optional[str], qparams: RequestParams):
9493
client.beacon.biosamples,
9594
query,
9695
qparams.query.pagination.skip,
97-
count
96+
0
9897
)
9998
negative_query={}
10099
ids_array = []
@@ -104,20 +103,28 @@ def get_biosample_with_id(entry_id: Optional[str], qparams: RequestParams):
104103
ids_array.append(elem_query)
105104

106105
negative_query['$nor']=ids_array
107-
LOG.debug(negative_query)
106+
#LOG.debug(negative_query)
108107
docs = get_documents(
109108
client.beacon.biosamples,
110109
negative_query,
111110
qparams.query.pagination.skip,
112-
qparams.query.pagination.limit
111+
0
113112
)
113+
LOG.debug(docs)
114114
count = get_count(client.beacon.biosamples, negative_query)
115+
elif include == 'NONE':
116+
docs = get_documents(
117+
client.beacon.biosamples,
118+
query,
119+
qparams.query.pagination.skip,
120+
qparams.query.pagination.limit
121+
)
115122
else:
116123
docs = get_documents(
117124
client.beacon.biosamples,
118125
query,
119126
qparams.query.pagination.skip,
120-
qparams.query.pagination.limit
127+
0
121128
)
122129
return schema, count, docs
123130

@@ -142,7 +149,7 @@ def get_variants_of_biosample(entry_id: Optional[str], qparams: RequestParams):
142149
client.beacon.genomicVariations,
143150
query,
144151
qparams.query.pagination.skip,
145-
count
152+
0
146153
)
147154
negative_query={}
148155
ids_array = []
@@ -152,20 +159,28 @@ def get_variants_of_biosample(entry_id: Optional[str], qparams: RequestParams):
152159
ids_array.append(elem_query)
153160

154161
negative_query['$nor']=ids_array
155-
LOG.debug(negative_query)
162+
#LOG.debug(negative_query)
156163
docs = get_documents(
157164
client.beacon.genomicVariations,
158165
negative_query,
159166
qparams.query.pagination.skip,
160-
qparams.query.pagination.limit
167+
0
161168
)
169+
LOG.debug(docs)
162170
count = get_count(client.beacon.genomicVariations, negative_query)
171+
elif include == 'NONE':
172+
docs = get_documents(
173+
client.beacon.genomicVariations,
174+
query,
175+
qparams.query.pagination.skip,
176+
qparams.query.pagination.limit
177+
)
163178
else:
164179
docs = get_documents(
165180
client.beacon.genomicVariations,
166181
query,
167182
qparams.query.pagination.skip,
168-
qparams.query.pagination.limit
183+
0
169184
)
170185
return schema, count, docs
171186

@@ -184,7 +199,7 @@ def get_analyses_of_biosample(entry_id: Optional[str], qparams: RequestParams):
184199
client.beacon.analyses,
185200
query,
186201
qparams.query.pagination.skip,
187-
count
202+
0
188203
)
189204
negative_query={}
190205
ids_array = []
@@ -194,20 +209,28 @@ def get_analyses_of_biosample(entry_id: Optional[str], qparams: RequestParams):
194209
ids_array.append(elem_query)
195210

196211
negative_query['$nor']=ids_array
197-
LOG.debug(negative_query)
212+
#LOG.debug(negative_query)
198213
docs = get_documents(
199214
client.beacon.analyses,
200215
negative_query,
201216
qparams.query.pagination.skip,
202-
qparams.query.pagination.limit
217+
0
203218
)
219+
LOG.debug(docs)
204220
count = get_count(client.beacon.analyses, negative_query)
221+
elif include == 'NONE':
222+
docs = get_documents(
223+
client.beacon.analyses,
224+
query,
225+
qparams.query.pagination.skip,
226+
qparams.query.pagination.limit
227+
)
205228
else:
206229
docs = get_documents(
207230
client.beacon.analyses,
208231
query,
209232
qparams.query.pagination.skip,
210-
qparams.query.pagination.limit
233+
0
211234
)
212235
return schema, count, docs
213236

@@ -225,7 +248,7 @@ def get_runs_of_biosample(entry_id: Optional[str], qparams: RequestParams):
225248
client.beacon.runs,
226249
query,
227250
qparams.query.pagination.skip,
228-
count
251+
0
229252
)
230253
negative_query={}
231254
ids_array = []
@@ -235,20 +258,28 @@ def get_runs_of_biosample(entry_id: Optional[str], qparams: RequestParams):
235258
ids_array.append(elem_query)
236259

237260
negative_query['$nor']=ids_array
238-
LOG.debug(negative_query)
261+
#LOG.debug(negative_query)
239262
docs = get_documents(
240263
client.beacon.runs,
241264
negative_query,
242265
qparams.query.pagination.skip,
243-
qparams.query.pagination.limit
266+
0
244267
)
268+
LOG.debug(docs)
245269
count = get_count(client.beacon.runs, negative_query)
270+
elif include == 'NONE':
271+
docs = get_documents(
272+
client.beacon.runs,
273+
query,
274+
qparams.query.pagination.skip,
275+
qparams.query.pagination.limit
276+
)
246277
else:
247278
docs = get_documents(
248279
client.beacon.runs,
249280
query,
250281
qparams.query.pagination.skip,
251-
qparams.query.pagination.limit
282+
0
252283
)
253284
return schema, count, docs
254285

@@ -262,6 +293,6 @@ def get_filtering_terms_of_biosample(entry_id: Optional[str], qparams: RequestPa
262293
query,
263294
remove_id,
264295
qparams.query.pagination.skip,
265-
qparams.query.pagination.limit
296+
0
266297
)
267298
return schema, count, docs

0 commit comments

Comments
 (0)