Search in sources :

Example 11 with ParameterSet

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;
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) PeakListsParameter(net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter) RawDataFilesParameter(net.sf.mzmine.parameters.parametertypes.selectors.RawDataFilesParameter)

Example 12 with ParameterSet

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);
    }
}
Also used : XPath(javax.xml.xpath.XPath) XPathExpression(javax.xml.xpath.XPathExpression) ParameterSet(net.sf.mzmine.parameters.ParameterSet) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) IOException(java.io.IOException) Document(org.w3c.dom.Document) IOException(java.io.IOException) XPathFactory(javax.xml.xpath.XPathFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) MZmineModule(net.sf.mzmine.modules.MZmineModule)

Example 13 with ParameterSet

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");
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet)

Example 14 with ParameterSet

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);
    }
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) Task(net.sf.mzmine.taskcontrol.Task) ArrayList(java.util.ArrayList) TaskStatus(net.sf.mzmine.taskcontrol.TaskStatus) TaskStatusListener(net.sf.mzmine.taskcontrol.TaskStatusListener) MZmineProcessingStep(net.sf.mzmine.modules.MZmineProcessingStep)

Example 15 with ParameterSet

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;
}
Also used : ParameterSet(net.sf.mzmine.parameters.ParameterSet) NodeList(org.w3c.dom.NodeList) Element(org.w3c.dom.Element) MZmineModule(net.sf.mzmine.modules.MZmineModule) Nonnull(javax.annotation.Nonnull)

Aggregations

ParameterSet (net.sf.mzmine.parameters.ParameterSet)53 ExitCode (net.sf.mzmine.util.ExitCode)19 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)11 File (java.io.File)9 ArrayList (java.util.ArrayList)8 SimpleParameterSet (net.sf.mzmine.parameters.impl.SimpleParameterSet)8 Task (net.sf.mzmine.taskcontrol.Task)8 Element (org.w3c.dom.Element)8 PeakList (net.sf.mzmine.datamodel.PeakList)6 MZmineModule (net.sf.mzmine.modules.MZmineModule)6 Document (org.w3c.dom.Document)6 IOException (java.io.IOException)5 DataPoint (net.sf.mzmine.datamodel.DataPoint)5 PeakListRow (net.sf.mzmine.datamodel.PeakListRow)5 Scan (net.sf.mzmine.datamodel.Scan)5 MZmineProcessingModule (net.sf.mzmine.modules.MZmineProcessingModule)5 Nonnull (javax.annotation.Nonnull)4 Feature (net.sf.mzmine.datamodel.Feature)4 IsotopePattern (net.sf.mzmine.datamodel.IsotopePattern)4 PeakListsParameter (net.sf.mzmine.parameters.parametertypes.selectors.PeakListsParameter)4