Search in sources :

Example 1 with CombinedMetFragProcess

use of de.ipbhalle.metfraglib.process.CombinedMetFragProcess in project MetFragRelaunched by ipb-halle.

the class MetFragRestController method process.

/**
 * runs a metfrag query
 *
 * @param args
 * @return
 * @throws CouldNotWriteStatusException
 * @throws CouldNotCreateProcessException
 */
@RequestMapping(method = RequestMethod.POST, value = "", produces = { MediaType.APPLICATION_JSON_VALUE })
@ResponseBody
public ResponseEntity<Resource<ProcessAssembler>> process(@RequestBody ProcessArguments args) throws CouldNotWriteStatusException, CouldNotCreateProcessException {
    File resFolder;
    String processid;
    try {
        resFolder = Files.createTempDirectory("java.io.tmpdir").toFile();
        processid = resFolder.getName();
        try {
            MetFragGlobalSettings settings = args.getSettingsObject(resFolder);
            // check settings
            SettingsChecker settingsChecker = new SettingsChecker();
            if (!settingsChecker.check(settings))
                throw new CouldNotCreateProcessException("Error: Corrupt parameters");
            logger.info("Storing in " + settings.get(VariableNames.STORE_RESULTS_PATH_NAME));
            CombinedMetFragProcess mp = new CombinedMetFragProcess(settings);
            this.writeStatus("RUNNING", processid);
            this.writeHost(processid);
            new Thread(() -> {
                System.out.println("staring run");
                try {
                    MetFragRestService.startMetFrag(mp, settings, resFolder.getAbsolutePath());
                } catch (IOException e) {
                    e.printStackTrace();
                    return;
                }
            }, "MyThread-" + processid).start();
        } catch (ParameterNotKnownException e) {
            e.printStackTrace();
            this.writeStatus("ERROR", processid);
            throw new CouldNotCreateProcessException("Error: Parameter not known");
        } catch (IOException e) {
            e.printStackTrace();
            throw new CouldNotCreateProcessException("Error: Could not write status");
        } catch (Exception e) {
            e.printStackTrace();
            this.writeStatus("ERROR", processid);
            throw new CouldNotCreateProcessException("Error: Unknown error");
        }
    } catch (IOException e) {
        throw new CouldNotWriteStatusException(e.getMessage());
    }
    Resource<ProcessAssembler> resource = new ProcessAssembler("process", processid).toResource();
    resource.add(linkTo(MetFragRestController.class).slash("process").withSelfRel());
    resource.add(linkTo(MetFragRestController.class).slash("status").slash(processid).withRel("status"));
    resource.add(linkTo(MetFragRestController.class).slash("host").slash(processid).withRel("host"));
    resource.add(linkTo(MetFragRestController.class).slash("result").slash(processid).withRel("result"));
    resource.add(linkTo(MetFragRestController.class).slash("resultzip").slash(processid).withRel("resultzip"));
    return new ResponseEntity<Resource<ProcessAssembler>>(resource, HttpStatus.CREATED);
}
Also used : CouldNotCreateProcessException(de.ipbhalle.exception.CouldNotCreateProcessException) MetFragGlobalSettings(de.ipbhalle.metfraglib.settings.MetFragGlobalSettings) CouldNotWriteStatusException(de.ipbhalle.exception.CouldNotWriteStatusException) IOException(java.io.IOException) ParameterNotKnownException(de.ipbhalle.metfraglib.exceptions.ParameterNotKnownException) CouldNotReadStatusException(de.ipbhalle.exception.CouldNotReadStatusException) CouldNotFetchResultsException(de.ipbhalle.exception.CouldNotFetchResultsException) ParameterNotKnownException(de.ipbhalle.metfraglib.exceptions.ParameterNotKnownException) CouldNotCreateProcessException(de.ipbhalle.exception.CouldNotCreateProcessException) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException) CouldNotRemoveProcessException(de.ipbhalle.exception.CouldNotRemoveProcessException) ExecutionException(java.util.concurrent.ExecutionException) CouldNotReadHostException(de.ipbhalle.exception.CouldNotReadHostException) CouldNotWriteStatusException(de.ipbhalle.exception.CouldNotWriteStatusException) ResponseEntity(org.springframework.http.ResponseEntity) SettingsChecker(de.ipbhalle.metfraglib.parameter.SettingsChecker) File(java.io.File) ProcessAssembler(de.ipbhalle.model.ProcessAssembler) CombinedMetFragProcess(de.ipbhalle.metfraglib.process.CombinedMetFragProcess) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 2 with CombinedMetFragProcess

use of de.ipbhalle.metfraglib.process.CombinedMetFragProcess in project MetFragRelaunched by ipb-halle.

the class MetfRag method generateMatchingFragments.

/**
 * @param molecule
 * @param masses
 * @param exactMass
 * @param mzabs
 * @param mzppm
 * @param posCharge
 * @param mode
 * @param treeDepth
 * @return
 */
public static IAtomContainer[] generateMatchingFragments(IAtomContainer molecule, double[] masses, double exactMass, double mzabs, double mzppm, boolean posCharge, int mode, int treeDepth) {
    Logger.getLogger("net.sf.jnati.deploy.artefact.ConfigManager").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.repository.ClasspathRepository").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.repository.LocalRepository").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.artefact.ManifestReader").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.NativeArtefactLocator").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.NativeLibraryLoader").setLevel(Level.ERROR);
    MoleculeFunctions.prepareAtomContainer(molecule, false);
    IAtomContainer[] moleculeAsArray = { molecule };
    String peaksString = "";
    if (masses.length > 0)
        peaksString += masses[0] + " 100";
    for (int i = 1; i < masses.length; i++) {
        peaksString += "\n" + masses[i] + " 100";
    }
    String[] score_names = { VariableNames.METFRAG_FRAGMENTER_SCORE_NAME };
    Double[] score_weights = { 1.0 };
    MetFragGlobalSettings settings = new MetFragGlobalSettings();
    settings.set(VariableNames.MOLECULES_IN_MEMORY, moleculeAsArray);
    settings.set(VariableNames.PEAK_LIST_STRING_NAME, peaksString);
    settings.set(VariableNames.METFRAG_DATABASE_TYPE_NAME, "LocalInMemoryDatabase");
    settings.set(VariableNames.METFRAG_PEAK_LIST_READER_NAME, "de.ipbhalle.metfraglib.peaklistreader.FilteredStringTandemMassPeakListReader");
    settings.set(VariableNames.METFRAG_SCORE_TYPES_NAME, score_names);
    settings.set(VariableNames.METFRAG_SCORE_WEIGHTS_NAME, score_weights);
    settings.set(VariableNames.RELATIVE_MASS_DEVIATION_NAME, mzppm);
    settings.set(VariableNames.ABSOLUTE_MASS_DEVIATION_NAME, mzabs);
    settings.set(VariableNames.IS_POSITIVE_ION_MODE_NAME, posCharge);
    settings.set(VariableNames.PRECURSOR_ION_MODE_NAME, mode);
    settings.set(VariableNames.PRECURSOR_NEUTRAL_MASS_NAME, exactMass);
    settings.set(VariableNames.MAXIMUM_TREE_DEPTH_NAME, (byte) treeDepth);
    settings.set(VariableNames.RESET_PRECURSOR_AFTER_PROCESSING, false);
    CombinedMetFragProcess mp = new CombinedMetFragProcess(settings);
    try {
        mp.retrieveCompounds();
    } catch (Exception e2) {
        System.err.println("Error retrieving candidates");
    }
    try {
        mp.run();
    } catch (Exception e) {
        System.err.println("Error running MetFrag process");
    }
    SortedScoredCandidateList scoredCandidateList = (SortedScoredCandidateList) mp.getCandidateList();
    MatchList assignedFragmentList = scoredCandidateList.getElement(0).getMatchList();
    IAtomContainer[] assignedFragments = new IAtomContainer[assignedFragmentList.getNumberElements()];
    for (int i = 0; i < assignedFragmentList.getNumberElements(); i++) {
        IAtomContainer currentFragment = assignedFragmentList.getElement(i).getBestMatchedFragment().getStructureAsIAtomContainer(scoredCandidateList.getElement(0).getPrecursorMolecule());
        currentFragment.setProperty("AssignedMassPeak", assignedFragmentList.getElement(i).getMatchedPeak().getMass());
        currentFragment.setProperty("FragmentMass", assignedFragmentList.getElement(i).getBestMatchedFragment().getMonoisotopicMass(scoredCandidateList.getElement(0).getPrecursorMolecule()));
        assignedFragments[i] = currentFragment;
    }
    return assignedFragments;
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) MatchList(de.ipbhalle.metfraglib.list.MatchList) MetFragGlobalSettings(de.ipbhalle.metfraglib.settings.MetFragGlobalSettings) SortedScoredCandidateList(de.ipbhalle.metfraglib.list.SortedScoredCandidateList) AtomTypeNotKnownFromInputListException(de.ipbhalle.metfraglib.exceptions.AtomTypeNotKnownFromInputListException) RelativeIntensityNotDefinedException(de.ipbhalle.metfraglib.exceptions.RelativeIntensityNotDefinedException) CombinedMetFragProcess(de.ipbhalle.metfraglib.process.CombinedMetFragProcess)

Example 3 with CombinedMetFragProcess

use of de.ipbhalle.metfraglib.process.CombinedMetFragProcess in project MetFragRelaunched by ipb-halle.

the class MetfRag method scoreMoleculesAgainstSpectrum.

/**
 * fragment and score molecules stored in a sdf file
 *
 * @param _pathToSDF
 * @param _masses
 * @param _intensities
 * @param _exactMass
 * @param _numberThreads
 * @param _mzabs
 * @param _mzppm
 * @param _searchppm
 * @param _posCharge
 * @param _mode
 * @param _treeDepth
 * @return
 */
public static IAtomContainer[] scoreMoleculesAgainstSpectrum(IAtomContainer[] atomContainerArray, double[] _masses, double[] _intensities, double _exactMass, int _numberThreads, double _mzabs, double _mzppm, boolean _posCharge, int _mode, int _treeDepth, String[] scoreNames, double[] scoreWeights) {
    Logger.getLogger("net.sf.jnati.deploy.artefact.ConfigManager").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.repository.ClasspathRepository").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.repository.LocalRepository").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.artefact.ManifestReader").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.NativeArtefactLocator").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.NativeLibraryLoader").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.resolver.ArtefactResolver").setLevel(Level.ERROR);
    Logger.getLogger("net.sf.jnati.deploy.source.JarSource").setLevel(Level.ERROR);
    double mzabs = _mzabs;
    double mzppm = _mzppm;
    double exactMass = _exactMass;
    int treeDepth = _treeDepth;
    int mode = _mode;
    int numberThreads = _numberThreads;
    boolean posCharge = _posCharge;
    double[] masses = _masses;
    double[] intensities = _intensities;
    IAtomContainer[] resultMols = new IAtomContainer[0];
    if (masses == null)
        return resultMols;
    if (intensities == null)
        return resultMols;
    if (masses.length != intensities.length)
        return resultMols;
    if (exactMass <= 0.0)
        return resultMols;
    if (numberThreads < -1 || numberThreads > 8)
        return resultMols;
    if (mzabs < 0.0 || mzppm < 0.0)
        return resultMols;
    if (mode != -1 && mode != 0 && mode != 1)
        return resultMols;
    if (treeDepth < 1 || treeDepth > 5)
        return resultMols;
    String peaksString = "";
    if (masses.length > 0)
        peaksString += masses[0] + " " + intensities[0];
    for (int i = 1; i < masses.length; i++) {
        peaksString += "\n" + masses[i] + " " + intensities[i];
    }
    Double[] scoreWeightsObject = new Double[scoreWeights.length];
    for (int i = 0; i < scoreWeightsObject.length; i++) scoreWeightsObject[i] = Double.valueOf(scoreWeights[i]);
    MetFragGlobalSettings settings = new MetFragGlobalSettings();
    settings.set(VariableNames.MOLECULES_IN_MEMORY, atomContainerArray);
    settings.set(VariableNames.PEAK_LIST_STRING_NAME, peaksString);
    settings.set(VariableNames.METFRAG_DATABASE_TYPE_NAME, "LocalInMemoryDatabase");
    settings.set(VariableNames.METFRAG_PEAK_LIST_READER_NAME, "de.ipbhalle.metfraglib.peaklistreader.FilteredStringTandemMassPeakListReader");
    settings.set(VariableNames.METFRAG_SCORE_TYPES_NAME, scoreNames);
    settings.set(VariableNames.METFRAG_SCORE_WEIGHTS_NAME, scoreWeightsObject);
    settings.set(VariableNames.RELATIVE_MASS_DEVIATION_NAME, mzppm);
    settings.set(VariableNames.ABSOLUTE_MASS_DEVIATION_NAME, mzabs);
    settings.set(VariableNames.IS_POSITIVE_ION_MODE_NAME, posCharge);
    settings.set(VariableNames.PRECURSOR_ION_MODE_NAME, mode);
    settings.set(VariableNames.PRECURSOR_NEUTRAL_MASS_NAME, exactMass);
    settings.set(VariableNames.MAXIMUM_TREE_DEPTH_NAME, (byte) treeDepth);
    CombinedMetFragProcess mp = new CombinedMetFragProcess(settings);
    try {
        mp.retrieveCompounds();
    } catch (Exception e2) {
        System.err.println("Error retrieving candidates");
        e2.printStackTrace();
        return new IAtomContainer[0];
    }
    try {
        mp.run();
    } catch (Exception e) {
        System.err.println("Error running MetFrag process");
        e.printStackTrace();
        return new IAtomContainer[0];
    }
    SortedScoredCandidateList scoredCandidateList = (SortedScoredCandidateList) mp.getCandidateList();
    resultMols = new IAtomContainer[scoredCandidateList.getNumberElements()];
    int numberOfPeaksUsed = scoredCandidateList.getNumberPeaksUsed();
    for (int i = 0; i < scoredCandidateList.getNumberElements(); i++) {
        ICandidate candidate = scoredCandidateList.getElement(i);
        IAtomContainer tmp = null;
        try {
            tmp = candidate.getAtomContainer();
            MoleculeFunctions.prepareAtomContainer(tmp, false);
        } catch (Exception e1) {
            e1.printStackTrace();
            continue;
        }
        if (candidate.getProperties().containsKey(VariableNames.INCHI_KEY_1_NAME) && candidate.getProperty(VariableNames.INCHI_KEY_1_NAME) != null)
            tmp.setProperty(VariableNames.INCHI_KEY_1_NAME, candidate.getProperty(VariableNames.INCHI_KEY_1_NAME));
        if (candidate.getProperties().containsKey(VariableNames.INCHI_KEY_2_NAME) && candidate.getProperty(VariableNames.INCHI_KEY_2_NAME) != null)
            tmp.setProperty(VariableNames.INCHI_KEY_2_NAME, candidate.getProperty(VariableNames.INCHI_KEY_2_NAME));
        if (candidate.getProperties().containsKey(VariableNames.INCHI_KEY_NAME) && candidate.getProperty(VariableNames.INCHI_KEY_NAME) != null)
            tmp.setProperty(VariableNames.INCHI_KEY_NAME, candidate.getProperty(VariableNames.INCHI_KEY_NAME));
        tmp.setProperty(VariableNames.IDENTIFIER_NAME, candidate.getIdentifier());
        IMolecularFormula molFormula = MolecularFormulaManipulator.getMolecularFormula(tmp);
        Double massDoubleOrig = null;
        try {
            massDoubleOrig = candidate.getMolecularFormula().getMonoisotopicMass();
        } catch (AtomTypeNotKnownFromInputListException e) {
            e.printStackTrace();
        }
        massDoubleOrig = (double) Math.round((massDoubleOrig) * 10000) / 10000;
        tmp.setProperty(VariableNames.MONOISOTOPIC_MASS_NAME, massDoubleOrig);
        tmp.setProperty(VariableNames.FINAL_SCORE_COLUMN_NAME, candidate.getProperty(VariableNames.FINAL_SCORE_COLUMN_NAME));
        for (int ii = 0; ii < scoreNames.length; ii++) {
            String scoreClassName = scoreNames[ii];
            tmp.setProperty(scoreClassName, candidate.getProperty(scoreClassName));
            tmp.setProperty(scoreClassName + "_Values", candidate.getProperty(scoreClassName + "_Values"));
        }
        if (candidate.getMatchList() != null)
            tmp.setProperty(VariableNames.NUMBER_EXPLAINED_PEAKS_COLUMN, candidate.getMatchList().getNumberElements());
        String peaksExplained = "";
        String sumFormulasOfFragmentsExplainedPeaks = "";
        if (candidate.getMatchList() != null) {
            for (int ii = 0; ii < candidate.getMatchList().getNumberElements(); ii++) {
                try {
                    peaksExplained += candidate.getMatchList().getElement(ii).getMatchedPeak().getMass() + "_" + candidate.getMatchList().getElement(ii).getMatchedPeak().getIntensity() + ";";
                } catch (RelativeIntensityNotDefinedException e1) {
                    e1.printStackTrace();
                }
                sumFormulasOfFragmentsExplainedPeaks += candidate.getMatchList().getElement(ii).getMatchedPeak().getMass() + ":" + candidate.getMatchList().getElement(ii).getBestMatchedFragment().getMolecularFormula(candidate.getPrecursorMolecule()) + ";";
            }
            if (sumFormulasOfFragmentsExplainedPeaks.length() != 0)
                sumFormulasOfFragmentsExplainedPeaks = sumFormulasOfFragmentsExplainedPeaks.substring(0, sumFormulasOfFragmentsExplainedPeaks.length() - 1);
            if (peaksExplained.length() != 0)
                peaksExplained = peaksExplained.substring(0, peaksExplained.length() - 1);
            if (peaksExplained.length() == 0)
                peaksExplained = "NA";
            if (sumFormulasOfFragmentsExplainedPeaks.length() == 0)
                sumFormulasOfFragmentsExplainedPeaks = "NA";
            tmp.setProperty(VariableNames.EXPLAINED_PEAKS_COLUMN, peaksExplained);
            tmp.setProperty(VariableNames.FORMULAS_OF_PEAKS_EXPLAINED_COLUMN, sumFormulasOfFragmentsExplainedPeaks);
        }
        tmp.setProperty(VariableNames.MOLECULAR_FORMULA_NAME, MolecularFormulaManipulator.getString(molFormula));
        tmp.setProperty(VariableNames.NUMBER_EXPLAINED_PEAKS_COLUMN, numberOfPeaksUsed);
        resultMols[i] = tmp;
    }
    return resultMols;
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) MetFragGlobalSettings(de.ipbhalle.metfraglib.settings.MetFragGlobalSettings) IMolecularFormula(org.openscience.cdk.interfaces.IMolecularFormula) AtomTypeNotKnownFromInputListException(de.ipbhalle.metfraglib.exceptions.AtomTypeNotKnownFromInputListException) RelativeIntensityNotDefinedException(de.ipbhalle.metfraglib.exceptions.RelativeIntensityNotDefinedException) AtomTypeNotKnownFromInputListException(de.ipbhalle.metfraglib.exceptions.AtomTypeNotKnownFromInputListException) RelativeIntensityNotDefinedException(de.ipbhalle.metfraglib.exceptions.RelativeIntensityNotDefinedException) ICandidate(de.ipbhalle.metfraglib.interfaces.ICandidate) SortedScoredCandidateList(de.ipbhalle.metfraglib.list.SortedScoredCandidateList) CombinedMetFragProcess(de.ipbhalle.metfraglib.process.CombinedMetFragProcess)

Example 4 with CombinedMetFragProcess

use of de.ipbhalle.metfraglib.process.CombinedMetFragProcess in project MetFragRelaunched by ipb-halle.

the class BeanSettingsContainer method preprocessRetentionTimeTrainingFile.

public void preprocessRetentionTimeTrainingFile() throws Exception {
    if (this.retentionTimeScoreTrainingFilePath == null || this.retentionTimeScoreTrainingFilePath.trim().length() == 0)
        return;
    if (this.availableCandidatePartitioningCoefficients == null || this.availableCandidatePartitioningCoefficients.size() == 0)
        return;
    java.io.File retentionTimeTrainingFile = new java.io.File(this.retentionTimeScoreTrainingFilePath);
    if (retentionTimeTrainingFile != null && retentionTimeTrainingFile.exists() && retentionTimeTrainingFile.canRead()) {
        MetFragGlobalSettings settings = new MetFragGlobalSettings();
        settings.set(VariableNames.LOG_LEVEL_NAME, Level.DEBUG);
        settings.set(VariableNames.METFRAG_DATABASE_TYPE_NAME, "LocalProperty");
        settings.set(VariableNames.LOCAL_DATABASE_PATH_NAME, this.retentionTimeScoreTrainingFilePath);
        CombinedMetFragProcess combinedMetFragProcess = new CombinedMetFragProcess(settings);
        boolean entriesRetrieved = combinedMetFragProcess.retrieveCompounds();
        if (entriesRetrieved) {
            CandidateList candidates = combinedMetFragProcess.getCandidateList();
            if (candidates == null || candidates.getNumberElements() <= 1)
                throw new TooFewCandidatesException();
            if (!candidates.getElement(0).getProperties().containsKey(VariableNames.RETENTION_TIME_NAME))
                throw new RetentionTimeNotFoundException();
            this.availablePartitioningCoefficients = new java.util.ArrayList<SelectItem>();
            java.util.Enumeration<String> keys = candidates.getElement(0).getProperties().keys();
            while (keys.hasMoreElements()) {
                String currentKey = keys.nextElement().trim();
                if (currentKey.equals(VariableNames.INCHI_NAME)) {
                    currentKey = "CDK";
                }
                for (int k = 0; k < this.availableCandidatePartitioningCoefficients.size(); k++) {
                    if (this.availableCandidatePartitioningCoefficients.get(k).getLabel().equals(currentKey)) {
                        if (currentKey.equals("CDK"))
                            this.availablePartitioningCoefficients.add(new SelectItem(currentKey));
                        else {
                            if (this.isValidLogValueProperty(currentKey, candidates))
                                this.availablePartitioningCoefficients.add(new SelectItem(currentKey));
                        }
                    }
                }
            }
        }
        Collections.sort(this.availablePartitioningCoefficients, new java.util.Comparator<SelectItem>() {

            @Override
            public int compare(SelectItem left, SelectItem right) {
                return ((String) left.getValue()).compareTo((String) right.getValue());
            }
        });
    } else
        this.availablePartitioningCoefficients = null;
}
Also used : MetFragGlobalSettings(de.ipbhalle.metfraglib.settings.MetFragGlobalSettings) RetentionTimeNotFoundException(de.ipbhalle.metfraglib.exceptions.RetentionTimeNotFoundException) SelectItem(javax.faces.model.SelectItem) CandidateList(de.ipbhalle.metfraglib.list.CandidateList) TooFewCandidatesException(de.ipbhalle.metfraglib.exceptions.TooFewCandidatesException) UploadedSuspectListFile(de.ipbhalle.metfragweb.datatype.UploadedSuspectListFile) CombinedMetFragProcess(de.ipbhalle.metfraglib.process.CombinedMetFragProcess)

Example 5 with CombinedMetFragProcess

use of de.ipbhalle.metfraglib.process.CombinedMetFragProcess in project MetFragRelaunched by ipb-halle.

the class BeanSettingsContainer method preprocessLocalDatabaseCandidates.

public void preprocessLocalDatabaseCandidates() throws Exception {
    MetFragGlobalSettings settings = new MetFragGlobalSettings();
    settings.set(VariableNames.METFRAG_DATABASE_TYPE_NAME, this.getDatabase());
    settings.set(VariableNames.LOCAL_DATABASE_PATH_NAME, this.candidateFilePath);
    CombinedMetFragProcess combinedMetFragProcess = new CombinedMetFragProcess(settings);
    boolean compoundsRetrieved = false;
    try {
        compoundsRetrieved = combinedMetFragProcess.retrieveCompounds();
    } catch (Exception e1) {
        compoundsRetrieved = false;
        throw new Exception();
    }
    if (compoundsRetrieved) {
        CandidateList candidates = combinedMetFragProcess.getCandidateList();
        if (candidates == null || candidates.getNumberElements() == 0) {
            this.massSearchAvailable = false;
            this.formulaSearchAvailable = false;
            this.identifierSearchAvailable = false;
            return;
        }
        this.massSearchAvailable = candidates.getElement(0).getProperties().containsKey(VariableNames.MONOISOTOPIC_MASS_NAME) ? true : false;
        this.formulaSearchAvailable = candidates.getElement(0).getProperties().containsKey(VariableNames.MOLECULAR_FORMULA_NAME) ? true : false;
        this.identifierSearchAvailable = candidates.getElement(0).getProperties().containsKey(VariableNames.IDENTIFIER_NAME) ? true : false;
        try {
            this.retrieveCompoundsButtonLabel = "Retrieve Candidates";
            this.databaseRelativeMassDeviation = null;
        } catch (Exception e) {
            this.retrieveCompoundsButtonLabel = "Retrieve Candidates";
        }
    }
}
Also used : MetFragGlobalSettings(de.ipbhalle.metfraglib.settings.MetFragGlobalSettings) CandidateList(de.ipbhalle.metfraglib.list.CandidateList) RetentionTimeNotFoundException(de.ipbhalle.metfraglib.exceptions.RetentionTimeNotFoundException) ParameterNotKnownException(de.ipbhalle.metfraglib.exceptions.ParameterNotKnownException) TooFewCandidatesException(de.ipbhalle.metfraglib.exceptions.TooFewCandidatesException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException) CombinedMetFragProcess(de.ipbhalle.metfraglib.process.CombinedMetFragProcess)

Aggregations

CombinedMetFragProcess (de.ipbhalle.metfraglib.process.CombinedMetFragProcess)15 MetFragGlobalSettings (de.ipbhalle.metfraglib.settings.MetFragGlobalSettings)14 AtomTypeNotKnownFromInputListException (de.ipbhalle.metfraglib.exceptions.AtomTypeNotKnownFromInputListException)6 CandidateList (de.ipbhalle.metfraglib.list.CandidateList)6 SortedScoredCandidateList (de.ipbhalle.metfraglib.list.SortedScoredCandidateList)6 RelativeIntensityNotDefinedException (de.ipbhalle.metfraglib.exceptions.RelativeIntensityNotDefinedException)5 File (java.io.File)5 SettingsChecker (de.ipbhalle.metfraglib.parameter.SettingsChecker)4 IOException (java.io.IOException)4 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)4 ParameterNotKnownException (de.ipbhalle.metfraglib.exceptions.ParameterNotKnownException)3 RetentionTimeNotFoundException (de.ipbhalle.metfraglib.exceptions.RetentionTimeNotFoundException)3 TooFewCandidatesException (de.ipbhalle.metfraglib.exceptions.TooFewCandidatesException)3 ICandidate (de.ipbhalle.metfraglib.interfaces.ICandidate)3 IMolecularFormula (org.openscience.cdk.interfaces.IMolecularFormula)3 MatchList (de.ipbhalle.metfraglib.list.MatchList)2 ScoredCandidateList (de.ipbhalle.metfraglib.list.ScoredCandidateList)2 FileNotFoundException (java.io.FileNotFoundException)2 CouldNotCreateProcessException (de.ipbhalle.exception.CouldNotCreateProcessException)1 CouldNotFetchResultsException (de.ipbhalle.exception.CouldNotFetchResultsException)1