Search in sources :

Example 1 with SpectralDBPeakIdentity

use of net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity in project mzmine2 by mzmine.

the class SpectralMatchTask method run.

/**
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    // check for mass list
    DataPoint[] spectraMassList;
    try {
        spectraMassList = getDataPoints(currentScan);
    } catch (MissingMassListException e) {
        // no mass list
        setStatus(TaskStatus.ERROR);
        setErrorMessage(MessageFormat.format("No masslist for name: {0} in scan {1} of raw file {2}", massListName, currentScan.getScanNumber(), currentScan.getDataFile().getName()));
        return;
    }
    // remove 13C isotopes
    if (removeIsotopes)
        spectraMassList = removeIsotopes(spectraMassList);
    setStatus(TaskStatus.PROCESSING);
    try {
        totalSteps = list.size();
        matches = new ArrayList<>();
        for (SpectralDBEntry ident : list) {
            if (isCanceled()) {
                logger.info("Added " + count + " spectral library matches (before being cancelled)");
                repaintWindow();
                return;
            }
            SpectralSimilarity sim = spectraDBMatch(spectraMassList, ident);
            if (sim != null && (!needsIsotopePattern || checkForIsotopePattern(sim, mzToleranceSpectra, minMatchedIsoSignals))) {
                count++;
                // use SpectralDBPeakIdentity to store all results similar to peaklist method
                matches.add(new SpectralDBPeakIdentity(currentScan, massListName, ident, sim, SpectraIdentificationSpectralDatabaseModule.MODULE_NAME));
            }
            // next row
            finishedSteps++;
        }
        addIdentities(matches);
        logger.info("Added " + count + " spectral library matches");
        // check if no match was found
        if (count == 0) {
            logger.log(Level.WARNING, "No data base matches found");
            setErrorMessage("No data base matches found. Spectral data base matching failed");
            list = null;
            return;
        }
    } catch (Exception e) {
        setStatus(TaskStatus.ERROR);
        logger.log(Level.SEVERE, "Spectral data base matching failed", e);
        setErrorMessage("Spectral data base matching failed");
        return;
    }
    // Repaint the window to reflect the change in the feature list
    repaintWindow();
    list = null;
    setStatus(TaskStatus.FINISHED);
}
Also used : DataPoint(net.sf.mzmine.datamodel.DataPoint) SpectralDBPeakIdentity(net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity) SpectralSimilarity(net.sf.mzmine.util.scans.similarity.SpectralSimilarity) SpectralDBEntry(net.sf.mzmine.util.spectraldb.entry.SpectralDBEntry) MissingMassListException(net.sf.mzmine.util.exceptions.MissingMassListException) MissingMassListException(net.sf.mzmine.util.exceptions.MissingMassListException)

Example 2 with SpectralDBPeakIdentity

use of net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity in project mzmine2 by mzmine.

the class RowsSpectralMatchTask method run.

/**
 * @see java.lang.Runnable#run()
 */
@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    for (PeakListRow row : rows) {
        if (isCanceled()) {
            logger.info("Added " + count + " spectral library matches (before being cancelled)");
            repaintWindow();
            return;
        }
        try {
            // All MS2 or only best MS2 scan
            // best MS1 scan
            // check for MS1 or MSMS scan
            List<Scan> scans = getScans(row);
            List<DataPoint[]> rowMassLists = new ArrayList<>();
            for (Scan scan : scans) {
                // get mass list and perform deisotoping if active
                DataPoint[] rowMassList = getDataPoints(scan, true);
                if (removeIsotopes)
                    rowMassList = removeIsotopes(rowMassList);
                rowMassLists.add(rowMassList);
            }
            // match against all library entries
            for (SpectralDBEntry ident : list) {
                SpectralDBPeakIdentity best = null;
                // match all scans against this ident to find best match
                for (int i = 0; i < scans.size(); i++) {
                    SpectralSimilarity sim = spectraDBMatch(row, rowMassLists.get(i), ident);
                    if (sim != null && (!needsIsotopePattern || SpectralMatchTask.checkForIsotopePattern(sim, mzToleranceSpectra, minMatchedIsoSignals)) && (best == null || best.getSimilarity().getScore() < sim.getScore())) {
                        best = new SpectralDBPeakIdentity(scans.get(i), massListName, ident, sim, METHOD);
                    }
                }
                // has match?
                if (best != null) {
                    addIdentity(row, best);
                    count++;
                }
            }
            // sort identities based on similarity score
            SortSpectralDBIdentitiesTask.sortIdentities(row);
        } catch (MissingMassListException e) {
            logger.log(Level.WARNING, "No mass list in spectrum for rowID=" + row.getID(), e);
            errorCounter++;
        }
        // check for max error (missing masslist)
        if (errorCounter > MAX_ERROR) {
            logger.log(Level.WARNING, "Data base matching failed. To many missing mass lists ");
            setStatus(TaskStatus.ERROR);
            setErrorMessage("Data base matching failed. To many missing mass lists ");
            list = null;
            return;
        }
        // next row
        finishedRows++;
    }
    if (count > 0)
        logger.info("Added " + count + " spectral library matches");
    // Repaint the window to reflect the change in the feature list
    repaintWindow();
    list = null;
    setStatus(TaskStatus.FINISHED);
}
Also used : PeakListRow(net.sf.mzmine.datamodel.PeakListRow) DataPoint(net.sf.mzmine.datamodel.DataPoint) SpectralDBPeakIdentity(net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity) ArrayList(java.util.ArrayList) SpectralSimilarity(net.sf.mzmine.util.scans.similarity.SpectralSimilarity) Scan(net.sf.mzmine.datamodel.Scan) SpectralDBEntry(net.sf.mzmine.util.spectraldb.entry.SpectralDBEntry) DataPoint(net.sf.mzmine.datamodel.DataPoint) MissingMassListException(net.sf.mzmine.util.exceptions.MissingMassListException)

Example 3 with SpectralDBPeakIdentity

use of net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity in project mzmine2 by mzmine.

the class SortSpectralDBIdentitiesTask method sortIdentities.

/**
 * Sort database matches by score
 *
 * @param row
 * @param filterMinSimilarity
 * @param minScore
 */
public static void sortIdentities(PeakListRow row, boolean filterMinSimilarity, double minScore) {
    // get all row identities
    PeakIdentity[] identities = row.getPeakIdentities();
    if (identities == null || identities.length == 0)
        return;
    // filter for SpectralDBPeakIdentity and write to map
    List<SpectralDBPeakIdentity> match = new ArrayList<>();
    for (PeakIdentity identity : identities) {
        if (identity instanceof SpectralDBPeakIdentity) {
            row.removePeakIdentity(identity);
            if (!filterMinSimilarity || ((SpectralDBPeakIdentity) identity).getSimilarity().getScore() >= minScore)
                match.add((SpectralDBPeakIdentity) identity);
        }
    }
    if (match.isEmpty())
        return;
    // reversed order: by similarity score
    match.sort((a, b) -> {
        return Double.compare(b.getSimilarity().getScore(), a.getSimilarity().getScore());
    });
    for (SpectralDBPeakIdentity entry : match) {
        row.addPeakIdentity(entry, false);
    }
    row.setPreferredPeakIdentity(match.get(0));
    // Notify the GUI about the change in the project
    MZmineCore.getProjectManager().getCurrentProject().notifyObjectChanged(row, false);
}
Also used : SpectralDBPeakIdentity(net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity) PeakIdentity(net.sf.mzmine.datamodel.PeakIdentity) SpectralDBPeakIdentity(net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity) ArrayList(java.util.ArrayList)

Example 4 with SpectralDBPeakIdentity

use of net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity in project mzmine2 by mzmine.

the class PeakListTablePopupMenu method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final Object src = e.getSource();
    if (deleteRowsItem.equals(src)) {
        final int[] rowsToDelete = table.getSelectedRows();
        final int[] unsortedIndexes = new int[rowsToDelete.length];
        for (int i = rowsToDelete.length - 1; i >= 0; i--) {
            unsortedIndexes[i] = table.convertRowIndexToModel(rowsToDelete[i]);
        }
        // sort row indexes and start removing from the last
        Arrays.sort(unsortedIndexes);
        // delete the rows starting from last
        for (int i = unsortedIndexes.length - 1; i >= 0; i--) {
            peakList.removeRow(unsortedIndexes[i]);
        }
        // Notify the GUI that peaklist contents have changed
        updateTableGUI();
    }
    if (plotRowsItem.equals(src)) {
        final int[] selectedTableRows = table.getSelectedRows();
        final PeakListRow[] selectedRows = new PeakListRow[selectedTableRows.length];
        for (int i = 0; i < selectedTableRows.length; i++) {
            selectedRows[i] = getPeakListRow(table.convertRowIndexToModel(selectedTableRows[i]));
        }
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                IntensityPlotModule.showIntensityPlot(MZmineCore.getProjectManager().getCurrentProject(), peakList, selectedRows);
            }
        });
    }
    if (showXICItem.equals(src) && allClickedPeakListRows.length != 0) {
        // Map peaks to their identity labels.
        final Map<Feature, String> labelsMap = new HashMap<Feature, String>(allClickedPeakListRows.length);
        final RawDataFile selectedDataFile = clickedDataFile == null ? allClickedPeakListRows[0].getBestPeak().getDataFile() : clickedDataFile;
        Range<Double> mzRange = null;
        final List<Feature> selectedPeaks = new ArrayList<Feature>(allClickedPeakListRows.length);
        for (final PeakListRow row : allClickedPeakListRows) {
            for (final Feature peak : row.getPeaks()) {
                if (mzRange == null) {
                    mzRange = peak.getRawDataPointsMZRange();
                    double upper = mzRange.upperEndpoint();
                    double lower = mzRange.lowerEndpoint();
                    if ((upper - lower) < 0.000001) {
                        // Workaround to make ultra narrow mzRanges (e.g. from imported mzTab peaklist),
                        // a more reasonable default for a HRAM instrument (~5ppm)
                        double fiveppm = (upper * 5E-6);
                        mzRange = Range.closed(lower - fiveppm, upper + fiveppm);
                    }
                } else {
                    mzRange = mzRange.span(peak.getRawDataPointsMZRange());
                }
            }
            final Feature filePeak = row.getPeak(selectedDataFile);
            if (filePeak != null) {
                selectedPeaks.add(filePeak);
                // Label the peak with the row's preferred identity.
                final PeakIdentity identity = row.getPreferredPeakIdentity();
                if (identity != null) {
                    labelsMap.put(filePeak, identity.getName());
                }
            }
        }
        ScanSelection scanSelection = new ScanSelection(selectedDataFile.getDataRTRange(1), 1);
        TICVisualizerModule.showNewTICVisualizerWindow(new RawDataFile[] { selectedDataFile }, selectedPeaks.toArray(new Feature[selectedPeaks.size()]), labelsMap, scanSelection, TICPlotType.BASEPEAK, mzRange);
    }
    if (showXICSetupItem.equals(src) && allClickedPeakListRows.length != 0) {
        // Map peaks to their identity labels.
        final Map<Feature, String> labelsMap = new HashMap<Feature, String>(allClickedPeakListRows.length);
        final RawDataFile[] selectedDataFiles = clickedDataFile == null ? peakList.getRawDataFiles() : new RawDataFile[] { clickedDataFile };
        Range<Double> mzRange = null;
        final ArrayList<Feature> allClickedPeaks = new ArrayList<Feature>(allClickedPeakListRows.length);
        final ArrayList<Feature> selectedClickedPeaks = new ArrayList<Feature>(allClickedPeakListRows.length);
        for (final PeakListRow row : allClickedPeakListRows) {
            // Label the peak with the row's preferred identity.
            final PeakIdentity identity = row.getPreferredPeakIdentity();
            for (final Feature peak : row.getPeaks()) {
                allClickedPeaks.add(peak);
                if (peak.getDataFile() == clickedDataFile) {
                    selectedClickedPeaks.add(peak);
                }
                if (mzRange == null) {
                    mzRange = peak.getRawDataPointsMZRange();
                } else {
                    mzRange = mzRange.span(peak.getRawDataPointsMZRange());
                }
                if (identity != null) {
                    labelsMap.put(peak, identity.getName());
                }
            }
        }
        ScanSelection scanSelection = new ScanSelection(selectedDataFiles[0].getDataRTRange(1), 1);
        TICVisualizerModule.setupNewTICVisualizer(MZmineCore.getProjectManager().getCurrentProject().getDataFiles(), selectedDataFiles, allClickedPeaks.toArray(new Feature[allClickedPeaks.size()]), selectedClickedPeaks.toArray(new Feature[selectedClickedPeaks.size()]), labelsMap, scanSelection, mzRange);
    }
    if (show2DItem.equals(src)) {
        final Feature showPeak = getSelectedPeak();
        if (showPeak != null) {
            TwoDVisualizerModule.show2DVisualizerSetupDialog(showPeak.getDataFile(), getPeakMZRange(showPeak), getPeakRTRange(showPeak));
        }
    }
    if (show3DItem.equals(src)) {
        final Feature showPeak = getSelectedPeak();
        if (showPeak != null) {
            Fx3DVisualizerModule.setupNew3DVisualizer(showPeak.getDataFile(), getPeakMZRange(showPeak), getPeakRTRange(showPeak), showPeak);
        }
    }
    if (manuallyDefineItem.equals(src)) {
        // ManualPeakPickerModule.runManualDetection(clickedDataFile, clickedPeakListRow, peakList,
        // table);
        XICManualPickerModule.runManualDetection(clickedDataFile, clickedPeakListRow, peakList, table);
    }
    if (showSpectrumItem.equals(src)) {
        final Feature showPeak = getSelectedPeak();
        if (showPeak != null) {
            SpectraVisualizerModule.showNewSpectrumWindow(showPeak.getDataFile(), showPeak.getRepresentativeScanNumber(), showPeak);
        }
    }
    if (openCompoundIdUrl.equals(src)) {
        if (clickedPeakListRow != null && clickedPeakListRow.getPreferredPeakIdentity() != null) {
            String url = clickedPeakListRow.getPreferredPeakIdentity().getPropertyValue(PeakIdentity.PROPERTY_URL);
            if (url != null && !url.isEmpty() && Desktop.isDesktopSupported()) {
                try {
                    Desktop.getDesktop().browse(new URI(url));
                } catch (IOException | URISyntaxException e1) {
                }
            }
        }
    }
    if (showMSMSItem.equals(src)) {
        if (allClickedPeakListRows != null && allClickedPeakListRows.length > 1) {
            // show multi msms window of multiple rows
            MultiMSMSWindow multi = new MultiMSMSWindow();
            multi.setData(allClickedPeakListRows, peakList.getRawDataFiles(), clickedDataFile, true, SortingProperty.MZ, SortingDirection.Ascending);
            multi.setVisible(true);
        } else {
            Feature showPeak = getSelectedPeakForMSMS();
            if (showPeak != null) {
                final int scanNumber = showPeak.getMostIntenseFragmentScanNumber();
                if (scanNumber > 0) {
                    SpectraVisualizerModule.showNewSpectrumWindow(showPeak.getDataFile(), scanNumber);
                } else {
                    MZmineCore.getDesktop().displayMessage(window, "There is no fragment for " + MZmineCore.getConfiguration().getMZFormat().format(showPeak.getMZ()) + " m/z in the current raw data.");
                }
            }
        }
    }
    // mirror of the two best fragment scans
    if (showMSMSMirrorItem.equals(src)) {
        if (allClickedPeakListRows != null && allClickedPeakListRows.length == 2) {
            PeakListRow a = allClickedPeakListRows[0];
            PeakListRow b = allClickedPeakListRows[1];
            Scan scan = a.getBestFragmentation();
            Scan mirror = b.getBestFragmentation();
            if (scan != null && mirror != null) {
                // show mirror msms window of two rows
                MirrorScanWindow mirrorWindow = new MirrorScanWindow();
                mirrorWindow.setScans(scan, mirror);
                mirrorWindow.setVisible(true);
            }
        }
    }
    // show spectral db matches
    if (showSpectralDBResults.equals(src)) {
        List<SpectralDBPeakIdentity> spectralID = Arrays.stream(clickedPeakListRow.getPeakIdentities()).filter(pi -> pi instanceof SpectralDBPeakIdentity).map(pi -> ((SpectralDBPeakIdentity) pi)).collect(Collectors.toList());
        if (!spectralID.isEmpty()) {
            SpectraIdentificationResultsWindow window = new SpectraIdentificationResultsWindow();
            window.addMatches(spectralID);
            window.setTitle("Matched " + spectralID.size() + " compounds for feature list row" + clickedPeakListRow.getID());
            window.setVisible(true);
        }
    }
    if (showAllMSMSItem.equals(src)) {
        final Feature showPeak = getSelectedPeakForMSMS();
        RawDataFile raw = clickedPeakListRow.getBestFragmentation().getDataFile();
        if (showPeak != null && showPeak.getMostIntenseFragmentScanNumber() != 0)
            raw = showPeak.getDataFile();
        if (clickedPeakListRow.getBestFragmentation() != null) {
            MultiSpectraVisualizerWindow multiSpectraWindow = new MultiSpectraVisualizerWindow(clickedPeakListRow, raw);
            multiSpectraWindow.setVisible(true);
        } else {
            MZmineCore.getDesktop().displayMessage(window, "There is no fragment for " + MZmineCore.getConfiguration().getMZFormat().format(showPeak.getMZ()) + " m/z in the current raw data.");
        }
    }
    if (showIsotopePatternItem.equals(src)) {
        final Feature showPeak = getSelectedPeak();
        if (showPeak != null && showPeak.getIsotopePattern() != null) {
            SwingUtilities.invokeLater(new Runnable() {

                @Override
                public void run() {
                    SpectraVisualizerModule.showNewSpectrumWindow(showPeak.getDataFile(), showPeak.getRepresentativeScanNumber(), showPeak.getIsotopePattern());
                }
            });
        }
    }
    if (formulaItem != null && formulaItem.equals(src)) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                FormulaPredictionModule.showSingleRowIdentificationDialog(clickedPeakListRow);
            }
        });
    }
    // peak.
    if (siriusItem != null && siriusItem.equals(src)) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                SiriusProcessingModule.showSingleRowIdentificationDialog(clickedPeakListRow);
            }
        });
    }
    if (onlineDbSearchItem != null && onlineDbSearchItem.equals(src)) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                OnlineDBSearchModule.showSingleRowIdentificationDialog(clickedPeakListRow);
            }
        });
    }
    if (spectralDbSearchItem != null && spectralDbSearchItem.equals(src)) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                LocalSpectralDBSearchModule.showSelectedRowsIdentificationDialog(allClickedPeakListRows, table);
            }
        });
    }
    if (nistSearchItem != null && nistSearchItem.equals(src)) {
        NistMsSearchModule.singleRowSearch(peakList, clickedPeakListRow);
    }
    if (addNewRowItem.equals(src)) {
        // find maximum ID and add 1
        int newID = 1;
        for (final PeakListRow row : peakList.getRows()) {
            if (row.getID() >= newID) {
                newID = row.getID() + 1;
            }
        }
        // create a new row
        final PeakListRow newRow = new SimplePeakListRow(newID);
        ManualPeakPickerModule.runManualDetection(peakList.getRawDataFiles(), newRow, peakList, table);
    }
    if (showPeakRowSummaryItem.equals(src)) {
        PeakSummaryVisualizerModule.showNewPeakSummaryWindow(clickedPeakListRow);
    }
    if (exportIsotopesItem.equals(src)) {
        IsotopePatternExportModule.exportIsotopePattern(clickedPeakListRow);
    }
    if (exportToSirius.equals(src)) {
        // export all selected rows
        SiriusExportModule.exportSingleRows(allClickedPeakListRows);
    }
    if (exportMSMSLibrary.equals(src)) {
        // open window with all selected rows
        MSMSLibrarySubmissionWindow libraryWindow = new MSMSLibrarySubmissionWindow();
        libraryWindow.setData(allClickedPeakListRows, SortingProperty.MZ, SortingDirection.Ascending, true);
        libraryWindow.setVisible(true);
    }
    if (exportMS1Library.equals(src)) {
        // open window with all selected rows
        MSMSLibrarySubmissionWindow libraryWindow = new MSMSLibrarySubmissionWindow();
        libraryWindow.setData(allClickedPeakListRows, SortingProperty.MZ, SortingDirection.Ascending, false);
        libraryWindow.setVisible(true);
    }
    if (exportMSMSItem.equals(src)) {
        MSMSExportModule.exportMSMS(clickedPeakListRow);
    }
    if (clearIdsItem.equals(src)) {
        // Delete identities of selected rows.
        for (final PeakListRow row : allClickedPeakListRows) {
            // Selected row index.
            for (final PeakIdentity id : row.getPeakIdentities()) {
                // Remove id.
                row.removePeakIdentity(id);
            }
        }
        // Update table GUI.
        updateTableGUI();
    }
    if (copyIdsItem.equals(src) && allClickedPeakListRows.length > 0) {
        final PeakIdentity id = allClickedPeakListRows[0].getPreferredPeakIdentity();
        if (id != null) {
            copiedId = (PeakIdentity) id.clone();
        }
    }
    if (pasteIdsItem.equals(src) && copiedId != null) {
        // Paste identity into selected rows.
        for (final PeakListRow row : allClickedPeakListRows) {
            row.setPreferredPeakIdentity((PeakIdentity) copiedId.clone());
        }
        // Update table GUI.
        updateTableGUI();
    }
}
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) MSMSLibrarySubmissionWindow(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.view.MSMSLibrarySubmissionWindow) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) Feature(net.sf.mzmine.datamodel.Feature) URI(java.net.URI) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) SimplePeakListRow(net.sf.mzmine.datamodel.impl.SimplePeakListRow) SpectraIdentificationResultsWindow(net.sf.mzmine.modules.visualization.spectra.spectralmatchresults.SpectraIdentificationResultsWindow) MirrorScanWindow(net.sf.mzmine.modules.visualization.spectra.simplespectra.mirrorspectra.MirrorScanWindow) ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) SpectralDBPeakIdentity(net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity) IOException(java.io.IOException) Point(java.awt.Point) SpectralDBPeakIdentity(net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity) PeakIdentity(net.sf.mzmine.datamodel.PeakIdentity) MultiMSMSWindow(net.sf.mzmine.modules.visualization.spectra.multimsms.MultiMSMSWindow) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Scan(net.sf.mzmine.datamodel.Scan) MultiSpectraVisualizerWindow(net.sf.mzmine.modules.visualization.spectra.simplespectra.MultiSpectraVisualizerWindow)

Example 5 with SpectralDBPeakIdentity

use of net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity in project mzmine2 by mzmine.

the class SpectralMatchTask method addIdentities.

private void addIdentities(List<SpectralDBPeakIdentity> matches) {
    for (SpectralDBPeakIdentity match : matches) {
        try {
            // TODO put into separate method and add comments
            // get data points of matching scans
            DataPoint[] spectraMassList = getDataPoints(currentScan);
            List<DataPoint[]> alignedDataPoints = ScanAlignment.align(mzToleranceSpectra, match.getEntry().getDataPoints(), spectraMassList);
            alignedSignals = ScanAlignment.removeUnaligned(alignedDataPoints);
            // add new mass list to the spectra for match
            DataPoint[] dataset = new DataPoint[alignedSignals.size()];
            for (int i = 0; i < dataset.length; i++) {
                dataset[i] = alignedSignals.get(i)[1];
            }
            String compoundName = match.getEntry().getField(DBEntryField.NAME).toString();
            String shortName = compoundName;
            // TODO remove or specify more - special naming format?
            int start = compoundName.indexOf("[");
            int end = compoundName.indexOf("]");
            if (start != -1 && start + 1 < compoundName.length() && end != -1 && end < compoundName.length())
                shortName = compoundName.substring(start + 1, end);
            DataPointsDataSet detectedCompoundsDataset = new DataPointsDataSet(shortName + " " + "Score: " + COS_FORM.format(match.getSimilarity().getScore()), dataset);
            spectraPlot.addDataSet(detectedCompoundsDataset, new Color((int) (Math.random() * 0x1000000)), true);
        } catch (MissingMassListException e) {
            logger.log(Level.WARNING, "No mass list for the selected spectrum", e);
            errorCounter++;
        }
    }
    resultWindow.addMatches(matches);
    resultWindow.revalidate();
    resultWindow.repaint();
    setStatus(TaskStatus.FINISHED);
}
Also used : SpectralDBPeakIdentity(net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity) DataPoint(net.sf.mzmine.datamodel.DataPoint) Color(java.awt.Color) DataPoint(net.sf.mzmine.datamodel.DataPoint) DataPointsDataSet(net.sf.mzmine.modules.visualization.spectra.simplespectra.datasets.DataPointsDataSet) MissingMassListException(net.sf.mzmine.util.exceptions.MissingMassListException)

Aggregations

SpectralDBPeakIdentity (net.sf.mzmine.util.spectraldb.entry.SpectralDBPeakIdentity)7 ArrayList (java.util.ArrayList)3 DataPoint (net.sf.mzmine.datamodel.DataPoint)3 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)2 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)2 Scan (net.sf.mzmine.datamodel.Scan)2 MissingMassListException (net.sf.mzmine.util.exceptions.MissingMassListException)2 SpectralSimilarity (net.sf.mzmine.util.scans.similarity.SpectralSimilarity)2 SpectralDBEntry (net.sf.mzmine.util.spectraldb.entry.SpectralDBEntry)2 Range (com.google.common.collect.Range)1 Color (java.awt.Color)1 Component (java.awt.Component)1 Desktop (java.awt.Desktop)1 GridLayout (java.awt.GridLayout)1 Point (java.awt.Point)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1