Skip to content

Commit 849da00

Browse files
committed
Create dataclasses for items listed under config.toml
1 parent 43c9f75 commit 849da00

File tree

2 files changed

+151
-16
lines changed

2 files changed

+151
-16
lines changed

main/config.toml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[general]
2+
context_names = ["naiveB", "smB"]
3+
taxon_id = "human" # accepts a bioDBnet taxon id, "human", or "mouse"
4+
5+
[rnaseq_preprocess]
6+
create_counts_matrix = true # set to false if using a pregenerated matrix file
7+
gene_format = "Ensembl" # accepts "Entrez", "Ensembl", and "Symbol"
8+
preprocess_mode = "provide-matrix" # "create-matrix" or "provide-matrix"
9+
10+
11+
[rna_seq_generation]
12+
trnaseq_config_file = "trnaseq_data_inputs_auto.xlsx"
13+
mrnaseq_config_file = "mrnaseq_data_inputs_auto.xlsx"
14+
rep_ratio = 0.75
15+
group_ratio = 0.75
16+
rep_ratio_h = 1.0
17+
group_ratio_h = 1.0
18+
technique = "zFPKM"
19+
quantile = 50
20+
min_zfpkm = -3
21+
22+
[proteomics_analysis]
23+
proteomics_config_file = "proteomics_data_inputs_paper.xlsx"
24+
rep_ratio = 0.75
25+
batch_ratio = 0.75
26+
high_rep_ratio = 1.0
27+
high_batch_ratio = 1.0
28+
quantile = 25
29+
30+
[merge_xomics]
31+
expression_requirement = 3
32+
requirement_adjust = "regressive"
33+
total_rna_weight = 6
34+
mrna_weight = 6
35+
single_cell_weight = 6
36+
proteomics_weight = 10
37+
38+
[model_creation]
39+
low_threshold = -5
40+
high_threshold = -3
41+
output_filetypes = "xml mat json"
42+
objective_dict = {}
43+
general_model_file = "GeneralModelUpdatedV2.mat"
44+
recon_algorithms = ['IMAT']
45+
solver = "GUROBI"
46+
boundary_reactions_filename = "default_boundary_rxns.csv"
47+
force_reactions_filename = "default_force_rxns.csv"
48+
exclude_reactions_filename = ""
49+
50+
[disease_analysis]
51+
disease_names = ["arthritis", "lupus_a", "lupus_b"]
52+
data_source = "rnaseq"
53+
54+
[drug_repurposing]
55+
sovler = "gurobi"
56+
drug_raw_file = "Repurposing_Hub_export.txt"
57+
58+
[about]
59+
version = "1.5.0"

main/py/project.py

Lines changed: 92 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -92,30 +92,106 @@ def __init__(self, projectdir):
9292
self.pydir = os.path.join(projectdir, "py")
9393

9494
self._toml_data: dict = self._read_from_toml()
95-
self.general = self._toml_data["general"]
96-
self.rnaseq_preprocess = self._toml_data["rnaseq_preprocess"]
97-
self.rna_seq_generation = self._toml_data["rna_seq_generation"]
98-
self.proteomics_analysis = self._toml_data["proteomics_analysis"]
99-
self.merge_xomics = self._toml_data["merge_xomics"]
100-
self.model_creation = self._toml_data["model_creation"]
101-
self.disease_analysis = self._toml_data["disease_analysis"]
102-
self.drug_repurposing = self._toml_data["drug_repurposing"]
103-
self.about = self._toml_data["about"]
10495

105-
self._add_date_to_about()
96+
self.general: general = self._get_general()
97+
self.rnaseq_preprocess: rnaseq_preprocess = self._get_rnaseq_preprocess()
98+
self.rna_seq_generation: rna_seq_generation = self._get_rna_seq_generation()
99+
self.proteomics_analysis: proteomics_analysis = self._get_proteomics_analysis()
100+
self.merge_xomics: merge_xomics = self._get_merge_xomics()
101+
self.model_creation: model_creation = self._get_model_creation()
102+
self.disease_analysis: disease_analysis = self._get_disease_analysis()
103+
self.drug_repurposing: drug_repurposing = self._get_drug_repurposing()
104+
self.about: about = self._get_about()
105+
106+
def _get_general(self) -> general:
107+
data: general = general(
108+
taxon_id=self._toml_data["general"]["taxon_id"],
109+
context_names=self._toml_data["general"]["context_names"],
110+
)
111+
return data
112+
113+
def _get_rnaseq_preprocess(self) -> rnaseq_preprocess:
114+
data: rnaseq_preprocess = rnaseq_preprocess(
115+
create_counts_matrix=self._toml_data["rnaseq_preprocess"]["create_counts_matrix"],
116+
gene_format=self._toml_data["rnaseq_preprocess"]["gene_format"],
117+
preprocess_mode=self._toml_data["rnaseq_preprocess"]["preprocess_mode"],
118+
)
119+
return data
120+
121+
def _get_rna_seq_generation(self) -> rna_seq_generation:
122+
data: rna_seq_generation = rna_seq_generation(
123+
trnaseq_config_file=self._toml_data["rna_seq_generation"]["trnaseq_config_file"],
124+
mrnaseq_config_file=self._toml_data["rna_seq_generation"]["mrnaseq_config_file"],
125+
technique=self._toml_data["rna_seq_generation"]["technique"],
126+
rep_ratio=self._toml_data["rna_seq_generation"]["rep_ratio"],
127+
group_ratio=self._toml_data["rna_seq_generation"]["group_ratio"],
128+
rep_ratio_h=self._toml_data["rna_seq_generation"]["rep_ratio_h"],
129+
group_ratio_h=self._toml_data["rna_seq_generation"]["group_ratio_h"],
130+
quantile=self._toml_data["rna_seq_generation"]["quantile"],
131+
min_zfpkm=self._toml_data["rna_seq_generation"]["min_zfpkm"],
132+
)
133+
return data
134+
135+
def _get_proteomics_analysis(self) -> proteomics_analysis:
136+
data: proteomics_analysis = proteomics_analysis(
137+
proteomics_config_file=self._toml_data["proteomics_analysis"]["proteomics_config_file"],
138+
rep_ratio=self._toml_data["proteomics_analysis"]["rep_ratio"],
139+
batch_ratio=self._toml_data["proteomics_analysis"]["batch_ratio"],
140+
high_rep_ratio=self._toml_data["proteomics_analysis"]["high_rep_ratio"],
141+
high_batch_ratio=self._toml_data["proteomics_analysis"]["high_batch_ratio"],
142+
quantile=self._toml_data["proteomics_analysis"]["quantile"],
143+
)
144+
return data
145+
146+
def _get_merge_xomics(self) -> merge_xomics:
147+
data: merge_xomics = merge_xomics(
148+
expression_requirement=self._toml_data["merge_xomics"]["expression_requirement"],
149+
requirement_adjust=self._toml_data["merge_xomics"]["requirement_adjust"],
150+
total_rna_weight=self._toml_data["merge_xomics"]["total_rna_weight"],
151+
mrna_weight=self._toml_data["merge_xomics"]["mrna_weight"],
152+
single_cell_weight=self._toml_data["merge_xomics"]["single_cell_weight"],
153+
proteomics_weight=self._toml_data["merge_xomics"]["proteomics_weight"],
154+
)
155+
return data
156+
157+
def _get_model_creation(self) -> model_creation:
158+
data: model_creation = model_creation(
159+
low_threshold=self._toml_data["model_creation"]["low_threshold"],
160+
high_threshold=self._toml_data["model_creation"]["high_threshold"],
161+
output_filetypes=self._toml_data["model_creation"]["output_filetypes"],
162+
objective_dict=self._toml_data["model_creation"]["objective_dict"],
163+
general_model_file=self._toml_data["model_creation"]["general_model_file"],
164+
solver=self._toml_data["model_creation"]["solver"],
165+
boundary_reactions_filename=self._toml_data["model_creation"]["boundary_reactions_filename"],
166+
force_reactions_filename=self._toml_data["model_creation"]["force_reactions_filename"],
167+
exclude_reactions_filename=self._toml_data["model_creation"]["exclude_reactions_filename"],
168+
recon_algorithms=self._toml_data["model_creation"]["recon_algorithms"],
169+
)
170+
return data
171+
172+
def _get_disease_analysis(self) -> disease_analysis:
173+
data: disease_analysis = disease_analysis(
174+
data_source=self._toml_data["disease_analysis"]["data_source"],
175+
disease_names=self._toml_data["disease_analysis"]["disease_names"],
176+
)
177+
return data
178+
179+
def _get_drug_repurposing(self) -> drug_repurposing:
180+
data: drug_repurposing = drug_repurposing(
181+
sovler=self._toml_data["drug_repurposing"]["sovler"],
182+
drug_raw_file=self._toml_data["drug_repurposing"]["drug_raw_file"],
183+
)
184+
return data
185+
186+
def _get_about(self) -> about:
187+
return about()
106188

107189
def _read_from_toml(self):
108190
toml_file: str = os.path.join(self.rootdir, "config.toml")
109191
with open(toml_file, "rb") as i_stream:
110192
data = tomllib.load(i_stream)
111193
return data
112194

113-
def _add_date_to_about(self):
114-
"""
115-
This function will add the current date in the format of "Month Day, Year" to the self.about dictionary
116-
"""
117-
self.about["date"] = datetime.now().strftime("%B %d, %Y")
118-
119195

120196
current_dir = os.getcwd()
121197
directory_list = current_dir.split("/")

0 commit comments

Comments
 (0)