Search in sources :

Example 1 with HeadLessDesktop

use of net.sf.mzmine.desktop.impl.HeadLessDesktop in project mzmine2 by mzmine.

the class SpectraIdentificationSpectralDatabaseTask method run.

/**
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    int count = 0;
    // add result frame
    resultWindow = new SpectraIdentificationResultsWindow();
    resultWindow.setVisible(true);
    try {
        tasks = parseFile(dataBaseFile);
        totalTasks = tasks.size();
        if (!tasks.isEmpty()) {
            // wait for the tasks to finish
            while (!isCanceled() && !tasks.isEmpty()) {
                for (int i = 0; i < tasks.size(); i++) {
                    if (tasks.get(i).isFinished() || tasks.get(i).isCanceled()) {
                        count += tasks.get(i).getCount();
                        tasks.remove(i);
                        i--;
                    }
                }
                // wait for all sub tasks to finish
                try {
                    Thread.sleep(100);
                } catch (Exception e) {
                    cancel();
                }
            }
            // cancelled
            if (isCanceled()) {
                tasks.stream().forEach(AbstractTask::cancel);
            }
        } else {
            setStatus(TaskStatus.ERROR);
            setErrorMessage("DB file was empty - or error while parsing " + dataBaseFile);
            return;
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Could not read file " + dataBaseFile, e);
        setStatus(TaskStatus.ERROR);
        setErrorMessage(e.toString());
    }
    logger.info("Added " + count + " spectral library matches");
    resultWindow.setTitle("Matched " + count + " compounds for scan#" + currentScan.getScanNumber());
    resultWindow.setMatchingFinished();
    resultWindow.revalidate();
    resultWindow.repaint();
    // Repaint the window
    Desktop desktop = MZmineCore.getDesktop();
    if (!(desktop instanceof HeadLessDesktop))
        desktop.getMainWindow().repaint();
    setStatus(TaskStatus.FINISHED);
}
Also used : AbstractTask(net.sf.mzmine.taskcontrol.AbstractTask) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop) Desktop(net.sf.mzmine.desktop.Desktop) SpectraIdentificationResultsWindow(net.sf.mzmine.modules.visualization.spectra.spectralmatchresults.SpectraIdentificationResultsWindow) IOException(java.io.IOException) UnsupportedFormatException(net.sf.mzmine.util.spectraldb.parser.UnsupportedFormatException) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop)

Example 2 with HeadLessDesktop

use of net.sf.mzmine.desktop.impl.HeadLessDesktop in project mzmine2 by mzmine.

the class CustomDBSearchTask method run.

/**
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    try {
        // read database contents in memory
        FileReader dbFileReader = new FileReader(dataBaseFile);
        databaseValues = CSVParser.parse(dbFileReader, fieldSeparator.charAt(0));
        if (ignoreFirstLine)
            finishedLines++;
        for (; finishedLines < databaseValues.length; finishedLines++) {
            if (isCanceled()) {
                dbFileReader.close();
                return;
            }
            try {
                processOneLine(databaseValues[finishedLines]);
            } catch (Exception e) {
            // ignore incorrect lines
            }
        }
        dbFileReader.close();
    } catch (Exception e) {
        logger.log(Level.WARNING, "Could not read file " + dataBaseFile, e);
        setStatus(TaskStatus.ERROR);
        setErrorMessage(e.toString());
        return;
    }
    // Add task description to peakList
    peakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Peak identification using database " + dataBaseFile, parameters));
    // Repaint the window to reflect the change in the feature list
    Desktop desktop = MZmineCore.getDesktop();
    if (!(desktop instanceof HeadLessDesktop))
        desktop.getMainWindow().repaint();
    setStatus(TaskStatus.FINISHED);
}
Also used : HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop) Desktop(net.sf.mzmine.desktop.Desktop) FileReader(java.io.FileReader) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop)

Example 3 with HeadLessDesktop

use of net.sf.mzmine.desktop.impl.HeadLessDesktop in project mzmine2 by mzmine.

the class AdductSearchTask method run.

@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    LOG.info("Starting adducts search in " + peakList);
    try {
        // Search the feature list for adducts.
        searchAdducts();
        if (!isCanceled()) {
            // Add task description to peakList.
            peakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Identification of adducts", parameters));
            // Repaint the window to reflect the change in the feature list
            Desktop desktop = MZmineCore.getDesktop();
            if (!(desktop instanceof HeadLessDesktop))
                desktop.getMainWindow().repaint();
            // Done.
            setStatus(TaskStatus.FINISHED);
            LOG.info("Finished adducts search in " + peakList);
        }
    } catch (Throwable t) {
        LOG.log(Level.SEVERE, "Adduct search error", t);
        setStatus(TaskStatus.ERROR);
        setErrorMessage(t.getMessage());
    }
}
Also used : HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop) Desktop(net.sf.mzmine.desktop.Desktop) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop)

Example 4 with HeadLessDesktop

use of net.sf.mzmine.desktop.impl.HeadLessDesktop in project mzmine2 by mzmine.

the class PrecursorDBSearchTask method run.

/**
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    int count = 0;
    try {
        tasks = parseFile(dataBaseFile);
        totalTasks = tasks.size();
        if (!tasks.isEmpty()) {
            // wait for the tasks to finish
            while (!isCanceled() && !tasks.isEmpty()) {
                for (int i = 0; i < tasks.size(); i++) {
                    if (tasks.get(i).isFinished() || tasks.get(i).isCanceled()) {
                        tasks.remove(i);
                        i--;
                    }
                }
                // wait for all sub tasks to finish
                try {
                    Thread.sleep(100);
                } catch (Exception e) {
                    cancel();
                }
            }
            // cancelled
            if (isCanceled()) {
                tasks.stream().forEach(AbstractTask::cancel);
            }
        } else {
            setStatus(TaskStatus.ERROR);
            setErrorMessage("DB file was empty - or error while parsing " + dataBaseFile);
        }
    } catch (Exception e) {
        logger.log(Level.SEVERE, "Could not read file " + dataBaseFile, e);
        setStatus(TaskStatus.ERROR);
        setErrorMessage(e.toString());
    }
    logger.info("Added " + matches.get() + " matches to possible precursors in library: " + dataBaseFile.getAbsolutePath());
    // Add task description to peakList
    peakList.addDescriptionOfAppliedTask(new SimplePeakListAppliedMethod("Possible precursor identification using MS/MS spectral database " + dataBaseFile, parameters));
    // Repaint the window to reflect the change in the feature list
    Desktop desktop = MZmineCore.getDesktop();
    if (!(desktop instanceof HeadLessDesktop))
        desktop.getMainWindow().repaint();
    setStatus(TaskStatus.FINISHED);
}
Also used : AbstractTask(net.sf.mzmine.taskcontrol.AbstractTask) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop) Desktop(net.sf.mzmine.desktop.Desktop) SimplePeakListAppliedMethod(net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod) IOException(java.io.IOException) UnsupportedFormatException(net.sf.mzmine.util.spectraldb.parser.UnsupportedFormatException) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop)

Example 5 with HeadLessDesktop

use of net.sf.mzmine.desktop.impl.HeadLessDesktop in project mzmine2 by mzmine.

the class PeakListIdentificationTask method notifyRow.

/**
 * Method notifies object about content update
 *
 * @param row to be notified
 */
private static void notifyRow(PeakListRow row) {
    MZmineCore.getProjectManager().getCurrentProject().notifyObjectChanged(row, false);
    Desktop desktop = MZmineCore.getDesktop();
    if (!(desktop instanceof HeadLessDesktop))
        desktop.getMainWindow().repaint();
}
Also used : HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop) Desktop(net.sf.mzmine.desktop.Desktop) HeadLessDesktop(net.sf.mzmine.desktop.impl.HeadLessDesktop)

Aggregations

Desktop (net.sf.mzmine.desktop.Desktop)17 HeadLessDesktop (net.sf.mzmine.desktop.impl.HeadLessDesktop)17 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)10 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)6 IOException (java.io.IOException)5 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)5 AbstractTask (net.sf.mzmine.taskcontrol.AbstractTask)4 UnsupportedFormatException (net.sf.mzmine.util.spectraldb.parser.UnsupportedFormatException)4 DataPoint (net.sf.mzmine.datamodel.DataPoint)3 Feature (net.sf.mzmine.datamodel.Feature)2 SpectraIdentificationResultsWindow (net.sf.mzmine.modules.visualization.spectra.spectralmatchresults.SpectraIdentificationResultsWindow)2 PeakListRowSorter (net.sf.mzmine.util.PeakListRowSorter)2 File (java.io.File)1 FileReader (java.io.FileReader)1 Locale (java.util.Locale)1 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)1 PeakList (net.sf.mzmine.datamodel.PeakList)1 Scan (net.sf.mzmine.datamodel.Scan)1 MainWindow (net.sf.mzmine.desktop.impl.MainWindow)1 MZmineConfigurationImpl (net.sf.mzmine.main.impl.MZmineConfigurationImpl)1