Search in sources :

Example 51 with PeakList

use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.

the class ProjectTreeMouseHandler method handlePopupTriggerEvent.

private void handlePopupTriggerEvent(MouseEvent e) {
    TreePath clickedPath = tree.getPathForLocation(e.getX(), e.getY());
    if (clickedPath == null)
        return;
    DefaultMutableTreeNode node = (DefaultMutableTreeNode) clickedPath.getLastPathComponent();
    Object clickedObject = node.getUserObject();
    if (clickedObject instanceof RawDataFile)
        dataFilePopupMenu.show(e.getComponent(), e.getX(), e.getY());
    if (clickedObject instanceof Scan)
        scanPopupMenu.show(e.getComponent(), e.getX(), e.getY());
    if (clickedObject instanceof MassList)
        massListPopupMenu.show(e.getComponent(), e.getX(), e.getY());
    if (clickedObject instanceof PeakList)
        peakListPopupMenu.show(e.getComponent(), e.getX(), e.getY());
    if (clickedObject instanceof PeakListRow)
        peakListRowPopupMenu.show(e.getComponent(), e.getX(), e.getY());
}
Also used : PeakListRow(net.sf.mzmine.datamodel.PeakListRow) TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Scan(net.sf.mzmine.datamodel.Scan) PeakList(net.sf.mzmine.datamodel.PeakList) MassList(net.sf.mzmine.datamodel.MassList)

Example 52 with PeakList

use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.

the class ProjectTreeRenderer method getTreeCellRendererComponent.

public Component getTreeCellRendererComponent(JTree tree, Object node, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) {
    JLabel label = (JLabel) super.getTreeCellRendererComponent(tree, node, sel, expanded, leaf, row, hasFocus);
    DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) node;
    Object embeddedObject = treeNode.getUserObject();
    if (embeddedObject instanceof MZmineProject) {
        label.setIcon(projectIcon);
        label.setFont(bigFont);
    }
    if (embeddedObject == RawDataTreeModel.dataFilesNodeName) {
        label.setIcon(dataFileIcon);
        label.setFont(bigFont);
    }
    if (embeddedObject == PeakListTreeModel.peakListsNodeName) {
        label.setFont(bigFont);
        label.setIcon(peakListsIcon);
    }
    if (embeddedObject instanceof RawDataFile) {
        label.setFont(smallerFont);
        boolean hasMassList = RawDataFileUtils.hasMassLists((RawDataFile) embeddedObject);
        if (hasMassList)
            label.setIcon(fileWithMassListIcon);
        else
            label.setIcon(fileIcon);
    }
    if (embeddedObject instanceof Scan) {
        Scan s = (Scan) embeddedObject;
        label.setIcon(spectrumIcon);
        label.setFont(smallFont);
        // could get blue text on blue background
        if (!sel) {
            if (s.getMSLevel() > 1)
                label.setForeground(Color.red);
            else
                label.setForeground(Color.blue);
        }
    }
    if (embeddedObject instanceof MassList) {
        label.setIcon(peakListIcon);
        label.setFont(smallFont);
    }
    if (embeddedObject instanceof PeakList) {
        PeakList p = (PeakList) embeddedObject;
        if (p.getNumberOfRawDataFiles() > 1) {
            label.setFont(smallerFont.deriveFont(Font.BOLD));
            label.setIcon(alignedPeaklistIcon);
        } else {
            label.setFont(smallerFont);
            label.setIcon(peakListIcon);
        }
    }
    if (embeddedObject instanceof PeakListRow) {
        PeakListRow r = (PeakListRow) embeddedObject;
        label.setIcon(peakIcon);
        label.setFont(smallFont);
        // Change the color only if the row is not selected
        if (!sel) {
            if (r.getPreferredPeakIdentity() != null) {
                label.setForeground(Color.red);
            }
        }
    }
    return label;
}
Also used : PeakListRow(net.sf.mzmine.datamodel.PeakListRow) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) JLabel(javax.swing.JLabel) MZmineProject(net.sf.mzmine.datamodel.MZmineProject) Scan(net.sf.mzmine.datamodel.Scan) PeakList(net.sf.mzmine.datamodel.PeakList) MassList(net.sf.mzmine.datamodel.MassList)

Example 53 with PeakList

use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.

the class BatchTask method run.

@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    logger.info("Starting a batch of " + totalSteps + " steps");
    // Listen for new items in the project
    MZmineProjectListener listener = new MZmineProjectListener() {

        @Override
        public void peakListAdded(PeakList newPeakList) {
            createdPeakLists.add(newPeakList);
        }

        @Override
        public void dataFileAdded(RawDataFile newFile) {
            createdDataFiles.add(newFile);
        }
    };
    project.addProjectListener(listener);
    // Process individual batch steps
    for (int i = 0; i < totalSteps; i++) {
        processQueueStep(i);
        processedSteps++;
        // Update the project reference in case new project was loaded
        if (project != MZmineCore.getProjectManager().getCurrentProject()) {
            project.removeProjectListener(listener);
            project = MZmineCore.getProjectManager().getCurrentProject();
            project.addProjectListener(listener);
        }
        // If we are canceled or ran into error, stop here
        if (isCanceled() || (getStatus() == TaskStatus.ERROR)) {
            return;
        }
    }
    project.removeProjectListener(listener);
    logger.info("Finished a batch of " + totalSteps + " steps");
    setStatus(TaskStatus.FINISHED);
}
Also used : RawDataFile(net.sf.mzmine.datamodel.RawDataFile) PeakList(net.sf.mzmine.datamodel.PeakList) MZmineProjectListener(net.sf.mzmine.datamodel.MZmineProjectListener)

Example 54 with PeakList

use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.

the class BatchTask method processQueueStep.

private void processQueueStep(int stepNumber) {
    logger.info("Starting step # " + (stepNumber + 1));
    // Run next step of the batch
    MZmineProcessingStep<?> currentStep = queue.get(stepNumber);
    MZmineProcessingModule method = (MZmineProcessingModule) currentStep.getModule();
    ParameterSet batchStepParameters = currentStep.getParameterSet();
    // the ones from the previous step
    if (createdDataFiles.isEmpty())
        createdDataFiles.addAll(previousCreatedDataFiles);
    if (createdPeakLists.isEmpty())
        createdPeakLists.addAll(previousCreatedPeakLists);
    // state of the batch
    for (Parameter<?> p : batchStepParameters.getParameters()) {
        if (p instanceof RawDataFilesParameter) {
            RawDataFilesParameter rdp = (RawDataFilesParameter) p;
            RawDataFile[] createdFiles = createdDataFiles.toArray(new RawDataFile[0]);
            final RawDataFilesSelection selectedFiles = rdp.getValue();
            if (selectedFiles == null) {
                setStatus(TaskStatus.ERROR);
                setErrorMessage("Invalid parameter settings for module " + method.getName() + ": " + "Missing parameter value for " + p.getName());
                return;
            }
            selectedFiles.setBatchLastFiles(createdFiles);
        }
    }
    // state of the batch
    for (Parameter<?> p : batchStepParameters.getParameters()) {
        if (p instanceof PeakListsParameter) {
            PeakListsParameter rdp = (PeakListsParameter) p;
            PeakList[] createdPls = createdPeakLists.toArray(new PeakList[0]);
            final PeakListsSelection selectedPeakLists = rdp.getValue();
            if (selectedPeakLists == null) {
                setStatus(TaskStatus.ERROR);
                setErrorMessage("Invalid parameter settings for module " + method.getName() + ": " + "Missing parameter value for " + p.getName());
                return;
            }
            selectedPeakLists.setBatchLastPeakLists(createdPls);
        }
    }
    // Clear the saved data files and feature lists. Save them to the
    // "previous" lists, in case the next step does not produce any new data
    previousCreatedDataFiles.clear();
    previousCreatedDataFiles.addAll(createdDataFiles);
    previousCreatedPeakLists.clear();
    previousCreatedPeakLists.addAll(createdPeakLists);
    createdDataFiles.clear();
    createdPeakLists.clear();
    // Check if the parameter settings are valid
    ArrayList<String> messages = new ArrayList<String>();
    boolean paramsCheck = batchStepParameters.checkParameterValues(messages);
    if (!paramsCheck) {
        setStatus(TaskStatus.ERROR);
        setErrorMessage("Invalid parameter settings for module " + method.getName() + ": " + Arrays.toString(messages.toArray()));
    }
    ArrayList<Task> currentStepTasks = new ArrayList<Task>();
    ExitCode exitCode = method.runModule(project, batchStepParameters, currentStepTasks);
    if (exitCode != ExitCode.OK) {
        setStatus(TaskStatus.ERROR);
        setErrorMessage("Could not start batch step " + method.getName());
        return;
    }
    // If current step didn't produce any tasks, continue with next step
    if (currentStepTasks.isEmpty())
        return;
    boolean allTasksFinished = false;
    // Submit the tasks to the task controller for processing
    MZmineCore.getTaskController().addTasks(currentStepTasks.toArray(new Task[0]));
    while (!allTasksFinished) {
        // If we canceled the batch, cancel all running tasks
        if (isCanceled()) {
            for (Task stepTask : currentStepTasks) stepTask.cancel();
            return;
        }
        // First set to true, then check all tasks
        allTasksFinished = true;
        for (Task stepTask : currentStepTasks) {
            TaskStatus stepStatus = stepTask.getStatus();
            // If any of them is not finished, keep checking
            if (stepStatus != TaskStatus.FINISHED)
                allTasksFinished = false;
            // If there was an error, we have to stop the whole batch
            if (stepStatus == TaskStatus.ERROR) {
                setStatus(TaskStatus.ERROR);
                setErrorMessage(stepTask.getTaskDescription() + ": " + stepTask.getErrorMessage());
                return;
            }
            // whole batch
            if (stepStatus == TaskStatus.CANCELED) {
                setStatus(TaskStatus.CANCELED);
                for (Task t : currentStepTasks) t.cancel();
                return;
            }
        }
        // Wait 1s before checking the tasks again
        if (!allTasksFinished) {
            synchronized (this) {
                try {
                    this.wait(1000);
                } catch (InterruptedException e) {
                // ignore
                }
            }
        }
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) Task(net.sf.mzmine.taskcontrol.Task) AbstractTask(net.sf.mzmine.taskcontrol.AbstractTask) ExitCode(net.sf.mzmine.util.ExitCode) ArrayList(java.util.ArrayList) MZmineProcessingModule(net.sf.mzmine.modules.MZmineProcessingModule) TaskStatus(net.sf.mzmine.taskcontrol.TaskStatus) RawDataFilesSelection(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesSelection) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) PeakListsSelection(net.sf.mzmine.parameters.parametertypes.selectors.PeakListsSelection) PeakListsParameter(net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter) PeakList(net.sf.mzmine.datamodel.PeakList) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)

Example 55 with PeakList

use of net.sf.mzmine.datamodel.PeakList in project mzmine2 by mzmine.

the class ProjectTreeEditor method isCellEditable.

public boolean isCellEditable(EventObject e) {
    if (e instanceof MouseEvent) {
        MouseEvent me = (MouseEvent) e;
        TreePath clickedPath = projectTree.getPathForLocation(me.getX(), me.getY());
        if (clickedPath == null)
            return false;
        DefaultMutableTreeNode node = (DefaultMutableTreeNode) clickedPath.getLastPathComponent();
        Object editedObject = node.getUserObject();
        return ((editedObject instanceof RawDataFile) || (editedObject instanceof PeakList));
    }
    return true;
}
Also used : MouseEvent(java.awt.event.MouseEvent) TreePath(javax.swing.tree.TreePath) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) EventObject(java.util.EventObject) PeakList(net.sf.mzmine.datamodel.PeakList)

Aggregations

PeakList (net.sf.mzmine.datamodel.PeakList)120 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)41 Nonnull (javax.annotation.Nonnull)40 Task (net.sf.mzmine.taskcontrol.Task)37 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)36 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)26 Feature (net.sf.mzmine.datamodel.Feature)19 ArrayList (java.util.ArrayList)15 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)11 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)11 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)10 File (java.io.File)9 FileWriter (java.io.FileWriter)8 ParameterSet (net.sf.mzmine.parameters.ParameterSet)8 IOException (java.io.IOException)7 DataPoint (net.sf.mzmine.datamodel.DataPoint)7 Vector (java.util.Vector)6 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)6 MZmineProject (net.sf.mzmine.datamodel.MZmineProject)6 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)6