Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete submission endpoint #137

Merged
merged 5 commits into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@

## [unreleased]
### Added
- Delete submission endpoint, with json example (under demo files)
### Changed
- Updated API submission schema to the latest available on `ncbi/clinvar` GitHub pages
- Modified the json submission example to use one from the ClinVar GitHib repo (`sample_clinical_significance_hgvs_submission.json`)
Expand Down
9 changes: 9 additions & 0 deletions preClinVar/demo/delete_submission_example.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"clinvarDeletion": {
"accessionSet": [
{
"accession": "SCV005395965"
}
]
}
}
33 changes: 32 additions & 1 deletion preClinVar/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@

from preClinVar.__version__ import VERSION
from preClinVar.build import build_header, build_submission
from preClinVar.constants import DRY_RUN_SUBMISSION_URL, SUBMISSION_URL, VALIDATE_SUBMISSION_URL
from preClinVar.constants import (
DRY_RUN_SUBMISSION_URL,
SUBMISSION_URL,
VALIDATE_SUBMISSION_URL,
)
from preClinVar.file_parser import csv_lines, file_fields_to_submission, tsv_lines
from preClinVar.validate import validate_submission

Expand Down Expand Up @@ -233,3 +237,30 @@ async def status(api_key: str = Form(), submission_id: str = Form()) -> JSONResp
status_code=actions_resp.status_code,
content=actions_resp.json(),
)


@app.post("/delete")
async def delete(api_key: str = Form(), clinvar_accession: str = Form()):
"""A proxy to the dry run submission ClinVar API endpoint"""
# Create a submission header
header = build_header(api_key)

# Create a submission deletion object
delete_obj = {"clinvarDeletion": {"accessionSet": [{"accession": clinvar_accession}]}}

data = {
"actions": [
{
"type": "AddData",
"targetDb": "clinvar",
"data": {"content": delete_obj},
}
]
}
# And send a POST request to the API
resp = requests.post(SUBMISSION_URL, data=json.dumps(data), headers=header)

return JSONResponse(
status_code=resp.status_code,
content=resp.json(),
)
Loading