sirius_bindings/
builder.rs

1//! A builder is a type of struct that will collect configurations and once build, prodiuces a complete struct.
2//!
3use crate::prelude::*;
4use crate::sirius_config::SiriusConfig;
5use crate::traits::IntoDefault;
6
7/// The SiriusBuilder is used to set the parameters of the SiriusConfig.
8#[derive(Default)]
9pub struct SiriusBuilder<V: Version> {
10    config: SiriusConfig<V>,
11}
12
13/// The functions in this block are used to set the parameters of the SiriusBuilder.
14/// Most of the functions come from the `sirius config` command. The comments in the functions are usually a copy-paste from the `sirius config --help` command.
15impl SiriusBuilder<Version5> {
16    /// Set the maximal value of m/z ratio on which Sirius calculation will be carried.
17    ///
18    /// # Arguments
19    ///
20    /// * `maximal_mz` - The maximal m/z ratio.
21    ///
22    /// # Example
23    ///
24    /// ```
25    /// use sirius_bindings::prelude::*;
26    ///
27    /// let sirius = SiriusBuilder::default()
28    ///    .maximal_mz(1000.0).unwrap()
29    ///   .build();
30    ///
31    /// assert!(SiriusBuilder::default().maximal_mz(-67.0).is_err());
32    /// assert!(SiriusBuilder::default().maximal_mz(0.0).is_err());
33    /// assert!(SiriusBuilder::default().maximal_mz(std::f64::NAN).is_err());
34    /// assert!(SiriusBuilder::default().maximal_mz(std::f64::INFINITY).is_err());
35    /// ```
36    ///
37    pub fn maximal_mz(mut self, maximal_mz: f64) -> Result<Self, String> {
38        if maximal_mz < 0.0 {
39            return Err(format!(
40                concat!("Maximal m/z ratio must be positive. ", "You provided {}."),
41                maximal_mz
42            ));
43        }
44        if maximal_mz == 0.0 {
45            return Err("Maximal m/z ratio cannot be 0".to_string());
46        }
47        if maximal_mz.is_nan() {
48            return Err("Maximal m/z ratio cannot be NaN".to_string());
49        }
50        if maximal_mz.is_infinite() {
51            return Err("Maximal m/z ratio cannot be infinite".to_string());
52        }
53
54        self.config
55            .add_core_parameter(CoreV5::MaximalMz(maximal_mz))?;
56        Ok(self)
57    }
58
59    /// Set the number of cores to use for the calculation.
60    /// # Arguments
61    /// * `n_cores` - The number of cores to use.
62    /// # Example
63    /// ```
64    /// use sirius_bindings::prelude::*;
65    /// let sirius = SiriusBuilder::default()
66    ///  .max_cpus(4).unwrap()
67    /// .build();
68    /// ```
69    pub fn max_cpus(mut self, n_cores: usize) -> Result<Self, String> {
70        self.config.add_core_parameter(CoreV5::NCpus(n_cores))?;
71        Ok(self)
72    }
73
74    /// Activate the use of the isotope settings filter.
75    /// # Arguments
76    /// * `isotope_settings_filter` - Whether to enable the isotope settings filter.
77    ///
78    /// # Example
79    /// ```
80    /// use sirius_bindings::prelude::*;
81    /// let sirius = SiriusBuilder::default()
82    ///   .isotope_settings_filter(true).unwrap()
83    ///   .build();
84    /// ```
85    pub fn isotope_settings_filter(
86        mut self,
87        isotope_settings_filter: bool,
88    ) -> Result<Self, String> {
89        self.config
90            .add_config_parameter(ConfigV5::IsotopeSettingsFilter(isotope_settings_filter))?;
91        Ok(self)
92    }
93
94    /// Set the database to be used for formula search.
95    /// # Arguments
96    /// * `formula_search_db` - The database to be used for formula search.
97    /// # Example
98    /// ```
99    /// use sirius_bindings::prelude::*;
100    /// let sirius = SiriusBuilder::default()
101    ///  .formula_search_db(DBVector::from(vec![SearchDB::Hmdb])).unwrap()
102    /// .build();
103    ///
104    /// assert!(SiriusBuilder::default().formula_search_db(DBVector::from(vec![SearchDB::Hmdb])).is_ok());
105    /// ```
106    pub fn formula_search_db(
107        mut self,
108        formula_search_db: crate::sirius_types::DBVector,
109    ) -> Result<Self, String> {
110        self.config
111            .add_config_parameter(ConfigV5::FormulaSearchDB(formula_search_db))?;
112        Ok(self)
113    }
114
115    /// Set the database to be used for the structure search.
116    /// # Arguments
117    /// * `structure_search_db` - The database to be used for the structure search.
118    /// # Example
119    /// ```
120    /// use sirius_bindings::prelude::*;
121    /// let sirius = SiriusBuilder::default()
122    /// .structure_search_db(DBVector::from(vec![SearchDB::Zincbio])).unwrap()
123    /// .build();
124    /// ```
125    pub fn structure_search_db(
126        mut self,
127        structure_search_db: crate::sirius_types::DBVector,
128    ) -> Result<Self, String> {
129        self.config
130            .add_config_parameter(ConfigV5::StructureSearchDB(structure_search_db))?;
131        Ok(self)
132    }
133
134    /// Set the timeout seconds for each tree.
135    /// # Arguments
136    /// * `timeout_seconds_per_tree` - The timeout seconds for each tree.
137    /// # Example
138    /// ```
139    /// use sirius_bindings::prelude::*;
140    /// let sirius = SiriusBuilder::default()
141    /// .timeout_seconds_per_tree(100).unwrap()
142    /// .build();
143    /// ```
144    pub fn timeout_seconds_per_tree(
145        mut self,
146        timeout_seconds_per_tree: u32,
147    ) -> Result<Self, String> {
148        self.config
149            .add_config_parameter(ConfigV5::TimeoutSecondsPerTree(timeout_seconds_per_tree))?;
150        Ok(self)
151    }
152
153    /// Set the number of candidates.
154    /// # Arguments
155    /// * `number_of_candidates` - The number of candidates.
156    pub fn number_of_candidates(mut self, number_of_candidates: u32) -> Result<Self, String> {
157        self.config
158            .add_config_parameter(ConfigV5::NumberOfCandidates(number_of_candidates))?;
159        Ok(self)
160    }
161
162    /// Set the number of candidates per ion.
163    /// # Arguments
164    /// * `number_of_candidates_per_ion` - The number of candidates per ion.
165    pub fn number_of_candidates_per_ion(
166        mut self,
167        number_of_candidates_per_ion: u32,
168    ) -> Result<Self, String> {
169        self.config
170            .add_config_parameter(ConfigV5::NumberOfCandidatesPerIon(
171                number_of_candidates_per_ion,
172            ))?;
173        Ok(self)
174    }
175
176    /// Sets the number of structure candidates.
177    /// # Arguments
178    /// * `number_of_structure_candidates` - The number of structure candidates.
179    pub fn number_of_structure_candidates(
180        mut self,
181        number_of_structure_candidates: u32,
182    ) -> Result<Self, String> {
183        self.config
184            .add_config_parameter(ConfigV5::NumberOfStructureCandidates(
185                number_of_structure_candidates,
186            ))?;
187        Ok(self)
188    }
189
190    /// Specify if the results should be recomputed.
191    /// # Arguments
192    /// * `recompute_results` - Whether to recompute the results.
193    pub fn recompute_results(mut self, recompute_results: bool) -> Result<Self, String> {
194        self.config
195            .add_config_parameter(ConfigV5::RecomputeResults(recompute_results))?;
196        Ok(self)
197    }
198
199    /// Whether to print citations we Sirius has finished running.
200    /// # Arguments
201    /// * `print_citations` - Whether to print citations.
202    pub fn print_citations(mut self, print_citations: bool) -> Result<Self, String> {
203        self.config
204            .add_config_parameter(ConfigV5::PrintCitations(print_citations))?;
205        Ok(self)
206    }
207
208    /// This configurations define a timeout for the tree computation.
209    /// As the underlying problem is NP-hard, it might take forever to compute trees for very challenging (e.g. large mass) compounds.
210    /// Setting a time constraint allow the program to continue with other instances and just skip the challenging ones.
211    /// Note that, due to multithreading, this time constraints are not absolutely accurate.
212    /// Set the maximum number of seconds for computing a single compound. Set to 0 to disable the time constraint.
213    /// # Arguments
214    /// * `timeout_seconds_per_instance` - The maximum number of seconds for computing a single compound.
215    pub fn timeout_seconds_per_instance(
216        mut self,
217        timeout_seconds_per_instance: u32,
218    ) -> Result<Self, String> {
219        self.config
220            .add_config_parameter(ConfigV5::TimeoutSecondsPerInstance(
221                timeout_seconds_per_instance,
222            ))?;
223        Ok(self)
224    }
225
226    /// Specifies if the list of Molecular Formula Identifications is filtered by a soft threshold (calculateThreshold)
227    /// before CSI:FingerID predictions are calculated.
228    /// # Arguments
229    /// * `formula_settings_filter` - Whether to filter the list of Molecular Formula Identifications.
230    pub fn formula_result_threshold(
231        mut self,
232        formula_result_threshold: bool,
233    ) -> Result<Self, String> {
234        self.config
235            .add_config_parameter(ConfigV5::FormulaResultThreshold(formula_result_threshold))?;
236        Ok(self)
237    }
238
239    /// Candidates matching the lipid class estimated by El Gordo will be tagged.
240    /// The lipid class will only be available if El Gordo predicts that the MS/MS is a lipid spectrum.
241    /// If this parameter is set to 'false' El Gordo will still be executed and e.g. improve the fragmentation tree,
242    /// but the matching candidates will not be tagged as lipid class.
243    /// # Arguments
244    /// * `inject_el_gordo_compounds` - Whether to inject El Gordo compounds.
245    pub fn inject_el_gordo_compounds(
246        mut self,
247        inject_el_gordo_compounds: bool,
248    ) -> Result<Self, String> {
249        self.config
250            .add_config_parameter(ConfigV5::InjectElGordoCompounds(inject_el_gordo_compounds))?;
251        Ok(self)
252    }
253
254    /// Sets the median noise intensity.
255    /// # Arguments
256    /// * `median_noise_intensity` - The median noise intensity.
257    pub fn median_noise_intensity(mut self, median_noise_intensity: f32) -> Result<Self, String> {
258        if median_noise_intensity < 0.0 {
259            return Err(format!(
260                concat!(
261                    "Median noise intensity must be positive. ",
262                    "You provided {}."
263                ),
264                median_noise_intensity
265            ));
266        }
267        self.config
268            .add_config_parameter(ConfigV5::MedianNoiseIntensity(median_noise_intensity))?;
269        Ok(self)
270    }
271
272    /// The average absolute deviation between theoretical and measured intensity of isotope peaks.
273    ///
274    /// Do not change this parameter without a good reason!    
275    ///
276    /// Ideally use the `ms1_absolute_intensity_error_default()` function.
277    /// # Arguments
278    /// * `ms1_absolute_intensity_error` - The average absolute deviation between theoretical and measured intensity of isotope peaks.
279    pub fn ms1_absolute_intensity_error(
280        mut self,
281        ms1_absolute_intensity_error: f32,
282    ) -> Result<Self, String> {
283        if ms1_absolute_intensity_error < 0.0 {
284            return Err(format!(
285                concat!(
286                    "MS1 absolute intensity error must be positive. ",
287                    "You provided {}."
288                ),
289                ms1_absolute_intensity_error
290            ));
291        }
292        self.config
293            .add_config_parameter(ConfigV5::MS1AbsoluteIntensityError(
294                ms1_absolute_intensity_error,
295            ))?;
296        Ok(self)
297    }
298
299    /// Ignore isotope peaks below this intensity.
300    /// This value should reflect the smallest relative intensive which is still above noise level.
301    /// Obviously, this is hard to judge without having absolute values.
302    /// Keeping this value around 1 percent is fine for most settings. Set it to smaller values if you trust your small intensities.
303    /// # Arguments
304    /// * `ms1_minimal_intensity_to_consider` - The minimal intensity to consider.
305    pub fn ms1_minimal_intensity_to_consider(
306        mut self,
307        ms1_minimal_intensity_to_consider: f32,
308    ) -> Result<Self, String> {
309        if ms1_minimal_intensity_to_consider < 0.0 {
310            return Err(format!(
311                concat!(
312                    "MS1 minimal intensity to consider must be positive. ",
313                    "You provided {}."
314                ),
315                ms1_minimal_intensity_to_consider
316            ));
317        }
318        self.config
319            .add_config_parameter(ConfigV5::MS1MinimalIntensityToConsider(
320                ms1_minimal_intensity_to_consider,
321            ))?;
322        Ok(self)
323    }
324
325    /// The average relative deviation between theoretical and measured intensity of isotope peaks.
326    ///
327    /// Do not change this parameter without a good reason!
328    ///
329    /// Ideally use the `ms1_relative_intensity_error_default()` function.
330    /// # Arguments
331    /// * `ms1_relative_intensity_error` - The average relative deviation between theoretical and measured intensity of isotope peaks.
332    pub fn ms1_relative_intensity_error(
333        mut self,
334        ms1_relative_intensity_error: f32,
335    ) -> Result<Self, String> {
336        if ms1_relative_intensity_error < 0.0 {
337            return Err(format!(
338                concat!(
339                    "MS1 relative intensity error must be positive. ",
340                    "You provided {}."
341                ),
342                ms1_relative_intensity_error
343            ));
344        }
345        self.config
346            .add_config_parameter(ConfigV5::MS1RelativeIntensityError(
347                ms1_relative_intensity_error,
348            ))?;
349        Ok(self)
350    }
351
352    /// Sets the noise threshold settings absolute threshold.
353    /// # Arguments
354    /// * `noise_threshold_settings_absolute_threshold` - The noise threshold settings absolute threshold.
355    pub fn noise_threshold_settings_intensity_threshold(
356        mut self,
357        noise_threshold_settings_intensity_threshold: f32,
358    ) -> Result<Self, String> {
359        if noise_threshold_settings_intensity_threshold < 0.0 {
360            return Err(format!(
361                concat!(
362                    "Noise threshold settings intensity threshold must be positive. ",
363                    "You provided {}."
364                ),
365                noise_threshold_settings_intensity_threshold
366            ));
367        }
368        self.config
369            .add_config_parameter(ConfigV5::NoiseThresholdSettingsIntensityThreshold(
370                noise_threshold_settings_intensity_threshold,
371            ))?;
372        Ok(self)
373    }
374
375    /// Sets the noise threshold settings maximal number of peaks.
376    /// # Arguments
377    /// * `noise_threshold_settings_maximal_number_of_peaks` - The noise threshold settings maximal number of peaks.
378    pub fn noise_threshold_settings_maximal_number_of_peaks(
379        mut self,
380        noise_threshold_settings_maximal_number_of_peaks: u32,
381    ) -> Result<Self, String> {
382        self.config
383            .add_config_parameter(ConfigV5::NoiseThresholdSettingsMaximalNumberOfPeaks(
384                noise_threshold_settings_maximal_number_of_peaks,
385            ))?;
386        Ok(self)
387    }
388
389    /// Sets if you want to cluster compounds before running ZODIAC.
390    /// # Arguments
391    /// * `zodiac_cluster_compounds` - Whether to cluster compounds before running ZODIAC.
392    pub fn zodiac_cluster_compounds(
393        mut self,
394        zodiac_cluster_compounds: bool,
395    ) -> Result<Self, String> {
396        self.config
397            .add_config_parameter(ConfigV5::ZodiacClusterCompounds(zodiac_cluster_compounds))?;
398        Ok(self)
399    }
400
401    /// Minimum number of candidates per compound which are forced to have at least \[minLocalConnections\] connections to other compounds.
402    /// E.g. 2 candidates per compound must have at least 10 connections to other compounds.
403    /// # Arguments
404    /// * `zodiac_edge_filter_thresholds_min_local_candidates` - The minimum number of candidates per compound.
405    pub fn zodiac_edge_filter_thresholds_min_local_candidates(
406        mut self,
407        zodiac_edge_filter_thresholds_min_local_candidates: u32,
408    ) -> Result<Self, String> {
409        self.config.add_config_parameter(
410            ConfigV5::ZodiacEdgeFilterThresholdsMinLocalCandidates(
411                zodiac_edge_filter_thresholds_min_local_candidates,
412            ),
413        )?;
414        Ok(self)
415    }
416
417    ///  Minimum number of connections per candidate which are forced for at least \[minLocalCandidates\] candidates to other compounds.
418    /// E.g. 2 candidates per compound must have at least 10 connections to other compounds.
419    /// # Arguments
420    /// * `zodiac_edge_filter_thresholds_min_local_connections` - The minimum number of connections per candidate.
421    pub fn zodiac_edge_filter_thresholds_min_local_connections(
422        mut self,
423        zodiac_edge_filter_thresholds_min_local_connections: u32,
424    ) -> Result<Self, String> {
425        self.config.add_config_parameter(
426            ConfigV5::ZodiacEdgeFilterThresholdsMinLocalConnections(
427                zodiac_edge_filter_thresholds_min_local_connections,
428            ),
429        )?;
430        Ok(self)
431    }
432
433    /// Defines the proportion of edges of the complete network which will be ignored.
434    /// # Arguments
435    /// * `zodiac_edge_filter_thresholds_threshold_filter` - The proportion of edges of the complete network which will be ignored.
436    pub fn zodiac_edge_filter_thresholds_threshold_filter(
437        mut self,
438        zodiac_edge_filter_thresholds_threshold_filter: f32,
439    ) -> Result<Self, String> {
440        if zodiac_edge_filter_thresholds_threshold_filter < 0.0 {
441            return Err(format!(
442                concat!(
443                    "Zodiac edge filter thresholds threshold filter must be positive. ",
444                    "You provided {}."
445                ),
446                zodiac_edge_filter_thresholds_threshold_filter
447            ));
448        }
449        self.config
450            .add_config_parameter(ConfigV5::ZodiacEdgeFilterThresholdsThresholdFilter(
451                zodiac_edge_filter_thresholds_threshold_filter,
452            ))?;
453        Ok(self)
454    }
455
456    /// Number of epochs considered as 'burn-in period'.
457    /// Samples from the beginning of a Markov chain do not accurately represent the desired distribution of candidates and are not used to estimate the ZODIAC score.
458    /// # Arguments
459    /// * `zodiac_epochs_burn_in_period` - The number of epochs considered as 'burn-in period'.
460    pub fn zodiac_epochs_burn_in_period(
461        mut self,
462        zodiac_epochs_burn_in_period: u32,
463    ) -> Result<Self, String> {
464        self.config
465            .add_config_parameter(ConfigV5::ZodiacEpochsBurnInPeriod(
466                zodiac_epochs_burn_in_period,
467            ))?;
468        Ok(self)
469    }
470
471    /// Number of epochs to run the Gibbs sampling. When multiple Markov chains are computed, all chains' iterations sum up to this value.
472    /// # Arguments
473    /// * `zodiac_epochs_iterations` - The number of epochs to run the Gibbs sampling.
474    pub fn zodiac_epochs_iterations(
475        mut self,
476        zodiac_epochs_number_of_epochs: u32,
477    ) -> Result<Self, String> {
478        self.config
479            .add_config_parameter(ConfigV5::ZodiacEpochsIterations(
480                zodiac_epochs_number_of_epochs,
481            ))?;
482        Ok(self)
483    }
484
485    /// Number of separate Gibbs sampling runs.
486    /// # Arguments
487    /// * `zodiac_epochs_number_of_markov_chains` - The number of separate Gibbs sampling runs.
488    pub fn zodiac_epochs_number_of_markov_chains(
489        mut self,
490        zodiac_epochs_number_of_markov_chains: u32,
491    ) -> Result<Self, String> {
492        self.config
493            .add_config_parameter(ConfigV5::ZodiacEpochsNumberOfMarkovChains(
494                zodiac_epochs_number_of_markov_chains,
495            ))?;
496        Ok(self)
497    }
498
499    /// Lambda used in the scoring function of spectral library hits. The higher this value the higher are librar hits weighted in ZODIAC scoring.
500    /// # Arguments
501    /// * `zodiac_library_scoring_lambda` - The lambda used in the scoring function of spectral library hits.
502    pub fn zodiac_library_scoring_lambda(
503        mut self,
504        zodiac_library_scoring_lambda: u32,
505    ) -> Result<Self, String> {
506        self.config
507            .add_config_parameter(ConfigV5::ZodiacLibraryScoringLambda(
508                zodiac_library_scoring_lambda,
509            ))?;
510        Ok(self)
511    }
512
513    /// Set the minimal cosine value. Values must be between 0 and 1.
514    /// # Arguments
515    /// * `zodiac_library_scoring_min_cosine` - The minimal cosine value.
516    /// # Example
517    /// ```
518    /// use sirius_bindings::prelude::*;
519    /// let sirius = SiriusBuilder::default()
520    /// .zodiac_library_scoring_min_cosine(0.5).unwrap()
521    /// .build();
522    /// ```
523    /// # Errors
524    /// If the value is not in the range 0 and 1.
525    /// # Example
526    /// ```
527    /// use sirius_bindings::prelude::*;
528    /// assert!(SiriusBuilder::default().zodiac_library_scoring_min_cosine(1.1).is_err());
529    /// assert!(SiriusBuilder::default().zodiac_library_scoring_min_cosine(-0.1).is_err());
530    /// ```
531    pub fn zodiac_library_scoring_min_cosine(
532        mut self,
533        zodiac_library_scoring_min_cosine: f32,
534    ) -> Result<Self, String> {
535        // Value must be in [0,1].
536        if !(0.0..=1.0).contains(&zodiac_library_scoring_min_cosine) {
537            // fast and easy way to check interval of values in Rust. Then add the "!" to negate the condition.
538            return Err(format!(
539                concat!(
540                    "Zodiac library scoring min cosine must be in [0,1]. ",
541                    "You provided {}."
542                ),
543                zodiac_library_scoring_min_cosine
544            ));
545        }
546        self.config
547            .add_config_parameter(ConfigV5::ZodiacLibraryScoringMinCosine(
548                zodiac_library_scoring_min_cosine,
549            ))?;
550        Ok(self)
551    }
552
553    /// Maximum number of candidate molecular formulas (fragmentation trees computed by SIRIUS) per compound which are considered by ZODIAC.
554    /// This is the threshold used for all compounds with mz below 300 m/z and is used to interpolate the number of candidates for larger compounds.
555    /// If lower than 0, all available candidates are considered.
556    /// # Arguments
557    /// * `zodiac_number_of_considered_candidates_at_300_mz` - The maximum number of candidate molecular formulas.
558    pub fn zodiac_number_of_considered_candidates_at_300_mz(
559        mut self,
560        zodiac_number_of_considered_candidates_at_300_mz: i32,
561    ) -> Result<Self, String> {
562        self.config
563            .add_config_parameter(ConfigV5::ZodiacNumberOfConsideredCandidatesAt300Mz(
564                zodiac_number_of_considered_candidates_at_300_mz,
565            ))?;
566        Ok(self)
567    }
568
569    /// Maximum number of candidate molecular formulas (fragmentation trees computed by SIRIUS) per compound which are considered by ZODIAC.
570    /// This is the threshold used for all compounds with mz below 800 m/z and is used to interpolate the number of candidates for larger compounds.
571    /// If lower than 0, all available candidates are considered.
572    /// # Arguments
573    /// * `zodiac_number_of_considered_candidates_at_800_mz` - The maximum number of candidate molecular formulas.
574    pub fn zodiac_number_of_considered_candidates_at_800_mz(
575        mut self,
576        zodiac_number_of_considered_candidates_at_800_mz: i32,
577    ) -> Result<Self, String> {
578        self.config
579            .add_config_parameter(ConfigV5::ZodiacNumberOfConsideredCandidatesAt800Mz(
580                zodiac_number_of_considered_candidates_at_800_mz,
581            ))?;
582        Ok(self)
583    }
584
585    /// Ratio of candidate molecular formulas (fragmentation trees computed by SIRIUS) per compound which are forced for each ionization to be
586    /// considered by ZODIAC. This depends on the number of candidates ZODIAC considers.
587    /// E.g. if 50 candidates are considered and a ratio of 0.2 is set,
588    /// at least 10 candidates per ionization will be considered, which might increase the number of candidates above 50.
589    /// # Arguments
590    /// * `zodiac_ratio_of_considered_candidates_per_ionization` - The ratio of candidate molecular formulas.
591    pub fn zodiac_ratio_of_considered_candidates_per_ionization(
592        mut self,
593        zodiac_ratio_of_considered_candidates_per_ionization: f32,
594    ) -> Result<Self, String> {
595        if !(0.0..=1.0).contains(&zodiac_ratio_of_considered_candidates_per_ionization) {
596            return Err(format!(
597                concat!(
598                    "Zodiac ratio of considered candidates per ionization must be in [0,1]. ",
599                    "You provided {}."
600                ),
601                zodiac_ratio_of_considered_candidates_per_ionization
602            ));
603        }
604        self.config.add_config_parameter(
605            ConfigV5::ZodiacRatioOfConsideredCandidatesPerIonization(
606                zodiac_ratio_of_considered_candidates_per_ionization,
607            ),
608        )?;
609        Ok(self)
610    }
611
612    /// As default ZODIAC runs a 2-step approach. First running 'good quality compounds' only, and afterwards including the remaining.
613    /// # Arguments
614    /// * `zodiac_run_in_two_steps` - Whether to run ZODIAC in two steps.
615    pub fn zodiac_run_in_two_steps(
616        mut self,
617        zodiac_run_in_two_steps: bool,
618    ) -> Result<Self, String> {
619        self.config
620            .add_config_parameter(ConfigV5::ZodiacRunInTwoSteps(zodiac_run_in_two_steps))?;
621        Ok(self)
622    }
623
624    /// Mass accuracy setting for MS1 spectra. Mass accuracies are always written as "X ppm (Y Da)"
625    /// with X and Y are numerical values. The ppm is a relative measure
626    /// (parts per million), Da is an absolute measure. For each mass, the
627    /// maximum of relative and absolute is used.
628    /// # Arguments
629    /// * `ms1_mass_deviation_allowed_mass_deviation` - The mass accuracy setting for MS1 spectra.
630    pub fn ms1_mass_deviation_allowed_mass_deviation(
631        mut self,
632        ms1_mass_deviation_allowed_mass_deviation: MassDeviation,
633    ) -> Result<Self, String> {
634        self.config
635            .add_config_parameter(ConfigV5::MS1MassDeviationAllowedMassDeviation(
636                ms1_mass_deviation_allowed_mass_deviation.must_be_positive()?,
637            ))?;
638        Ok(self)
639    }
640
641    /// The difference is mass deviation between two masses.
642    /// # Arguments
643    /// * `ms1_mass_deviation_mass_difference_deviation` - The mass deviation between two masses.
644    pub fn ms1_mass_deviation_mass_difference_deviation(
645        mut self,
646        ms1_mass_deviation_mass_difference_deviation: MassDeviation,
647    ) -> Result<Self, String> {
648        self.config
649            .add_config_parameter(ConfigV5::MS1MassDeviationMassDifferenceDeviation(
650                ms1_mass_deviation_mass_difference_deviation.must_be_positive()?,
651            ))?;
652        Ok(self)
653    }
654
655    /// The standard mass deviation for MS1 spectra.
656    /// # Arguments
657    /// * `ms1_mass_deviation_standard_mass_deviation` - The standard mass deviation for MS1 spectra.
658    pub fn ms1_mass_deviation_standard_mass_deviation(
659        mut self,
660        ms1_mass_deviation_standard_mass_deviation: MassDeviation,
661    ) -> Result<Self, String> {
662        self.config
663            .add_config_parameter(ConfigV5::MS1MassDeviationStandardMassDeviation(
664                ms1_mass_deviation_standard_mass_deviation.must_be_positive()?,
665            ))?;
666        Ok(self)
667    }
668
669    /// The standard mass deviation for MS2 spectra.
670    /// # Arguments
671    /// * `ms2_mass_deviation_mass_difference_deviation` - The standard mass deviation for MS2 spectra.
672    pub fn ms2_mass_deviation_standard_mass_deviation(
673        mut self,
674        ms2_mass_deviation_standard_mass_deviation: MassDeviation,
675    ) -> Result<Self, String> {
676        self.config
677            .add_config_parameter(ConfigV5::MS2MassDeviationStandardMassDeviation(
678                ms2_mass_deviation_standard_mass_deviation.must_be_positive()?,
679            ))?;
680        Ok(self)
681    }
682
683    /// Mass accuracy setting for MS2 spectra. Mass accuracies are always written as "X ppm (Y Da)"
684    /// with X and Y are numerical values. The ppm is a relative measure
685    /// (parts per million), Da is an absolute measure. For each mass, the
686    /// maximum of relative and absolute is used.
687    /// # Arguments
688    /// * `ms2_mass_deviation_allowed_mass_deviation` - The mass accuracy setting for MS2 spectra.
689    pub fn ms2_mass_deviation_allowed_mass_deviation(
690        mut self,
691        ms2_mass_deviation_allowed_mass_deviation: MassDeviation,
692    ) -> Result<Self, String> {
693        self.config
694            .add_config_parameter(ConfigV5::MS2MassDeviationAllowedMassDeviation(
695                ms2_mass_deviation_allowed_mass_deviation.must_be_positive()?,
696            ))?;
697        Ok(self)
698    }
699
700    /// Detectable elements are added to the chemical alphabet, if there are indications for them (e.g. in isotope pattern)
701    /// # Arguments
702    /// * `formula_settings_detectable` - The detectable elements.
703    pub fn formula_settings_detectable(
704        mut self,
705        formula_settings_detectable: AtomVector,
706    ) -> Result<Self, String> {
707        self.config
708            .add_config_parameter(ConfigV5::FormulaSettingsDetectable(
709                formula_settings_detectable,
710            ))?;
711        Ok(self)
712    }
713
714    /// These configurations hold the information how to
715    /// autodetect elements based on the given formula constraints.
716    /// Note: If the compound is already assigned to a
717    /// specific molecular formula, this annotation is
718    /// ignored. Enforced elements are always considered.
719    /// # Arguments
720    /// * `formula_settings_enforced` - The enforced elements.
721    pub fn formula_settings_enforced(
722        mut self,
723        formula_settings_enforced: AtomVector,
724    ) -> Result<Self, String> {
725        self.config
726            .add_config_parameter(ConfigV5::FormulaSettingsEnforced(formula_settings_enforced))?;
727        Ok(self)
728    }
729
730    /// Fallback elements are used, if the auto-detection fails (e.g. no isotope pattern available)
731    /// # Arguments
732    /// * `formula_settings_fallback` - The fallback elements.
733    pub fn formula_settings_fallback(
734        mut self,
735        formula_settings_fallback: AtomVector,
736    ) -> Result<Self, String> {
737        self.config
738            .add_config_parameter(ConfigV5::FormulaSettingsFallback(formula_settings_fallback))?;
739        Ok(self)
740    }
741
742    /// Enable/Disable the hypothesen driven recalibration of MS/MS spectra.
743    /// Must be either 'ALLOWED' or FORBIDDEN'.
744    /// # Arguments
745    /// * `forbid_recalibration` - Whether to forbid recalibration.
746    pub fn forbid_recalibration(
747        mut self,
748        forbid_recalibration: ForbidRecalibration,
749    ) -> Result<Self, String> {
750        self.config
751            .add_config_parameter(ConfigV5::ForbidRecalibration(forbid_recalibration))?;
752        Ok(self)
753    }
754
755    /// Set minimum m/z to enable heuristic preprocessing. The heuristic will be used to initially rank the formula candidates.
756    /// The Top (NumberOfCandidates) candidates will then be computed exactly by solving the ILP.
757    /// # Arguments
758    /// * `use_heuristic_mz_to_use_heuristic` - The minimum m/z to enable heuristic preprocessing.
759    pub fn use_heuristic_mz_to_use_heuristic(
760        mut self,
761        use_heuristic_mz_to_use_heuristic: u32,
762    ) -> Result<Self, String> {
763        self.config
764            .add_config_parameter(ConfigV5::UseHeuristicMZToUseHeuristic(
765                use_heuristic_mz_to_use_heuristic,
766            ))?;
767        Ok(self)
768    }
769
770    /// Set minimum m/z to only use heuristic tree computation. No exact tree computation (ILP) will be performed for this compounds.
771    /// # Arguments
772    /// * `use_heuristic_mz_to_use_heuristic_only` - The minimum m/z to only use heuristic tree computation.
773    pub fn use_heuristic_mz_to_use_heuristic_only(
774        mut self,
775        use_heuristic_mz_to_use_heuristic: u32,
776    ) -> Result<Self, String> {
777        self.config
778            .add_config_parameter(ConfigV5::UseHeuristicMZToUseHeuristicOnly(
779                use_heuristic_mz_to_use_heuristic,
780            ))?;
781        Ok(self)
782    }
783
784    ///  Detectable ion modes which are only considered if there is an indication in the MS1 scan (e.g. correct mass delta).
785    pub fn adduct_settings_detectable(
786        mut self,
787        adduct_settings_detectable: AdductsVector,
788    ) -> Result<Self, String> {
789        self.config
790            .add_config_parameter(ConfigV5::AdductSettingsDetectable(
791                adduct_settings_detectable,
792            ))?;
793        Ok(self)
794    }
795
796    /// Fallback ion modes which are considered if the auto detection did not find any indication for an ion mode.
797    /// # Arguments
798    /// * `adduct_settings_fallback` - The fallback ion modes.
799    pub fn adduct_settings_fallback(
800        mut self,
801        adduct_settings_fallback: AdductsVector,
802    ) -> Result<Self, String> {
803        self.config
804            .add_config_parameter(ConfigV5::AdductSettingsFallback(adduct_settings_fallback))?;
805        Ok(self)
806    }
807
808    /// Configuration profile to store instrument specific algorithm properties. Some of the default profiles are: 'qtof', 'orbitrap', 'fticr'.
809    /// # Arguments
810    /// * `algorithm_profile` - The algorithm profile.
811    pub fn algorithm_profile(mut self, algorithm_profile: Instruments) -> Result<Self, String> {
812        self.config
813            .add_config_parameter(ConfigV5::AlgorithmProfile(algorithm_profile))?;
814        Ok(self)
815    }
816
817    /// Keywords that can be assigned to a input spectrum to judge its quality.
818    /// Available keywords are: Good, LowIntensity, NoMS1Peak, FewPeaks, Chimeric, NotMonoisotopicPeak, PoorlyExplained
819    /// # Arguments
820    /// * `compound_quality` - The compound quality.
821    pub fn compound_quality(mut self, compound_quality: CompoundQuality) -> Result<Self, String> {
822        self.config
823            .add_config_parameter(ConfigV5::CompoundQuality(compound_quality))?;
824        Ok(self)
825    }
826
827    /// Enforced ion modes that are always considered.
828    /// # Arguments
829    /// * `adduct_settings_enforced` - The enforced ion modes.
830    pub fn adduct_settings_enforced(
831        mut self,
832        adduct_settings_enforced: AdductSettingsEnforced,
833    ) -> Result<Self, String> {
834        self.config
835            .add_config_parameter(ConfigV5::AdductSettingsEnforced(adduct_settings_enforced))?;
836        Ok(self)
837    }
838
839    /// This configuration holds a set of user given formulas to be used as candidates for SIRIUS
840    /// Note: This set might be merged with other sources like formulas from databases
841    /// Set of Molecular Formulas to be used as candidates for molecular formula estimation with SIRIUS
842    /// # Arguments
843    /// * `candidate_formulas` - The candidate formulas.
844    pub fn candidate_formulas(
845        mut self,
846        candidate_formulas: CandidateFormulas,
847    ) -> Result<Self, String> {
848        self.config
849            .add_config_parameter(ConfigV5::CandidateFormulas(candidate_formulas))?;
850        Ok(self)
851    }
852
853    /// Allows the USER to Specify the ScoreType that is used to rank the list of Molecular Formula Identifications
854    /// before CSI:FingerID predictions are calculated. Auto means that this ScoreType is automatically set depending on the executed workflow.
855    /// # Arguments
856    /// * `formula_result_ranking_score` - The score type that is used to rank the list of Molecular Formula Identifications.
857    pub fn formula_result_ranking_score(
858        mut self,
859        formula_result_ranking_score: FormulaResultRankingScore,
860    ) -> Result<Self, String> {
861        self.config
862            .add_config_parameter(ConfigV5::FormulaResultRankingScore(
863                formula_result_ranking_score,
864            ))?;
865        Ok(self)
866    }
867
868    /// Wheter to use the isotopes for the MS2 spectra.
869    pub fn isotope_ms2_settings(
870        mut self,
871        isotope_ms2_settings: IsotopeMS2Settings,
872    ) -> Result<Self, String> {
873        self.config
874            .add_config_parameter(ConfigV5::IsotopeMS2Settings(isotope_ms2_settings))?;
875        Ok(self)
876    }
877
878    /// multiplier for the isotope score. Set to 0 to disable isotope scoring. Otherwise, the score from isotope pattern analysis is multiplied with this coefficient.
879    /// Set to a value larger than one if your isotope pattern data is of much better quality than your MS/MS data.
880    /// # Arguments
881    /// * `isotope_settings_multiplier` - The multiplier for the isotope score.
882    pub fn isotope_settings_multiplier(
883        mut self,
884        isotope_settings_multiplier: u32,
885    ) -> Result<Self, String> {
886        self.config
887            .add_config_parameter(ConfigV5::IsotopeSettingsMultiplier(
888                isotope_settings_multiplier,
889            ))?;
890        Ok(self)
891    }
892
893    /// The absolute threshold for the noise
894    /// # Arguments
895    /// * `noise_threshold_settings_absolute_threshold` - The absolute threshold for the noise.
896    pub fn noise_threshold_settings_absolute_threshold(
897        mut self,
898        noise_threshold_settings_absolute_threshold: u32,
899    ) -> Result<Self, String> {
900        self.config
901            .add_config_parameter(ConfigV5::NoiseThresholdSettingsAbsoluteThreshold(
902                noise_threshold_settings_absolute_threshold,
903            ))?;
904        Ok(self)
905    }
906
907    /// The base peak for the noise.
908    /// # Arguments
909    /// * `noise_threshold_settings_base_peak` - The base peak for the noise.
910    pub fn noise_threshold_settings_base_peak(
911        mut self,
912        noise_threshold_settings_base_peak: BasePeak,
913    ) -> Result<Self, String> {
914        self.config
915            .add_config_parameter(ConfigV5::NoiseThresholdSettingsBasePeak(
916                noise_threshold_settings_base_peak,
917            ))?;
918        Ok(self)
919    }
920
921    /// Setups the algorithm for the structure predictors. This should be CSI:FingerID
922    /// # Arguments
923    /// * `structure_predictors` - The algorithm for the structure predictors.
924    pub fn structure_predictors(
925        mut self,
926        structure_predictors: StructurePredictors,
927    ) -> Result<Self, String> {
928        self.config
929            .add_config_parameter(ConfigV5::StructurePredictors(structure_predictors))?;
930        Ok(self)
931    }
932
933    /// An adduct switch is a switch of the ionization mode within a spectrum, e.g. an ion replaces an
934    /// sodium adduct with a protonation during fragmentation. Such adduct switches heavily increase the
935    /// complexity of the analysis, but for certain adducts they might happen
936    /// regularly. Adduct switches are written in the form  {@literal a -> b, a -> c, d -> c} where a, b,
937    /// c, and d are adducts and  {@literal a -> b} denotes an allowed switch from a to b within the MS/MS spectrum.
938    /// # Arguments
939    /// * `possible_adduct_switches` - The possible adduct switches.
940    pub fn possible_adduct_switches(
941        mut self,
942        possible_adduct_switches: PossibleAdductSwitches,
943    ) -> Result<Self, String> {
944        self.config
945            .add_config_parameter(ConfigV5::PossibleAdductSwitches(possible_adduct_switches))?;
946        Ok(self)
947    }
948
949    /// End `sirius config` command parameters.
950
951    ///
952    ///
953    ///
954    ///
955    /// Wether to enable the Formula module.
956    pub fn enable_formula(mut self) -> Result<Self, String> {
957        self.config.add_formula_parameter(FormulaV5::Enabled)?;
958        Ok(self)
959    }
960
961    /// Set whether to display the help of Formula.
962    pub fn formula_help(mut self) -> Result<Self, String> {
963        self.config.add_formula_parameter(FormulaV5::Help)?;
964        Ok(self)
965    }
966
967    /// Set whether to display the version of Formula.
968    pub fn formula_version(mut self) -> Result<Self, String> {
969        self.config.add_formula_parameter(FormulaV5::Version)?;
970        Ok(self)
971    }
972
973    /// Wether to enable the Zodiac module.
974    pub fn enable_zodiac(mut self) -> Result<Self, String> {
975        self.config.add_zodiac_parameter(ZodiacV5::Enabled)?;
976        Ok(self)
977    }
978
979    /// Set whether to display the help of Zodiac.
980    pub fn zodiac_help(mut self) -> Result<Self, String> {
981        self.config.add_zodiac_parameter(ZodiacV5::Help)?;
982        Ok(self)
983    }
984
985    /// Set whether to display the version of Zodiac.
986    pub fn zodiac_version(mut self) -> Result<Self, String> {
987        self.config.add_zodiac_parameter(ZodiacV5::Version)?;
988        Ok(self)
989    }
990
991    /// Wether to enable the Fingerprint module.
992    pub fn enable_fingerprint(mut self) -> Result<Self, String> {
993        self.config
994            .add_fingerprint_parameter(FingerprintV5::Enabled)?;
995        Ok(self)
996    }
997
998    /// Set whether to display the help of Fingerprint.
999    pub fn fingerprint_help(mut self) -> Result<Self, String> {
1000        self.config.add_fingerprint_parameter(FingerprintV5::Help)?;
1001        Ok(self)
1002    }
1003
1004    /// Set whether to display the version of Fingerprint.
1005    pub fn fingerprint_version(mut self) -> Result<Self, String> {
1006        self.config
1007            .add_fingerprint_parameter(FingerprintV5::Version)?;
1008        Ok(self)
1009    }
1010
1011    /// Wether to enable the Structure module.
1012    pub fn enable_structure(mut self) -> Result<Self, String> {
1013        self.config.add_structure_parameter(StructureV5::Enabled)?;
1014        Ok(self)
1015    }
1016
1017    /// Set whether to display the help of Structure.
1018    pub fn structure_help(mut self) -> Result<Self, String> {
1019        self.config.add_structure_parameter(StructureV5::Help)?;
1020        Ok(self)
1021    }
1022
1023    /// Set whether to display the version of Structure.
1024    pub fn structure_version(mut self) -> Result<Self, String> {
1025        self.config.add_structure_parameter(StructureV5::Version)?;
1026        Ok(self)
1027    }
1028
1029    /// Whether to enable the Canopus module.
1030    pub fn enable_canopus(mut self) -> Result<Self, String> {
1031        self.config.add_canopus_parameter(CanopusV5::Enabled)?;
1032        Ok(self)
1033    }
1034
1035    /// Set whether to display the help of Canopus.
1036    pub fn canopus_help(mut self) -> Result<Self, String> {
1037        self.config.add_canopus_parameter(CanopusV5::Help)?;
1038        Ok(self)
1039    }
1040
1041    /// Set whether to display the version of Canopus.
1042    pub fn canopus_version(mut self) -> Result<Self, String> {
1043        self.config.add_canopus_parameter(CanopusV5::Version)?;
1044        Ok(self)
1045    }
1046
1047    /// Whether to enable the WriteSummaries module.
1048    pub fn enable_write_summaries(mut self) -> Result<Self, String> {
1049        self.config
1050            .add_write_summaries_parameter(WriteSummariesV5::Enabled)?;
1051        Ok(self)
1052    }
1053
1054    /// Set whether to display the help of WriteSummaries.
1055    pub fn write_summaries_help(mut self) -> Result<Self, String> {
1056        self.config
1057            .add_write_summaries_parameter(WriteSummariesV5::Help)?;
1058        Ok(self)
1059    }
1060
1061    /// Set whether to display the version of WriteSummaries.
1062    pub fn write_summaries_version(mut self) -> Result<Self, String> {
1063        self.config
1064            .add_write_summaries_parameter(WriteSummariesV5::Version)?;
1065        Ok(self)
1066    }
1067}
1068
1069impl<V: Version> SiriusBuilder<V> {
1070    /// Build the Sirius instance from the configuration.
1071    /// # Example
1072    /// ```
1073    /// use sirius_bindings::prelude::*;
1074    /// let sirius = SiriusBuilder::<Version5>::default().build();
1075    /// ```
1076    pub fn build(self) -> Sirius<V> {
1077        Sirius::from(self.config)
1078    }
1079}
1080
1081impl SiriusBuilder<Version5> {
1082    /// Set to default maximal value of m/z ratio on which Sirius calculation will be carried.
1083    ///
1084    /// # Example
1085    ///
1086    /// ```
1087    /// use sirius_bindings::prelude::*;
1088    ///
1089    /// let sirius = SiriusBuilder::default()
1090    ///    .maximal_mz_default().unwrap()
1091    ///  .build();
1092    ///
1093    /// assert!(SiriusBuilder::default().maximal_mz_default().is_ok());
1094    ///
1095    /// assert!(SiriusBuilder::default().maximal_mz_default().unwrap().maximal_mz_default().is_err());
1096    ///
1097    ///
1098    /// ```
1099    pub fn maximal_mz_default(mut self) -> Result<Self, String> {
1100        self.config
1101            .add_core_parameter(CoreV5::MaximalMz(f64::default()).into_default())?;
1102        Ok(self)
1103    }
1104
1105    /// Set to default the number of CPUs to use. By default, all available CPUs are used.
1106    pub fn max_cpus_default(mut self) -> Result<Self, String> {
1107        self.config
1108            .add_core_parameter(CoreV5::NCpus(usize::default()).into_default())?;
1109        Ok(self)
1110    }
1111
1112    /// Set to default isotope settings filter.
1113    pub fn isotope_settings_filter_default(mut self) -> Result<Self, String> {
1114        self.config.add_config_parameter(
1115            ConfigV5::IsotopeSettingsFilter(bool::default()).into_default(),
1116        )?;
1117        Ok(self)
1118    }
1119
1120    /// Set to default isotope settings intensity threshold.
1121    pub fn formula_search_db_default(mut self) -> Result<Self, String> {
1122        self.config.add_config_parameter(
1123            ConfigV5::FormulaSearchDB(crate::sirius_types::DBVector::default()).into_default(),
1124        )?;
1125        Ok(self)
1126    }
1127
1128    /// Set to default structure search db.
1129    pub fn structure_search_db_default(mut self) -> Result<Self, String> {
1130        self.config.add_config_parameter(
1131            ConfigV5::StructureSearchDB(crate::sirius_types::DBVector::default()).into_default(),
1132        )?;
1133        Ok(self)
1134    }
1135
1136    /// Set to default timeout seconds per tree.
1137    pub fn timeout_seconds_per_tree_default(mut self) -> Result<Self, String> {
1138        self.config
1139            .add_config_parameter(ConfigV5::TimeoutSecondsPerTree(u32::default()).into_default())?;
1140        Ok(self)
1141    }
1142
1143    /// Set to default number of candidates.
1144    pub fn number_of_candidates_default(mut self) -> Result<Self, String> {
1145        self.config
1146            .add_config_parameter(ConfigV5::NumberOfCandidates(u32::default()).into_default())?;
1147        Ok(self)
1148    }
1149
1150    /// Set to default number of candidates per ion.
1151    pub fn number_of_candidates_per_ion_default(mut self) -> Result<Self, String> {
1152        self.config.add_config_parameter(
1153            ConfigV5::NumberOfCandidatesPerIon(u32::default()).into_default(),
1154        )?;
1155        Ok(self)
1156    }
1157
1158    /// Set to default number of structure candidates.
1159    pub fn number_of_structure_candidates_default(mut self) -> Result<Self, String> {
1160        self.config.add_config_parameter(
1161            ConfigV5::NumberOfStructureCandidates(u32::default()).into_default(),
1162        )?;
1163        Ok(self)
1164    }
1165
1166    /// Set to default wheter to recompute results.
1167    pub fn recompute_results_default(mut self) -> Result<Self, String> {
1168        self.config
1169            .add_config_parameter(ConfigV5::RecomputeResults(bool::default()).into_default())?;
1170        Ok(self)
1171    }
1172
1173    /// Set to default wheter to print citations.
1174    pub fn print_citations_default(mut self) -> Result<Self, String> {
1175        self.config
1176            .add_config_parameter(ConfigV5::PrintCitations(bool::default()).into_default())?;
1177        Ok(self)
1178    }
1179
1180    /// Set to default timeout seconds per instance.
1181    pub fn timeout_seconds_per_instance_default(mut self) -> Result<Self, String> {
1182        self.config.add_config_parameter(
1183            ConfigV5::TimeoutSecondsPerInstance(u32::default()).into_default(),
1184        )?;
1185        Ok(self)
1186    }
1187
1188    /// Set to default wheter to use the formula result threshold.
1189    pub fn formula_result_threshold_default(mut self) -> Result<Self, String> {
1190        self.config.add_config_parameter(
1191            ConfigV5::FormulaResultThreshold(bool::default()).into_default(),
1192        )?;
1193        Ok(self)
1194    }
1195
1196    /// Whether to use the default El Gordo compounds setting.
1197    pub fn inject_el_gordo_compounds_default(mut self) -> Result<Self, String> {
1198        self.config.add_config_parameter(
1199            ConfigV5::InjectElGordoCompounds(bool::default()).into_default(),
1200        )?;
1201        Ok(self)
1202    }
1203
1204    /// Set to default the median noise intensity.
1205    pub fn median_noise_intensity_default(mut self) -> Result<Self, String> {
1206        self.config
1207            .add_config_parameter(ConfigV5::MedianNoiseIntensity(f32::default()).into_default())?;
1208        Ok(self)
1209    }
1210
1211    /// Set to default the MS1 absolute intensity error.
1212    pub fn ms1_absolute_intensity_error_default(mut self) -> Result<Self, String> {
1213        self.config.add_config_parameter(
1214            ConfigV5::MS1AbsoluteIntensityError(f32::default()).into_default(),
1215        )?;
1216        Ok(self)
1217    }
1218
1219    /// Set to default the MS1 minimal intensity to consider.
1220    pub fn ms1_minimal_intensity_to_consider_default(mut self) -> Result<Self, String> {
1221        self.config.add_config_parameter(
1222            ConfigV5::MS1MinimalIntensityToConsider(f32::default()).into_default(),
1223        )?;
1224        Ok(self)
1225    }
1226
1227    /// Set to default the MS1 relative intensity error.
1228    pub fn ms1_relative_intensity_error_default(mut self) -> Result<Self, String> {
1229        self.config.add_config_parameter(
1230            ConfigV5::MS1RelativeIntensityError(f32::default()).into_default(),
1231        )?;
1232        Ok(self)
1233    }
1234
1235    /// Set to default the noise threshold settings intensity threshold.
1236    pub fn noise_threshold_settings_intensity_threshold_default(mut self) -> Result<Self, String> {
1237        self.config.add_config_parameter(
1238            ConfigV5::NoiseThresholdSettingsIntensityThreshold(f32::default()).into_default(),
1239        )?;
1240        Ok(self)
1241    }
1242
1243    /// Set to default the noise threshold settings maximal number of peaks.
1244    pub fn noise_threshold_settings_maximal_number_of_peaks_default(
1245        mut self,
1246    ) -> Result<Self, String> {
1247        self.config.add_config_parameter(
1248            ConfigV5::NoiseThresholdSettingsMaximalNumberOfPeaks(u32::default()).into_default(),
1249        )?;
1250        Ok(self)
1251    }
1252
1253    /// Wheter to set to default the clustering of compounds before running zodiac.
1254    pub fn zodiac_cluster_compounds_default(mut self) -> Result<Self, String> {
1255        self.config.add_config_parameter(
1256            ConfigV5::ZodiacClusterCompounds(bool::default()).into_default(),
1257        )?;
1258        Ok(self)
1259    }
1260
1261    /// Set to default the zodiac edge filter thresholds min local candidates.
1262    pub fn zodiac_edge_filter_thresholds_min_local_candidates_default(
1263        mut self,
1264    ) -> Result<Self, String> {
1265        self.config.add_config_parameter(
1266            ConfigV5::ZodiacEdgeFilterThresholdsMinLocalCandidates(u32::default()).into_default(),
1267        )?;
1268        Ok(self)
1269    }
1270
1271    /// Set to default the zodiac edge filter thresholds min local connections.
1272    pub fn zodiac_edge_filter_thresholds_min_local_connections_default(
1273        mut self,
1274    ) -> Result<Self, String> {
1275        self.config.add_config_parameter(
1276            ConfigV5::ZodiacEdgeFilterThresholdsMinLocalConnections(u32::default()).into_default(),
1277        )?;
1278        Ok(self)
1279    }
1280
1281    /// Set to default the zodiac edge filter thresholds theshold filter.
1282    pub fn zodiac_edge_filter_thresholds_threshold_filter_default(
1283        mut self,
1284    ) -> Result<Self, String> {
1285        self.config.add_config_parameter(
1286            ConfigV5::ZodiacEdgeFilterThresholdsThresholdFilter(f32::default()).into_default(),
1287        )?;
1288        Ok(self)
1289    }
1290
1291    /// Set to default the zodiac epochs burn in period.
1292    pub fn zodiac_epochs_burn_in_period_default(mut self) -> Result<Self, String> {
1293        self.config.add_config_parameter(
1294            ConfigV5::ZodiacEpochsBurnInPeriod(u32::default()).into_default(),
1295        )?;
1296        Ok(self)
1297    }
1298
1299    /// Set to default the zodiac epochs iterations.
1300    pub fn zodiac_epochs_iterations_default(mut self) -> Result<Self, String> {
1301        self.config.add_config_parameter(
1302            ConfigV5::ZodiacEpochsIterations(u32::default()).into_default(),
1303        )?;
1304        Ok(self)
1305    }
1306
1307    /// Set to default the zodiac epochs number of markov chains.
1308    pub fn zodiac_epochs_number_of_markov_chains_default(mut self) -> Result<Self, String> {
1309        self.config.add_config_parameter(
1310            ConfigV5::ZodiacEpochsNumberOfMarkovChains(u32::default()).into_default(),
1311        )?;
1312        Ok(self)
1313    }
1314
1315    /// Sdet to default the zodiac library scoring lambda.
1316    pub fn zodiac_library_scoring_lambda_default(mut self) -> Result<Self, String> {
1317        self.config.add_config_parameter(
1318            ConfigV5::ZodiacLibraryScoringLambda(u32::default()).into_default(),
1319        )?;
1320        Ok(self)
1321    }
1322
1323    /// Set to default the zodiac library scoring min cosine.
1324    pub fn zodiac_library_scoring_min_cosine_default(mut self) -> Result<Self, String> {
1325        self.config.add_config_parameter(
1326            ConfigV5::ZodiacLibraryScoringMinCosine(f32::default()).into_default(),
1327        )?;
1328        Ok(self)
1329    }
1330
1331    /// Set to default the number of considered candidates at 300 mz.
1332    pub fn zodiac_number_of_considered_candidates_at_300_mz_default(
1333        mut self,
1334    ) -> Result<Self, String> {
1335        self.config.add_config_parameter(
1336            ConfigV5::ZodiacNumberOfConsideredCandidatesAt300Mz(i32::default()).into_default(),
1337        )?;
1338        Ok(self)
1339    }
1340
1341    /// Set to default the number of considered candidates at 800 mz.
1342    pub fn zodiac_number_of_considered_candidates_at_800_mz_default(
1343        mut self,
1344    ) -> Result<Self, String> {
1345        self.config.add_config_parameter(
1346            ConfigV5::ZodiacNumberOfConsideredCandidatesAt800Mz(i32::default()).into_default(),
1347        )?;
1348        Ok(self)
1349    }
1350
1351    /// Set to default the ratio of considered candidates per ionization.
1352    pub fn zodiac_ratio_of_considered_candidates_per_ionization_default(
1353        mut self,
1354    ) -> Result<Self, String> {
1355        self.config.add_config_parameter(
1356            ConfigV5::ZodiacRatioOfConsideredCandidatesPerIonization(f32::default()).into_default(),
1357        )?;
1358        Ok(self)
1359    }
1360
1361    /// Whether to set to default the run in two steps.
1362    pub fn zodiac_run_in_two_steps_default(mut self) -> Result<Self, String> {
1363        self.config
1364            .add_config_parameter(ConfigV5::ZodiacRunInTwoSteps(bool::default()).into_default())?;
1365        Ok(self)
1366    }
1367
1368    /// Set to default the allowed mass deviation for MS1 spectra.
1369    pub fn ms1_mass_deviation_allowed_mass_deviation_default(mut self) -> Result<Self, String> {
1370        self.config.add_config_parameter(
1371            ConfigV5::MS1MassDeviationAllowedMassDeviation(
1372                MassDeviation::Ppm(f32::default()).must_be_positive()?,
1373            )
1374            .into_default(),
1375        )?;
1376        Ok(self)
1377    }
1378
1379    /// Set to default the mass difference deviation for MS1 spectra.
1380    pub fn ms1_mass_deviation_mass_difference_deviation_default(mut self) -> Result<Self, String> {
1381        self.config.add_config_parameter(
1382            ConfigV5::MS1MassDeviationMassDifferenceDeviation(
1383                MassDeviation::Ppm(f32::default()).must_be_positive()?,
1384            )
1385            .into_default(),
1386        )?;
1387        Ok(self)
1388    }
1389
1390    /// Set to default the standard mass deviation for MS1 spectra.
1391    pub fn ms1_mass_deviation_standard_mass_deviation_default(mut self) -> Result<Self, String> {
1392        self.config.add_config_parameter(
1393            ConfigV5::MS1MassDeviationStandardMassDeviation(
1394                MassDeviation::Ppm(f32::default()).must_be_positive()?,
1395            )
1396            .into_default(),
1397        )?;
1398        Ok(self)
1399    }
1400
1401    /// Set to default the standard mass deviation for MS2 spectra.
1402    pub fn ms2_mass_deviation_standard_mass_deviation_default(mut self) -> Result<Self, String> {
1403        self.config.add_config_parameter(
1404            ConfigV5::MS2MassDeviationStandardMassDeviation(
1405                MassDeviation::Ppm(f32::default()).must_be_positive()?,
1406            )
1407            .into_default(),
1408        )?;
1409        Ok(self)
1410    }
1411
1412    /// Set to default the mass accuracy setting for MS2 spectra.
1413    pub fn ms2_mass_deviation_allowed_mass_deviation_default(mut self) -> Result<Self, String> {
1414        self.config.add_config_parameter(
1415            ConfigV5::MS2MassDeviationAllowedMassDeviation(
1416                MassDeviation::Ppm(f32::default()).must_be_positive()?,
1417            )
1418            .into_default(),
1419        )?;
1420        Ok(self)
1421    }
1422
1423    /// Set to default the detectable elements.
1424    pub fn formula_settings_detectable_default(mut self) -> Result<Self, String> {
1425        self.config.add_config_parameter(
1426            ConfigV5::FormulaSettingsDetectable(AtomVector::default()).into_default(),
1427        )?;
1428        Ok(self)
1429    }
1430
1431    /// Set to default the enforced elements.
1432    pub fn formula_settings_enforced_default(mut self) -> Result<Self, String> {
1433        self.config.add_config_parameter(
1434            ConfigV5::FormulaSettingsEnforced(AtomVector::default()).into_default(),
1435        )?;
1436        Ok(self)
1437    }
1438
1439    /// Set to default the fallback elements.
1440    pub fn formula_settings_fallback_default(mut self) -> Result<Self, String> {
1441        self.config.add_config_parameter(
1442            ConfigV5::FormulaSettingsFallback(AtomVector::default()).into_default(),
1443        )?;
1444        Ok(self)
1445    }
1446
1447    /// Set to default the forbid recalibration.
1448    pub fn forbid_recalibration_default(mut self) -> Result<Self, String> {
1449        self.config.add_config_parameter(
1450            ConfigV5::ForbidRecalibration(ForbidRecalibration::default()).into_default(),
1451        )?;
1452        Ok(self)
1453    }
1454
1455    /// Set to default the minimum m/z to enable heuristic preprocessing.
1456    pub fn use_heuristic_mz_to_use_heuristic_default(mut self) -> Result<Self, String> {
1457        self.config.add_config_parameter(
1458            ConfigV5::UseHeuristicMZToUseHeuristic(u32::default()).into_default(),
1459        )?;
1460        Ok(self)
1461    }
1462
1463    /// Set to default the minimum m/z to only use heuristic tree computation.
1464    pub fn use_heuristic_mz_to_use_heuristic_only_default(mut self) -> Result<Self, String> {
1465        self.config.add_config_parameter(
1466            ConfigV5::UseHeuristicMZToUseHeuristicOnly(u32::default()).into_default(),
1467        )?;
1468        Ok(self)
1469    }
1470
1471    /// Set to default the detectable adducts.
1472    pub fn adduct_settings_detectable_default(mut self) -> Result<Self, String> {
1473        self.config.add_config_parameter(
1474            ConfigV5::AdductSettingsDetectable(AdductsVector::default()).into_default(),
1475        )?;
1476        Ok(self)
1477    }
1478
1479    /// Set to default the fallback adducts.
1480    pub fn adduct_settings_fallback_default(mut self) -> Result<Self, String> {
1481        self.config.add_config_parameter(
1482            ConfigV5::AdductSettingsFallback(AdductsVector::default()).into_default(),
1483        )?;
1484        Ok(self)
1485    }
1486
1487    /// Set to default the algorithm profile.
1488    pub fn algorithm_profile_default(mut self) -> Result<Self, String> {
1489        self.config.add_config_parameter(
1490            ConfigV5::AlgorithmProfile(Instruments::default()).into_default(),
1491        )?;
1492        Ok(self)
1493    }
1494
1495    /// Set to default the compound quality.
1496    pub fn compound_quality_default(mut self) -> Result<Self, String> {
1497        self.config.add_config_parameter(
1498            ConfigV5::CompoundQuality(CompoundQuality::default()).into_default(),
1499        )?;
1500        Ok(self)
1501    }
1502
1503    /// Set to default the enforced adducts.
1504    pub fn adduct_settings_enforced_default(mut self) -> Result<Self, String> {
1505        self.config.add_config_parameter(
1506            ConfigV5::AdductSettingsEnforced(AdductSettingsEnforced::default()).into_default(),
1507        )?;
1508        Ok(self)
1509    }
1510
1511    /// Set to default the candidate formulas.
1512    pub fn candidate_formulas_default(mut self) -> Result<Self, String> {
1513        self.config.add_config_parameter(
1514            ConfigV5::CandidateFormulas(CandidateFormulas::default()).into_default(),
1515        )?;
1516        Ok(self)
1517    }
1518
1519    /// Set to default the formula result ranking score.
1520    pub fn formula_result_ranking_score_default(mut self) -> Result<Self, String> {
1521        self.config.add_config_parameter(
1522            ConfigV5::FormulaResultRankingScore(FormulaResultRankingScore::default())
1523                .into_default(),
1524        )?;
1525        Ok(self)
1526    }
1527
1528    /// Set to default the isotope ms2 settings.
1529    pub fn isotope_ms2_settings_default(mut self) -> Result<Self, String> {
1530        self.config.add_config_parameter(
1531            ConfigV5::IsotopeMS2Settings(IsotopeMS2Settings::default()).into_default(),
1532        )?;
1533        Ok(self)
1534    }
1535
1536    /// Set to default the isotope settings multiplier.
1537    pub fn isotope_settings_multiplier_default(mut self) -> Result<Self, String> {
1538        self.config.add_config_parameter(
1539            ConfigV5::IsotopeSettingsMultiplier(u32::default()).into_default(),
1540        )?;
1541        Ok(self)
1542    }
1543
1544    /// Set to default the noise threshold settings absolute threshold.
1545    pub fn noise_threshold_settings_absolute_threshold_default(mut self) -> Result<Self, String> {
1546        self.config.add_config_parameter(
1547            ConfigV5::NoiseThresholdSettingsAbsoluteThreshold(u32::default()).into_default(),
1548        )?;
1549        Ok(self)
1550    }
1551
1552    /// Set to default the noise threshold settings base peak.
1553    pub fn noise_threshold_settings_base_peak_default(mut self) -> Result<Self, String> {
1554        self.config.add_config_parameter(
1555            ConfigV5::NoiseThresholdSettingsBasePeak(BasePeak::default()).into_default(),
1556        )?;
1557        Ok(self)
1558    }
1559
1560    /// Set to default the structure predictors algorithm.
1561    pub fn structure_predictors_default(mut self) -> Result<Self, String> {
1562        self.config.add_config_parameter(
1563            ConfigV5::StructurePredictors(StructurePredictors::default()).into_default(),
1564        )?;
1565        Ok(self)
1566    }
1567
1568    /// Set to default the possible adduct switches.
1569    pub fn possible_adduct_switches_default(mut self) -> Result<Self, String> {
1570        self.config.add_config_parameter(
1571            ConfigV5::PossibleAdductSwitches(PossibleAdductSwitches::default()).into_default(),
1572        )?;
1573        Ok(self)
1574    }
1575}