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;
}
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);
}
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;
}
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);
}
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();
}
}
}
Aggregations