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