|
3 | 3 | from ga4gh.va_spec.base.core import CohortAlleleFrequencyStudyResult |
4 | 4 |
|
5 | 5 | from anyvlm.schemas.vlm import ( |
6 | | - HandoverType, |
7 | | - ResponseField, |
8 | | - ResponseSummary, |
9 | | - ResultSet, |
10 | 6 | VlmResponse, |
11 | 7 | ) |
12 | | -from anyvlm.utils.types import Zygosity |
13 | 8 |
|
14 | 9 |
|
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: |
27 | 13 | """Craft a VlmResponse object from a list of CohortAlleleFrequencyStudyResults. |
28 | 14 |
|
29 | 15 | :param caf_data: A list of `CohortAlleleFrequencyStudyResult` objects that will be used to build the VlmResponse |
30 | 16 | :return: A `VlmResponse` object. |
31 | 17 | """ |
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 |
0 commit comments