Skip to content

Commit

Permalink
change to staticmethod and clean up sonarcloud issue
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpru committed Jan 11, 2024
1 parent 0e57efd commit 91b8043
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
22 changes: 11 additions & 11 deletions cg/meta/workflow/raredisease.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,8 @@ def get_pipeline_parameters(self, case_id: str) -> PipelineParameters:
outdir=self.get_case_path(case_id=case_id),
)

def get_phenotype_code(self, phenotype: str) -> int:
@staticmethod
def get_phenotype_code(phenotype: str) -> int:
"""Return Raredisease phenotype code."""
LOG.debug("Translate phenotype to int")
if phenotype == "unaffected":
Expand All @@ -117,23 +118,22 @@ def get_phenotype_code(self, phenotype: str) -> int:
else:
return 0

def get_sex_code(self, sex: str) -> int:
"""Return Raredisease phenotype code."""
LOG.debug("Translate phenotype to int")
@staticmethod
def get_sex_code(sex: str) -> int:
"""Return Raredisease sex code."""
LOG.debug("Translate sex to int")
if sex == "male":
return 1
elif sex == "female":
return 2
else:
return 0

def get_parental_id(self, parent: CaseSample) -> str:
"""Return Raredisease phenotype code."""
LOG.debug("Translate phenotype to int")
if parent:
return parent.internal_id
else:
return ""
@staticmethod
def get_parental_id(parent: CaseSample) -> str:
"""Return Raredisease parental id."""
LOG.debug("Return parental id")
return parent.internal_id if parent else ""

@property
def root(self) -> str:
Expand Down
6 changes: 5 additions & 1 deletion tests/meta/workflow/test_prepare_fastq_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,11 @@ def test_add_decompressed_sample_loops_through_spring(
case = analysis_store.get_case_by_internal_id(case_id)
sample = case.samples[0]

with mock.patch.object(files, "get_hk_files_dict", return_value={},), mock.patch.object(
with mock.patch.object(
files,
"get_hk_files_dict",
return_value={},
), mock.patch.object(
files,
"get_spring_paths",
return_value=[CompressionData(spring_file.with_suffix(""))],
Expand Down

0 comments on commit 91b8043

Please sign in to comment.