Skip to content

Commit

Permalink
1.6.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mbaudis committed Mar 7, 2024
1 parent 7b40720 commit d15d810
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 80 deletions.
6 changes: 4 additions & 2 deletions bycon/definitions/argument_definitions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ include_resultset_responses:
type: string
cmdFlags:
- --includeResultsetResponses
description: requested schema, e.g. biosample
description: >-
* include resultset responses, e.g. HIT, MISS
* kind of a holdover from Beacon pre-v1
# query / data selection

Expand Down Expand Up @@ -120,7 +122,7 @@ assembly_id:
cmdFlags:
- --assemblyId
description: assembly id
default: GRCh38
# default: GRCh38

reference_name:
type: string
Expand Down
7 changes: 0 additions & 7 deletions bycon/definitions/beacon_defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ entity_defaults:
beacon_schema:
entity_type: configuration
schema: https://progenetix.org/services/schemas/beaconInfoResults/
h->o_access_key: Null
content: {}

################################################################################
Expand All @@ -85,7 +84,6 @@ entity_defaults:
beacon_schema:
entity_type: map
schema: https://progenetix.org/services/schemas/beaconMapSchema/
h->o_access_key: Null

################################################################################

Expand All @@ -98,7 +96,6 @@ entity_defaults:
beacon_schema:
entity_type: configuration
schema: https://progenetix.org/services/schemas/beaconConfigurationSchema/
h->o_access_key: Null

################################################################################

Expand All @@ -111,7 +108,6 @@ entity_defaults:
beacon_schema:
entity_type: entryType
schema: https://progenetix.org/services/schemas/entryTypesSchema/
h->o_access_key: Null

################################################################################

Expand All @@ -124,7 +120,6 @@ entity_defaults:
beacon_schema:
entity_type: filteringTerm
schema: https://progenetix.org/services/schemas/filteringTermsSchema/
h->o_access_key: Null

################################################################################

Expand Down Expand Up @@ -206,7 +201,6 @@ entity_defaults:
pagination:
skip: 0
limit: 10
include_resultset_responses: false

##############################################################################

Expand All @@ -222,5 +216,4 @@ entity_defaults:
pagination:
skip: 0
limit: 10
include_resultset_responses: false

34 changes: 30 additions & 4 deletions bycon/lib/beacon_response_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,16 @@ def collectionsResponse(self):
return

colls, queries = ByconCollections(self.byc).populatedCollections()
colls = self.__collections_response_remap_cohorts(colls)
self.data_response["response"].update({"collections": colls})
self.record_queries.update({"entities": queries})
self.__collections_response_update_summaries()
self.__meta_add_received_request_summary_parameters()
self.__meta_add_parameters()
self.__meta_clean_parameters()
self.__response_clean_parameters()
self.__check_switch_to_error_response()
# self.__response_clean_parameters()
self.data_response.get("meta", {}).get("received_request_summary", {}).pop("include_resultset_responses", None)
return self.data_response


Expand Down Expand Up @@ -224,6 +226,31 @@ def __resultSetResponse_force_autorized_granularities(self):
self.data_response.pop("response", None)


# -------------------------------------------------------------------------#

def __collections_response_remap_cohorts(self, colls=[]):
if not "cohort" in self.byc.get("response_entity_id", "___none___"):
return colls
pop_keys = ["_id", "child_terms", "code_matches", "count", "dataset_id", "db_key", "namespace_prefix", "ft_type", "collation_type", "hierarchy_paths", "parent_terms", "scope"]
for c in colls:
c_k = f'{c.get("scope", "")}.{c.get("db_key", "")}'
c.update({
"id": c.get("id", "___none___"),
"cohort_type": "beacon-defined",
"cohort_size": c.get("count"),
"name": c.get("label", ""),
# "inclusion_criteria": {
# "description": c.get("description", "NA"),
# c_k: c.get("id"),
# "dataset_id": c.get("dataset_id")
# }
})
for k in pop_keys:
c.pop(k, None)

return colls


# -------------------------------------------------------------------------#

def __response_clean_parameters(self):
Expand All @@ -235,9 +262,8 @@ def __response_clean_parameters(self):

def __meta_clean_parameters(self):
r_m = self.data_response.get("meta", {})

if "beaconCollectionsResponse" in self.response_schema:
r_m.get("received_request_summary", {}).pop("include_resultset_responses", None)
# TBD?!



# -------------------------------------------------------------------------#
Expand Down
4 changes: 3 additions & 1 deletion bycon/lib/bycon_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ def set_debug_state(debug=False) -> bool:
def refactor_value_from_defined_type(parameter, values, definition):
p_d_t = definition.get("type", "string")
values = list(x for x in values if x is not None)
values = list(x for x in values if x != "None")
values = list(x for x in values if x.lower() not in ["none", "null"])
if len(values) == 0:
return None
if "array" in p_d_t:
p_i_t = definition.get("items", "string")
if "int" in p_i_t:
Expand Down
3 changes: 2 additions & 1 deletion bycon/lib/cgi_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ def parse_GET(byc):
# CAVE: Only predefined parameters are accepted!
if p_d in a_defs:
values = form_return_listvalue(form_data, p)
BYC_PARS.update({p_d: refactor_value_from_defined_type(p, values, a_defs[p_d])})
if (v := refactor_value_from_defined_type(p, values, a_defs[p_d])):
BYC_PARS.update({p_d: v})
else:
w_m = '!!! Unmatched parameter {p_d}: {form_data.getvalue(p)}'
BYC["WARNINGS"].append(w_m)
Expand Down
4 changes: 2 additions & 2 deletions bycon/lib/variant_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ def vrsVariant(self, variant):
# TODO: since the vrs_variant has been created as a new object we now
# add the annotation fields back (should empties be omitted?)
for v_s in ("biosample_id", "callset_id", "id", "variant_internal_id"):
vrs_v.update({v_s: self.byc_variant.get(v_s)})
if (v_v := self.byc_variant.get(v_s)):
vrs_v.update({v_s: v_v})
vrs_v.update({"variant_alternative_ids": self.byc_variant.get("variant_alternative_ids", [])})
for v_o in ("identifiers", "info", "molecular_attributes", "variant_level_data"):
vrs_v.update({v_o: self.byc_variant.get(v_o, {})})
Expand Down Expand Up @@ -222,7 +223,6 @@ def __vrs_cnv(self):
def __create_canonical_variant(self):
v = self.byc_variant
v.update({"errors": []})

self.__byc_variant_normalize_type()
self.__byc_variant_normalize_chromosome()
self.__byc_variant_normalize_positions()
Expand Down
24 changes: 2 additions & 22 deletions bycon/schemas/models/json/progenetix-model/cohorts/endpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -274,17 +274,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconBooleanResponse.json"
},
{
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCountResponse.json"
},
{
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconResultsetsResponse.json"
}
]
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCollectionsResponse.json"
}
}
}
Expand All @@ -294,17 +284,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconBooleanResponse.json"
},
{
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCountResponse.json"
},
{
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCollectionsResponse.json"
}
]
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCollectionsResponse.json"
}
}
}
Expand Down
24 changes: 2 additions & 22 deletions bycon/schemas/models/json/progenetix-model/datasets/endpoints.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,17 +397,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconBooleanResponse.json"
},
{
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCountResponse.json"
},
{
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconResultsetsResponse.json"
}
]
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCollectionsResponse.json"
}
}
}
Expand All @@ -417,17 +407,7 @@
"content": {
"application/json": {
"schema": {
"oneOf": [
{
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconBooleanResponse.json"
},
{
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCountResponse.json"
},
{
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCollectionsResponse.json"
}
]
"$ref": "https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCollectionsResponse.json"
}
}
}
Expand Down
10 changes: 2 additions & 8 deletions bycon/schemas/models/src/progenetix-model/cohorts/endpoints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,13 @@ components:
content:
application/json:
schema:
oneOf:
- $ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconBooleanResponse.json
- $ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCountResponse.json
- $ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconResultsetsResponse.json
$ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCollectionsResponse.json
CollectionsResponse:
description: Successful collection list operation.
content:
application/json:
schema:
oneOf:
- $ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconBooleanResponse.json
- $ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCountResponse.json
- $ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCollectionsResponse.json
$ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCollectionsResponse.json
parameters:
requestedSchema:
name: requestedSchema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,19 +244,13 @@ components:
content:
application/json:
schema:
oneOf:
- $ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconBooleanResponse.json
- $ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCountResponse.json
- $ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconResultsetsResponse.json
$ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCollectionsResponse.json
CollectionsResponse:
description: Successful collection list operation.
content:
application/json:
schema:
oneOf:
- $ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconBooleanResponse.json
- $ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCountResponse.json
- $ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCollectionsResponse.json
$ref: https://raw.githubusercontent.com/ga4gh-beacon/beacon-v2/main/framework/json/responses/beaconCollectionsResponse.json
parameters:
requestedSchema:
name: requestedSchema
Expand Down
12 changes: 12 additions & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ through the Perl based [**PGX** project](http://github.com/progenetix/PGX/).

## Changes Tracker

### 2024-03-07 (v1.6.2)

* adding a `__collections_response_remap_cohorts(self, colls=[])` function
to reformat the collections response for cohorts from the collations format
- TODO: define cohorts as separate entities which are read in during collations
generation, with their additional parameters etc.
* fixed the openAPI endpoints for collation responses (datasets & cohorts); are
[incorrect in current Beacon spec.](https://github.com/ga4gh-beacon/beacon-v2/issues/116)
* bug fix `byconaut`: matrix export was broken since 1.6.1
* exception capture for wrong form values: string values of "None", "none", "Null",
"null" from GET requests are now converted to logical `None` (i.e. removed)

### 2024-03-06 (v1.6.1)

* bug fix: individuals & phenopackets endpoints were broken in 1.6.0 due to missed
Expand Down
1 change: 0 additions & 1 deletion local/beacon_defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ entity_defaults:
beacon_schema:
entity_type: configuration
schema: https://progenetix.org/services/schemas/beaconInfoResults/
h->o_access_key: Null
# TODO: move `content` to `local` file.
content:
beacon_id: org.progenetix
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

setup(
name="bycon",
version="1.6.0",
version="1.6.2",
description="A Python-based environment for the Beacon v2 genomics API",
long_description=long_description,
long_description_content_type="text/markdown",
Expand Down
2 changes: 1 addition & 1 deletion updev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ BY=(./dist/*tar.gz)
pip3 install $BY
# pipreqs --force .
# python3 -m build --wheel && twine upload dist/*
# git tag v1.6.0 & git push --tags
# git tag v1.6.2 & git push --tags
./install.py
../byconaut/install.py

0 comments on commit d15d810

Please sign in to comment.