diff --git a/bycon/beaconServer/tests/GET-examples.md b/bycon/beaconServer/tests/GET-examples.md index 6335397e3..ce9c9e77f 100644 --- a/bycon/beaconServer/tests/GET-examples.md +++ b/bycon/beaconServer/tests/GET-examples.md @@ -2,17 +2,17 @@ http://progenetix.test/beacon/biosamples/?datasetIds=progenetix&referenceName=refseq:NC_000009.12&variantType=EFO:0030067&start=21500000&start=21975098&end=21967753&end=22500000&filters=NCIT:C3058 -http://progenetix.org/beacon/genomicVariations/?referenceName=NC_000017.11&start=7577120&referenceBases=G&alternateBases=A&debug=1 +http://progenetix.org/beacon/genomicVariations/?referenceName=NC_000017.11&start=7577120&referenceBases=G&alternateBases=A -https://progenetix.org/beacon/g_variants/?filters=NCIT:C7712&output=pgxseg&debug=1 +https://progenetix.org/beacon/g_variants/?filters=NCIT:C7712&output=pgxseg -https://progenetix.org/beacon/analyses/?referenceName=17&variantType=DEL&start=5000000&start=7676592&end=7669607&end=10000000&filters=&output=pgxmatrix&debug=1 +https://progenetix.org/beacon/analyses/?referenceName=17&variantType=DEL&start=5000000&start=7676592&end=7669607&end=10000000&filters=&output=pgxmatrix -https://progenetix.org/beacon/analyses?referenceName=17&variantType=DEL&start=5000000&start=7676592&end=7669607&end=10000000&filters=cellosaurus&output=pgxmatrix&debug=1 +https://progenetix.org/beacon/analyses?referenceName=17&variantType=DEL&start=5000000&start=7676592&end=7669607&end=10000000&filters=cellosaurus&output=pgxmatrix -http://progenetix.org/beacon/biosamples?filters=NCIT:C3697&output=table&debug=1 +http://progenetix.org/beacon/biosamples?filters=NCIT:C3697&output=table -http://progenetix.org/beacon/biosamples?referenceName=9&start=10000000,12000000&end=12500000,15000000&variantType=DEL&filters=pgx:icdom-81703&debug=1 +http://progenetix.org/beacon/biosamples?referenceName=9&start=10000000,12000000&end=12500000,15000000&variantType=DEL&filters=pgx:icdom-81703 http://progenetix.org/beacon/biosamples/onekgbs-HG00142/g_variants diff --git a/bycon/definitions/datatable_mappings.yaml b/bycon/definitions/datatable_mappings.yaml index c0bef3377..23f3f70a2 100644 --- a/bycon/definitions/datatable_mappings.yaml +++ b/bycon/definitions/datatable_mappings.yaml @@ -517,7 +517,7 @@ definitions: variant_state_id: type: string db_key: variant_state.id - indexed: True + indexed: True # might not beneeded if first in a compound index compact: True variant_state_label: type: string diff --git a/bycon/lib/bycon_helpers.py b/bycon/lib/bycon_helpers.py index e27f8ca71..68ecac8e9 100644 --- a/bycon/lib/bycon_helpers.py +++ b/bycon/lib/bycon_helpers.py @@ -12,8 +12,7 @@ def set_debug_state(debug=False) -> bool: """ Function to provide a text response header for debugging purposes, i.e. to print out the error or test parameters to a browser session. - The common way would be to add either a `/debug=1/` part to a REST path or - to provide a `...&debug=1` query parameter. + The common way would be to add either a `?debugMode=true` query parameter. """ if BYC["DEBUG_MODE"] is True: return True diff --git a/bycon/lib/cgi_parsing.py b/bycon/lib/cgi_parsing.py index 4ddce8710..b38e05c32 100644 --- a/bycon/lib/cgi_parsing.py +++ b/bycon/lib/cgi_parsing.py @@ -110,12 +110,10 @@ def rest_path_elements(byc): | | | | required required optional optional """ - - r_p_r = byc.get("request_path_root", "beacon") - if not environ.get('REQUEST_URI'): return + r_p_r = byc.get("request_path_root", "beacon") url_comps = urlparse(environ.get('REQUEST_URI')) url_p = url_comps.path p_items = re.split('/', url_p) @@ -123,10 +121,6 @@ def rest_path_elements(byc): if not r_p_r in p_items: return - for d_k in ["&debug=1", "debug=1", "debug=true"]: - if d_k in p_items: - p_items.remove(d_k) - p_items = list(filter(None, p_items)) r_i = p_items.index(r_p_r) diff --git a/bycon/lib/query_generation.py b/bycon/lib/query_generation.py index bd32356d1..13eec382f 100644 --- a/bycon/lib/query_generation.py +++ b/bycon/lib/query_generation.py @@ -254,22 +254,18 @@ def __query_from_variant_pars(self): def __create_geneVariantRequest_query(self): # query database for gene and use coordinates to create range query vp = self.varguments - gene_data = GeneInfo().returnGene(vp["gene_id"]) - # TODO: error report/warning if not gene_data: return - gene = gene_data[0] # Since this is a pre-processor to the range request self.varguments.update( { - "reference_name": "refseq:{}".format(gene["accession_version"]), - "start": [ gene["start"] ], - "end": [ gene["end"] ] + "reference_name": f'refseq:{gene.get("accession_version", "___none___")}', + "start": [ gene.get("start", 0) ], + "end": [ gene.get("end", 1) ] } ) - self.variant_request_type = "variantRangeRequest" @@ -279,7 +275,6 @@ def __create_aminoacidChangeRequest_query(self): vp = self.varguments if not "aminoacid_change" in vp: return - v_p_defs = self.argument_definitions v_q = { v_p_defs["aminoacid_change"]["db_key"]: vp.get("aminoacid_change", "___none___")} @@ -304,7 +299,6 @@ def __create_variantTypeRequest_query(self): vp = self.varguments if not "variant_type" in vp: return - v_q = self.__create_in_query_for_parameter("variant_type", v_p_defs["variant_type"]["db_key"], vp) return v_q diff --git a/bycon/lib/response_remapping.py b/bycon/lib/response_remapping.py index e36564d3a..f14684e40 100644 --- a/bycon/lib/response_remapping.py +++ b/bycon/lib/response_remapping.py @@ -162,6 +162,7 @@ def remap_biosamples(r_s_res, byc): e_r = [] for r_k, r_v in bs_r.get("references", {}).items(): e_r.append(__reference_object_from_ontology_term(r_k, r_v, byc)) + r_s_res[bs_i].update({ "sample_origin_type": {"id": "OBI:0001479", "label": "specimen from organism"}, "external_references": e_r @@ -186,9 +187,8 @@ def remap_biosamples(r_s_res, byc): def __reference_object_from_ontology_term(filter_type, ontology_term, byc): if "label" in ontology_term: - ontology_term.update({"description": ontology_term.get("label")}) + ontology_term.update({"description": ontology_term.get("label", "")}) ontology_term.pop("label", None) - f_t_d = byc["filter_definitions"].get(filter_type, {}) r_d = f_t_d.get("reference") if not r_d: @@ -196,7 +196,6 @@ def __reference_object_from_ontology_term(filter_type, ontology_term, byc): r_r = r_d.get("replace", []) if len(r_r) == 2: o_id = ontology_term.get("id", "___none___").replace(r_r[0], r_r[1]) - ontology_term.update({"reference": f'{r_d.get("root")}{o_id}'}) return ontology_term @@ -290,10 +289,13 @@ def phenopack_individual(ind, data_db, byc): ################################################################################ def clean_empty_fields(this_object): + protected = ["external_references"] if not isinstance(this_object, dict): return this_object for k in list(this_object.keys()): + if k in protected: + continue if isinstance(this_object[k], dict): if not this_object[k]: this_object.pop(k, None) diff --git a/docs/changes.md b/docs/changes.md index 399d2425b..e9c466043 100644 --- a/docs/changes.md +++ b/docs/changes.md @@ -13,6 +13,11 @@ through the Perl based [**PGX** project](http://github.com/progenetix/PGX/). ## Changes Tracker +### 2024-02-21 (v.1.5.1) + +* hot fix: added "protected" status for `external_references` in general empty + field clean-up since the object is required by the front-end (even if empty list) + ### 2024-02-20 (v.1.5.0) * refactoring global configs into `bycon/config.py` to slowly get rid of some of