Search in sources :

Example 6 with ScanSelection

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

the class MassDetectionParameters method showSetupDialog.

@Override
public ExitCode showSetupDialog(Window parent, boolean valueCheckRequired) {
    ExitCode exitCode = super.showSetupDialog(parent, valueCheckRequired);
    // If the parameters are not complete, let's just stop here
    if (exitCode != ExitCode.OK)
        return exitCode;
    RawDataFile[] selectedFiles = getParameter(dataFiles).getValue().getMatchingRawDataFiles();
    // If no file selected (e.g. in batch mode setup), just return
    if ((selectedFiles == null) || (selectedFiles.length == 0))
        return exitCode;
    // Do an additional check for centroid/continuous data and show a
    // warning if there is a potential problem
    long numCentroided = 0, numProfile = 0;
    ScanSelection scanSel = getParameter(scanSelection).getValue();
    for (RawDataFile file : selectedFiles) {
        Scan[] scans = scanSel.getMatchingScans(file);
        for (Scan s : scans) {
            if (s.getSpectrumType() == MassSpectrumType.CENTROIDED)
                numCentroided++;
            else
                numProfile++;
        }
    }
    // If no scans found, let's just stop here
    if (numCentroided + numProfile == 0)
        return exitCode;
    // Do we have mostly centroided scans?
    final double proportionCentroided = (double) numCentroided / (numCentroided + numProfile);
    final boolean mostlyCentroided = proportionCentroided > 0.5;
    logger.finest("Proportion of scans estimated to be centroided: " + proportionCentroided);
    // Check the selected mass detector
    String massDetectorName = getParameter(massDetector).getValue().toString();
    if (mostlyCentroided && (!massDetectorName.startsWith("Centroid"))) {
        String msg = "MZmine thinks you are running the profile mode mass detector on (mostly) centroided scans. This will likely produce wrong results. Try the Centroid mass detector instead.";
        MZmineCore.getDesktop().displayMessage(null, msg);
    }
    if ((!mostlyCentroided) && (massDetectorName.startsWith("Centroid"))) {
        String msg = "MZmine thinks you are running the centroid mass detector on (mostly) profile scans. This will likely produce wrong results.";
        MZmineCore.getDesktop().displayMessage(null, msg);
    }
    return exitCode;
}
Also used : ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) ExitCode(net.sf.mzmine.util.ExitCode) Scan(net.sf.mzmine.datamodel.Scan)

Example 7 with ScanSelection

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

the class TwoDVisualizerModule method show2DVisualizerSetupDialog.

public static void show2DVisualizerSetupDialog(RawDataFile dataFile, Range<Double> mzRange, Range<Double> rtRange) {
    ParameterSet parameters = MZmineCore.getConfiguration().getModuleParameters(TwoDVisualizerModule.class);
    parameters.getParameter(TwoDVisualizerParameters.dataFiles).setValue(RawDataFilesSelectionType.SPECIFIC_FILES, new RawDataFile[] { dataFile });
    if (rtRange != null)
        parameters.getParameter(TwoDVisualizerParameters.scanSelection).setValue(new ScanSelection(rtRange, 1));
    if (mzRange != null)
        parameters.getParameter(TwoDVisualizerParameters.mzRange).setValue(mzRange);
    ExitCode exitCode = parameters.showSetupDialog(MZmineCore.getDesktop().getMainWindow(), true);
    if (exitCode != ExitCode.OK)
        return;
    ScanSelection scanSel = parameters.getParameter(TwoDVisualizerParameters.scanSelection).getValue();
    Scan[] scans = scanSel.getMatchingScans(dataFile);
    rtRange = ScanUtils.findRtRange(scans);
    mzRange = parameters.getParameter(TwoDVisualizerParameters.mzRange).getValue();
    TwoDVisualizerWindow newWindow = new TwoDVisualizerWindow(dataFile, scans, rtRange, mzRange, parameters);
    newWindow.setVisible(true);
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) ExitCode(net.sf.mzmine.util.ExitCode) Scan(net.sf.mzmine.datamodel.Scan)

Example 8 with ScanSelection

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

the class TwoDVisualizerModule method runModule.

@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
    RawDataFile[] dataFiles = parameters.getParameter(TwoDVisualizerParameters.dataFiles).getValue().getMatchingRawDataFiles();
    ScanSelection scanSel = parameters.getParameter(TwoDVisualizerParameters.scanSelection).getValue();
    Scan[] scans = scanSel.getMatchingScans(dataFiles[0]);
    Range<Double> rtRange = ScanUtils.findRtRange(scans);
    Range<Double> mzRange = parameters.getParameter(TwoDVisualizerParameters.mzRange).getValue();
    TwoDVisualizerWindow newWindow = new TwoDVisualizerWindow(dataFiles[0], scans, rtRange, mzRange, parameters);
    newWindow.setVisible(true);
    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 9 with ScanSelection

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

the class XICManualPickerDialog method setMassRange.

private void setMassRange() {
    Range<Double> r = mzRangeComp.getValue();
    if (r == null || r.upperEndpoint() < r.lowerEndpoint()) {
        MZmineCore.getDesktop().displayErrorMessage(null, "Manual integration", "Mass range invalid.");
        return;
    }
    parameters.getParameter(XICManualPickerParameters.mzRange).setValue(r);
    ScanSelection sel = new ScanSelection(rawDataFile.getDataRTRange(), 1);
    Scan[] scans = sel.getMatchingScans(rawDataFile);
    TICDataSet ds = new TICDataSet(dataSet.getDataFile(), scans, r, null, TICPlotType.TIC);
    getTicPlot().removeAllTICDataSets();
    getTicPlot().addTICDataset(ds);
}
Also used : ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) TICDataSet(net.sf.mzmine.modules.visualization.tic.TICDataSet) Scan(net.sf.mzmine.datamodel.Scan)

Example 10 with ScanSelection

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

the class ScatterPlotChart method actionPerformed.

public void actionPerformed(ActionEvent event) {
    super.actionPerformed(event);
    String command = event.getActionCommand();
    if (command.equals("SETUP_AXES")) {
        AxesSetupDialog dialog = new AxesSetupDialog(window, plot);
        dialog.setVisible(true);
        return;
    }
    if (command.equals("TIC")) {
        double valueX = plot.getDomainCrosshairValue();
        double valueY = plot.getRangeCrosshairValue();
        PeakListRow selectedRow = mainDataSet.getRow(valueX, valueY);
        if (selectedRow == null) {
            MZmineCore.getDesktop().displayErrorMessage(window, "No peak is selected");
            return;
        }
        Feature[] peaks = selectedRow.getPeaks();
        Range<Double> rtRange = peakList.getRowsRTRange();
        Range<Double> mzRange = PeakUtils.findMZRange(peaks);
        // Label best peak with preferred identity.
        final Feature bestPeak = selectedRow.getBestPeak();
        final PeakIdentity peakIdentity = selectedRow.getPreferredPeakIdentity();
        final Map<Feature, String> labelMap = new HashMap<Feature, String>(1);
        if (bestPeak != null && peakIdentity != null) {
            labelMap.put(bestPeak, peakIdentity.getName());
        }
        ScanSelection scanSelection = new ScanSelection(rtRange, 1);
        TICVisualizerModule.showNewTICVisualizerWindow(peakList.getRawDataFiles(), peaks, labelMap, scanSelection, TICPlotType.BASEPEAK, mzRange);
    }
    if ("SAVE_EMF".equals(command)) {
        JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter("EMF Image", "EMF");
        chooser.setFileFilter(filter);
        int returnVal = chooser.showSaveDialog(null);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            String file = chooser.getSelectedFile().getPath();
            if (!file.toLowerCase().endsWith(".emf"))
                file += ".emf";
            int width = (int) this.getSize().getWidth();
            int height = (int) this.getSize().getHeight();
            // Save image
            SaveImage SI = new SaveImage(getChart(), file, width, height, FileType.EMF);
            new Thread(SI).start();
        }
    }
    if ("SAVE_EPS".equals(command)) {
        JFileChooser chooser = new JFileChooser();
        FileNameExtensionFilter filter = new FileNameExtensionFilter("EPS Image", "EPS");
        chooser.setFileFilter(filter);
        int returnVal = chooser.showSaveDialog(null);
        if (returnVal == JFileChooser.APPROVE_OPTION) {
            String file = chooser.getSelectedFile().getPath();
            if (!file.toLowerCase().endsWith(".eps"))
                file += ".eps";
            int width = (int) this.getSize().getWidth();
            int height = (int) this.getSize().getHeight();
            // Save image
            SaveImage SI = new SaveImage(getChart(), file, width, height, FileType.EPS);
            new Thread(SI).start();
        }
    }
}
Also used : ScanSelection(net.sf.mzmine.parameters.parametertypes.selectors.ScanSelection) HashMap(java.util.HashMap) FileNameExtensionFilter(javax.swing.filechooser.FileNameExtensionFilter) SaveImage(net.sf.mzmine.util.SaveImage) Feature(net.sf.mzmine.datamodel.Feature) AxesSetupDialog(net.sf.mzmine.util.dialogs.AxesSetupDialog) PeakIdentity(net.sf.mzmine.datamodel.PeakIdentity) PeakListRow(net.sf.mzmine.datamodel.PeakListRow) JFileChooser(javax.swing.JFileChooser)

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