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

build: pin cool-seq-tool~=0.6.0 #575

Merged
merged 1 commit into from
Jul 25, 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
2 changes: 1 addition & 1 deletion Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ pydantic = "==2.*"
"ga4gh.vrs" = {version = "~=2.0.0a10", extras = ["extras"]}
gene-normalizer = "~=0.4.0"
boto3 = "*"
cool-seq-tool = "~=0.5.0"
cool-seq-tool = "~=0.6.0"
bioutils = "*"
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dependencies = [
"ga4gh.vrs[extras] ~= 2.0.0a10",
"gene-normalizer ~=0.4.0",
"boto3",
"cool-seq-tool ~=0.5.0",
"cool-seq-tool ~=0.6.0",
"bioutils"
]
dynamic = ["version"]
Expand Down
4 changes: 2 additions & 2 deletions src/variation/gnomad_vcf_to_protein_variation.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,8 +272,8 @@ def _get_genomic_pos_range(
for the original position change
"""
# Get cDNA reading frame
start_reading_frame = self.mane_transcript._get_reading_frame(c_start_pos + 1) # noqa: SLF001
end_reading_frame = self.mane_transcript._get_reading_frame(c_end_pos) # noqa: SLF001
start_reading_frame = self.mane_transcript.get_reading_frame(c_start_pos + 1)
end_reading_frame = self.mane_transcript.get_reading_frame(c_end_pos)

# Get genomic position range change
# This ensures that there 3 nucleotides needed for codon
Expand Down
56 changes: 51 additions & 5 deletions src/variation/schemas/service_schema.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Module containing schemas for services"""

from enum import Enum
from typing import Literal

from cool_seq_tool.schemas import ToCdnaService as ToCdna
from cool_seq_tool.schemas import ToGenomicService as ToGenomic
from pydantic import ConfigDict
from cool_seq_tool.schemas import ResidueMode
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr

from variation import __version__
from variation.schemas.normalize_response_schema import ServiceMeta
Expand All @@ -21,9 +21,33 @@ class ClinVarAssembly(str, Enum):
HG18 = "hg18"


class ToCdnaService(ToCdna):
class CdnaRepresentation(BaseModel, extra="forbid"):
"""Model response for cDNA representation"""

c_ac: StrictStr
c_start_pos: StrictInt
c_end_pos: StrictInt
cds_start: StrictInt
residue_mode: Literal["inter-residue"] = ResidueMode.INTER_RESIDUE.value

model_config = ConfigDict(
json_schema_extra={
"example": {
"c_ac": "NM_004333.6",
"c_start_pos": 1797,
"c_end_pos": 1800,
"cds_start": 226,
"residue_mode": ResidueMode.INTER_RESIDUE.value,
}
}
)


class ToCdnaService(BaseModel, extra="forbid"):
"""Service model response for protein -> cDNA"""

c_data: CdnaRepresentation | None = None
warnings: list[StrictStr] = []
service_meta: ServiceMeta

model_config = ConfigDict(
Expand All @@ -48,9 +72,31 @@ class ToCdnaService(ToCdna):
)


class ToGenomicService(ToGenomic):
class GenomicRepresentation(BaseModel, extra="forbid"):
"""Model response for genomic representation"""

g_ac: StrictStr
g_start_pos: StrictInt
g_end_pos: StrictInt
residue_mode: Literal["inter-residue"] = ResidueMode.INTER_RESIDUE.value

model_config = ConfigDict(
json_schema_extra={
"example": {
"g_ac": "NC_000007.13",
"g_start_pos": 140453134,
"g_end_pos": 140453137,
"residue_mode": ResidueMode.INTER_RESIDUE.value,
}
}
)


class ToGenomicService(BaseModel, extra="forbid"):
"""Service model response for cDNA -> genomic"""

g_data: GenomicRepresentation | None = None
warnings: list[StrictStr] = []
service_meta: ServiceMeta

model_config = ConfigDict(
Expand Down
32 changes: 20 additions & 12 deletions src/variation/translators/ambiguous_translator_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,24 @@ async def get_grch38_data_ambiguous(
"""
pos0, pos1, pos2, pos3, new_ac = None, None, None, None, None
if classification.ambiguous_type == AmbiguousType.AMBIGUOUS_1:
# `g_to_grch38` return inter-residue, but we want residue here
# so we increment start by 1
grch38_pos0_pos1 = await self.mane_transcript.g_to_grch38(
ac, classification.pos0, classification.pos1
ac, classification.pos0 + 1, classification.pos1
)
if grch38_pos0_pos1:
pos0, pos1 = grch38_pos0_pos1["pos"]
ac_pos0_pos1 = grch38_pos0_pos1["ac"]
pos0, pos1 = grch38_pos0_pos1.pos
ac_pos0_pos1 = grch38_pos0_pos1.ac

# `g_to_grch38` return inter-residue, but we want residue here
# so we increment start by 1
grch38_pos2_pos3 = await self.mane_transcript.g_to_grch38(
ac, classification.pos2, classification.pos3
ac, classification.pos2 + 1, classification.pos3
)

if grch38_pos2_pos3:
pos2, pos3 = grch38_pos2_pos3["pos"]
ac_pos2_pos3 = grch38_pos2_pos3["ac"]
pos2, pos3 = grch38_pos2_pos3.pos
ac_pos2_pos3 = grch38_pos2_pos3.ac

if ac_pos0_pos1 != ac_pos2_pos3:
errors.append(
Expand All @@ -78,22 +82,26 @@ async def get_grch38_data_ambiguous(
AmbiguousType.AMBIGUOUS_2,
AmbiguousType.AMBIGUOUS_5,
}:
# `g_to_grch38` return inter-residue, but we want residue here
# so we increment start by 1
grch38 = await self.mane_transcript.g_to_grch38(
ac, classification.pos1, classification.pos2
ac, classification.pos1 + 1, classification.pos2
)
if grch38:
pos1, pos2 = grch38["pos"]
new_ac = grch38["ac"]
pos1, pos2 = grch38.pos
new_ac = grch38.ac
elif classification.ambiguous_type == AmbiguousType.AMBIGUOUS_7:
# `g_to_grch38` return inter-residue, but we want residue here
# so we increment start by 1
Comment on lines +94 to +95
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this, but needed a quick fix. I think I may make an issue in Cool-Seq-Tool to provide start/end residue mode arguments.

grch38 = await self.mane_transcript.g_to_grch38(
ac, classification.pos0, classification.pos2
ac, classification.pos0 + 1, classification.pos2
)
if grch38:
(
pos0,
pos2,
) = grch38["pos"]
new_ac = grch38["ac"]
) = grch38.pos
new_ac = grch38.ac

if not new_ac:
errors.append(f"Unable to find a GRCh38 accession for: {ac}")
Expand Down
16 changes: 10 additions & 6 deletions src/variation/translators/genomic_del_dup_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,23 @@ async def get_grch38_data(
pos0, pos1, new_ac = None, None, None

if classification.pos1:
# `g_to_grch38` return inter-residue, but we want residue here
# so we increment start by 1
grch38_pos = await self.mane_transcript.g_to_grch38(
ac, classification.pos0, classification.pos1
ac, classification.pos0 + 1, classification.pos1
)
if grch38_pos:
pos0, pos1 = grch38_pos["pos"]
new_ac = grch38_pos["ac"]
pos0, pos1 = grch38_pos.pos
new_ac = grch38_pos.ac
else:
# `g_to_grch38` return inter-residue, but we want residue here
# so we increment start by 1
grch38_pos = await self.mane_transcript.g_to_grch38(
ac, classification.pos0, classification.pos0
ac, classification.pos0 + 1, classification.pos0
)
if grch38_pos:
pos0, _ = grch38_pos["pos"]
new_ac = grch38_pos["ac"]
pos0, _ = grch38_pos.pos
new_ac = grch38_pos.ac

if not new_ac:
errors.append(f"Unable to find a GRCh38 accession for: {ac}")
Expand Down
2 changes: 1 addition & 1 deletion src/variation/translators/genomic_delins.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ async def translate(
coord_type = AnnotationLayer.CDNA
validation_result.classification = classification
else:
vrs_seq_loc_ac = mane.alt_ac
vrs_seq_loc_ac = mane.ac
coord_type = AnnotationLayer.GENOMIC

vrs_allele = self.vrs.to_vrs_allele(
Expand Down
2 changes: 1 addition & 1 deletion src/variation/translators/genomic_insertion.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ async def translate(
coord_type = AnnotationLayer.CDNA
validation_result.classification = classification
else:
vrs_seq_loc_ac = mane.alt_ac
vrs_seq_loc_ac = mane.ac
coord_type = AnnotationLayer.GENOMIC

vrs_allele = self.vrs.to_vrs_allele(
Expand Down
2 changes: 1 addition & 1 deletion src/variation/translators/genomic_reference_agree.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ async def translate(
coord_type = AnnotationLayer.CDNA
validation_result.classification = classification
else:
vrs_seq_loc_ac = mane.alt_ac
vrs_seq_loc_ac = mane.ac
coord_type = AnnotationLayer.GENOMIC

vrs_allele = self.vrs.to_vrs_allele(
Expand Down
2 changes: 1 addition & 1 deletion src/variation/translators/genomic_substitution.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async def translate(
coord_type = AnnotationLayer.CDNA
validation_result.classification = classification
else:
vrs_seq_loc_ac = mane.alt_ac
vrs_seq_loc_ac = mane.ac
coord_type = AnnotationLayer.GENOMIC

vrs_allele = self.vrs.to_vrs_allele(
Expand Down