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

Check if score set has variants before mapping, return error if not #25

Merged
merged 2 commits into from
Nov 21, 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
8 changes: 8 additions & 0 deletions src/api/routers/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ async def map_scoreset(urn: str) -> ScoresetMapping:
msg = f"Unable to acquire resource from MaveDB: {e}"
raise HTTPException(status_code=500, detail=msg) from e

if not records:
return JSONResponse(
content=ScoresetMapping(
metadata=metadata,
error_message="Score set contains no variants to map",
).model_dump(exclude_none=True)
)

try:
alignment_result = align(metadata, True)
except BlatNotFoundError as e:
Expand Down
14 changes: 14 additions & 0 deletions src/dcd_mapping/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,20 @@ async def map_scoreset_urn(
_logger.critical(msg)
click.echo(f"Error: {msg}")
raise e

if not records:
_emit_info("Score set contains no variants to map", silent, logging.ERROR)
final_output = write_scoreset_mapping_to_json(
urn,
ScoresetMapping(
metadata=metadata,
error_message="Score set contains no variants to map",
),
output_path,
)
_emit_info(f"Score set mapping output saved to: {final_output}.", silent)
return

await map_scoreset(
metadata, records, output_path, vrs_version, prefer_genomic, silent
)
Loading