Search in sources :

Example 1 with SpectraVisualizerWindow

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow in project mzmine2 by mzmine.

the class ProjectTreeMouseHandler method handleDoubleClickEvent.

private void handleDoubleClickEvent(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) {
        RawDataFile clickedFile = (RawDataFile) clickedObject;
        TICVisualizerModule.setupNewTICVisualizer(clickedFile);
    }
    if (clickedObject instanceof PeakList) {
        PeakList clickedPeakList = (PeakList) clickedObject;
        PeakListTableModule.showNewPeakListVisualizerWindow(clickedPeakList);
    }
    if (clickedObject instanceof Scan) {
        Scan clickedScan = (Scan) clickedObject;
        SpectraVisualizerModule.showNewSpectrumWindow(clickedScan.getDataFile(), clickedScan.getScanNumber());
    }
    if (clickedObject instanceof MassList) {
        MassList clickedMassList = (MassList) clickedObject;
        Scan clickedScan = clickedMassList.getScan();
        SpectraVisualizerWindow window = SpectraVisualizerModule.showNewSpectrumWindow(clickedScan.getDataFile(), clickedScan.getScanNumber());
        MassListDataSet dataset = new MassListDataSet(clickedMassList);
        window.addDataSet(dataset, Color.green);
    }
    if (clickedObject instanceof PeakListRow) {
        PeakListRow clickedPeak = (PeakListRow) clickedObject;
        PeakSummaryVisualizerModule.showNewPeakSummaryWindow(clickedPeak);
    }
}
Also used : SpectraVisualizerWindow(net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow) 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) MassListDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.MassListDataSet) MassList(net.sf.mzmine.datamodel.MassList)

Example 2 with SpectraVisualizerWindow

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow in project mzmine2 by mzmine.

the class FeatureOverviewWindow method addSpectraMS2.

private JSplitPane addSpectraMS2() {
    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    SpectraVisualizerWindow spectraWindowMS2 = new SpectraVisualizerWindow(rawFiles[0]);
    spectraWindowMS2.loadRawData(rawFiles[0].getScan(feature.getMostIntenseFragmentScanNumber()));
    pane.add(spectraWindowMS2.getSpectrumPlot());
    pane.add(spectraWindowMS2.getToolBar());
    pane.setResizeWeight(1);
    pane.setEnabled(false);
    pane.setDividerSize(0);
    return pane;
}
Also used : SpectraVisualizerWindow(net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow) JSplitPane(javax.swing.JSplitPane)

Example 3 with SpectraVisualizerWindow

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow 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 4 with SpectraVisualizerWindow

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow in project mzmine2 by mzmine.

the class ResultWindow method actionPerformed.

public void actionPerformed(ActionEvent e) {
    String command = e.getActionCommand();
    if (command.equals("EXPORT")) {
        // Ask for filename
        JFileChooser fileChooser = new JFileChooser();
        fileChooser.setApproveButtonText("Export");
        int result = fileChooser.showSaveDialog(MZmineCore.getDesktop().getMainWindow());
        if (result != JFileChooser.APPROVE_OPTION)
            return;
        File outputFile = fileChooser.getSelectedFile();
        try {
            FileWriter fileWriter = new FileWriter(outputFile);
            BufferedWriter writer = new BufferedWriter(fileWriter);
            writer.write("Formula,Mass,RDBE,Isotope pattern score,MS/MS score");
            writer.newLine();
            for (int row = 0; row < resultsTable.getRowCount(); row++) {
                int modelRow = resultsTable.convertRowIndexToModel(row);
                ResultFormula formula = resultsTableModel.getFormula(modelRow);
                writer.write(formula.getFormulaAsString());
                writer.write(",");
                writer.write(String.valueOf(formula.getExactMass()));
                writer.write(",");
                if (formula.getRDBE() != null)
                    writer.write(String.valueOf(formula.getRDBE()));
                writer.write(",");
                if (formula.getIsotopeScore() != null)
                    writer.write(String.valueOf(formula.getIsotopeScore()));
                writer.write(",");
                if (formula.getMSMSScore() != null)
                    writer.write(String.valueOf(formula.getMSMSScore()));
                writer.newLine();
            }
            writer.close();
        } catch (Exception ex) {
            MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "Error writing to file " + outputFile + ": " + ExceptionUtils.exceptionToString(ex));
        }
        return;
    }
    // The following actions require a single row to be selected
    int index = resultsTable.getSelectedRow();
    if (index < 0) {
        MZmineCore.getDesktop().displayMessage(MZmineCore.getDesktop().getMainWindow(), "Please select one result");
        return;
    }
    index = resultsTable.convertRowIndexToModel(index);
    ResultFormula formula = resultsTableModel.getFormula(index);
    if (command.equals("ADD")) {
        SimplePeakIdentity newIdentity = new SimplePeakIdentity(formula.getFormulaAsString());
        peakListRow.addPeakIdentity(newIdentity, false);
        // Notify the GUI about the change in the project
        MZmineCore.getProjectManager().getCurrentProject().notifyObjectChanged(peakListRow, false);
        // Repaint the window to reflect the change in the feature list
        MZmineCore.getDesktop().getMainWindow().repaint();
        dispose();
    }
    if (command.equals("COPY")) {
        String formulaString = formula.getFormulaAsString();
        StringSelection stringSelection = new StringSelection(formulaString);
        Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
        clipboard.setContents(stringSelection, null);
    }
    if (command.equals("SHOW_ISOTOPES")) {
        logger.finest("Showing isotope pattern for formula " + formula.getFormulaAsString());
        IsotopePattern predictedPattern = formula.getPredictedIsotopes();
        if (predictedPattern == null)
            return;
        Feature peak = peakListRow.getBestPeak();
        RawDataFile dataFile = peak.getDataFile();
        int scanNumber = peak.getRepresentativeScanNumber();
        SpectraVisualizerModule.showNewSpectrumWindow(dataFile, scanNumber, null, peak.getIsotopePattern(), predictedPattern);
    }
    if (command.equals("SHOW_MSMS")) {
        Feature bestPeak = peakListRow.getBestPeak();
        RawDataFile dataFile = bestPeak.getDataFile();
        int msmsScanNumber = bestPeak.getMostIntenseFragmentScanNumber();
        if (msmsScanNumber < 1)
            return;
        SpectraVisualizerWindow msmsPlot = SpectraVisualizerModule.showNewSpectrumWindow(dataFile, msmsScanNumber);
        if (msmsPlot == null)
            return;
        Map<DataPoint, String> annotation = formula.getMSMSannotation();
        if (annotation == null)
            return;
        msmsPlot.addAnnotation(annotation);
    }
}
Also used : FileWriter(java.io.FileWriter) IsotopePattern(net.sf.mzmine.datamodel.IsotopePattern) SimplePeakIdentity(net.sf.mzmine.datamodel.impl.SimplePeakIdentity) Feature(net.sf.mzmine.datamodel.Feature) DataPoint(net.sf.mzmine.datamodel.DataPoint) BufferedWriter(java.io.BufferedWriter) StringSelection(java.awt.datatransfer.StringSelection) SpectraVisualizerWindow(net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow) JFileChooser(javax.swing.JFileChooser) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) DataPoint(net.sf.mzmine.datamodel.DataPoint) Clipboard(java.awt.datatransfer.Clipboard) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) File(java.io.File)

Example 5 with SpectraVisualizerWindow

use of net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow in project mzmine2 by mzmine.

the class FeatureOverviewWindow method addSpectraMS1.

private JSplitPane addSpectraMS1() {
    JSplitPane pane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    SpectraVisualizerWindow spectraWindowMS1 = new SpectraVisualizerWindow(rawFiles[0]);
    spectraWindowMS1.loadRawData(rawFiles[0].getScan(feature.getRepresentativeScanNumber()));
    pane.add(spectraWindowMS1.getSpectrumPlot());
    pane.add(spectraWindowMS1.getToolBar());
    pane.setResizeWeight(1);
    pane.setEnabled(false);
    pane.setDividerSize(0);
    return pane;
}
Also used : SpectraVisualizerWindow(net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow) JSplitPane(javax.swing.JSplitPane)

Aggregations

SpectraVisualizerWindow (net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerWindow)5 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)3 JSplitPane (javax.swing.JSplitPane)2 TreePath (javax.swing.tree.TreePath)2 MassList (net.sf.mzmine.datamodel.MassList)2 PeakList (net.sf.mzmine.datamodel.PeakList)2 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)2 Scan (net.sf.mzmine.datamodel.Scan)2 MassListDataSet (net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.MassListDataSet)2 Clipboard (java.awt.datatransfer.Clipboard)1 StringSelection (java.awt.datatransfer.StringSelection)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 ArrayList (java.util.ArrayList)1 JFileChooser (javax.swing.JFileChooser)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 DataPoint (net.sf.mzmine.datamodel.DataPoint)1 Feature (net.sf.mzmine.datamodel.Feature)1 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)1