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

feat!: rename VRS 1.3 class #33

Merged
merged 2 commits into from
May 16, 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
12 changes: 6 additions & 6 deletions src/dcd_mapping/annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
ScoresetMetadata,
TargetSequenceType,
TxSelectResult,
VrsObject1_x,
VrsMapping1_3,
)

_logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -247,7 +247,7 @@ def get_mapped_reference_sequence(
)


def _set_layer(ss: str, mappings: list[VrsObject1_x]) -> AnnotationLayer:
def _set_layer(ss: str, mappings: list[VrsMapping1_3]) -> AnnotationLayer:
if ss.startswith("urn:mavedb:00000097"):
return AnnotationLayer.PROTEIN
for var in mappings:
Expand All @@ -256,7 +256,7 @@ def _set_layer(ss: str, mappings: list[VrsObject1_x]) -> AnnotationLayer:
return AnnotationLayer.PROTEIN


def _format_score_mapping(var: VrsObject1_x, layer: AnnotationLayer) -> dict | None:
def _format_score_mapping(var: VrsMapping1_3, layer: AnnotationLayer) -> dict | None:
if var and var.layer == layer:
if "members" in var.pre_mapped_variants:
pre_mapped_members = []
Expand All @@ -282,7 +282,7 @@ def _format_score_mapping(var: VrsObject1_x, layer: AnnotationLayer) -> dict | N

def save_mapped_output_json(
ss: str,
mappings: list[VrsObject1_x],
mappings: list[VrsMapping1_3],
align_result: AlignmentResult,
tx_output: TxSelectResult | None = None,
output_path: Path | None = None,
Expand Down Expand Up @@ -346,9 +346,9 @@ def _format_start_end(ss: str, start: int, end: int) -> list[int]:

def annotate(
tx_select_results: TxSelectResult | None,
vrs_results: list[VrsObject1_x],
vrs_results: list[VrsMapping1_3],
metadata: ScoresetMetadata,
) -> list[VrsObject1_x]:
) -> list[VrsMapping1_3]:
"""TODO"""
sr = get_seqrepo()
for var in vrs_results:
Expand Down
6 changes: 3 additions & 3 deletions src/dcd_mapping/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class TxSelectResult(BaseModel):
###################### WORKING: ################################


class VrsObject1_x(BaseModel): # noqa: N801
class VrsMapping1_3(BaseModel): # noqa: N801
"""Define response object for VRS 1.x object"""

mavedb_id: StrictStr
Expand Down Expand Up @@ -261,7 +261,7 @@ def generate_allele_structure(self, var: Allele) -> dict:
},
}

def output_vrs_variations(self, layer: AnnotationLayer) -> VrsObject1_x:
def output_vrs_variations(self, layer: AnnotationLayer) -> VrsMapping1_3:
"""Construct VRS 1.3 compatible objects from 2.0a models.

:param layer: The Annotation Layer (genomic or protein)
Expand Down Expand Up @@ -319,7 +319,7 @@ def output_vrs_variations(self, layer: AnnotationLayer) -> VrsObject1_x:
else:
post_mapped_variants = post_mapped_variants[0]

return VrsObject1_x(
return VrsMapping1_3(
mavedb_id=self.mavedb_id,
pre_mapped_variants=pre_mapped_variants,
post_mapped_variants=post_mapped_variants,
Expand Down
14 changes: 7 additions & 7 deletions src/dcd_mapping/vrs_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
TargetType,
TxSelectResult,
VrsMapping,
VrsObject1_x,
VrsMapping1_3,
)

__all__ = ["vrs_map"]
Expand Down Expand Up @@ -69,7 +69,7 @@ def _map_protein_coding_pro(
align_result: AlignmentResult,
sequence_id: str,
transcript: TxSelectResult,
) -> VrsObject1_x | None:
) -> VrsMapping1_3 | None:
"""Construct VRS object mapping for ``hgvs_pro`` variant column entry

These arguments are a little lazy and could be pruned down later
Expand Down Expand Up @@ -159,7 +159,7 @@ def _map_protein_coding(
records: list[ScoreRow],
transcript: TxSelectResult,
align_result: AlignmentResult,
) -> list[VrsObject1_x]:
) -> list[VrsMapping1_3]:
"""Perform mapping on protein coding experiment results

:param metadata: The metadata for a score set
Expand All @@ -168,7 +168,7 @@ def _map_protein_coding(
:param align_results: The alignment data for a score set
:return: A list of mappings
"""
variations: list[VrsObject1_x] = []
variations: list[VrsMapping1_3] = []
if metadata.target_sequence_type == TargetSequenceType.DNA:
sequence = str(
Seq(metadata.target_sequence).translate(table="1", stop_symbol="")
Expand Down Expand Up @@ -223,15 +223,15 @@ def _map_regulatory_noncoding(
metadata: ScoresetMetadata,
records: list[ScoreRow],
align_result: AlignmentResult,
) -> list[VrsObject1_x]:
) -> list[VrsMapping1_3]:
"""Perform mapping on noncoding/regulatory experiment results

:param metadata: metadata for URN
:param records: list of MAVE experiment result rows
:param align_result: An AlignmentResult object for a score set
:return: A list of VRS mappings
"""
variations: list[VrsObject1_x] = []
variations: list[VrsMapping1_3] = []
sequence_id = store_sequence(metadata.target_sequence)

for row in records:
Expand Down Expand Up @@ -380,7 +380,7 @@ def vrs_map(
records: list[ScoreRow],
transcript: TxSelectResult | None = None,
silent: bool = True,
) -> list[VrsObject1_x] | None:
) -> list[VrsMapping1_3] | None:
"""Given a description of a MAVE scoreset and an aligned transcript, generate
the corresponding VRS objects.

Expand Down
4 changes: 2 additions & 2 deletions tests/test_vrs_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
AlignmentResult,
ScoresetMetadata,
TxSelectResult,
VrsObject1_x,
VrsMapping1_3,
)
from dcd_mapping.vrs_map import vrs_map


def _assert_correct_vrs_map(
mapping: VrsObject1_x, expected_mappings_data: dict[str, dict]
mapping: VrsMapping1_3, expected_mappings_data: dict[str, dict]
):
assert (
mapping.mavedb_id in expected_mappings_data
Expand Down
Loading