Search in sources :

Example 11 with UserParameter

use of net.sf.mzmine.parameters.UserParameter in project mzmine2 by mzmine.

the class RowsFilterParameters method showSetupDialog.

@Override
public ExitCode showSetupDialog(Window parent, boolean valueCheckRequired) {
    // Update the parameter choices
    UserParameter<?, ?>[] newChoices = MZmineCore.getProjectManager().getCurrentProject().getParameters();
    String[] choices;
    if (newChoices == null || newChoices.length == 0) {
        choices = new String[1];
        choices[0] = "No parameters defined";
    } else {
        choices = new String[newChoices.length + 1];
        choices[0] = "Ignore groups";
        for (int i = 0; i < newChoices.length; i++) {
            choices[i + 1] = "Filtering by " + newChoices[i].getName();
        }
    }
    getParameter(RowsFilterParameters.GROUPSPARAMETER).setChoices(choices);
    ParameterSetupDialog dialog = new ParameterSetupDialog(parent, valueCheckRequired, this);
    dialog.setVisible(true);
    return dialog.getExitCode();
}
Also used : UserParameter(net.sf.mzmine.parameters.UserParameter) ParameterSetupDialog(net.sf.mzmine.parameters.dialogs.ParameterSetupDialog)

Example 12 with UserParameter

use of net.sf.mzmine.parameters.UserParameter in project mzmine2 by mzmine.

the class SignificanceTask method calculateSignificance.

private void calculateSignificance() throws IllegalStateException {
    if (peakListRows.length == 0) {
        return;
    }
    List<Set<RawDataFile>> groups = getGroups(userParameter);
    finishedPercentage = 0.0;
    final double finishedStep = 1.0 / peakListRows.length;
    for (PeakListRow row : peakListRows) {
        if (isCanceled()) {
            break;
        }
        finishedPercentage += finishedStep;
        double[][] intensityGroups = new double[groups.size()][];
        for (int i = 0; i < groups.size(); ++i) {
            Set<RawDataFile> groupFiles = groups.get(i);
            intensityGroups[i] = Arrays.stream(row.getPeaks()).filter(peak -> groupFiles.contains(peak.getDataFile())).mapToDouble(Feature::getHeight).toArray();
        }
        Double pValue = oneWayAnova(intensityGroups);
        // Save results
        PeakInformation peakInformation = row.getPeakInformation();
        if (peakInformation == null) {
            peakInformation = new SimplePeakInformation();
        }
        peakInformation.getAllProperties().put(P_VALUE_KEY, pValue == null ? EMPTY_STRING : pValue.toString());
        row.setPeakInformation(peakInformation);
    }
}
Also used : IntStream(java.util.stream.IntStream) net.sf.mzmine.datamodel(net.sf.mzmine.datamodel) java.util(java.util) MZmineCore(net.sf.mzmine.main.MZmineCore) TaskStatus(net.sf.mzmine.taskcontrol.TaskStatus) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Level(java.util.logging.Level) SimplePeakInformation(net.sf.mzmine.datamodel.impl.SimplePeakInformation) ParameterSet(net.sf.mzmine.parameters.ParameterSet) AbstractTask(net.sf.mzmine.taskcontrol.AbstractTask) Entry(java.util.Map.Entry) UserParameter(net.sf.mzmine.parameters.UserParameter) FDistribution(org.apache.commons.math3.distribution.FDistribution) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) MathIllegalArgumentException(org.apache.commons.math3.exception.MathIllegalArgumentException) ParameterSet(net.sf.mzmine.parameters.ParameterSet) SimplePeakInformation(net.sf.mzmine.datamodel.impl.SimplePeakInformation) SimplePeakInformation(net.sf.mzmine.datamodel.impl.SimplePeakInformation)

Example 13 with UserParameter

use of net.sf.mzmine.parameters.UserParameter in project mzmine2 by mzmine.

the class ParameterSetupDialog method addDialogComponents.

/**
 * Constructs all components of the dialog
 */
@SuppressWarnings({ "unchecked", "rawtypes" })
protected void addDialogComponents() {
    // Main panel which holds all the components in a grid
    mainPanel = new GridBagPanel();
    int rowCounter = 0;
    int vertWeightSum = 0;
    // Create labels and components for each parameter
    for (Parameter p : parameterSet.getParameters()) {
        if (!(p instanceof UserParameter))
            continue;
        UserParameter up = (UserParameter) p;
        JComponent comp = up.createEditingComponent();
        comp.setToolTipText(up.getDescription());
        // Set the initial value
        Object value = up.getValue();
        if (value != null)
            up.setValueToComponent(comp, value);
        // Add listeners so we are notified about any change in the values
        addListenersToComponent(comp);
        // By calling this we make sure the components will never be resized
        // smaller than their optimal size
        comp.setMinimumSize(comp.getPreferredSize());
        comp.setToolTipText(up.getDescription());
        JLabel label = new JLabel(p.getName());
        mainPanel.add(label, 0, rowCounter);
        label.setLabelFor(comp);
        parametersAndComponents.put(p.getName(), comp);
        JComboBox t = new JComboBox();
        int comboh = t.getPreferredSize().height;
        int comph = comp.getPreferredSize().height;
        // Multiple selection will be expandable, other components not
        int verticalWeight = comph > 2 * comboh ? 1 : 0;
        vertWeightSum += verticalWeight;
        mainPanel.add(comp, 1, rowCounter, 1, 1, 1, verticalWeight, GridBagConstraints.VERTICAL);
        rowCounter++;
    }
    // Add a single empty cell to the 99th row. This cell is expandable
    // (weightY is 1), therefore the other components will be
    // aligned to the top, which is what we want
    // JComponent emptySpace = (JComponent) Box.createVerticalStrut(1);
    // mainPanel.add(emptySpace, 0, 99, 3, 1, 0, 1);
    // Create a separate panel for the buttons
    pnlButtons = new JPanel();
    btnOK = GUIUtils.addButton(pnlButtons, "OK", null, this);
    btnCancel = GUIUtils.addButton(pnlButtons, "Cancel", null, this);
    if (helpURL != null) {
        btnHelp = GUIUtils.addButton(pnlButtons, "Help", null, this);
    }
    /*
     * Last row in the table will be occupied by the buttons. We set the row number to 100 and width
     * to 3, spanning the 3 component columns defined above.
     */
    if (vertWeightSum == 0) {
        mainPanel.add(Box.createGlue(), 0, 99, 3, 1, 1, 1);
    }
    if (footerMessage == null) {
        mainPanel.addCenter(pnlButtons, 0, 100, 3, 1);
    } else {
        // Footer
        JEditorPane editorPane = GUIUtils.addEditorPane(footerMessage);
        editorPane.addHyperlinkListener(new HyperlinkListener() {

            @Override
            public void hyperlinkUpdate(HyperlinkEvent e) {
                if (HyperlinkEvent.EventType.ACTIVATED.equals(e.getEventType())) {
                    try {
                        Desktop.getDesktop().browse(e.getURL().toURI());
                    } catch (Exception ex) {
                        ex.printStackTrace();
                    }
                }
            }
        });
        // This line is important on Windows, where resizing the dialog has unexpected consequences on
        // some components
        editorPane.setMinimumSize(editorPane.getPreferredSize());
        mainPanel.add(editorPane, 0, 98, 3, 1);
        mainPanel.addCenter(pnlButtons, 0, 100, 3, 1);
    }
    // Add some space around the widgets
    GUIUtils.addMargin(mainPanel, 10);
    // Add the main panel as the only component of this dialog
    add(mainPanel);
    pack();
}
Also used : JPanel(javax.swing.JPanel) HyperlinkEvent(javax.swing.event.HyperlinkEvent) JComboBox(javax.swing.JComboBox) JComponent(javax.swing.JComponent) JLabel(javax.swing.JLabel) UserParameter(net.sf.mzmine.parameters.UserParameter) HyperlinkListener(javax.swing.event.HyperlinkListener) JEditorPane(javax.swing.JEditorPane) Parameter(net.sf.mzmine.parameters.Parameter) UserParameter(net.sf.mzmine.parameters.UserParameter) HiddenParameter(net.sf.mzmine.parameters.parametertypes.HiddenParameter) GridBagPanel(net.sf.mzmine.util.components.GridBagPanel)

Example 14 with UserParameter

use of net.sf.mzmine.parameters.UserParameter in project mzmine2 by mzmine.

the class HeatMapParameters method showSetupDialog.

@Override
public ExitCode showSetupDialog(Window parent, boolean valueCheckRequired) {
    // Update the parameter choices
    MZmineProject project = MZmineCore.getProjectManager().getCurrentProject();
    UserParameter<?, ?>[] newChoices = project.getParameters();
    getParameter(HeatMapParameters.selectionData).setChoices(newChoices);
    if (newChoices.length > 0) {
        ArrayList<Object> values = new ArrayList<Object>();
        for (RawDataFile dataFile : project.getDataFiles()) {
            Object paramValue = project.getParameterValue(newChoices[0], dataFile);
            if (paramValue == null) {
                continue;
            }
            if (!values.contains(paramValue)) {
                values.add(paramValue);
            }
        }
        Object[] newValues = values.toArray();
        getParameter(HeatMapParameters.referenceGroup).setChoices(newValues);
    }
    HeatmapSetupDialog dialog = new HeatmapSetupDialog(parent, valueCheckRequired, this);
    dialog.setVisible(true);
    return dialog.getExitCode();
}
Also used : UserParameter(net.sf.mzmine.parameters.UserParameter) RawDataFile(net.sf.mzmine.datamodel.RawDataFile) ArrayList(java.util.ArrayList) MZmineProject(net.sf.mzmine.datamodel.MZmineProject)

Example 15 with UserParameter

use of net.sf.mzmine.parameters.UserParameter in project mzmine2 by mzmine.

the class GraphicsExportDialog method updateParameterSetFromComponents.

@SuppressWarnings({ "unchecked", "rawtypes" })
protected void updateParameterSetFromComponents() {
    for (Parameter<?> p : parameters.getParameters()) {
        if (!(p instanceof UserParameter))
            continue;
        UserParameter up = (UserParameter) p;
        JComponent component = parametersAndComponents.get(p.getName());
        up.setValueFromComponent(component);
    }
    for (Parameter<?> p : chartParam.getParameters()) {
        if (!(p instanceof UserParameter))
            continue;
        UserParameter up = (UserParameter) p;
        JComponent component = parametersAndComponents.get(p.getName());
        up.setValueFromComponent(component);
    }
}
Also used : UserParameter(net.sf.mzmine.parameters.UserParameter) JComponent(javax.swing.JComponent)

Aggregations

UserParameter (net.sf.mzmine.parameters.UserParameter)22 JComponent (javax.swing.JComponent)8 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)5 MZmineProject (net.sf.mzmine.datamodel.MZmineProject)4 ArrayList (java.util.ArrayList)3 JComboBox (javax.swing.JComboBox)3 JLabel (javax.swing.JLabel)3 Parameter (net.sf.mzmine.parameters.Parameter)3 ParameterSet (net.sf.mzmine.parameters.ParameterSet)3 GridBagPanel (net.sf.mzmine.util.components.GridBagPanel)3 DataPoint (net.sf.mzmine.datamodel.DataPoint)2 ParameterSetupDialog (net.sf.mzmine.parameters.dialogs.ParameterSetupDialog)2 DoubleParameter (net.sf.mzmine.parameters.parametertypes.DoubleParameter)2 StringParameter (net.sf.mzmine.parameters.parametertypes.StringParameter)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 java.util (java.util)1 HashMap (java.util.HashMap)1