Search in sources :

Example 51 with Feature

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

the class PeakListTablePopupMenu method show.

@Override
public void show(final Component invoker, final int x, final int y) {
    // Select the row where clicked?
    final Point clickedPoint = new Point(x, y);
    final int clickedRow = table.rowAtPoint(clickedPoint);
    if (table.getSelectedRowCount() < 2) {
        ListSelectionModel selectionModel = table.getSelectionModel();
        selectionModel.setSelectionInterval(clickedRow, clickedRow);
    }
    // First, disable all the Show... items
    show2DItem.setEnabled(false);
    show3DItem.setEnabled(false);
    manuallyDefineItem.setEnabled(false);
    showMSMSItem.setEnabled(false);
    showMSMSMirrorItem.setEnabled(false);
    showSpectralDBResults.setEnabled(false);
    showAllMSMSItem.setEnabled(false);
    showIsotopePatternItem.setEnabled(false);
    showPeakRowSummaryItem.setEnabled(false);
    exportIsotopesItem.setEnabled(false);
    exportMSMSItem.setEnabled(false);
    exportMenu.setEnabled(false);
    // Enable row items if applicable
    final int[] selectedRows = table.getSelectedRows();
    final boolean rowsSelected = selectedRows.length > 0;
    deleteRowsItem.setEnabled(rowsSelected);
    clearIdsItem.setEnabled(rowsSelected);
    pasteIdsItem.setEnabled(rowsSelected && copiedId != null);
    plotRowsItem.setEnabled(rowsSelected);
    showMenu.setEnabled(rowsSelected);
    idsMenu.setEnabled(rowsSelected);
    exportIsotopesItem.setEnabled(rowsSelected);
    exportToSirius.setEnabled(rowsSelected);
    exportMSMSLibrary.setEnabled(rowsSelected);
    exportMS1Library.setEnabled(rowsSelected);
    exportMenu.setEnabled(rowsSelected);
    final boolean oneRowSelected = selectedRows.length == 1;
    searchMenu.setEnabled(true);
    // search methods for single rows
    onlineDbSearchItem.setEnabled(oneRowSelected);
    nistSearchItem.setEnabled(oneRowSelected);
    formulaItem.setEnabled(oneRowSelected);
    siriusItem.setEnabled(oneRowSelected);
    // search methods for single and multiple rows
    spectralDbSearchItem.setEnabled(true);
    // Find the row and column where the user clicked
    clickedDataFile = null;
    final int clickedColumn = columnModel.getColumn(table.columnAtPoint(clickedPoint)).getModelIndex();
    if (clickedRow >= 0 && clickedColumn >= 0) {
        final int rowIndex = table.convertRowIndexToModel(clickedRow);
        clickedPeakListRow = getPeakListRow(rowIndex);
        allClickedPeakListRows = new PeakListRow[selectedRows.length];
        for (int i = 0; i < selectedRows.length; i++) {
            allClickedPeakListRows[i] = getPeakListRow(table.convertRowIndexToModel(selectedRows[i]));
        }
        // Enable items.
        show2DItem.setEnabled(oneRowSelected);
        show3DItem.setEnabled(oneRowSelected);
        showPeakRowSummaryItem.setEnabled(oneRowSelected);
        if (clickedPeakListRow.getBestPeak() != null) {
            exportMSMSItem.setEnabled(oneRowSelected && clickedPeakListRow.getBestPeak().getMostIntenseFragmentScanNumber() > 0);
        }
        // If we clicked on data file columns, check the peak
        if (clickedColumn >= CommonColumnType.values().length) {
            // Enable manual peak picking
            manuallyDefineItem.setEnabled(oneRowSelected);
            // Find the actual peak, if we have it.
            clickedDataFile = peakList.getRawDataFile((clickedColumn - CommonColumnType.values().length) / DataFileColumnType.values().length);
            final Feature clickedPeak = getPeakListRow(table.convertRowIndexToModel(clickedRow)).getPeak(clickedDataFile);
            // If we have the peak, enable Show... items
            if (clickedPeak != null && oneRowSelected) {
                showIsotopePatternItem.setEnabled(clickedPeak.getIsotopePattern() != null);
            }
        } else {
            showIsotopePatternItem.setEnabled(clickedPeakListRow.getBestIsotopePattern() != null && oneRowSelected);
        }
        long nRowsWithFragmentation = Arrays.stream(allClickedPeakListRows).filter(r -> r.getBestFragmentation() != null).count();
        // always show for multi MSMS window
        showMSMSItem.setEnabled((oneRowSelected && getSelectedPeakForMSMS() != null && getSelectedPeakForMSMS().getMostIntenseFragmentScanNumber() > 0) || (selectedRows.length > 1 && nRowsWithFragmentation > 1));
        // always show if at least one fragmentation is available
        showAllMSMSItem.setEnabled(clickedPeakListRow.getBestFragmentation() != null && oneRowSelected);
        // only show if selected rows == 2 and both have MS2
        boolean bothMS2 = selectedRows.length == 2 && nRowsWithFragmentation == 2;
        showMSMSMirrorItem.setEnabled(bothMS2);
        // has identity of spectral database match
        showSpectralDBResults.setEnabled(hasSpectralDBIdentities(clickedPeakListRow));
        // open id url if available
        PeakIdentity pi = clickedPeakListRow.getPreferredPeakIdentity();
        String url = null;
        if (pi != null)
            url = pi.getPropertyValue(PeakIdentity.PROPERTY_URL);
        openCompoundIdUrl.setEnabled(url != null && !url.isEmpty());
    }
    copyIdsItem.setEnabled(oneRowSelected && allClickedPeakListRows[0].getPreferredPeakIdentity() != null);
    super.show(invoker, x, y);
}
Also used : SiriusExportModule(net.sf.mzmine.modules.peaklistmethods.io.siriusexport.SiriusExportModule) Arrays(java.util.Arrays) IntensityPlotModule(net.sf.mzmine.modules.visualization.intensityplot.IntensityPlotModule) URISyntaxException(java.net.URISyntaxException) Point(java.awt.Point) SpectraVisualizerModule(net.sf.mzmine.modules.visualization.spectra.simplespectra.SpectraVisualizerModule) DataFileColumnType(net.sf.mzmine.modules.visualization.peaklisttable.table.DataFileColumnType) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) SpectralDBPeakIdentity(net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity) SiriusProcessingModule(net.sf.mzmine.modules.peaklistmethods.identification.sirius.SiriusProcessingModule) Map(java.util.Map) URI(java.net.URI) PeakListTable(net.sf.mzmine.modules.visualization.peaklisttable.table.PeakListTable) ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) Fx3DVisualizerModule(net.sf.mzmine.modules.visualization.fx3d.Fx3DVisualizerModule) SortingProperty(net.sf.mzmine.util.SortingProperty) FormulaPredictionModule(net.sf.mzmine.modules.peaklistmethods.identification.formulaprediction.FormulaPredictionModule) Range(com.google.common.collect.Range) JMenu(javax.swing.JMenu) GUIUtils(net.sf.mzmine.util.GUIUtils) CommonColumnType(net.sf.mzmine.modules.visualization.peaklisttable.table.CommonColumnType) Component(java.awt.Component) Collectors(java.util.stream.Collectors) List(java.util.List) PeakSummaryVisualizerModule(net.sf.mzmine.modules.visualization.peaksummary.PeakSummaryVisualizerModule) MirrorScanWindow(net.sf.mzmine.modules.visualization.spectra.simplespectra.mirrorspectra.MirrorScanWindow) ListSelectionModel(javax.swing.ListSelectionModel) Scan(net.sf.mzmine.datamodel.Scan) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) MZmineCore(net.sf.mzmine.main.MZmineCore) ActionListener(java.awt.event.ActionListener) TICVisualizerModule(net.sf.mzmine.modules.visualization.tic.TICVisualizerModule) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) HashMap(java.util.HashMap) PeakList(net.sf.mzmine.datamodel.PeakList) ArrayList(java.util.ArrayList) MSMSLibrarySubmissionWindow(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.view.MSMSLibrarySubmissionWindow) SwingUtilities(javax.swing.SwingUtilities) MultiSpectraVisualizerWindow(net.sf.mzmine.modules.visualization.spectra.simplespectra.MultiSpectraVisualizerWindow) Feature(net.sf.mzmine.datamodel.Feature) JMenuItem(javax.swing.JMenuItem) AbstractTableModel(javax.swing.table.AbstractTableModel) XICManualPickerModule(net.sf.mzmine.modules.rawdatamethods.peakpicking.manual.XICManualPickerModule) MSMSExportModule(net.sf.mzmine.modules.visualization.peaklisttable.export.MSMSExportModule) NistMsSearchModule(net.sf.mzmine.modules.peaklistmethods.identification.nist.NistMsSearchModule) ManualPeakPickerModule(net.sf.mzmine.modules.rawdatamethods.peakpicking.manual.ManualPeakPickerModule) PeakListTableColumnModel(net.sf.mzmine.modules.visualization.peaklisttable.table.PeakListTableColumnModel) Desktop(java.awt.Desktop) MultiMSMSWindow(net.sf.mzmine.modules.visualization.spectra.multimsms.MultiMSMSWindow) TICPlotType(net.sf.mzmine.modules.visualization.tic.TICPlotType) JPopupMenu(javax.swing.JPopupMenu) SpectraIdentificationResultsWindow(net.sf.mzmine.modules.visualization.spectra.spectralmatchresults.SpectraIdentificationResultsWindow) TwoDVisualizerModule(net.sf.mzmine.modules.visualization.twod.TwoDVisualizerModule) IOException(java.io.IOException) ActionEvent(java.awt.event.ActionEvent) IsotopePatternExportModule(net.sf.mzmine.modules.visualization.peaklisttable.export.IsotopePatternExportModule) SortingDirection(net.sf.mzmine.util.SortingDirection) OnlineDBSearchModule(net.sf.mzmine.modules.peaklistmethods.identification.onlinedbsearch.OnlineDBSearchModule) LocalSpectralDBSearchModule(net.sf.mzmine.modules.peaklistmethods.identification.spectraldbsearch.LocalSpectralDBSearchModule) PeakIdentity(net.sf.mzmine.datamodel.PeakIdentity) SpectralDBPeakIdentity(net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity) PeakIdentity(net.sf.mzmine.datamodel.PeakIdentity) ListSelectionModel(javax.swing.ListSelectionModel) Point(java.awt.Point) Feature(net.sf.mzmine.datamodel.Feature) Point(java.awt.Point)

Example 52 with Feature

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

the class MSMSExportModule method exportMSMS.

public static void exportMSMS(PeakListRow row) {
    ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(MSMSExportModule.class);
    ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    if (exitCode != ExitCode.OK)
        return;
    File outputFile = parameters.getParameter(MSMSExportParameters.outputFile).getValue();
    String massListName = parameters.getParameter(MSMSExportParameters.massList).getValue();
    if ((outputFile == null) || (massListName == null))
        return;
    // Best peak always exists, because feature list row has at least one peak
    Feature bestPeak = row.getBestPeak();
    // Get the MS/MS scan number
    int msmsScanNumber = bestPeak.getMostIntenseFragmentScanNumber();
    if (msmsScanNumber < 1) {
        MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "There is no MS/MS scan for peak " + bestPeak);
        return;
    }
    // MS/MS scan must exist, because msmsScanNumber was > 0
    Scan msmsScan = bestPeak.getDataFile().getScan(msmsScanNumber);
    MassList massList = msmsScan.getMassList(massListName);
    if (massList == null) {
        MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "There is no mass list called " + massListName + " for MS/MS scan #" + msmsScanNumber + " (" + bestPeak.getDataFile() + ")");
        return;
    }
    DataPoint[] peaks = massList.getDataPoints();
    try {
        FileWriter fileWriter = new FileWriter(outputFile);
        BufferedWriter writer = new BufferedWriter(fileWriter);
        for (DataPoint peak : peaks) {
            writer.write(peak.getMZ() + " " + peak.getIntensity());
            writer.newLine();
        }
        writer.close();
    } catch (Exception e) {
        e.printStackTrace();
        MZmineCore.getDesktop().displayErrorMessage(MZmineCore.getDesktop().getMainWindow(), "Error writing to file " + outputFile + ": " + ExceptionUtils.exceptionToString(e));
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) ExitCode(net.sf.mzmine.util.ExitCode) FileWriter(java.io.FileWriter) Feature(net.sf.mzmine.datamodel.Feature) DataPoint(net.sf.mzmine.datamodel.DataPoint) BufferedWriter(java.io.BufferedWriter) DataPoint(net.sf.mzmine.datamodel.DataPoint) Scan(net.sf.mzmine.datamodel.Scan) File(java.io.File) MassList(net.sf.mzmine.datamodel.MassList)

Example 53 with Feature

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

the class IntensityPlotTooltipGenerator method generateToolTip.

/**
 * @see org.jfree.chart.labels.CategoryToolTipGenerator#generateToolTip(org.jfree.data.category.CategoryDataset,
 *      int, int)
 */
public String generateToolTip(CategoryDataset dataset, int row, int column) {
    Format intensityFormat = MZmineCore.getConfiguration().getIntensityFormat();
    Feature[] peaks = ((IntensityPlotDataset) dataset).getPeaks(row, column);
    RawDataFile[] files = ((IntensityPlotDataset) dataset).getFiles(column);
    StringBuffer sb = new StringBuffer();
    for (int i = 0; i < files.length; i++) {
        sb.append(files[i].getName());
        sb.append(": ");
        if (peaks[i] != null) {
            sb.append(peaks[i].toString());
            sb.append(", height: ");
            sb.append(intensityFormat.format(peaks[i].getHeight()));
        } else {
            sb.append("N/A");
        }
        sb.append("\n");
    }
    return sb.toString();
}
Also used : Format(java.text.Format) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Feature(net.sf.mzmine.datamodel.Feature)

Example 54 with Feature

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

the class Fx3DStageController method addMenuItems.

private void addMenuItems() {
    removeMenu.getItems().clear();
    for (Fx3DAbstractDataset dataset : visualizedMeshPlots) {
        MenuItem menuItem = new MenuItem(dataset.getFileName());
        removeMenu.getItems().add(menuItem);
        menuItem.setOnAction(new EventHandler<ActionEvent>() {

            public void handle(ActionEvent e) {
                LOG.finest("Context menu invoked. Remove Data file button clicked. Removing dataset " + dataset.getFileName() + " from the plot.");
                visualizedFiles.remove(dataset.getFile());
                visualizedMeshPlots.remove(dataset);
                updateGraph();
                addMenuItems();
            }
        });
    }
    addDatafileMenu.getItems().clear();
    for (RawDataFile file : allDataFiles) {
        if (!visualizedFiles.contains(file)) {
            MenuItem menuItem = new MenuItem(file.getName());
            addDatafileMenu.getItems().add(menuItem);
            final Fx3DStageController controller = this;
            menuItem.setOnAction(new EventHandler<ActionEvent>() {

                public void handle(ActionEvent e) {
                    LOG.finest("Context menu invoked. Add Data file button clicked. Adding dataset " + file.getName() + " to the plot.");
                    MZmineCore.getTaskController().addTask(new Fx3DSamplingTask(file, scanSel, mzRange, rtResolution, mzResolution, controller), TaskPriority.HIGH);
                    addMenuItems();
                }
            });
        }
    }
    addFeatureMenu.getItems().clear();
    for (PeakList peakList : allPeakLists) {
        Menu peakListMenu = new Menu(peakList.getName());
        addFeatureMenu.getItems().add(peakListMenu);
        RawDataFile[] dataFiles = peakList.getRawDataFiles();
        for (RawDataFile dataFile : dataFiles) {
            Menu dataFileMenu = new Menu(dataFile.getName());
            peakListMenu.getItems().add(dataFileMenu);
            Feature[] features = peakList.getPeaks(dataFile);
            for (Feature feature : features) {
                if (feature.getRawDataPointsRTRange().lowerEndpoint() >= rtRange.lowerEndpoint() && feature.getRawDataPointsRTRange().upperEndpoint() <= mzRange.upperEndpoint() && feature.getRawDataPointsMZRange().lowerEndpoint() >= mzRange.lowerEndpoint() && feature.getRawDataPointsMZRange().upperEndpoint() <= mzRange.upperEndpoint()) {
                    if (!visualizedFiles.contains(feature)) {
                        MenuItem menuItem = new MenuItem(feature.toString());
                        dataFileMenu.getItems().add(menuItem);
                        menuItem.setOnAction(new EventHandler<ActionEvent>() {

                            public void handle(ActionEvent e) {
                                LOG.finest("Context menu invoked. Add Feature button clicked. Adding dataset " + feature.toString() + " to the plot.");
                                PeakListRow row = peakList.getPeakRow(feature);
                                FeatureSelection featureSelection = new FeatureSelection(peakList, feature, row, dataFile);
                                Fx3DFeatureDataset featureDataset = new Fx3DFeatureDataset(featureSelection, rtResolution, mzResolution, rtRange, mzRange, maxOfAllBinnedIntensity, Color.rgb(165, 42, 42, 0.9));
                                addDataset(featureDataset);
                                addMenuItems();
                            }
                        });
                    }
                }
            }
        }
    }
}
Also used : ActionEvent(javafx.event.ActionEvent) MenuItem(javafx.scene.control.MenuItem) Feature(net.sf.mzmine.datamodel.Feature) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Menu(javafx.scene.control.Menu) PeakList(net.sf.mzmine.datamodel.PeakList) FeatureSelection(net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection)

Example 55 with Feature

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

the class PeakListTableModel method getValueAt.

/**
 * This method returns the value at given coordinates of the dataset or null if it is a missing
 * value
 */
public Object getValueAt(int row, int col) {
    PeakListRow peakListRow = peakList.getRow(row);
    if (isCommonColumn(col)) {
        CommonColumnType commonColumn = getCommonColumn(col);
        switch(commonColumn) {
            case ROWID:
                return new Integer(peakListRow.getID());
            case AVERAGEMZ:
                return new Double(peakListRow.getAverageMZ());
            case AVERAGERT:
                if (peakListRow.getAverageRT() <= 0)
                    return null;
                return new Double(peakListRow.getAverageRT());
            case COMMENT:
                return peakListRow.getComment();
            case IDENTITY:
                return peakListRow.getPreferredPeakIdentity();
            case PEAKSHAPE:
                return peakListRow;
        }
    } else {
        DataFileColumnType dataFileColumn = getDataFileColumn(col);
        RawDataFile file = getColumnDataFile(col);
        Feature peak = peakListRow.getPeak(file);
        if (peak == null) {
            if (dataFileColumn == DataFileColumnType.STATUS)
                return FeatureStatus.UNKNOWN;
            else
                return null;
        }
        switch(dataFileColumn) {
            case STATUS:
                return peak.getFeatureStatus();
            case PEAKSHAPE:
                return peak;
            case MZ:
                return peak.getMZ();
            case RT:
                if (peak.getRT() <= 0)
                    return null;
                return peak.getRT();
            case HEIGHT:
                if (peak.getHeight() <= 0)
                    return null;
                return peak.getHeight();
            case AREA:
                return peak.getArea();
            case DURATION:
                double rtLen = peak.getRawDataPointsRTRange().upperEndpoint() - peak.getRawDataPointsRTRange().lowerEndpoint();
                return rtLen;
            case CHARGE:
                if (peak.getCharge() <= 0)
                    return null;
                return new Integer(peak.getCharge());
            case RT_START:
                return peak.getRawDataPointsRTRange().lowerEndpoint();
            case RT_END:
                return peak.getRawDataPointsRTRange().upperEndpoint();
            case DATAPOINTS:
                return peak.getScanNumbers().length;
            case FWHM:
                return peak.getFWHM();
            case TF:
                return peak.getTailingFactor();
            case AF:
                return peak.getAsymmetryFactor();
            case PARENT_ROW_ID:
                return peak.getParentChromatogramRowID();
        }
    }
    return null;
}
Also used : PeakListRow(net.sf.mzmine.datamodel.PeakListRow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Feature(net.sf.mzmine.datamodel.Feature)

Aggregations

Feature (net.sf.mzmine.datamodel.Feature)115 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)70 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)60 SimplePeakListRow (net.sf.mzmine.datamodel.impl.SimplePeakListRow)41 DataPoint (net.sf.mzmine.datamodel.DataPoint)35 SimpleFeature (net.sf.mzmine.datamodel.impl.SimpleFeature)35 SimplePeakList (net.sf.mzmine.datamodel.impl.SimplePeakList)25 Scan (net.sf.mzmine.datamodel.Scan)22 PeakList (net.sf.mzmine.datamodel.PeakList)20 ArrayList (java.util.ArrayList)17 SimplePeakListAppliedMethod (net.sf.mzmine.datamodel.impl.SimplePeakListAppliedMethod)16 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)15 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)15 SimpleDataPoint (net.sf.mzmine.datamodel.impl.SimpleDataPoint)13 PeakListAppliedMethod (net.sf.mzmine.datamodel.PeakList.PeakListAppliedMethod)10 MassList (net.sf.mzmine.datamodel.MassList)9 HashMap (java.util.HashMap)8 Vector (java.util.Vector)8 ScanSelection (net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection)7 TreeMap (java.util.TreeMap)6