Skip to content

Commit

Permalink
4.9.9 - backport of CandidateFormulas parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
mfleisch committed Nov 11, 2021
1 parent 6340cbf commit a7865b6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 52 deletions.
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
/*
* This file is part of the SIRIUS Software for analyzing MS and MS/MS data
*
* Copyright (C) 2013-2020 Kai Dührkop, Markus Fleischauer, Marcus Ludwig, Martin A. Hoffman, Fleming Kretschmer, Marvin Meusel and Sebastian Böcker,
* Chair of Bioinformatics, Friedrich-Schiller University.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU Affero General Public License
* as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along with SIRIUS. If not, see <https://www.gnu.org/licenses/agpl-3.0.txt>
*/

/*
* This file is part of the SIRIUS library for analyzing MS and MS/MS data
*
Expand All @@ -37,7 +18,6 @@
package de.unijena.bioinf.ms.frontend.subtools.sirius;

import de.unijena.bioinf.ChemistryBase.ms.DetectedAdducts;
import de.unijena.bioinf.ChemistryBase.ms.ft.model.Whiteset;
import de.unijena.bioinf.FragmentationTreeConstruction.computation.tree.TreeBuilderFactory;
import de.unijena.bioinf.ms.frontend.DefaultParameter;
import de.unijena.bioinf.ms.frontend.completion.DataSourceCandidates;
Expand Down Expand Up @@ -137,10 +117,9 @@ public void setDatabase(DefaultParameter dbList) throws Exception {
}

@Option(names = {"-f", "--formulas"}, description = "Specify a list of candidate formulas the method should use. Omit this option if you want to consider all possible molecular formulas")
public void setFormulaWhiteList(List<String> formulaWhiteList) {
formulaWhiteSet = Whiteset.of(formulaWhiteList);
public void setCandidateFormulas(DefaultParameter formulas) throws Exception {
defaultConfigOptions.changeOption("CandidateFormulas", formulas);
}
public Whiteset formulaWhiteSet = null;


@Option(names = {"--no-isotope-filter"}, description = "Disable molecular formula filter. When filtering is enabled, molecular formulas are excluded if their theoretical isotope pattern does not match the theoretical one, even if their MS/MS pattern has high score.")
Expand All @@ -167,7 +146,7 @@ public void setIonsEnforced(DefaultParameter adductList) throws Exception {
}


//heuristic threshods
//heuristic thresholds
@Option(names = {"--heuristic"}, descriptionKey ="UseHeuristic.mzToUseHeuristic" , description = "Enable heuristic preprocessing for compounds >= the specified m/z.")
public void setMzToUseHeuristic(DefaultParameter value) throws Exception {
defaultConfigOptions.changeOption("UseHeuristic.mzToUseHeuristic", value);
Expand Down Expand Up @@ -230,10 +209,7 @@ public void setTrustGuessIonFromMS1(boolean trust) {

@Override
public InstanceJob.Factory<SiriusSubToolJob> call() throws Exception {
return new InstanceJob.Factory<>(
sub -> new SiriusSubToolJob(this, sub),
getInvalidator()
);
return new InstanceJob.Factory<>(SiriusSubToolJob::new, getInvalidator());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import de.unijena.bioinf.ChemistryBase.ms.DetectedAdducts;
import de.unijena.bioinf.ChemistryBase.ms.Ms2Experiment;
import de.unijena.bioinf.ChemistryBase.ms.ft.model.CandidateFormulas;
import de.unijena.bioinf.ChemistryBase.ms.ft.model.Whiteset;
import de.unijena.bioinf.ChemistryBase.ms.properties.FinalConfig;
import de.unijena.bioinf.chemdb.annotations.FormulaSearchDB;
Expand All @@ -41,16 +42,10 @@
import java.util.Optional;

public class SiriusSubToolJob extends InstanceJob {
//todo this is only a temporary solution. parameters should be annotated to the exp
// we do not want to have the sub-tool management to be dependent on a cli parsing library
protected final SiriusOptions cliOptions;

public SiriusSubToolJob(SiriusOptions cliOptions, JobSubmitter jobSubmitter) {
public SiriusSubToolJob(JobSubmitter jobSubmitter) {
super(jobSubmitter, false);
this.cliOptions = cliOptions;
}


@Override
public boolean isAlreadyComputed(@NotNull Instance inst) {
return !inst.loadCompoundContainer().getResults().isEmpty();
Expand All @@ -62,27 +57,29 @@ protected void computeAndAnnotateResult(final @NotNull Instance inst) throws Exc
// set whiteSet or merge with whiteSet from db search if available
Whiteset wSet = null;

checkForInterruption();
{
checkForInterruption();

// create WhiteSet from DB if necessary
//todo do we really want to restrict to organic even if the db is user selected
final Optional<FormulaSearchDB> searchDB = exp.getAnnotation(FormulaSearchDB.class);
if (searchDB.isPresent() && searchDB.get().containsDBs())
wSet = submitSubJob(new FormulaWhiteListJob(ApplicationCore.WEB_API.getChemDB(), searchDB.get().searchDBs, exp, true, false))
.awaitResult();
// create WhiteSet from DB if necessary
//todo do we really want to restrict to organic even if the db is user selected
final Optional<FormulaSearchDB> searchDB = exp.getAnnotation(FormulaSearchDB.class);
if (searchDB.isPresent() && searchDB.get().containsDBs())
wSet = submitSubJob(new FormulaWhiteListJob(ApplicationCore.WEB_API.getChemDB(), searchDB.get().searchDBs, exp, true, false))
.awaitResult();

checkForInterruption();
checkForInterruption();


// todo this should be moved to annotations at some point.
// so that the cli parser dependency can be removed
if (cliOptions.formulaWhiteSet != null) {
if (wSet != null)
wSet = wSet.add(cliOptions.formulaWhiteSet);
else
wSet = cliOptions.formulaWhiteSet;
// so that the cli parser dependency can be removed
if (exp.getAnnotation(CandidateFormulas.class).map(CandidateFormulas::formulas).map(Whiteset::notEmpty).orElse(false)) {
final Whiteset userFormulas = exp.getAnnotation(CandidateFormulas.class).map(CandidateFormulas::formulas).orElseThrow();
if (wSet != null)
wSet = wSet.add(userFormulas);
else
wSet = userFormulas;
}
exp.setAnnotation(Whiteset.class, wSet);
}
exp.setAnnotation(Whiteset.class, wSet);

checkForInterruption();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#here you can provide properties that may be needed during build- AND during runtime and should not be editable by the user at runtime
de.unijena.bioinf.siriusFrontend.version=4.9.8
de.unijena.bioinf.siriusFrontend.version=4.9.9

de.unijena.bioinf.sirius.version=4.6.1
de.unijena.bioinf.fingerid.version=1.6.0
Expand Down

0 comments on commit a7865b6

Please sign in to comment.