use of net.sf.mzmine.taskcontrol.Task in project mzmine2 by mzmine.
the class MultiThreadPeakFinderMainTask method run.
@Override
public void run() {
setStatus(TaskStatus.PROCESSING);
logger.info("Running multithreaded gap filler on " + peakList);
// Create new results feature list
processedPeakList = createResultsPeakList();
progress = 0.5;
// split raw data files into groups for each thread (task)
// Obtain the settings of max concurrent threads
// as this task uses one thread
int maxRunningThreads = getMaxThreads();
// raw files
int raw = peakList.getNumberOfRawDataFiles();
// create consumer of resultpeaklist
SubTaskFinishListener listener = new SubTaskFinishListener(project, parameters, peakList, removeOriginal, maxRunningThreads);
// Submit the tasks to the task controller for processing
Task[] tasks = createSubTasks(raw, maxRunningThreads, listener);
// listener for status change: Cancel / error
TaskStatusListener list = new TaskStatusListener() {
@Override
public void taskStatusChanged(Task task, TaskStatus newStatus, TaskStatus oldStatus) {
if (newStatus.equals(TaskStatus.CANCELED) || newStatus.equals(TaskStatus.ERROR)) {
// if one is cancelled, stop all
synchronized (this) {
// cancel all
for (Task t : tasks) {
if (t instanceof AbstractTask)
((AbstractTask) t).removeTaskStatusListener(this);
t.cancel();
}
}
}
}
};
// add listener to all sub tasks
for (Task t : tasks) {
if (t instanceof AbstractTask)
((AbstractTask) t).addTaskStatusListener(list);
// add to batchMode collection
if (batchTasks != null)
batchTasks.add(t);
}
// start
MZmineCore.getTaskController().addTasks(tasks);
// listener will take care of adding the final list
progress = 1;
// end
logger.info("All sub tasks started for multithreaded gap-filling on " + peakList);
setStatus(TaskStatus.FINISHED);
}
use of net.sf.mzmine.taskcontrol.Task in project mzmine2 by mzmine.
the class CustomDBSearchModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
PeakList[] peakLists = parameters.getParameter(CustomDBSearchParameters.peakLists).getValue().getMatchingPeakLists();
for (PeakList peakList : peakLists) {
Task newTask = new CustomDBSearchTask(peakList, parameters);
tasks.add(newTask);
}
return ExitCode.OK;
}
use of net.sf.mzmine.taskcontrol.Task in project mzmine2 by mzmine.
the class PeaklistClearAnnotationsModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
final PeakList[] peakLists = parameters.getParameter(PeaklistClearAnnotationsParameters.PEAK_LISTS).getValue().getMatchingPeakLists();
for (PeakList peakList : peakLists) {
Task newTask = new PeaklistClearAnnotationsTask(project, peakList, parameters);
tasks.add(newTask);
}
return ExitCode.OK;
}
use of net.sf.mzmine.taskcontrol.Task in project mzmine2 by mzmine.
the class PeakFilterModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
final PeakList[] peakLists = parameters.getParameter(PeakFilterParameters.PEAK_LISTS).getValue().getMatchingPeakLists();
for (PeakList peakList : peakLists) {
Task newTask = new PeakFilterTask(project, peakList, parameters);
tasks.add(newTask);
}
return ExitCode.OK;
}
use of net.sf.mzmine.taskcontrol.Task in project mzmine2 by mzmine.
the class PeakListBlankSubtractionModule method runModule.
@Override
public ExitCode runModule(MZmineProject project, ParameterSet parameters, Collection<Task> tasks) {
Task task = new PeakListBlankSubtractionMasterTask(project, (PeakListBlankSubtractionParameters) parameters);
tasks.add(task);
return ExitCode.OK;
}
Aggregations