sciforge-hub 0.0.4

Central hub orchestrating Sciforge subsystems (api, engine, tools).
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
//! Dispatch handler for microbiology functions.

use super::super::params::*;
use crate::domain::biology as bio;
use crate::domain::common::errors::{HubError, HubResult};
use crate::engine::experience::runner::RunOutput;

pub(super) fn dispatch(func: &str, p: &Params) -> HubResult<RunOutput> {
    match func {
        "micro_biofilm_formation_rate" => Ok(RunOutput::Scalar(
            bio::microbiology::biofilm::biofilm_formation_rate(
                get_f(p, "planktonic")?,
                get_f(p, "attachment_rate")?,
                get_f(p, "surface_area")?,
                get_f(p, "detachment_rate")?,
                get_f(p, "biofilm")?,
            ),
        )),
        "biofilm_thickness" => Ok(RunOutput::Scalar(
            bio::microbiology::biofilm::biofilm_thickness(
                get_f(p, "growth_rate")?,
                get_f(p, "nutrient")?,
                get_f(p, "ks")?,
                get_f(p, "detachment")?,
                get_f(p, "t")?,
            ),
        )),
        "micro_extracellular_matrix_production" => Ok(RunOutput::Scalar(
            bio::microbiology::biofilm::extracellular_matrix_production(
                get_f(p, "cell_density")?,
                get_f(p, "signal")?,
                get_f(p, "max_rate")?,
                get_f(p, "threshold")?,
            ),
        )),
        "biofilm_diffusion_limitation" => Ok(RunOutput::Scalar(
            bio::microbiology::biofilm::biofilm_diffusion_limitation(
                get_f(p, "bulk_conc")?,
                get_f(p, "thickness")?,
                get_f(p, "diffusion_biofilm")?,
                get_f(p, "consumption_rate")?,
            ),
        )),
        "persister_fraction" => Ok(RunOutput::Scalar(
            bio::microbiology::biofilm::persister_fraction(
                get_f(p, "antibiotic_conc")?,
                get_f(p, "mic")?,
                get_f(p, "base_fraction")?,
                get_f(p, "max_fraction")?,
            ),
        )),
        "antibiotic_resistance_mutation_rate" => Ok(RunOutput::Scalar(
            bio::microbiology::biofilm::antibiotic_resistance_mutation_rate(
                get_f(p, "population")?,
                get_f(p, "mutation_rate")?,
                get_f(p, "selective_advantage")?,
            ),
        )),
        "minimum_inhibitory_concentration_ratio" => Ok(RunOutput::Scalar(
            bio::microbiology::biofilm::minimum_inhibitory_concentration_ratio(
                get_f(p, "mic_resistant")?,
                get_f(p, "mic_susceptible")?,
            ),
        )),
        "horizontal_gene_transfer" => Ok(RunOutput::Scalar(
            bio::microbiology::biofilm::horizontal_gene_transfer(
                get_f(p, "donor")?,
                get_f(p, "recipient")?,
                get_f(p, "conjugation_rate")?,
            ),
        )),
        "competence_transformation" => Ok(RunOutput::Scalar(
            bio::microbiology::biofilm::competence_transformation(
                get_f(p, "dna_conc")?,
                get_f(p, "competent_cells")?,
                get_f(p, "uptake_rate")?,
                get_f(p, "integration_efficiency")?,
            ),
        )),
        "phage_therapy_lysis" => {
            let (a, b) = bio::microbiology::biofilm::phage_therapy_lysis(
                get_f(p, "phage")?,
                get_f(p, "bacteria")?,
                get_f(p, "adsorption_rate")?,
                get_f(p, "burst_size")?,
                get_f(p, "latent_period")?,
                get_f(p, "dt")?,
            );
            Ok(RunOutput::Pair(a, b))
        }
        "chemostat_steady_state_biomass" => Ok(RunOutput::Scalar(
            bio::microbiology::culture::chemostat_steady_state_biomass(
                get_f(p, "y")?,
                get_f(p, "s_in")?,
                get_f(p, "ks")?,
                get_f(p, "mu_max")?,
                get_f(p, "d")?,
            ),
        )),
        "chemostat_washout_dilution" => Ok(RunOutput::Scalar(
            bio::microbiology::culture::chemostat_washout_dilution(
                get_f(p, "mu_max")?,
                get_f(p, "s_in")?,
                get_f(p, "ks")?,
            ),
        )),
        "minimum_inhibitory_concentration" => Ok(RunOutput::Scalar(
            bio::microbiology::culture::minimum_inhibitory_concentration(
                get_f(p, "e0")?,
                get_f(p, "emax")?,
                get_f(p, "ec50")?,
                get_f(p, "n")?,
                get_f(p, "target_kill")?,
            ),
        )),
        "competitive_exclusion" => {
            let (a, b, c) = bio::microbiology::culture::competitive_exclusion(
                get_f(p, "x1")?,
                get_f(p, "x2")?,
                get_f(p, "s")?,
                get_f(p, "mu1")?,
                get_f(p, "mu2")?,
                get_f(p, "ks1")?,
                get_f(p, "ks2")?,
                get_f(p, "y1")?,
                get_f(p, "y2")?,
                get_f(p, "d")?,
                get_f(p, "s_in")?,
            );
            Ok(RunOutput::Triple(a, b, c))
        }
        "serial_dilution" => Ok(RunOutput::Vector(
            bio::microbiology::culture::serial_dilution(
                get_f(p, "n0")?,
                get_f(p, "dilution_factor")?,
                get_u(p, "transfers")?,
                get_f(p, "growth_per_cycle")?,
            ),
        )),
        "biofilm_formation" => {
            let (a, b) = bio::microbiology::culture::biofilm_formation(
                get_f(p, "planktonic")?,
                get_f(p, "attachment_rate")?,
                get_f(p, "detachment_rate")?,
                get_f(p, "biofilm")?,
                get_f(p, "carrying_capacity")?,
            );
            Ok(RunOutput::Pair(a, b))
        }
        "quorum_sensing" => Ok(RunOutput::Scalar(
            bio::microbiology::culture::quorum_sensing(
                get_f(p, "cell_density")?,
                get_f(p, "autoinducer_production")?,
                get_f(p, "threshold")?,
                get_f(p, "n_hill")?,
            ),
        )),
        "colony_forming_units" => Ok(RunOutput::Scalar(
            bio::microbiology::culture::colony_forming_units(
                get_f(p, "od600")?,
                get_f(p, "calibration_factor")?,
            ),
        )),
        "turbidostat" => Ok(RunOutput::Scalar(bio::microbiology::culture::turbidostat(
            get_f(p, "biomass")?,
            get_f(p, "target_od")?,
            get_f(p, "mu")?,
            get_f(p, "dt")?,
        ))),
        "ph_growth_response" => Ok(RunOutput::Scalar(
            bio::microbiology::culture::ph_growth_response(
                get_f(p, "ph")?,
                get_f(p, "ph_opt")?,
                get_f(p, "ph_min")?,
                get_f(p, "ph_max")?,
            ),
        )),
        "monod_growth" => Ok(RunOutput::Scalar(bio::microbiology::growth::monod_growth(
            get_f(p, "mu_max")?,
            get_f(p, "s")?,
            get_f(p, "ks")?,
        ))),
        "monod_dynamics" => {
            let (a, b) = bio::microbiology::growth::monod_dynamics(
                get_f(p, "x")?,
                get_f(p, "s")?,
                get_f(p, "mu_max")?,
                get_f(p, "ks")?,
                get_f(p, "y")?,
                get_f(p, "d")?,
                get_f(p, "s_in")?,
            );
            Ok(RunOutput::Pair(a, b))
        }
        "monod_simulate" => Ok(RunOutput::PairVec(
            bio::microbiology::growth::monod_simulate(
                get_f(p, "x0")?,
                get_f(p, "s0")?,
                get_f(p, "mu_max")?,
                get_f(p, "ks")?,
                get_f(p, "y")?,
                get_f(p, "d")?,
                get_f(p, "s_in")?,
                get_f(p, "dt")?,
                get_u(p, "steps")?,
            ),
        )),
        "bacterial_growth_phases" => Ok(RunOutput::Scalar(
            bio::microbiology::growth::bacterial_growth_phases(
                get_f(p, "n0")?,
                get_f(p, "mu")?,
                get_f(p, "k")?,
                get_f(p, "lag")?,
                get_f(p, "t")?,
            ),
        )),
        "generation_time_bacteria" => Ok(RunOutput::Scalar(
            bio::microbiology::growth::generation_time_bacteria(get_f(p, "mu")?),
        )),
        "death_phase" => Ok(RunOutput::Scalar(bio::microbiology::growth::death_phase(
            get_f(p, "n_peak")?,
            get_f(p, "death_rate")?,
            get_f(p, "t")?,
        ))),
        "diauxic_growth" => Ok(RunOutput::Scalar(
            bio::microbiology::growth::diauxic_growth(
                get_f(p, "s1")?,
                get_f(p, "s2")?,
                get_f(p, "mu1")?,
                get_f(p, "mu2")?,
                get_f(p, "ks1")?,
                get_f(p, "ks2")?,
                get_f(p, "ki")?,
            ),
        )),
        "fermentation_yield" => Ok(RunOutput::Scalar(
            bio::microbiology::metabolism::fermentation_yield(
                get_f(p, "substrate")?,
                get_f(p, "yield_coefficient")?,
            ),
        )),
        "micro_anaerobic_atp_yield" => Ok(RunOutput::Scalar(
            bio::microbiology::metabolism::anaerobic_atp_yield(
                get_f(p, "glucose_moles")?,
                get_f(p, "pathway_efficiency")?,
            ),
        )),
        "chemolithoautotrophy_energy" => Ok(RunOutput::Scalar(
            bio::microbiology::metabolism::chemolithoautotrophy_energy(
                get_f(p, "delta_g")?,
                get_f(p, "moles_substrate")?,
                get_f(p, "efficiency")?,
            ),
        )),
        "nitrogen_fixation_cost" => Ok(RunOutput::Scalar(
            bio::microbiology::metabolism::nitrogen_fixation_cost(
                get_f(p, "n2_fixed")?,
                get_f(p, "atp_per_n2")?,
            ),
        )),
        "denitrification_rate" => Ok(RunOutput::Scalar(
            bio::microbiology::metabolism::denitrification_rate(
                get_f(p, "no3")?,
                get_f(p, "carbon_source")?,
                get_f(p, "max_rate")?,
                get_f(p, "ks_no3")?,
                get_f(p, "ks_c")?,
            ),
        )),
        "sulfate_reduction_rate" => Ok(RunOutput::Scalar(
            bio::microbiology::metabolism::sulfate_reduction_rate(
                get_f(p, "sulfate")?,
                get_f(p, "electron_donor")?,
                get_f(p, "max_rate")?,
                get_f(p, "ks_so4")?,
                get_f(p, "ks_donor")?,
            ),
        )),
        "methanogenesis_rate" => Ok(RunOutput::Scalar(
            bio::microbiology::metabolism::methanogenesis_rate(
                get_f(p, "co2")?,
                get_f(p, "h2")?,
                get_f(p, "max_rate")?,
                get_f(p, "ks_co2")?,
                get_f(p, "ks_h2")?,
                get_f(p, "temperature")?,
            ),
        )),
        "anammox_rate" => Ok(RunOutput::Scalar(
            bio::microbiology::metabolism::anammox_rate(
                get_f(p, "nh4")?,
                get_f(p, "no2")?,
                get_f(p, "max_rate")?,
                get_f(p, "ks_nh4")?,
                get_f(p, "ks_no2")?,
            ),
        )),
        "iron_oxidation_rate" => Ok(RunOutput::Scalar(
            bio::microbiology::metabolism::iron_oxidation_rate(
                get_f(p, "fe2")?,
                get_f(p, "o2")?,
                get_f(p, "ph")?,
                get_f(p, "max_rate")?,
            ),
        )),
        "bioremediation_degradation" => Ok(RunOutput::Scalar(
            bio::microbiology::metabolism::bioremediation_degradation(
                get_f(p, "contaminant")?,
                get_f(p, "biomass")?,
                get_f(p, "max_rate")?,
                get_f(p, "ks")?,
                get_f(p, "inhibition_conc")?,
            ),
        )),
        "quorum_sensing_ahl" => Ok(RunOutput::Scalar(
            bio::microbiology::quorum::quorum_sensing_ahl(
                get_f(p, "n")?,
                get_f(p, "k_prod")?,
                get_f(p, "k_deg")?,
                get_f(p, "diffusion")?,
            ),
        )),
        "quorum_activation" => Ok(RunOutput::Scalar(
            bio::microbiology::quorum::quorum_activation(
                get_f(p, "ahl")?,
                get_f(p, "threshold")?,
                get_f(p, "n")?,
            ),
        )),
        "quorum_bistable" => Ok(RunOutput::Vector(
            bio::microbiology::quorum::quorum_bistable(
                get_f(p, "ahl0")?,
                get_f(p, "n_cells")?,
                get_f(p, "k_prod")?,
                get_f(p, "k_deg")?,
                get_f(p, "k_auto")?,
                get_f(p, "threshold")?,
                get_f(p, "hill_n")?,
                get_f(p, "dt")?,
                get_u(p, "steps")?,
            ),
        )),
        "biofilm_growth" => Ok(RunOutput::Scalar(
            bio::microbiology::quorum::biofilm_growth(
                get_f(p, "b")?,
                get_f(p, "mu")?,
                get_f(p, "k_attach")?,
                get_f(p, "planktonic")?,
                get_f(p, "k_detach")?,
                get_f(p, "k_max")?,
            ),
        )),
        "biofilm_simulate" => Ok(RunOutput::PairVec(
            bio::microbiology::quorum::biofilm_simulate(
                get_f(p, "b0")?,
                get_f(p, "planktonic0")?,
                get_f(p, "mu")?,
                get_f(p, "k_attach")?,
                get_f(p, "k_detach")?,
                get_f(p, "k_max")?,
                get_f(p, "growth_p")?,
                get_f(p, "dt")?,
                get_u(p, "steps")?,
            ),
        )),
        "antibiotic_kill" => Ok(RunOutput::Scalar(
            bio::microbiology::quorum::antibiotic_kill(
                get_f(p, "n")?,
                get_f(p, "mic")?,
                get_f(p, "conc")?,
                get_f(p, "k_max")?,
                get_f(p, "hill")?,
            ),
        )),
        "mutation_resistance_probability" => Ok(RunOutput::Scalar(
            bio::microbiology::quorum::mutation_resistance_probability(
                get_f(p, "mu")?,
                get_f(p, "n")?,
            ),
        )),
        "anaerobic_atp_yield" => Ok(RunOutput::Scalar(
            bio::microbiology::metabolism::anaerobic_atp_yield(
                get_f(p, "glucose_moles")?,
                get_f(p, "pathway_efficiency")?,
            ),
        )),
        "biofilm_formation_rate" => Ok(RunOutput::Scalar(
            bio::microbiology::biofilm::biofilm_formation_rate(
                get_f(p, "planktonic")?,
                get_f(p, "attachment_rate")?,
                get_f(p, "surface_area")?,
                get_f(p, "detachment_rate")?,
                get_f(p, "biofilm")?,
            ),
        )),
        "extracellular_matrix_production" => Ok(RunOutput::Scalar(
            bio::microbiology::biofilm::extracellular_matrix_production(
                get_f(p, "cell_density")?,
                get_f(p, "signal")?,
                get_f(p, "max_rate")?,
                get_f(p, "threshold")?,
            ),
        )),
        _ => Err(HubError::InvalidInput(format!("unknown function: {func}"))),
    }
}