Search in sources :

Example 1 with LibrarySubmitIonParameters

use of net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitIonParameters in project mzmine2 by mzmine.

the class LibrarySubmitTask method run.

@Override
public void run() {
    setStatus(TaskStatus.PROCESSING);
    for (Entry<LibrarySubmitIonParameters, DataPoint[]> e : map.entrySet()) {
        LibrarySubmitIonParameters param = e.getKey();
        DataPoint[] dps = e.getValue();
        // at least 2 data points
        if (dps != null && dps.length > 2) {
            // export / submit json?
            if (fileJson != null || submitGNPS) {
                String json = GnpsJsonGenerator.generateJSON(param, dps);
                log.info(json);
                if (saveLocal && fileJson != null) {
                    if (writeToLocalGnpsJsonFile(fileJson, json))
                        writeResults("GNPS json entry successfully writen" + fileJson.getAbsolutePath(), Result.SUCCED);
                    else
                        writeResults("Error while writing GNPS json entry to " + fileJson.getAbsolutePath(), Result.ERROR);
                }
                if (submitGNPS)
                    submitGNPS(json);
            }
            // export msp?
            if (fileMSP != null) {
                if (writeToLocalMSPFIle(fileMSP, param, dps))
                    writeResults("MSP entry successfully writen to " + fileMSP.getAbsolutePath(), Result.SUCCED);
                else
                    writeResults("Error while writing msp entry to " + fileMSP.getAbsolutePath(), Result.ERROR);
            }
        }
        done++;
    }
    setStatus(TaskStatus.FINISHED);
}
Also used : DataPoint(net.sf.mzmine.datamodel.DataPoint) LibrarySubmitIonParameters(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitIonParameters)

Example 2 with LibrarySubmitIonParameters

use of net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitIonParameters in project mzmine2 by mzmine.

the class MSMSLibrarySubmissionWindow method createIonParameters.

/**
 * The full set of parameters for the submission/creation of one library entry
 *
 * @param paramSubmit
 * @param paramMeta
 * @param ion
 * @return
 */
private LibrarySubmitIonParameters createIonParameters(LibrarySubmitParameters paramSubmit, LibraryMetaDataParameters paramMeta, ScanSelectPanel ion) {
    LibrarySubmitIonParameters ionParam = new LibrarySubmitIonParameters();
    ionParam.getParameter(LibrarySubmitIonParameters.META_PARAM).setValue(paramMeta);
    ionParam.getParameter(LibrarySubmitIonParameters.SUBMIT_PARAM).setValue(paramSubmit);
    if (isFragmentScan) {
        String adduct = ion.getAdduct();
        double precursorMZ = ion.getPrecursorMZ();
        int charge = ion.getPrecursorCharge();
        ionParam.getParameter(LibrarySubmitIonParameters.ADDUCT).setValue(adduct == null || adduct.isEmpty() ? null : adduct);
        ionParam.getParameter(LibrarySubmitIonParameters.CHARGE).setValue(charge == 0 ? null : charge);
        ionParam.getParameter(LibrarySubmitIonParameters.MZ).setValue(precursorMZ == 0d ? null : precursorMZ);
    } else {
        // MS1
        ionParam.getParameter(LibrarySubmitIonParameters.ADDUCT).setValue(null);
        ionParam.getParameter(LibrarySubmitIonParameters.CHARGE).setValue(null);
        ionParam.getParameter(LibrarySubmitIonParameters.MZ).setValue(null);
    }
    return (LibrarySubmitIonParameters) ionParam.cloneParameterSet();
}
Also used : LibrarySubmitIonParameters(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitIonParameters) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Example 3 with LibrarySubmitIonParameters

use of net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitIonParameters in project mzmine2 by mzmine.

the class MSMSLibrarySubmissionWindow method submitSpectra.

/**
 * Submit. Checks parameters and adduct for each selected ion
 */
private void submitSpectra() {
    if (checkParameters()) {
        // check number of ions
        int ions = countSelectedIons();
        // for ms level >1 (fragmentation scan MS/MS)
        int mslevel = paramMeta.getParameter(LibraryMetaDataParameters.MS_LEVEL).getValue();
        if (mslevel == 1)
            paramSubmit.getParameter(LibrarySubmitParameters.SUBMIT_GNPS).setValue(false);
        else {
            int adducts = countSelectedAdducts();
            // every valid selected ion needs an adduct for MS2
            if (ions != adducts) {
                MZmineCore.getDesktop().displayErrorMessage(this, "ERROR", MessageFormat.format("Not all adducts are set: {0} ion spectra selected and only {1}  adducts set", ions, adducts));
                return;
            }
        }
        // 
        if (ions == 0) {
            log.info("No MS/MS spectrum selected or valid");
            DialogLoggerUtil.showMessageDialogForTime(this, "Error", "No MS/MS spectrum selected or valid", 1500);
        } else {
            String message = ions + " MS/MS spectra were selected. Submit?";
            if (mslevel > 1) {
                message += " (" + streamSelection().filter(pn -> pn.isValidAndSelected() && pn.hasAdduct()).map(ScanSelectPanel::getAdduct).collect(Collectors.joining(", ")) + ")";
            } else {
                message += " (MS1)";
            }
            // show accept dialog
            if (DialogLoggerUtil.showDialogYesNo(this, "Submission?", message)) {
                // create library / submit to GNPS
                HashMap<LibrarySubmitIonParameters, DataPoint[]> map = new HashMap<>(ions);
                for (ScanSelectPanel ion : pnScanSelect) {
                    if (ion.isValidAndSelected()) {
                        // create ion param
                        LibrarySubmitIonParameters ionParam = createIonParameters(paramSubmit, paramMeta, ion);
                        DataPoint[] dps = ion.getFilteredDataPoints();
                        // submit and save locally
                        map.put(ionParam, dps);
                    }
                }
                // start task
                log.info("Added task to export library entries: " + ions + " MS/MS spectra were selected");
                LibrarySubmitTask task = new LibrarySubmitTask(this, map);
                MZmineCore.getTaskController().addTask(task);
            }
        }
    }
}
Also used : Color(java.awt.Color) OptionalModuleComponent(net.sf.mzmine.parameters.parametertypes.submodules.OptionalModuleComponent) Arrays(java.util.Arrays) URL(java.net.URL) ItemListener(java.awt.event.ItemListener) DataPoint(net.sf.mzmine.datamodel.DataPoint) JCheckBoxMenuItem(javax.swing.JCheckBoxMenuItem) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) ChartViewWrapper(net.sf.mzmine.chartbasics.gui.wrapper.ChartViewWrapper) EChartPanel(net.sf.mzmine.chartbasics.gui.swing.EChartPanel) Map(java.util.Map) ScanSortMode(net.sf.mzmine.util.scans.sorting.ScanSortMode) LibrarySubmitTask(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.LibrarySubmitTask) UserParameter(net.sf.mzmine.parameters.UserParameter) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) JFrame(javax.swing.JFrame) JMenuBar(javax.swing.JMenuBar) ScrollPaneConstants(javax.swing.ScrollPaneConstants) GridBagPanel(net.sf.mzmine.util.components.GridBagPanel) SortingProperty(net.sf.mzmine.util.SortingProperty) Font(java.awt.Font) PeakListRowSorter(net.sf.mzmine.util.PeakListRowSorter) LibraryMetaDataParameters(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibraryMetaDataParameters) JMenu(javax.swing.JMenu) GUIUtils(net.sf.mzmine.util.GUIUtils) GridBagConstraints(java.awt.GridBagConstraints) Logger(java.util.logging.Logger) LibrarySubmitParameters(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitParameters) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) Platform(javafx.application.Platform) Dimension(java.awt.Dimension) List(java.util.List) Stream(java.util.stream.Stream) ComboComponent(net.sf.mzmine.parameters.parametertypes.ComboComponent) EmptyBorder(javax.swing.border.EmptyBorder) AbstractMSMSIdentity(net.sf.mzmine.datamodel.identities.ms2.interf.AbstractMSMSIdentity) JPanel(javax.swing.JPanel) Scan(net.sf.mzmine.datamodel.Scan) MZmineCore(net.sf.mzmine.main.MZmineCore) Parameter(net.sf.mzmine.parameters.Parameter) ActionListener(java.awt.event.ActionListener) JSplitPane(javax.swing.JSplitPane) LibrarySubmitModule(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.LibrarySubmitModule) HashMap(java.util.HashMap) LibrarySubmitIonParameters(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitIonParameters) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) GridLayout(java.awt.GridLayout) IntegerComponent(net.sf.mzmine.parameters.parametertypes.IntegerComponent) DelayedDocumentListener(net.sf.mzmine.framework.listener.DelayedDocumentListener) JMenuItem(javax.swing.JMenuItem) JFreeChart(org.jfree.chart.JFreeChart) Hashtable(java.util.Hashtable) JComponent(javax.swing.JComponent) HelpWindow(net.sf.mzmine.desktop.impl.helpwindow.HelpWindow) MZTolerance(net.sf.mzmine.parameters.parametertypes.tolerances.MZTolerance) JButton(javax.swing.JButton) MigLayout(net.miginfocom.swing.MigLayout) ValueAxis(org.jfree.chart.axis.ValueAxis) ActionEvent(java.awt.event.ActionEvent) ChartGroup(net.sf.mzmine.chartbasics.chartgroups.ChartGroup) Consumer(java.util.function.Consumer) JScrollPane(javax.swing.JScrollPane) SortingDirection(net.sf.mzmine.util.SortingDirection) MassListComponent(net.sf.mzmine.parameters.parametertypes.MassListComponent) OptionalParameterComponent(net.sf.mzmine.parameters.parametertypes.OptionalParameterComponent) JLabel(javax.swing.JLabel) DialogLoggerUtil(net.sf.mzmine.util.DialogLoggerUtil) PseudoSpectrumDataSet(net.sf.mzmine.modules.visualization.spectra.multimsms.pseudospectra.PseudoSpectrumDataSet) DoubleComponent(net.sf.mzmine.parameters.parametertypes.DoubleComponent) HashMap(java.util.HashMap) DataPoint(net.sf.mzmine.datamodel.DataPoint) LibrarySubmitIonParameters(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitIonParameters) LibrarySubmitTask(net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.LibrarySubmitTask) DataPoint(net.sf.mzmine.datamodel.DataPoint)

Aggregations

DataPoint (net.sf.mzmine.datamodel.DataPoint)3 LibrarySubmitIonParameters (net.sf.mzmine.modules.peaklistmethods.io.spectraldbsubmit.param.LibrarySubmitIonParameters)3 BorderLayout (java.awt.BorderLayout)1 Color (java.awt.Color)1 Dimension (java.awt.Dimension)1 Font (java.awt.Font)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridLayout (java.awt.GridLayout)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 ItemListener (java.awt.event.ItemListener)1 URL (java.net.URL)1 MessageFormat (java.text.MessageFormat)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashMap (java.util.HashMap)1 Hashtable (java.util.Hashtable)1 List (java.util.List)1 Map (java.util.Map)1 Objects (java.util.Objects)1