use of net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter 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.RawDataFilesParameter in project mzmine2 by mzmine.
the class ADAP3DModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
RawDataFile[] dataFiles = parameters.getParameter(new RawDataFilesParameter()).getValue().getMatchingRawDataFiles();
for (int i = 0; i < dataFiles.length; i++) {
Task newTask = new ADAP3DTask(project, dataFiles[i], parameters.cloneParameterSet());
tasks.add(newTask);
}
return ExitCode.OK;
}
use of net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter in project mzmine2 by mzmine.
the class GridMassModule method runModule.
@Override
@Nonnull
public ExitCode runModule(@Nonnull MZmineProject project, @Nonnull ParameterSet parameters, @Nonnull Collection<Task> tasks) {
RawDataFile[] dataFiles = parameters.getParameter(new RawDataFilesParameter()).getValue().getMatchingRawDataFiles();
for (int i = 0; i < dataFiles.length; i++) {
Task newTask = new GridMassTask(project, dataFiles[i], parameters.cloneParameterSet());
tasks.add(newTask);
}
return ExitCode.OK;
}
use of net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter in project mzmine2 by mzmine.
the class BatchSetupComponent method actionPerformed.
@Override
public void actionPerformed(final ActionEvent e) {
final Object src = e.getSource();
if (btnAdd.equals(src)) {
// Processing module selected?
final Object selectedItem = methodsCombo.getSelectedItem();
if (selectedItem instanceof BatchModuleWrapper) {
// Show method's set-up dialog.
final BatchModuleWrapper wrappedModule = (BatchModuleWrapper) selectedItem;
final MZmineProcessingModule selectedMethod = (MZmineProcessingModule) wrappedModule.getModule();
final ParameterSet methodParams = MZmineCore.getConfiguration().getModuleParameters(selectedMethod.getClass());
// Clone the parameter set
final ParameterSet stepParams = methodParams.cloneParameterSet();
// data file and feature list selection
if (!batchQueue.isEmpty()) {
for (Parameter<?> param : stepParams.getParameters()) {
if (param instanceof RawDataFilesParameter) {
final RawDataFilesParameter rdfp = (RawDataFilesParameter) param;
final RawDataFilesSelection selection = new RawDataFilesSelection();
selection.setSelectionType(RawDataFilesSelectionType.BATCH_LAST_FILES);
rdfp.setValue(selection);
}
if (param instanceof PeakListsParameter) {
final PeakListsParameter plp = (PeakListsParameter) param;
final PeakListsSelection selection = new PeakListsSelection();
selection.setSelectionType(PeakListsSelectionType.BATCH_LAST_PEAKLISTS);
plp.setValue(selection);
}
}
}
// Configure parameters
if (stepParams.getParameters().length > 0) {
Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
ExitCode exitCode = stepParams.showSetupDialog(parent, false);
if (exitCode != ExitCode.OK)
return;
}
// Make a new batch step
final MZmineProcessingStep<MZmineProcessingModule> step = new MZmineProcessingStepImpl<MZmineProcessingModule>(selectedMethod, stepParams);
// Add step to queue.
batchQueue.add(step);
currentStepsList.setListData(batchQueue);
currentStepsList.setSelectedIndex(currentStepsList.getModel().getSize() - 1);
}
}
if (btnRemove.equals(src)) {
// Remove selected step.
final MZmineProcessingStep<?> selected = (MZmineProcessingStep<?>) currentStepsList.getSelectedValue();
if (selected != null) {
final int index = currentStepsList.getSelectedIndex();
batchQueue.remove(selected);
currentStepsList.setListData(batchQueue);
selectStep(index);
}
}
if (btnClear.equals(src)) {
// Clear the queue.
batchQueue.clear();
currentStepsList.setListData(batchQueue);
}
if (btnConfig.equals(src)) {
// Configure the selected item.
final MZmineProcessingStep<?> selected = (MZmineProcessingStep<?>) currentStepsList.getSelectedValue();
final ParameterSet parameters = selected == null ? null : selected.getParameterSet();
if (parameters != null) {
Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
parameters.showSetupDialog(parent, false);
}
}
if (btnSave.equals(src)) {
try {
final File file = chooser.getSaveFile(this, XML_EXTENSION);
if (file != null) {
saveBatchSteps(file);
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, "A problem occurred saving the file.\n" + ex.getMessage(), "Saving Failed", JOptionPane.ERROR_MESSAGE);
}
}
if (btnLoad.equals(src)) {
try {
// Load the steps.
final File file = chooser.getLoadFile(this);
if (file != null) {
// Load the batch steps.
loadBatchSteps(file);
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(this, "A problem occurred loading the file.\n" + ex.getMessage(), "Loading Failed", JOptionPane.ERROR_MESSAGE);
}
}
}
use of net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter in project mzmine2 by mzmine.
the class BatchQueueParameter method checkValue.
@Override
public boolean checkValue(final Collection<String> errorMessages) {
boolean allParamsOK = true;
if (value == null) {
// Parameters not set.
errorMessages.add(getName() + " is not set");
allParamsOK = false;
} else {
// Check each step.
for (final MZmineProcessingStep<?> batchStep : value) {
// Check step's parameters.
final ParameterSet params = batchStep.getParameterSet();
if (params == null)
continue;
for (final Parameter<?> parameter : params.getParameters()) {
// Ignore the raw data files and feature lists parameters
if (!(parameter instanceof RawDataFilesParameter) && !(parameter instanceof PeakListsParameter) && !parameter.checkValue(errorMessages)) {
allParamsOK = false;
}
}
}
}
return allParamsOK;
}
Aggregations