Skip to content

Commit

Permalink
Merge pull request #301 from EGA-archive/develop
Browse files Browse the repository at this point in the history
Cross queries implemented
  • Loading branch information
costero-e authored Mar 26, 2024
2 parents 8e789b9 + 410de6e commit b3cdf0e
Show file tree
Hide file tree
Showing 14 changed files with 570 additions and 447 deletions.
40 changes: 0 additions & 40 deletions Makefile

This file was deleted.

7 changes: 6 additions & 1 deletion beacon/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def main(path=None):
#)

beacon = web.Application(
middlewares=[web.normalize_path_middleware(), middlewares.error_middleware, cors_middleware(origins=["https://beacon-network-test.ega-archive.org", "https://beacon-network-test2.ega-archive.org", "https://beacon-network-demo.ega-archive.org","https://beacon-network-demo2.ega-archive.org", "http://localhost:3000", "http://localhost:3010", "https://beacon-network-cineca-demo.ega-archive.org"])]
middlewares=[web.normalize_path_middleware(), middlewares.error_middleware, cors_middleware(origins=["https://beacon-network-test.ega-archive.org", "https://beacon-network-test2.ega-archive.org", "https://beacon-network-demo.ega-archive.org","https://beacon-network-demo2.ega-archive.org", "http://localhost:3000", "http://localhost:3010", "https://beacon-network-cineca-demo.ega-archive.org", "https://cancer-beacon-demo.ega-archive.org"])]
)


Expand Down Expand Up @@ -107,6 +107,11 @@ def main(path=None):
expose_headers="*",
allow_methods=("POST", "PATCH", "GET", "OPTIONS"),
allow_headers=DEFAULT_ALLOW_HEADERS),
"https://cancer-beacon-demo.ega-archive.org":
aiohttp_cors.ResourceOptions(allow_credentials=True,
expose_headers="*",
allow_methods=("POST", "PATCH", "GET", "OPTIONS"),
allow_headers=DEFAULT_ALLOW_HEADERS),
"http://localhost:3010":
aiohttp_cors.ResourceOptions(allow_credentials=True,
expose_headers="*",
Expand Down
4 changes: 3 additions & 1 deletion beacon/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,6 @@
#
ontologies_folder = "deploy/ontologies/"

#json_buffer_size = 10000
#json_buffer_size = 10000

alphanumeric_terms = ['libraryStrategy', 'molecularAttributes.geneIds']
2 changes: 0 additions & 2 deletions beacon/db/analyses.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def get_analyses(entry_id: Optional[str], qparams: RequestParams, dataset: str):
count, dataset_count, docs = get_docs_by_response_type(include, query, datasets_dict, dataset, limit, skip, mongo_collection, idq)
return schema, count, dataset_count, docs


def get_analysis_with_id(entry_id: Optional[str], qparams: RequestParams, dataset: str):
collection = 'analyses'
idq="biosampleId"
Expand All @@ -75,7 +74,6 @@ def get_analysis_with_id(entry_id: Optional[str], qparams: RequestParams, datase
count, dataset_count, docs = get_docs_by_response_type(include, query, datasets_dict, dataset, limit, skip, mongo_collection, idq)
return schema, count, dataset_count, docs


def get_variants_of_analysis(entry_id: Optional[str], qparams: RequestParams, dataset: str):
collection = 'analyses'
mongo_collection = client.beacon.genomicVariations
Expand Down
28 changes: 6 additions & 22 deletions beacon/db/extract_filtering_terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,22 +273,22 @@ def get_filtering_object(terms_ids: list, collection_name: str):
'label': ontology_label,
# TODO: Use conf.py -> beaconGranularity to not disclouse counts in the filtering terms
#'count': get_ontology_term_count(collection_name, onto),
'scope': [collection_name]
'scope': [collection_name[0:-1]]
})

terms.append({
'type': 'alphanumeric',
'id': field,
# TODO: Use conf.py -> beaconGranularity to not disclouse counts in the filtering terms
#'count': get_ontology_term_count(collection_name, onto),
'scope': [collection_name]
'scope': [collection_name[0:-1]]
})
terms.append({
'type': 'custom',
'id': '{}:{}'.format(field,label),
# TODO: Use conf.py -> beaconGranularity to not disclouse counts in the filtering terms
#'count': get_ontology_term_count(collection_name, onto),
'scope': [collection_name]
'scope': [collection_name[0:-1]]
})
if label == 'Weight':
terms.append({
Expand All @@ -297,7 +297,7 @@ def get_filtering_object(terms_ids: list, collection_name: str):
'label': ontology_label,
# TODO: Use conf.py -> beaconGranularity to not disclouse counts in the filtering terms
#'count': get_ontology_term_count(collection_name, onto),
'scope': [collection_name]
'scope': [collection_name[0:-1]]
})
if label == 'BMI':
terms.append({
Expand All @@ -306,7 +306,7 @@ def get_filtering_object(terms_ids: list, collection_name: str):
'label': ontology_label,
# TODO: Use conf.py -> beaconGranularity to not disclouse counts in the filtering terms
#'count': get_ontology_term_count(collection_name, onto),
'scope': [collection_name]
'scope': [collection_name[0:-1]]
})
if label == 'Height-standing':
terms.append({
Expand All @@ -315,28 +315,12 @@ def get_filtering_object(terms_ids: list, collection_name: str):
'label': ontology_label,
# TODO: Use conf.py -> beaconGranularity to not disclouse counts in the filtering terms
#'count': get_ontology_term_count(collection_name, onto),
'scope': [collection_name]
'scope': [collection_name[0:-1]]
})

print(terms)
except Exception:
pass

#path = "beacon/db/filtering_terms/filtering_terms_{}.txt".format(collection_name)
path = "/beacon/beacon/db/filtering_terms/filtering_terms_{}.txt".format(collection_name)
with open(path, 'w') as f:
for item in list_of_ontologies:
f.write(item+"\n")
f.close()
'''
seen = set()
new_l = []
for d in terms:
t = tuple(sorted(d.items()))
if t not in seen:
seen.add(t)
new_l.append(d)
'''

return terms

Expand Down
Loading

0 comments on commit b3cdf0e

Please sign in to comment.