Skip to content

Commit

Permalink
add(mip analysis upload workaround) (#3332) (patch)
Browse files Browse the repository at this point in the history
# Description

allow multiple data analyses mip upload
  • Loading branch information
ChrOertlin authored Jun 12, 2024
1 parent a5e0a04 commit 462adfd
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion cg/meta/workflow/mip_dna.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
import logging

from cg.constants import DEFAULT_CAPTURE_KIT, Workflow
from cg.constants.constants import AnalysisType
from cg.constants.gene_panel import GENOME_BUILD_37
from cg.constants.pedigree import Pedigree
from cg.meta.workflow.mip import MipAnalysisAPI
from cg.models.cg_config import CGConfig
from cg.models.mip.mip_analysis import MipAnalysis
from cg.store.models import CaseSample
from cg.store.models import CaseSample, Case
from cg.utils import Process

LOG = logging.getLogger(__name__)


class MipDNAAnalysisAPI(MipAnalysisAPI):
def __init__(self, config: CGConfig, workflow: Workflow = Workflow.MIP_DNA):
Expand Down Expand Up @@ -73,3 +77,20 @@ def get_genome_build(self, case_id: str) -> str:
"""Return the reference genome build version of a MIP-DNA analysis."""
analysis_metadata: MipAnalysis = self.get_latest_metadata(case_id)
return analysis_metadata.genome_build

def get_data_analysis_type(self, case_id: str) -> str:
"""
Return the data analysis type of a MIP-DNA analysis.
Patch for the typical behaviour of the AnalysisAPI function.
It does not raise an error with multiple analysis types.
"""
case: Case = self.get_validated_case(case_id)
analysis_types: set[str] = {
link.sample.application_version.application.analysis_type for link in case.links
}
if len(analysis_types) > 1:
LOG.warning(
f"Multiple analysis types found. Defaulting to {AnalysisType.WHOLE_GENOME_SEQUENCING}."
)
return AnalysisType.WHOLE_GENOME_SEQUENCING
return analysis_types.pop() if analysis_types else None

0 comments on commit 462adfd

Please sign in to comment.