use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.
the class RTScore method calculateScore.
public double calculateScore(AlignmentPath path, PeakListRow peak, ParameterSet parameters) {
try {
rtTolerance = parameters.getParameter(PathAlignerParameters.RTTolerance).getValue();
mzTolerance = parameters.getParameter(PathAlignerParameters.MZTolerance).getValue();
Range<Double> rtRange = rtTolerance.getToleranceRange(path.getRT());
Range<Double> mzRange = mzTolerance.getToleranceRange(path.getMZ());
if (!rtRange.contains(peak.getAverageRT()) || !mzRange.contains(peak.getAverageMZ())) {
return WORST_SCORE;
}
double mzDiff = Math.abs(path.getMZ() - peak.getAverageMZ());
double rtDiff = Math.abs(path.getRT() - peak.getAverageRT());
double score = ((mzDiff / (RangeUtils.rangeLength(mzRange) / 2.0))) + ((rtDiff / (RangeUtils.rangeLength(rtRange) / 2.0)));
if (parameters.getParameter(PathAlignerParameters.SameChargeRequired).getValue()) {
if (!PeakUtils.compareChargeState(path.convertToAlignmentRow(0), peak)) {
return WORST_SCORE;
}
}
if (parameters.getParameter(PathAlignerParameters.SameIDRequired).getValue()) {
if (!PeakUtils.compareIdentities(path.convertToAlignmentRow(0), peak)) {
return WORST_SCORE;
}
}
if (parameters.getParameter(PathAlignerParameters.compareIsotopePattern).getValue()) {
IsotopePattern ip1 = path.convertToAlignmentRow(0).getBestIsotopePattern();
IsotopePattern ip2 = peak.getBestIsotopePattern();
if ((ip1 != null) && (ip2 != null)) {
ParameterSet isotopeParams = parameters.getParameter(PathAlignerParameters.compareIsotopePattern).getEmbeddedParameters();
if (!IsotopePatternScoreCalculator.checkMatch(ip1, ip2, isotopeParams)) {
return WORST_SCORE;
}
}
}
return score;
} catch (NullPointerException e) {
e.printStackTrace();
return WORST_SCORE;
}
}
use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.
the class BaselineCorrector method collectCommonParameters.
/**
* Getting general parameters (common to all the correctors).
*
* @param generalParameters The parameters common to all methods (grabbed from
* "BaselineCorrectionParameters")
*/
public void collectCommonParameters(final ParameterSet parameters) {
ParameterSet generalParameters;
if (parameters != null) {
generalParameters = parameters;
} else if (BaselineCorrectionParameters.getBaselineCorrectionParameters() == null) {
generalParameters = MZmineCore.getConfiguration().getModuleParameters(BaselineCorrectionModule.class);
} else {
generalParameters = BaselineCorrectionParameters.getBaselineCorrectionParameters();
}
// Get common parameters.
rEgineType = generalParameters.getParameter(BaselineCorrectionParameters.RENGINE_TYPE).getValue();
suffix = generalParameters.getParameter(BaselineCorrectionParameters.SUFFIX).getValue();
chromatogramType = generalParameters.getParameter(BaselineCorrectionParameters.CHROMOTAGRAM_TYPE).getValue();
binWidth = generalParameters.getParameter(BaselineCorrectionParameters.MZ_BIN_WIDTH).getValue();
useBins = generalParameters.getParameter(BaselineCorrectionParameters.USE_MZ_BINS).getValue();
msLevel = generalParameters.getParameter(BaselineCorrectionParameters.MS_LEVEL).getValue();
}
use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.
the class ProcessingComponent method setParameters.
/**
* Opens the parameter setup dialog of the selected module.
*/
private void setParameters(@Nonnull DefaultMutableTreeNode _selected) {
if (_selected == null || !(_selected instanceof DPPModuleTreeNode))
return;
DPPModuleTreeNode selected = (DPPModuleTreeNode) _selected;
ParameterSet stepParameters = selected.getParameters();
if (stepParameters.getParameters().length > 0 && !selected.isDialogShowing()) {
selected.setDialogShowing(true);
ExitCode exitCode = stepParameters.showSetupDialog(null, true);
selected.setDialogShowing(false);
if (exitCode == ExitCode.OK) {
// store the parameters in the tree item
selected.setParameters(stepParameters);
// sendValueWrapper(); // update the list
}
}
}
use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.
the class BatchQueue method loadFromXml.
/**
* De-serialize from XML.
*
* @param xmlElement the element that holds the XML.
* @return the de-serialized value.
*/
public static BatchQueue loadFromXml(final Element xmlElement) {
// Set the parameter choice for the RowsFilterModule
String[] choices;
choices = new String[1];
choices[0] = "No parameters defined";
MZmineCore.getConfiguration().getModuleParameters(RowsFilterModule.class).getParameter(RowsFilterParameters.GROUPSPARAMETER).setChoices(choices);
// Create an empty queue.
final BatchQueue queue = new BatchQueue();
// Get the loaded modules.
final Collection<MZmineModule> allModules = MZmineCore.getAllModules();
// Process the batch step elements.
final NodeList nodes = xmlElement.getElementsByTagName(BATCH_STEP_ELEMENT);
final int nodesLength = nodes.getLength();
for (int i = 0; i < nodesLength; i++) {
final Element stepElement = (Element) nodes.item(i);
final String methodName = stepElement.getAttribute(METHOD_ELEMENT);
// Find a matching module.
for (final MZmineModule module : allModules) {
if (module instanceof MZmineProcessingModule && module.getClass().getName().equals(methodName)) {
// Get parameters and add step to queue.
final ParameterSet parameterSet = MZmineCore.getConfiguration().getModuleParameters(module.getClass());
final ParameterSet methodParams = parameterSet.cloneParameterSet();
methodParams.loadValuesFromXML(stepElement);
queue.add(new MZmineProcessingStepImpl<MZmineProcessingModule>((MZmineProcessingModule) module, methodParams));
break;
}
}
}
return queue;
}
use of net.sf.mzmine.parameters.ParameterSet 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);
}
}
}
Aggregations