Skip to content

Commit be12487

Browse files
just raise a 'NotImplementedError' for 'build_vlm_response_from_caf_data' for now instead of trying to guess how things will be formatted
1 parent f354a34 commit be12487

File tree

3 files changed

+7
-45
lines changed

3 files changed

+7
-45
lines changed

src/anyvlm/functions/build_vlm_response.py

Lines changed: 4 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,54 +3,16 @@
33
from ga4gh.va_spec.base.core import CohortAlleleFrequencyStudyResult
44

55
from anyvlm.schemas.vlm import (
6-
HandoverType,
7-
ResponseField,
8-
ResponseSummary,
9-
ResultSet,
106
VlmResponse,
117
)
12-
from anyvlm.utils.types import Zygosity
138

149

15-
def _get_caf_zygosity() -> Zygosity:
16-
"""Extracts a zygosity from a CohortAlleleFrequencyStudyResult.
17-
#TODO: We will need to implement this function during or after Issue #16 based on how we choose to
18-
store CAF data/implement the CAF data pull.
19-
20-
:param caf_study_result: The CohortAlleleFrequencyStudyResult whose zygosity we wish to determine.
21-
:return: The `Zygosity` of the study result.
22-
"""
23-
raise NotImplementedError
24-
25-
26-
def build_vlm_response(caf_data: list[CohortAlleleFrequencyStudyResult]) -> VlmResponse:
10+
def build_vlm_response_from_caf_data(
11+
caf_data: list[CohortAlleleFrequencyStudyResult],
12+
) -> VlmResponse:
2713
"""Craft a VlmResponse object from a list of CohortAlleleFrequencyStudyResults.
2814
2915
:param caf_data: A list of `CohortAlleleFrequencyStudyResult` objects that will be used to build the VlmResponse
3016
:return: A `VlmResponse` object.
3117
"""
32-
result_sets: list[ResultSet] = []
33-
if caf_data:
34-
total: int = sum(
35-
[caf_study_result.focusAlleleCount for caf_study_result in caf_data]
36-
) # TODO: I'm not sure this is the right field? Will need to verify during/after Issue #16.
37-
response_summary = ResponseSummary(exists=True, total=total)
38-
39-
for caf_study_result in caf_data:
40-
result_sets.extend(
41-
[
42-
ResultSet(
43-
exists=True,
44-
# TODO - HandoverType.id represents the ID of the node from which the dataset was pulled.
45-
# In the future, this ID should be set dynamically.
46-
id=f"{HandoverType.id} {_get_caf_zygosity()}",
47-
resultsCount=caf_study_result.focusAlleleCount,
48-
)
49-
]
50-
)
51-
else:
52-
response_summary = ResponseSummary(exists=False, total=0)
53-
54-
return VlmResponse(
55-
responseSummary=response_summary, response=ResponseField(resultSets=result_sets)
56-
)
18+
raise NotImplementedError # TODO: Implement this during/after Issue #16

src/anyvlm/restapi/vlm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from ga4gh.va_spec.base.core import CohortAlleleFrequencyStudyResult
88

99
from anyvlm.anyvar.base_client import BaseAnyVarClient
10-
from anyvlm.functions.build_vlm_response import build_vlm_response
10+
from anyvlm.functions.build_vlm_response import build_vlm_response_from_caf_data
1111
from anyvlm.functions.get_caf import get_caf
1212
from anyvlm.main import app
1313
from anyvlm.schemas.vlm import (
@@ -67,4 +67,4 @@ def vlm_query(
6767
caf_data: list[CohortAlleleFrequencyStudyResult] = get_caf(
6868
anyvar_client, assemblyId, referenceName, start, referenceBases, alternateBases
6969
)
70-
return build_vlm_response(caf_data)
70+
return build_vlm_response_from_caf_data(caf_data)

src/anyvlm/schemas/vlm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class ResultSet(BaseModel):
6363
exists: bool
6464
id: str = Field(
6565
...,
66-
description="id should be constructed of the `HandoverType.id` + the ResultSet's zygosity",
66+
description="id should be constructed of the `HandoverType.id` + the ResultSet's zygosity. See `validate_resultset_ids` validator in `VlmResponse` class.",
6767
examples=["Geno2MP Homozygous", "MyGene2 Heterozygous"],
6868
)
6969
results: list = Field(

0 commit comments

Comments
 (0)