Skip to content

Commit

Permalink
Added a new endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
mgcam committed May 24, 2024
1 parent 4a0b5b4 commit 68db65d
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 2 deletions.
21 changes: 20 additions & 1 deletion lang_qc/endpoints/pacbio_well.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
from lang_qc.db.mlwh_connection import get_mlwh_db
from lang_qc.db.qc_connection import get_qc_db
from lang_qc.db.qc_schema import User
from lang_qc.models.pacbio.well import PacBioPagedWells, PacBioWellFull
from lang_qc.models.pacbio.well import PacBioPagedWells, PacBioWellFull, PacBioWellLibraries
from lang_qc.models.qc_flow_status import QcFlowStatusEnum
from lang_qc.models.qc_state import QcState, QcStateBasic
from lang_qc.util.auth import check_user
Expand Down Expand Up @@ -185,6 +185,25 @@ def get_seq_metrics(
return PacBioWellFull(db_well=mlwh_well, qc_state=qc_state)


@router.get(
"/products/{id_product}/seq_level/libs",
summary="Get full sequencing QC metrics and state for a product",
responses={
status.HTTP_404_NOT_FOUND: {"description": "Well product does not exist"},
status.HTTP_422_UNPROCESSABLE_ENTITY: {"description": "Invalid product ID"},
},
response_model=PacBioWellFull,
)
def get_well_lims_info(
id_product: ChecksumSHA256,
mlwhdb_session: Session = Depends(get_mlwh_db),
) -> PacBioWellLibraries:

mlwh_well = _find_well_product_or_error(id_product, mlwhdb_session)
return PacBioWellLibraries(db_well=mlwh_well)



@router.post(
"/products/{id_product}/qc_claim",
summary="Claim the well to start QC",
Expand Down
21 changes: 20 additions & 1 deletion lang_qc/models/pacbio/well.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from pydantic.dataclasses import dataclass

from lang_qc.db.mlwh_schema import PacBioRunWellMetrics
from lang_qc.models.pacbio.experiment import PacBioExperiment
from lang_qc.models.pacbio.experiment import PacBioExperiment, PacBioLibrary
from lang_qc.models.pacbio.qc_data import QCDataWell
from lang_qc.models.pager import PagedResponse
from lang_qc.models.qc_state import QcState
Expand Down Expand Up @@ -226,3 +226,22 @@ def pre_root(cls, values: dict[str, Any]) -> dict[str, Any]:
assigned["experiment_tracking"] = PacBioExperiment.from_orm(experiment_info)

return assigned

@dataclass(kw_only=True, frozen=True)
class PacBioWellLibraries(PacBioWell):
"""A full response model for a single PacBio well."""

libraries: list[PacBioLibrary] = Field(
title="Experiment tracking information",
)

@model_validator(mode="before")
def pre_root(cls, values: dict[str, Any]) -> dict[str, Any]:

assigned = super().pre_root(values)
mlwh_db_row: PacBioRunWellMetrics = values.kwargs["db_well"]
assigned["libraries"] = [
PacBioLibrary(db_library=row) for row in mlwh_db_row.get_experiment_info()
]

return assigned

0 comments on commit 68db65d

Please sign in to comment.