Search in sources :

Example 6 with MZmineProject

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

the class ProjectTreeMouseHandler method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    if (command.equals("SHOW_TIC")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        TICVisualizerModule.setupNewTICVisualizer(selectedFiles);
    }
    if (command.equals("SHOW_SPECTRUM")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        SpectraVisualizerModule module = MZmineCore.getModuleInstance(SpectraVisualizerModule.class);
        ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(SpectraVisualizerModule.class);
        parameters.getParameter(SpectraVisualizerParameters.dataFiles).setValue(RawDataFilesSelectionType.SPECIFIC_FILES, selectedFiles);
        ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
        MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
        if (exitCode == ExitCode.OK)
            module.runModule(project, parameters, new ArrayList<Task>());
    }
    if (command.equals("SHOW_IDA")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        if (selectedFiles.length == 0)
            return;
        MsMsVisualizerModule.showIDAVisualizerSetupDialog(selectedFiles[0]);
    }
    if (command.equals("SHOW_2D")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        if (selectedFiles.length == 0)
            return;
        TwoDVisualizerModule.show2DVisualizerSetupDialog(selectedFiles[0]);
    }
    if (command.equals("SHOW_3D")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        if (selectedFiles.length == 0)
            return;
        Fx3DVisualizerModule.setupNew3DVisualizer(selectedFiles[0]);
    }
    if (command.equals("SORT_FILES")) {
        // save current selection
        TreePath[] savedSelection = tree.getSelectionPaths();
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        SortDataFilesModule module = MZmineCore.getModuleInstance(SortDataFilesModule.class);
        ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(SortDataFilesModule.class);
        params.getParameter(SortDataFilesParameters.dataFiles).setValue(RawDataFilesSelectionType.SPECIFIC_FILES, selectedFiles);
        module.runModule(MZmineCore.getProjectManager().getCurrentProject(), params, new ArrayList<Task>());
        // restore selection
        tree.setSelectionPaths(savedSelection);
    }
    if (command.equals("REMOVE_EXTENSION")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        for (RawDataFile file : selectedFiles) {
            file.setName(FilenameUtils.removeExtension(file.toString()));
        }
        tree.updateUI();
    }
    if (command.equals("EXPORT_FILE")) {
        RawDataExportModule exportModule = MZmineCore.getModuleInstance(RawDataExportModule.class);
        ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(RawDataExportModule.class);
        ExitCode ec = params.showSetupDialog(null, true);
        if (ec == ExitCode.OK) {
            ParameterSet parametersCopy = params.cloneParameterSet();
            ArrayList<Task> tasks = new ArrayList<>();
            MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
            exportModule.runModule(project, parametersCopy, tasks);
            MZmineCore.getTaskController().addTasks(tasks.toArray(new Task[0]));
        }
    }
    if (command.equals("RENAME_FILE")) {
        TreePath path = tree.getSelectionPath();
        if (path == null)
            return;
        else
            tree.startEditingAtPath(path);
    }
    if (command.equals("REMOVE_FILE")) {
        RawDataFile[] selectedFiles = tree.getSelectedObjects(RawDataFile.class);
        PeakList[] allPeakLists = MZmineCore.getProjectManager().getCurrentProject().getPeakLists();
        for (RawDataFile file : selectedFiles) {
            for (PeakList peakList : allPeakLists) {
                if (peakList.hasRawDataFile(file)) {
                    String msg = "Cannot remove file " + file.getName() + ", because it is present in the feature list " + peakList.getName();
                    MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), msg);
                    return;
                }
            }
            MZmineCore.getProjectManager().getCurrentProject().removeFile(file);
        }
    }
    if (command.equals("SHOW_SCAN")) {
        Scan[] selectedScans = tree.getSelectedObjects(Scan.class);
        for (Scan scan : selectedScans) {
            SpectraVisualizerModule.showNewSpectrumWindow(scan.getDataFile(), scan.getScanNumber());
        }
    }
    if (command.equals("EXPORT_SCAN")) {
        Scan[] selectedScans = tree.getSelectedObjects(Scan.class);
        ExportScansModule.showSetupDialog(selectedScans);
    }
    if (command.equals("SHOW_MASSLIST")) {
        MassList[] selectedMassLists = tree.getSelectedObjects(MassList.class);
        for (MassList massList : selectedMassLists) {
            Scan scan = massList.getScan();
            SpectraVisualizerWindow window = SpectraVisualizerModule.showNewSpectrumWindow(scan.getDataFile(), scan.getScanNumber());
            MassListDataSet dataset = new MassListDataSet(massList);
            window.addDataSet(dataset, Color.green);
        }
    }
    if (command.equals("REMOVE_MASSLIST")) {
        MassList[] selectedMassLists = tree.getSelectedObjects(MassList.class);
        for (MassList massList : selectedMassLists) {
            Scan scan = massList.getScan();
            scan.removeMassList(massList);
        }
    }
    if (command.equals("REMOVE_ALL_MASSLISTS")) {
        MassList[] selectedMassLists = tree.getSelectedObjects(MassList.class);
        for (MassList massList : selectedMassLists) {
            String massListName = massList.getName();
            RawDataFile[] dataFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
            for (RawDataFile dataFile : dataFiles) {
                int[] scanNumbers = dataFile.getScanNumbers();
                for (int scanNum : scanNumbers) {
                    Scan scan = dataFile.getScan(scanNum);
                    MassList ml = scan.getMassList(massListName);
                    if (ml != null)
                        scan.removeMassList(ml);
                }
            }
        }
    }
    if (command.equals("SHOW_PEAKLIST_TABLES")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) {
            PeakListTableModule.showNewPeakListVisualizerWindow(peakList);
        }
    }
    if (command.equals("SHOW_PEAKLIST_INFO")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) {
            InfoVisualizerModule.showNewPeakListInfo(peakList);
        }
    }
    if (command.equals("SHOW_SCATTER_PLOT")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) {
            ScatterPlotVisualizerModule.showNewScatterPlotWindow(peakList);
        }
    }
    if (command.equals("SORT_PEAKLISTS")) {
        // save current selection
        TreePath[] savedSelection = tree.getSelectionPaths();
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        SortPeakListsModule module = MZmineCore.getModuleInstance(SortPeakListsModule.class);
        ParameterSet params = MZmineCore.getConfiguration().getModuleParameters(SortPeakListsModule.class);
        params.getParameter(SortPeakListsParameters.peakLists).setValue(PeakListsSelectionType.SPECIFIC_PEAKLISTS, selectedPeakLists);
        module.runModule(MZmineCore.getProjectManager().getCurrentProject(), params, new ArrayList<Task>());
        // restore selection
        tree.setSelectionPaths(savedSelection);
    }
    if (command.equals("RENAME_FEATURELIST")) {
        TreePath path = tree.getSelectionPath();
        if (path == null)
            return;
        else
            tree.startEditingAtPath(path);
    }
    if (command.equals("REMOVE_PEAKLIST")) {
        PeakList[] selectedPeakLists = tree.getSelectedObjects(PeakList.class);
        for (PeakList peakList : selectedPeakLists) MZmineCore.getProjectManager().getCurrentProject().removePeakList(peakList);
    }
    if (command.equals("SHOW_PEAK_SUMMARY")) {
        PeakListRow[] selectedRows = tree.getSelectedObjects(PeakListRow.class);
        for (PeakListRow row : selectedRows) {
            PeakSummaryVisualizerModule.showNewPeakSummaryWindow(row);
        }
    }
}
Also used : Task(net.sf.mzmine.taskcontrol.Task) ExitCode(net.sf.mzmine.util.ExitCode) ArrayList(java.util.ArrayList) SpectraVisualizerWindow(net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) SpectraVisualizerModule(net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerModule) MZmineProject(net.sf.mzmine.datamodel.MZmineProject) MassListDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.MassListDataSet) ParameterSet(net.sf.mzmine.parameters.ParameterSet) SortDataFilesModule(net.sf.mzmine.modules.rawdatamethods.sortdatafiles.SortDataFilesModule) RawDataExportModule(net.sf.mzmine.modules.rawdatamethods.rawdataexport.RawDataExportModule) TreePath(javax.swing.tree.TreePath) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Scan(net.sf.mzmine.datamodel.Scan) PeakList(net.sf.mzmine.datamodel.PeakList) MassList(net.sf.mzmine.datamodel.MassList) SortPeakListsModule(net.sf.mzmine.modules.peaklistmethods.sortpeaklists.SortPeakListsModule)

Example 7 with MZmineProject

use of net.sf.mzmine.datamodel.MZmineProject 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 8 with MZmineProject

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

the class MainMenu method actionPerformed.

/**
 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 */
@Override
public void actionPerformed(ActionEvent e) {
    Object src = e.getSource();
    MZmineRunnableModule module = moduleMenuItems.get(src);
    if (module != null) {
        ParameterSet moduleParameters = MZmineCore.getConfiguration().getModuleParameters(module.getClass());
        RawDataFile[] selectedFiles = MZmineCore.getDesktop().getSelectedDataFiles();
        if (selectedFiles.length > 0) {
            for (Parameter<?> p : moduleParameters.getParameters()) {
                if (p instanceof RawDataFilesParameter) {
                    RawDataFilesParameter rdp = (RawDataFilesParameter) p;
                    rdp.setValue(RawDataFilesSelectionType.GUI_SELECTED_FILES);
                }
            }
        }
        PeakList[] selectedPeakLists = MZmineCore.getDesktop().getSelectedPeakLists();
        if (selectedPeakLists.length > 0) {
            for (Parameter<?> p : moduleParameters.getParameters()) {
                if (p instanceof PeakListsParameter) {
                    PeakListsParameter plp = (PeakListsParameter) p;
                    plp.setValue(PeakListsSelectionType.GUI_SELECTED_PEAKLISTS);
                }
            }
        }
        logger.finest("Setting parameters for module " + module.getName());
        ExitCode exitCode = moduleParameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
        if (exitCode == ExitCode.OK) {
            ParameterSet parametersCopy = moduleParameters.cloneParameterSet();
            logger.finest("Starting module " + module.getName() + " with parameters " + parametersCopy);
            ArrayList<Task> tasks = new ArrayList<Task>();
            MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
            module.runModule(project, parametersCopy, tasks);
            MZmineCore.getTaskController().addTasks(tasks.toArray(new Task[0]));
        }
        return;
    }
    if (src == projectExit) {
        MZmineCore.getDesktop().exitMZmine();
    }
    if (src == projectSaveParameters) {
        JFileChooser chooser = new JFileChooser();
        int returnVal = chooser.showSaveDialog(MZmineCore.getDesktop().getMainWindow());
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File configFile = chooser.getSelectedFile();
            try {
                MZmineCore.getConfiguration().saveConfiguration(configFile);
            } catch (Exception ex) {
                MZmineCore.getDesktop().displayException(MZmineCore.getDesktop().getMainWindow(), ex);
            }
        }
    }
    if (src == projectLoadParameters) {
        JFileChooser chooser = new JFileChooser();
        int returnVal = chooser.showOpenDialog(MZmineCore.getDesktop().getMainWindow());
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            File configFile = chooser.getSelectedFile();
            try {
                MZmineCore.getConfiguration().loadConfiguration(configFile);
            } catch (Exception ex) {
                MZmineCore.getDesktop().displayException(MZmineCore.getDesktop().getMainWindow(), ex);
            }
        }
    }
    if (src == projectSampleParameters) {
        ProjectParametersSetupDialog dialog = new ProjectParametersSetupDialog();
        dialog.setVisible(true);
    }
    if (src == projectPreferences) {
        MZminePreferences preferences = MZmineCore.getConfiguration().getPreferences();
        preferences.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    }
    if (src == showAbout) {
        MainWindow mainWindow = (MainWindow) MZmineCore.getDesktop();
        mainWindow.showAboutDialog();
    }
    if (src == checkUpdate) {
        // Check for updated version
        NewVersionCheck NVC = new NewVersionCheck(CheckType.MENU);
        new Thread(NVC).start();
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) ProjectOpeningTask(net.sf.mzmine.modules.projectmethods.projectload.ProjectOpeningTask) Task(net.sf.mzmine.taskcontrol.Task) MZmineRunnableModule(net.sf.mzmine.modules.MZmineRunnableModule) ProjectParametersSetupDialog(net.sf.mzmine.project.parameterssetup.ProjectParametersSetupDialog) ExitCode(net.sf.mzmine.util.ExitCode) ArrayList(java.util.ArrayList) NewVersionCheck(net.sf.mzmine.main.NewVersionCheck) MZminePreferences(net.sf.mzmine.desktop.preferences.MZminePreferences) JFileChooser(javax.swing.JFileChooser) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) MZmineProject(net.sf.mzmine.datamodel.MZmineProject) PeakListsParameter(net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter) PeakList(net.sf.mzmine.datamodel.PeakList) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) File(java.io.File) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)

Example 9 with MZmineProject

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

the class SignificanceParameters method showSetupDialog.

@Override
public ExitCode showSetupDialog(Window parent, boolean valueCheckRequired) {
    // Update the parameter choices
    MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
    UserParameter[] newChoices = project.getParameters();
    getParameter(SignificanceParameters.selectionData).setChoices(newChoices);
    // Add a message
    String message = "<html>To view the results of ANOVA test, export the feature list to CSV file " + "and look for column ANOVA_P_VALUE. Click Help for details.</html>";
    ParameterSetupDialog dialog = new ParameterSetupDialog(parent, valueCheckRequired, this, message);
    dialog.setVisible(true);
    return dialog.getExitCode();
}
Also used : UserParameter(net.sf.mzmine.parameters.UserParameter) MZmineProject(net.sf.mzmine.datamodel.MZmineProject) ParameterSetupDialog(net.sf.mzmine.parameters.dialogs.ParameterSetupDialog)

Example 10 with MZmineProject

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

the class IntensityPlotDataset method getFiles.

RawDataFile[] getFiles(Comparable<?> xValue) {
    if (xAxisValueSource instanceof String) {
        RawDataFile columnFile = selectedFiles[getColumnIndex(xValue)];
        return new RawDataFile[] { columnFile };
    }
    if (xAxisValueSource instanceof ParameterWrapper) {
        HashSet<RawDataFile> files = new HashSet<RawDataFile>();
        UserParameter<?, ?> xAxisParameter = ((ParameterWrapper) xAxisValueSource).getParameter();
        MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
        for (RawDataFile file : selectedFiles) {
            Object fileValue = project.getParameterValue(xAxisParameter, file);
            if (fileValue == null)
                continue;
            if (fileValue.equals(xValue))
                files.add(file);
        }
        return files.toArray(new RawDataFile[0]);
    }
    return null;
}
Also used : RawDataFile(net.sf.mzmine.datamodel.RawDataFile) MZmineProject(net.sf.mzmine.datamodel.MZmineProject) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

Aggregations

MZmineProject (net.sf.mzmine.datamodel.MZmineProject)11 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)8 PeakList (net.sf.mzmine.datamodel.PeakList)5 UserParameter (net.sf.mzmine.parameters.UserParameter)4 ArrayList (java.util.ArrayList)3 ParameterSet (net.sf.mzmine.parameters.ParameterSet)3 Task (net.sf.mzmine.taskcontrol.Task)3 ExitCode (net.sf.mzmine.util.ExitCode)3 Nonnull (javax.annotation.Nonnull)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 TreePath (javax.swing.tree.TreePath)2 MassList (net.sf.mzmine.datamodel.MassList)2 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)2 Scan (net.sf.mzmine.datamodel.Scan)2 File (java.io.File)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 HashSet (java.util.HashSet)1 LinkedHashSet (java.util.LinkedHashSet)1 JFileChooser (javax.swing.JFileChooser)1