Skip to content

Commit

Permalink
Update imports of Housekeeper store (#2889)(patch)
Browse files Browse the repository at this point in the history
In Clinical-Genomics/housekeeper#191 the location of the Housekeeepr Store was changed


### Fixed

- The imports to Housekeeper store point to the correct location
  • Loading branch information
diitaz93 authored Jan 31, 2024
1 parent 785fce6 commit bc33669
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
10 changes: 5 additions & 5 deletions cg/apps/housekeeper/hk.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

from housekeeper.include import checksum as hk_checksum
from housekeeper.include import include_version
from housekeeper.store import Store, models
from housekeeper.store.database import create_all_tables, drop_all_tables, initialize_database
from housekeeper.store.models import Archive, Bundle, File, Version
from housekeeper.store.models import Archive, Bundle, File, Tag, Version
from housekeeper.store.store import Store
from sqlalchemy.orm import Query

from cg.constants import SequencingFileTag
Expand Down Expand Up @@ -256,7 +256,7 @@ def last_version(self, bundle: str) -> Version:
self._store._get_query(table=Version)
.join(Version.bundle)
.filter(Bundle.name == bundle)
.order_by(models.Version.created_at.desc())
.order_by(Version.created_at.desc())
.first()
)

Expand Down Expand Up @@ -299,13 +299,13 @@ def new_tag(self, name: str, category: str = None):
"""Create a new tag."""
return self._store.new_tag(name, category)

def add_tag(self, name: str, category: str = None) -> models.Tag:
def add_tag(self, name: str, category: str = None) -> Tag:
"""Add a tag to the database."""
tag_obj = self._store.new_tag(name, category)
self.add_commit(tag_obj)
return tag_obj

def get_tag(self, name: str) -> models.Tag:
def get_tag(self, name: str) -> Tag:
"""Fetch a tag."""
return self._store.get_tag(name)

Expand Down
11 changes: 6 additions & 5 deletions cg/meta/upload/gt.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import logging
from pathlib import Path

from housekeeper.store.models import File, Version

from cg.apps.gt import GenotypeAPI
from cg.apps.housekeeper.hk import HousekeeperAPI
from cg.apps.housekeeper.hk import models as housekeeper_models
from cg.constants.constants import FileFormat, Pipeline, PrepCategory
from cg.constants.housekeeper_tags import HkMipAnalysisTag
from cg.constants.subject import Sex
Expand Down Expand Up @@ -55,7 +56,7 @@ def data(self, analysis_obj: Analysis) -> dict:
raise ValueError(f"Pipeline {analysis_obj.pipeline} does not support Genotype upload")
return data

def _get_samples_sex_mip(self, case_obj: Case, hk_version: housekeeper_models.Version) -> dict:
def _get_samples_sex_mip(self, case_obj: Case, hk_version: Version) -> dict:
qc_metrics_file = self.get_qcmetrics_file(hk_version)
analysis_sexes = self.analysis_sex(qc_metrics_file)
samples_sex = {}
Expand Down Expand Up @@ -87,7 +88,7 @@ def analysis_sex(self, qc_metrics_file: Path) -> dict:
for sample_id_metric in qc_metrics.sample_id_metrics
}

def get_bcf_file(self, hk_version_obj: housekeeper_models.Version) -> housekeeper_models.File:
def get_bcf_file(self, hk_version_obj: Version) -> File:
"""Fetch a bcf file and return the file object"""
genotype_files: list = self._get_genotype_files(version_id=hk_version_obj.id)
for genotype_file in genotype_files:
Expand All @@ -96,7 +97,7 @@ def get_bcf_file(self, hk_version_obj: housekeeper_models.Version) -> housekeepe
return genotype_file
raise FileNotFoundError(f"No vcf or bcf file found for bundle {hk_version_obj.bundle_id}")

def get_qcmetrics_file(self, hk_version_obj: housekeeper_models.Version) -> Path:
def get_qcmetrics_file(self, hk_version_obj: Version) -> Path:
"""Fetch a qc_metrics file and return the path"""
hk_qcmetrics = self.hk.files(
version=hk_version_obj.id, tags=HkMipAnalysisTag.QC_METRICS
Expand All @@ -117,7 +118,7 @@ def upload(self, data: dict, replace: bool = False):
self.gt.upload(str(data["bcf"]), data["samples_sex"], force=replace)

@staticmethod
def _is_variant_file(genotype_file: housekeeper_models.File):
def _is_variant_file(genotype_file: File):
return genotype_file.full_path.endswith("vcf.gz") or genotype_file.full_path.endswith("bcf")

def _get_genotype_files(self, version_id: int) -> list:
Expand Down
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bc33669

Please sign in to comment.