Search in sources :

Example 1 with ScanSelection

use of net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection in project mzmine2 by mzmine.

the class Fx3DVisualizerModule method setupNew3DVisualizer.

public static void setupNew3DVisualizer(final RawDataFile dataFile, final Range<Double> mzRange, final Range<Double> rtRange, final Feature featureToShow) {
    final ParameterSet myParameters = MZmineCore.getConfiguration().getModuleParameters(Fx3DVisualizerModule.class);
    final Fx3DVisualizerModule myInstance = MZmineCore.getModuleInstance(Fx3DVisualizerModule.class);
    myParameters.getParameter(Fx3DVisualizerParameters.dataFiles).setValue(RawDataFilesSelectionType.SPECIFIC_FILES, new RawDataFile[] { dataFile });
    myParameters.getParameter(Fx3DVisualizerParameters.scanSelection).setValue(new ScanSelection(rtRange, 1));
    myParameters.getParameter(Fx3DVisualizerParameters.mzRange).setValue(mzRange);
    List<FeatureSelection> featuresList = Lists.newArrayList();
    if (featureToShow != null) {
        FeatureSelection selectedFeature = new FeatureSelection(null, featureToShow, null, null);
        featuresList.add(selectedFeature);
    }
    myParameters.getParameter(Fx3DVisualizerParameters.features).setValue(featuresList);
    if (myParameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true) == ExitCode.OK) {
        myInstance.runModule(MZmineCore.getProjectManager().getCurrentProject(), myParameters.cloneParameterSet(), new ArrayList<Task>());
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) Task(net.sf.mzmine.taskcontrol.Task) FeatureSelection(net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection)

Example 2 with ScanSelection

use of net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection in project mzmine2 by mzmine.

the class Fx3DVisualizerModule method runModule.

@SuppressWarnings("null")
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    final RawDataFile[] currentDataFiles = parameters.getParameter(Fx3DVisualizerParameters.dataFiles).getValue().getMatchingRawDataFiles();
    final ScanSelection scanSel = parameters.getParameter(Fx3DVisualizerParameters.scanSelection).getValue();
    final List<FeatureSelection> featureSelList = parameters.getParameter(Fx3DVisualizerParameters.features).getValue();
    LOG.finest("Feature selection is:" + featureSelList.toString());
    for (FeatureSelection selection : featureSelList) {
        LOG.finest("Selected features are:" + selection.getFeature().toString());
    }
    Range<Double> rtRange = ScanUtils.findRtRange(scanSel.getMatchingScans(MZmineCore.getProjectManager().getCurrentProject().getDataFiles()[0]));
    ParameterSet myParameters = MZmineCore.getConfiguration().getModuleParameters(Fx3DVisualizerModule.class);
    Range<Double> mzRange = myParameters.getParameter(Fx3DVisualizerParameters.mzRange).getValue();
    int rtRes = myParameters.getParameter(Fx3DVisualizerParameters.rtResolution).getValue();
    int mzRes = myParameters.getParameter(Fx3DVisualizerParameters.mzResolution).getValue();
    Platform.runLater(() -> {
        if (!Platform.isSupported(ConditionalFeature.SCENE3D)) {
            JOptionPane.showMessageDialog(null, "The platform does not provide 3D support.");
            return;
        }
        FXMLLoader loader = new FXMLLoader((getClass().getResource("Fx3DStage.fxml")));
        Stage stage = null;
        try {
            stage = loader.load();
            LOG.finest("Stage has been successfully loaded from the FXML loader.");
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        String title = "";
        Fx3DStageController controller = loader.getController();
        controller.setScanSelection(scanSel);
        controller.setRtAndMzResolutions(rtRes, mzRes);
        controller.setRtAndMzValues(rtRange, mzRange);
        for (int i = 0; i < currentDataFiles.length; i++) {
            MZmineCore.getTaskController().addTask(new Fx3DSamplingTask(currentDataFiles[i], scanSel, mzRange, rtRes, mzRes, controller), TaskPriority.HIGH);
        }
        controller.addFeatureSelections(featureSelList);
        for (int i = 0; i < currentDataFiles.length; i++) {
            title = title + currentDataFiles[i].toString() + " ";
        }
        stage.show();
        stage.setMinWidth(stage.getWidth());
        stage.setMinHeight(stage.getHeight());
    });
    return ExitCode.OK;
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) IOException(java.io.IOException) FXMLLoader(javafx.fxml.FXMLLoader) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Stage(javafx.stage.Stage) FeatureSelection(net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection) Nonnull(javax.annotation.Nonnull)

Example 3 with ScanSelection

use of net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection in project mzmine2 by mzmine.

the class MZRangeComponent method actionPerformed.

@Override
public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == setAutoButton) {
        RawDataFile[] currentFiles = MZmineCore.getProjectManager().getCurrentProject().getDataFiles();
        ScanSelection scanSelection = new ScanSelection();
        try {
            ParameterSetupDialog setupDialog = (ParameterSetupDialog) SwingUtilities.getWindowAncestor(this);
            RawDataFilesComponent rdc = (RawDataFilesComponent) setupDialog.getComponentForParameter(new RawDataFilesParameter());
            if (rdc != null) {
                RawDataFile[] matchingFiles = rdc.getValue().getMatchingRawDataFiles();
                if (matchingFiles.length > 0)
                    currentFiles = matchingFiles;
            }
            ScanSelectionComponent ssc = (ScanSelectionComponent) setupDialog.getComponentForParameter(new ScanSelectionParameter());
            if (ssc != null)
                scanSelection = ssc.getValue();
        } catch (Exception e) {
            e.printStackTrace();
        }
        Range<Double> mzRange = null;
        for (RawDataFile file : currentFiles) {
            Scan[] scans = scanSelection.getMatchingScans(file);
            for (Scan s : scans) {
                Range<Double> scanRange = s.getDataPointMZRange();
                if (scanRange == null)
                    continue;
                if (mzRange == null)
                    mzRange = scanRange;
                else
                    mzRange = mzRange.span(scanRange);
            }
        }
        if (mzRange != null)
            setValue(mzRange);
    }
    if (src == fromMassButton) {
        Range<Double> mzRange = MzRangeMassCalculatorModule.showRangeCalculationDialog();
        if (mzRange != null)
            setValue(mzRange);
    }
    if (src == fromFormulaButton) {
        Range<Double> mzRange = MzRangeFormulaCalculatorModule.showRangeCalculationDialog();
        if (mzRange != null)
            setValue(mzRange);
    }
}
Also used : ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) ScanSelectionParameter(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelectionParameter) ParameterSetupDialog(net.sf.mzmine.parameters.dialogs.ParameterSetupDialog) RawDataFilesComponent(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesComponent) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Scan(net.sf.mzmine.datamodel.Scan) ScanSelectionComponent(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelectionComponent) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)

Example 4 with ScanSelection

use of net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection in project mzmine2 by mzmine.

the class ExportScansFromRawFilesModule method runModule.

@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    ScanSelection select = parameters.getParameter(ExportScansFromRawFilesParameters.scanSelect).getValue();
    Scan[] scans = new Scan[0];
    for (RawDataFile raw : parameters.getParameter(ExportScansFromRawFilesParameters.dataFiles).getValue().getMatchingRawDataFiles()) {
        scans = ArrayUtils.addAll(scans, select.getMatchingScans(raw));
    }
    ExportScansTask task = new ExportScansTask(scans, parameters);
    tasks.add(task);
    return ExitCode.OK;
}
Also used : ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) Scan(net.sf.mzmine.datamodel.Scan) Nonnull(javax.annotation.Nonnull)

Example 5 with ScanSelection

use of net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection in project mzmine2 by mzmine.

the class MultiSpectraVisualizerWindow method addSpectra.

private JPanel addSpectra(int scan) {
    JPanel panel = new JPanel(new BorderLayout());
    // Split pane for eic plot (top) and spectrum (bottom)
    JSplitPane bottomPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    // Create EIC plot
    // labels for TIC visualizer
    Map<Feature, String> labelsMap = new HashMap<Feature, String>(0);
    Feature peak = row.getPeak(activeRaw);
    // scan selection
    ScanSelection scanSelection = new ScanSelection(activeRaw.getDataRTRange(1), 1);
    // mz range
    Range<Double> mzRange = null;
    mzRange = peak.getRawDataPointsMZRange();
    // optimize output by extending the range
    double upper = mzRange.upperEndpoint();
    double lower = mzRange.lowerEndpoint();
    double fiveppm = (upper * 5E-6);
    mzRange = Range.closed(lower - fiveppm, upper + fiveppm);
    // labels
    labelsMap.put(peak, peak.toString());
    // get EIC window
    TICVisualizerWindow window = new // raw
    TICVisualizerWindow(// raw
    new RawDataFile[] { activeRaw }, // plot type
    TICPlotType.BASEPEAK, // scan selection
    scanSelection, // mz range
    mzRange, // selected features
    new Feature[] { peak }, // labels
    labelsMap);
    // get EIC Plot
    TICPlot ticPlot = window.getTICPlot();
    ticPlot.setPreferredSize(new Dimension(600, 200));
    ticPlot.getChart().getLegend().setVisible(false);
    // add a retention time Marker to the EIC
    ValueMarker marker = new ValueMarker(activeRaw.getScan(scan).getRetentionTime());
    marker.setPaint(Color.RED);
    marker.setStroke(new BasicStroke(3.0f));
    XYPlot plot = (XYPlot) ticPlot.getChart().getPlot();
    plot.addDomainMarker(marker);
    bottomPane.add(ticPlot);
    bottomPane.setResizeWeight(0.5);
    bottomPane.setEnabled(true);
    bottomPane.setDividerSize(5);
    bottomPane.setDividerLocation(200);
    JSplitPane spectrumPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    // get MS/MS spectra window
    SpectraVisualizerWindow spectraWindow = new SpectraVisualizerWindow(activeRaw);
    spectraWindow.loadRawData(activeRaw.getScan(scan));
    // get MS/MS spectra plot
    SpectraPlot spectrumPlot = spectraWindow.getSpectrumPlot();
    spectrumPlot.getChart().getLegend().setVisible(false);
    spectrumPlot.setPreferredSize(new Dimension(600, 400));
    spectrumPane.add(spectrumPlot);
    spectrumPane.add(spectraWindow.getToolBar());
    spectrumPane.setResizeWeight(1);
    spectrumPane.setEnabled(false);
    spectrumPane.setDividerSize(0);
    bottomPane.add(spectrumPane);
    panel.add(bottomPane);
    panel.setBorder(BorderFactory.createLineBorder(Color.black));
    return panel;
}
Also used : BasicStroke(java.awt.BasicStroke) JPanel(javax.swing.JPanel) ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) HashMap(java.util.HashMap) Dimension(java.awt.Dimension) Feature(net.sf.mzmine.datamodel.Feature) TICVisualizerWindow(net.sf.mzmine.modules.visualization.tic.TICVisualizerWindow) BorderLayout(java.awt.BorderLayout) XYPlot(org.jfree.chart.plot.XYPlot) JSplitPane(javax.swing.JSplitPane) TICPlot(net.sf.mzmine.modules.visualization.tic.TICPlot) ValueMarker(org.jfree.chart.plot.ValueMarker)

Aggregations

ScanSelection (net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection)14 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)8 Scan (net.sf.mzmine.datamodel.Scan)8 Feature (net.sf.mzmine.datamodel.Feature)6 HashMap (java.util.HashMap)5 Nonnull (javax.annotation.Nonnull)4 PeakIdentity (net.sf.mzmine.datamodel.PeakIdentity)3 ParameterSet (net.sf.mzmine.parameters.ParameterSet)3 Range (com.google.common.collect.Range)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 JSplitPane (javax.swing.JSplitPane)2 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)2 FeatureSelection (net.sf.mzmine.parameters.parametertypes.selectors.FeatureSelection)2 ExitCode (net.sf.mzmine.util.ExitCode)2 BasicStroke (java.awt.BasicStroke)1 BorderLayout (java.awt.BorderLayout)1 Component (java.awt.Component)1 Desktop (java.awt.Desktop)1