2
2
3
3
import logging
4
4
from cg .constants import Workflow
5
+ from cg .constants .subject import PlinkPhenotypeStatus , PlinkSex
5
6
from cg .meta .workflow .nf_analysis import NfAnalysisAPI
6
7
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
7
11
8
12
LOG = logging .getLogger (__name__ )
9
13
@@ -18,3 +22,72 @@ def __init__(
18
22
workflow : Workflow = Workflow .NALLO ,
19
23
):
20
24
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
+ )
0 commit comments