use of net.sf.mzmine.parameters.ParameterSet 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;
}
use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.
the class MZmineConfigurationImpl method loadConfiguration.
@Override
public void loadConfiguration(File file) throws IOException {
try {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document configuration = dBuilder.parse(file);
XPathFactory factory = XPathFactory.newInstance();
XPath xpath = factory.newXPath();
logger.finest("Loading desktop configuration");
XPathExpression expr = xpath.compile("//configuration/preferences");
NodeList nodes = (NodeList) expr.evaluate(configuration, XPathConstants.NODESET);
if (nodes.getLength() == 1) {
Element preferencesElement = (Element) nodes.item(0);
// that needs this key for encryption
if (file.equals(MZmineConfiguration.CONFIG_FILE))
new SimpleParameterSet(new Parameter[] { globalEncrypter }).loadValuesFromXML(preferencesElement);
preferences.loadValuesFromXML(preferencesElement);
}
logger.finest("Loading last projects");
expr = xpath.compile("//configuration/lastprojects");
nodes = (NodeList) expr.evaluate(configuration, XPathConstants.NODESET);
if (nodes.getLength() == 1) {
Element lastProjectsElement = (Element) nodes.item(0);
lastProjects.loadValueFromXML(lastProjectsElement);
}
logger.finest("Loading modules configuration");
for (MZmineModule module : MZmineCore.getAllModules()) {
String className = module.getClass().getName();
expr = xpath.compile("//configuration/modules/module[@class='" + className + "']/parameters");
nodes = (NodeList) expr.evaluate(configuration, XPathConstants.NODESET);
if (nodes.getLength() != 1)
continue;
Element moduleElement = (Element) nodes.item(0);
ParameterSet moduleParameters = getModuleParameters(module.getClass());
moduleParameters.loadValuesFromXML(moduleElement);
}
logger.info("Loaded configuration from file " + file);
} catch (Exception e) {
throw new IOException(e);
}
}
use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.
the class MZminePreferences method updateSystemProxySettings.
private void updateSystemProxySettings() {
// Update system proxy settings
Boolean proxyEnabled = getParameter(proxySettings).getValue();
if ((proxyEnabled != null) && (proxyEnabled)) {
ParameterSet proxyParams = getParameter(proxySettings).getEmbeddedParameters();
String address = proxyParams.getParameter(ProxySettings.proxyAddress).getValue();
String port = proxyParams.getParameter(ProxySettings.proxyPort).getValue();
System.setProperty("http.proxySet", "true");
System.setProperty("http.proxyHost", address);
System.setProperty("http.proxyPort", port);
} else {
System.clearProperty("http.proxySet");
System.clearProperty("http.proxyHost");
System.clearProperty("http.proxyPort");
}
}
use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.
the class DataPointProcessingController method execute.
/**
* This will execute the modules associated with the plot. It will start with the first one and
* execute the following ones afterwards automatically. This method is called by the public method
* execute(). The status listener in this method starts the next task recursively after the
* previous one has finished.
*
* @param dp
* @param module
* @param plot
*/
private void execute(DataPoint[] dp, MZmineProcessingStep<DataPointProcessingModule> step, SpectraPlot plot) {
if (queue == null || queue.isEmpty() || plot == null) {
logger.warning("execute called, without queue or plot being set.");
setStatus(ControllerStatus.FINISHED);
return;
}
if (getForcedStatus() == ForcedControllerStatus.CANCEL || getStatus() == ControllerStatus.CANCELED) {
setResults(ProcessedDataPoint.convert(dp));
logger.finest("Canceled controller, not starting new tasks. Results are set to latest array.");
setStatus(ControllerStatus.CANCELED);
return;
}
List<String> err = new ArrayList<>();
if (!step.getParameterSet().checkParameterValues(err)) {
setResults(ProcessedDataPoint.convert(dp));
setStatus(ControllerStatus.CANCELED);
logger.warning(step.getModule().getName() + " - Not all parameters set." + Arrays.toString(err.toArray(new String[0])));
return;
}
if (step.getModule() instanceof DataPointProcessingModule) {
DataPointProcessingModule inst = step.getModule();
ParameterSet parameters = step.getParameterSet();
Task t = ((DataPointProcessingModule) inst).createTask(dp, parameters, plot, this, new TaskStatusListener() {
@Override
public void taskStatusChanged(Task task, TaskStatus newStatus, TaskStatus oldStatus) {
if (!(task instanceof DataPointProcessingTask)) {
// TODO: Throw exception?
logger.warning("This should have been a DataPointProcessingTask.");
return;
}
// logger.finest("Task status changed to " + newStatus.toString());
switch(newStatus) {
case FINISHED:
if (queue.hasNextStep(step)) {
if (DataPointProcessingManager.getInst().isRunning(((DataPointProcessingTask) task).getController())) {
MZmineProcessingStep<DataPointProcessingModule> next = queue.getNextStep(step);
// pass results to next task and start recursively
ProcessedDataPoint[] result = ((DataPointProcessingTask) task).getResults();
((DataPointProcessingTask) task).displayResults();
execute(result, next, plot);
} else {
logger.warning("This controller was already removed from the running list, although it " + "had not finished processing. Exiting");
break;
}
} else {
setResults(((DataPointProcessingTask) task).getResults());
((DataPointProcessingTask) task).displayResults();
setStatus(ControllerStatus.FINISHED);
}
break;
case PROCESSING:
setStatus(ControllerStatus.PROCESSING);
break;
case WAITING:
// should we even set to WAITING here?
break;
case ERROR:
setStatus(ControllerStatus.ERROR);
break;
case CANCELED:
setStatus(ControllerStatus.CANCELED);
break;
}
}
});
logger.finest("Start processing of " + t.getClass().getName());
MZmineCore.getTaskController().addTask(t);
// maybe we need this some time
setCurrentTask((DataPointProcessingTask) t);
setCurrentStep(step);
}
}
use of net.sf.mzmine.parameters.ParameterSet in project mzmine2 by mzmine.
the class DataPointProcessingQueue method loadfromXML.
@Nonnull
public static DataPointProcessingQueue loadfromXML(@Nonnull final Element xmlElement) {
DataPointProcessingQueue queue = new DataPointProcessingQueue();
// Get the loaded modules.
final Collection<MZmineModule> allModules = MZmineCore.getAllModules();
// Process the processing step elements.
final NodeList nodes = xmlElement.getElementsByTagName(DATA_POINT_PROCESSING_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);
logger.finest("loading method " + methodName);
for (MZmineModule module : allModules) {
if (module instanceof DataPointProcessingModule && module.getClass().getName().equals(methodName)) {
// since the same module can be used in different ms levels, we need to clone the
// parameter set, so we can have different values for every ms level
ParameterSet parameterSet = MZmineCore.getConfiguration().getModuleParameters(module.getClass()).cloneParameterSet();
parameterSet.loadValuesFromXML(stepElement);
queue.add(new MZmineProcessingStepImpl<DataPointProcessingModule>((DataPointProcessingModule) module, parameterSet));
// add to treeView
break;
}
}
}
return queue;
}
Aggregations