Skip to content

Commit 24d5787

Browse files
authored
Merge branch 'master' into write_config_taxprofiler
2 parents 802b985 + a88f171 commit 24d5787

File tree

30 files changed

+2319
-1425
lines changed

30 files changed

+2319
-1425
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 65.0.13
2+
current_version = 66.0.2
33
commit = True
44
tag = True
55
tag_name = v{new_version}

.github/workflows/tests_and_coverage.yml

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,8 @@ jobs:
2424
with:
2525
virtualenvs-create: false
2626

27-
- name: Cache dependencies
28-
uses: actions/cache@v4
29-
id: cache
30-
with:
31-
path: ${{ env.pythonLocation }}
32-
key: ${{ env.pythonLocation }}-${{ hashFiles('**/poetry.lock') }}
33-
3427
- name: Install Dependencies
35-
if: steps.cache.outputs.cache-hit != 'true'
36-
run: poetry install --no-interaction
28+
run: poetry install --no-interaction --all-extras
3729

3830
- name: Test with Pytest & Coveralls
3931
run: |

cg/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
__title__ = "cg"
2-
__version__ = "65.0.13"
2+
__version__ = "66.0.2"

cg/cli/workflow/nallo/base.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
import rich_click as click
66

77
from cg.cli.utils import CLICK_CONTEXT_SETTINGS
8+
9+
from cg.cli.workflow.nf_analysis import config_case, run, start
10+
811
from cg.constants.constants import MetaApis
912
from cg.meta.workflow.analysis import AnalysisAPI
1013
from cg.meta.workflow.nallo import NalloAnalysisAPI
@@ -18,3 +21,8 @@ def nallo(context: click.Context) -> None:
1821
"""GMS/Nallo analysis workflow."""
1922
AnalysisAPI.get_help(context)
2023
context.obj.meta_apis[MetaApis.ANALYSIS_API] = NalloAnalysisAPI(config=context.obj)
24+
25+
26+
nallo.add_command(config_case)
27+
nallo.add_command(run)
28+
nallo.add_command(start)

cg/cli/workflow/nf_analysis.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@
77

88
from cg.cli.workflow.commands import ARGUMENT_CASE_ID
99
from cg.cli.workflow.utils import validate_force_store_option
10-
from cg.constants import EXIT_FAIL, EXIT_SUCCESS
10+
from cg.constants import EXIT_FAIL, EXIT_SUCCESS, Workflow
1111
from cg.constants.cli_options import DRY_RUN, FORCE, COMMENT
1212
from cg.constants.constants import MetaApis
1313
from cg.exc import AnalysisNotReadyError, CgError, HousekeeperStoreError
1414
from cg.meta.workflow.nf_analysis import NfAnalysisAPI
1515

1616
from cg.models.cg_config import CGConfig
17+
from cg.store.models import Case
1718

1819
LOG = logging.getLogger(__name__)
1920

@@ -186,7 +187,9 @@ def start(
186187
analysis_api: NfAnalysisAPI = context.meta_apis[MetaApis.ANALYSIS_API]
187188
try:
188189
analysis_api.status_db.verify_case_exists(case_internal_id=case_id)
189-
analysis_api.prepare_fastq_files(case_id=case_id, dry_run=dry_run)
190+
case: Case = analysis_api.status_db.get_case_by_internal_id(case_id)
191+
if case.data_analysis != Workflow.NALLO:
192+
analysis_api.prepare_fastq_files(case_id=case_id, dry_run=dry_run)
190193
analysis_api.config_case(case_id=case_id, dry_run=dry_run)
191194
analysis_api.run_nextflow_analysis(
192195
case_id=case_id,

cg/meta/upload/mutant/mutant.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@ def upload(self, ctx: Context, case: Case, restart: bool) -> None:
2424
self.gsaid_api.upload(case.internal_id)
2525
self.fohm_api.aggregate_delivery(case_ids=[case.internal_id])
2626
self.fohm_api.sync_files_sftp()
27+
self.fohm_api.send_mail_reports()
2728
self.update_uploaded_at(latest_analysis)

cg/meta/workflow/nallo.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
import logging
44
from cg.constants import Workflow
5+
from cg.constants.subject import PlinkPhenotypeStatus, PlinkSex
56
from cg.meta.workflow.nf_analysis import NfAnalysisAPI
67
from cg.models.cg_config import CGConfig
8+
from cg.models.nallo.nallo import NalloSampleSheetHeaders, NalloSampleSheetEntry, NalloParameters
9+
from cg.store.models import CaseSample
10+
from pathlib import Path
711

812
LOG = logging.getLogger(__name__)
913

@@ -18,3 +22,72 @@ def __init__(
1822
workflow: Workflow = Workflow.NALLO,
1923
):
2024
super().__init__(config=config, workflow=workflow)
25+
self.root_dir: str = config.nallo.root
26+
self.workflow_bin_path: str = config.nallo.workflow_bin_path
27+
self.profile: str = config.nallo.profile
28+
self.conda_env: str = config.nallo.conda_env
29+
self.conda_binary: str = config.nallo.conda_binary
30+
self.platform: str = config.nallo.platform
31+
self.params: str = config.nallo.params
32+
self.workflow_config_path: str = config.nallo.config
33+
self.resources: str = config.nallo.resources
34+
self.tower_binary_path: str = config.tower_binary_path
35+
self.tower_workflow: str = config.nallo.tower_workflow
36+
self.account: str = config.nallo.slurm.account
37+
self.email: str = config.nallo.slurm.mail_user
38+
self.compute_env_base: str = config.nallo.compute_env
39+
self.revision: str = config.nallo.revision
40+
self.nextflow_binary_path: str = config.nallo.binary_path
41+
42+
@property
43+
def sample_sheet_headers(self) -> list[str]:
44+
"""Headers for sample sheet."""
45+
return NalloSampleSheetHeaders.list()
46+
47+
def get_sample_sheet_content_per_sample(self, case_sample: CaseSample) -> list[list[str]]:
48+
"""Collect and format information required to build a sample sheet for a single sample."""
49+
read_file_paths = self.get_bam_read_file_paths(sample=case_sample.sample)
50+
sample_sheet_entries = []
51+
52+
for bam_path in read_file_paths:
53+
sample_sheet_entry = NalloSampleSheetEntry(
54+
project=case_sample.case.internal_id,
55+
sample=case_sample.sample.internal_id,
56+
read_file=Path(bam_path),
57+
family_id=case_sample.case.internal_id,
58+
paternal_id=case_sample.get_paternal_sample_id or "0",
59+
maternal_id=case_sample.get_maternal_sample_id or "0",
60+
sex=self.get_sex_code(case_sample.sample.sex),
61+
phenotype=self.get_phenotype_code(case_sample.status),
62+
)
63+
sample_sheet_entries.extend(sample_sheet_entry.reformat_sample_content)
64+
return sample_sheet_entries
65+
66+
@staticmethod
67+
def get_phenotype_code(phenotype: str) -> int:
68+
"""Return Nallo phenotype code."""
69+
LOG.debug("Translate phenotype to integer code")
70+
try:
71+
code = PlinkPhenotypeStatus[phenotype.upper()]
72+
except KeyError:
73+
raise ValueError(f"{phenotype} is not a valid phenotype")
74+
return code
75+
76+
@staticmethod
77+
def get_sex_code(sex: str) -> int:
78+
"""Return Nallo sex code."""
79+
LOG.debug("Translate sex to integer code")
80+
try:
81+
code = PlinkSex[sex.upper()]
82+
except KeyError:
83+
raise ValueError(f"{sex} is not a valid sex")
84+
return code
85+
86+
def get_built_workflow_parameters(self, case_id: str) -> NalloParameters:
87+
"""Return parameters."""
88+
outdir = self.get_case_path(case_id=case_id)
89+
90+
return NalloParameters(
91+
input=self.get_sample_sheet_path(case_id=case_id),
92+
outdir=outdir,
93+
)

cg/meta/workflow/nf_analysis.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
WorkflowManager,
1919
)
2020
from cg.constants.gene_panel import GenePanelGenomeBuild
21+
from cg.constants.housekeeper_tags import AlignmentFileTag
2122
from cg.constants.nextflow import NFX_WORK_DIR
2223
from cg.constants.nf_analysis import NfTowerStatus
2324
from cg.constants.tb import AnalysisStatus
@@ -252,6 +253,15 @@ def get_paired_read_paths(self, sample=Sample) -> tuple[list[str], list[str]]:
252253
)
253254
return fastq_forward_read_paths, fastq_reverse_read_paths
254255

256+
def get_bam_read_file_paths(self, sample=Sample) -> list[Path]:
257+
"""Gather BAM file path for a sample based on the BAM tag."""
258+
return [
259+
Path(hk_file.full_path)
260+
for hk_file in self.housekeeper_api.files(
261+
bundle=sample.internal_id, tags={AlignmentFileTag.BAM}
262+
)
263+
]
264+
255265
def get_sample_sheet_content_per_sample(self, case_sample: CaseSample) -> list[list[str]]:
256266
"""Collect and format information required to build a sample sheet for a single sample."""
257267
raise NotImplementedError

cg/models/cg_config.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,24 @@ class MipConfig(BaseModel):
211211
script: str
212212

213213

214+
class NalloConfig(CommonAppConfig):
215+
binary_path: str | None = None
216+
compute_env: str
217+
conda_binary: str | None = None
218+
conda_env: str
219+
platform: str
220+
params: str
221+
config: str
222+
resources: str
223+
launch_directory: str
224+
workflow_bin_path: str
225+
profile: str
226+
revision: str
227+
root: str
228+
slurm: SlurmConfig
229+
tower_workflow: str
230+
231+
214232
class RarediseaseConfig(CommonAppConfig):
215233
binary_path: str | None = None
216234
compute_env: str
@@ -444,6 +462,7 @@ class CGConfig(BaseModel):
444462
mip_rd_dna: MipConfig | None = Field(None, alias="mip-rd-dna")
445463
mip_rd_rna: MipConfig | None = Field(None, alias="mip-rd-rna")
446464
mutant: MutantConfig | None = None
465+
nallo: NalloConfig | None = None
447466
raredisease: RarediseaseConfig | None = None
448467
rnafusion: RnafusionConfig | None = None
449468
statina: StatinaConfig | None = None

cg/models/nallo/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)