3939
4040@router .post (path = "/map/{urn}" , status_code = 200 , response_model = ScoresetMapping )
4141@with_mavedb_score_set
42- async def map_scoreset (urn : str , store_path : Path | None = None ) -> ScoresetMapping :
42+ async def map_scoreset (urn : str , store_path : Path | None = None ) -> JSONResponse :
4343 """Perform end-to-end mapping for a scoreset.
4444
4545 :param urn: identifier for a scoreset.
@@ -49,9 +49,11 @@ async def map_scoreset(urn: str, store_path: Path | None = None) -> ScoresetMapp
4949 metadata = get_scoreset_metadata (urn , store_path )
5050 records = get_scoreset_records (metadata , True , store_path )
5151 except ScoresetNotSupportedError as e :
52- return ScoresetMapping (
53- metadata = None ,
54- error_message = str (e ).strip ("'" ),
52+ return JSONResponse (
53+ content = ScoresetMapping (
54+ metadata = None ,
55+ error_message = str (e ).strip ("'" ),
56+ ).model_dump (exclude_none = True )
5557 )
5658 except ResourceAcquisitionError as e :
5759 msg = f"Unable to acquire resource from MaveDB: { e } "
@@ -116,11 +118,14 @@ async def map_scoreset(urn: str, store_path: Path | None = None) -> ScoresetMapp
116118 metadata = metadata , error_message = str (e ).strip ("'" )
117119 ).model_dump (exclude_none = True )
118120 )
119- # TODO this should instead check if all values in dict are none. or might not need this at all.
120- if vrs_results is None or len (vrs_results ) == 0 :
121- return ScoresetMapping (
122- metadata = metadata ,
123- error_message = "No variant mappings available for this score set" ,
121+ if not vrs_results or all (
122+ mapping_result is None for mapping_result in vrs_results .values ()
123+ ):
124+ return JSONResponse (
125+ content = ScoresetMapping (
126+ metadata = metadata ,
127+ error_message = "No variant mappings available for this score set" ,
128+ ).model_dump (exclude_none = True )
124129 )
125130
126131 annotated_vrs_results = {}
@@ -139,11 +144,14 @@ async def map_scoreset(urn: str, store_path: Path | None = None) -> ScoresetMapp
139144 metadata = metadata , error_message = str (e ).strip ("'" )
140145 ).model_dump (exclude_none = True )
141146 )
142- # TODO this should instead check if all values in dict are none. or might not need this at all.
143- if annotated_vrs_results is None or len (annotated_vrs_results ) == 0 :
144- return ScoresetMapping (
145- metadata = metadata ,
146- error_message = "No annotated variant mappings available for this score set" ,
147+ if not annotated_vrs_results or all (
148+ mapping_result is None for mapping_result in annotated_vrs_results .values ()
149+ ):
150+ return JSONResponse (
151+ content = ScoresetMapping (
152+ metadata = metadata ,
153+ error_message = "No annotated variant mappings available for this score set" ,
154+ ).model_dump (exclude_none = True )
147155 )
148156
149157 try :
0 commit comments