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);
}
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);
}
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());
}
}
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);
}
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();
}
Aggregations