Skip to content

Commit

Permalink
fix: properly parsing comma-separated list on REST API (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
holtgrewe committed Sep 13, 2023
1 parent aa14b9b commit 97fdfee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
1 change: 0 additions & 1 deletion cada_prio/predict.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ def run_prediction(
# Map gene IDs to HGNC IDs
genes = []
for orig_gene in orig_genes or []:
print(all_to_hgnc.get(orig_gene))
if orig_gene in all_to_hgnc:
genes.append(all_to_hgnc[orig_gene].hgnc_id)
else:
Expand Down
10 changes: 6 additions & 4 deletions cada_prio/rest_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,14 @@ class PredictionResult(BaseModel):
# Register endpoint for the prediction
@app.get("/predict")
async def handle_predict(
hpo_terms: typing.Annotated[typing.List[str], Query()],
genes: typing.Annotated[typing.Optional[typing.List[str]], Query()] = [],
hpo_terms: typing.Annotated[str, Query()],
genes: typing.Annotated[typing.Optional[str], Query()] = None,
):
hpo_terms_list = hpo_terms.split(",")
genes_list = genes.split(",") if genes else None
_, sorted_scores = predict.run_prediction(
hpo_terms,
genes,
hpo_terms_list,
genes_list,
GLOBAL_STATIC["all_to_hgnc"],
GLOBAL_STATIC["graph"],
GLOBAL_STATIC["model"],
Expand Down

0 comments on commit 97fdfee

Please sign in to comment.