Search in sources :

Example 6 with StringParameter

use of net.sf.mzmine.parameters.parametertypes.StringParameter in project mzmine2 by mzmine.

the class PeakSelectionComponent method actionPerformed.

public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == addButton) {
        final IntRangeParameter idParameter = new IntRangeParameter("ID", "Range of included peak IDs", false, null);
        final MZRangeParameter mzParameter = new MZRangeParameter(false);
        final RTRangeParameter rtParameter = new RTRangeParameter(false);
        final StringParameter nameParameter = new StringParameter("Name", "Peak identity name", null, false);
        SimpleParameterSet paramSet = new SimpleParameterSet(new Parameter[] { idParameter, mzParameter, rtParameter, nameParameter });
        Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
        ExitCode exitCode = paramSet.showSetupDialog(parent, true);
        if (exitCode == ExitCode.OK) {
            Range<Integer> idRange = paramSet.getParameter(idParameter).getValue();
            Range<Double> mzRange = paramSet.getParameter(mzParameter).getValue();
            Range<Double> rtRange = paramSet.getParameter(rtParameter).getValue();
            String name = paramSet.getParameter(nameParameter).getValue();
            PeakSelection ps = new PeakSelection(idRange, mzRange, rtRange, name);
            selectionListModel.addElement(ps);
        }
    }
    if (src == allButton) {
        PeakSelection ps = new PeakSelection(null, null, null, null);
        selectionListModel.clear();
        selectionListModel.addElement(ps);
    }
    if (src == removeButton) {
        for (PeakSelection p : selectionList.getSelectedValuesList()) {
            selectionListModel.removeElement(p);
        }
    }
    if (src == clearButton) {
        selectionListModel.clear();
    }
}
Also used : Window(java.awt.Window) StringParameter(net.sf.mzmine.parameters.parametertypes.StringParameter) RTRangeParameter(net.sf.mzmine.parameters.parametertypes.ranges.RTRangeParameter) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) IntRangeParameter(net.sf.mzmine.parameters.parametertypes.ranges.IntRangeParameter) ExitCode(net.sf.mzmine.util.ExitCode) MZRangeParameter(net.sf.mzmine.parameters.parametertypes.ranges.MZRangeParameter)

Example 7 with StringParameter

use of net.sf.mzmine.parameters.parametertypes.StringParameter in project mzmine2 by mzmine.

the class AddProjectParameterDialog method actionPerformed.

public void actionPerformed(ActionEvent actionEvent) {
    Object src = actionEvent.getSource();
    Desktop desktop = MZmineCore.getDesktop();
    if (src == buttonAddParameter) {
        if (fieldName.getText().length() == 0) {
            desktop.displayErrorMessage(this, "Give a name for the parameter first.");
            return;
        }
        String paramName = fieldName.getText();
        UserParameter<?, ?> parameter = null;
        if (radiobuttonNumerical.isSelected()) {
            parameter = new DoubleParameter(paramName, null);
        }
        if (radiobuttonFreeText.isSelected()) {
            parameter = new StringParameter(paramName, null);
        }
        if (radiobuttonCategorical.isSelected()) {
            String[] possibleValues = new String[categories.size()];
            if (possibleValues.length == 0) {
                desktop.displayErrorMessage(this, "Give at least a single parameter value.");
                return;
            }
            for (int valueIndex = 0; valueIndex < categories.size(); valueIndex++) possibleValues[valueIndex] = (String) categories.get(valueIndex);
            parameter = new ComboParameter<String>(paramName, null, possibleValues);
        }
        mainDialog.addParameter(parameter);
        dispose();
    }
    if (src == buttonCancel) {
        dispose();
    }
    if ((src == radiobuttonNumerical) || (src == radiobuttonCategorical) || (src == radiobuttonFreeText)) {
        if (radiobuttonCategorical.isSelected()) {
            switchCategoricalFields(true);
        } else {
            switchCategoricalFields(false);
        }
    }
    if (src == buttonAddCategory) {
        String inputValue = JOptionPane.showInputDialog("Please input a new value");
        if ((inputValue == null) || (inputValue.trim().length() == 0))
            return;
        if (((DefaultListModel<String>) listCategories.getModel()).contains(inputValue)) {
            desktop.displayErrorMessage(this, "Value already exists.");
            return;
        }
        ((DefaultListModel<String>) listCategories.getModel()).addElement(inputValue);
    }
    if (src == buttonRemoveCategory) {
        int[] selectedIndices = listCategories.getSelectedIndices();
        if ((selectedIndices == null) || (selectedIndices.length == 0)) {
            desktop.displayErrorMessage(this, "Select at least one value first.");
            return;
        }
        for (int selectedIndex : selectedIndices) {
            ((DefaultListModel<String>) listCategories.getModel()).removeElementAt(selectedIndex);
        }
    }
}
Also used : StringParameter(net.sf.mzmine.parameters.parametertypes.StringParameter) DoubleParameter(net.sf.mzmine.parameters.parametertypes.DoubleParameter) Desktop(net.sf.mzmine.desktop.Desktop) DefaultListModel(javax.swing.DefaultListModel)

Example 8 with StringParameter

use of net.sf.mzmine.parameters.parametertypes.StringParameter in project mzmine2 by mzmine.

the class ScanSelectionComponent method actionPerformed.

public void actionPerformed(ActionEvent event) {
    Object src = event.getSource();
    if (src == setButton) {
        SimpleParameterSet paramSet;
        ExitCode exitCode;
        Window parent = (Window) SwingUtilities.getAncestorOfClass(Window.class, this);
        final IntRangeParameter scanNumParameter = new IntRangeParameter("Scan number", "Range of included scan numbers", false, scanNumberRange);
        final IntegerParameter baseFilteringIntegerParameter = new IntegerParameter("Base Filtering Integer", "Enter an integer for which every multiple of that integer in the list will be filtered. (Every Nth element will be shown)", this.baseFilteringInteger, false);
        final RTRangeParameter rtParameter = new RTRangeParameter(false);
        if (scanRTRange != null)
            rtParameter.setValue(scanRTRange);
        final IntegerParameter msLevelParameter = new IntegerParameter("MS level", "MS level", msLevel, false);
        final StringParameter scanDefinitionParameter = new StringParameter("Scan definition", "Include only scans that match this scan definition. You can use wild cards, e.g. *FTMS*", scanDefinition, false);
        final String[] polarityTypes = { "Any", "+", "-" };
        final ComboParameter<String> polarityParameter = new ComboParameter<>("Polarity", "Include only scans of this polarity", polarityTypes);
        if ((polarity == PolarityType.POSITIVE) || (polarity == PolarityType.NEGATIVE))
            polarityParameter.setValue(polarity.asSingleChar());
        final String[] spectraTypes = { "Any", "Centroided", "Profile", "Thresholded" };
        final ComboParameter<String> spectrumTypeParameter = new ComboParameter<>("Spectrum type", "Include only spectra of this type", spectraTypes);
        if (spectrumType != null) {
            switch(spectrumType) {
                case CENTROIDED:
                    spectrumTypeParameter.setValue(spectraTypes[1]);
                    break;
                case PROFILE:
                    spectrumTypeParameter.setValue(spectraTypes[2]);
                    break;
                case THRESHOLDED:
                    spectrumTypeParameter.setValue(spectraTypes[3]);
                    break;
            }
        }
        paramSet = new SimpleParameterSet(new Parameter[] { scanNumParameter, baseFilteringIntegerParameter, rtParameter, msLevelParameter, scanDefinitionParameter, polarityParameter, spectrumTypeParameter });
        exitCode = paramSet.showSetupDialog(parent, true);
        if (exitCode == ExitCode.OK) {
            scanNumberRange = paramSet.getParameter(scanNumParameter).getValue();
            this.baseFilteringInteger = paramSet.getParameter(baseFilteringIntegerParameter).getValue();
            scanRTRange = paramSet.getParameter(rtParameter).getValue();
            msLevel = paramSet.getParameter(msLevelParameter).getValue();
            scanDefinition = paramSet.getParameter(scanDefinitionParameter).getValue();
            final int selectedPolarityIndex = Arrays.asList(polarityTypes).indexOf(paramSet.getParameter(polarityParameter).getValue());
            switch(selectedPolarityIndex) {
                case 1:
                    polarity = PolarityType.POSITIVE;
                    break;
                case 2:
                    polarity = PolarityType.NEGATIVE;
                    break;
                default:
                    polarity = null;
                    break;
            }
            final int selectedSpectraTypeIndex = Arrays.asList(spectraTypes).indexOf(paramSet.getParameter(spectrumTypeParameter).getValue());
            switch(selectedSpectraTypeIndex) {
                case 1:
                    spectrumType = MassSpectrumType.CENTROIDED;
                    break;
                case 2:
                    spectrumType = MassSpectrumType.PROFILE;
                    break;
                case 3:
                    spectrumType = MassSpectrumType.THRESHOLDED;
                    break;
                default:
                    spectrumType = null;
                    break;
            }
        }
    }
    if (src == clearButton) {
        scanNumberRange = null;
        baseFilteringInteger = null;
        scanRTRange = null;
        polarity = null;
        spectrumType = null;
        msLevel = null;
        scanDefinition = null;
    }
    updateRestrictionList();
}
Also used : Window(java.awt.Window) IntegerParameter(net.sf.mzmine.parameters.parametertypes.IntegerParameter) StringParameter(net.sf.mzmine.parameters.parametertypes.StringParameter) SimpleParameterSet(net.sf.mzmine.parameters.impl.SimpleParameterSet) RTRangeParameter(net.sf.mzmine.parameters.parametertypes.ranges.RTRangeParameter) IntRangeParameter(net.sf.mzmine.parameters.parametertypes.ranges.IntRangeParameter) ExitCode(net.sf.mzmine.util.ExitCode) ComboParameter(net.sf.mzmine.parameters.parametertypes.ComboParameter) Parameter(net.sf.mzmine.parameters.Parameter) StringParameter(net.sf.mzmine.parameters.parametertypes.StringParameter) IntRangeParameter(net.sf.mzmine.parameters.parametertypes.ranges.IntRangeParameter) RTRangeParameter(net.sf.mzmine.parameters.parametertypes.ranges.RTRangeParameter) ComboParameter(net.sf.mzmine.parameters.parametertypes.ComboParameter) IntegerParameter(net.sf.mzmine.parameters.parametertypes.IntegerParameter)

Example 9 with StringParameter

use of net.sf.mzmine.parameters.parametertypes.StringParameter in project mzmine2 by mzmine.

the class MzTabImportTask method importVariables.

private void importVariables(MZTabFile mzTabFile, Map<Integer, RawDataFile> rawDataFiles) {
    // Add sample parameters if available in mzTab file
    SortedMap<Integer, StudyVariable> variableMap = mzTabFile.getMetadata().getStudyVariableMap();
    if (variableMap.isEmpty())
        return;
    UserParameter<?, ?> newParameter = new StringParameter(inputFile.getName() + " study variable", "");
    project.addParameter(newParameter);
    for (Entry<Integer, StudyVariable> entry : variableMap.entrySet()) {
        // Stop the process if cancel() was called
        if (isCanceled())
            return;
        String variableValue = entry.getValue().getDescription();
        SortedMap<Integer, Assay> assayMap = entry.getValue().getAssayMap();
        for (Entry<Integer, RawDataFile> rawDataEntry : rawDataFiles.entrySet()) {
            RawDataFile rawData = rawDataEntry.getValue();
            Assay dataFileAssay = assayMap.get(rawDataEntry.getKey());
            if (dataFileAssay != null)
                project.setParameterValue(newParameter, rawData, variableValue);
        }
    }
}
Also used : Assay(uk.ac.ebi.pride.jmztab.model.Assay) StudyVariable(uk.ac.ebi.pride.jmztab.model.StudyVariable) StringParameter(net.sf.mzmine.parameters.parametertypes.StringParameter) RawDataFile(net.sf.mzmine.datamodel.RawDataFile)

Example 10 with StringParameter

use of net.sf.mzmine.parameters.parametertypes.StringParameter in project mzmine2 by mzmine.

the class UserParameterOpenHandler_2_5 method startElement.

/**
 * @see org.xml.sax.helpers.DefaultHandler#startElement(java.lang.String, java.lang.String,
 *      java.lang.String, org.xml.sax.Attributes)
 */
public void startElement(String namespaceURI, String lName, String qName, Attributes attrs) throws SAXException {
    if (canceled)
        throw new SAXException("Parsing canceled");
    // <PARAMETERS>
    if (qName.equals(UserParameterElementName_2_5.PARAMETERS.getElementName())) {
        String count = attrs.getValue(UserParameterElementName_2_5.COUNT.getElementName());
        totalParams = Integer.parseInt(count);
    }
    // <PARAMETER>
    if (qName.equals(UserParameterElementName_2_5.PARAMETER.getElementName())) {
        String name = attrs.getValue(UserParameterElementName_2_5.NAME.getElementName());
        String type = attrs.getValue(UserParameterElementName_2_5.TYPE.getElementName());
        if (type.equals(DoubleParameter.class.getSimpleName())) {
            currentParameter = new DoubleParameter(name, null);
        } else if (type.equals(StringParameter.class.getSimpleName())) {
            currentParameter = new StringParameter(name, null);
        } else if (type.equals(ComboParameter.class.getSimpleName())) {
            currentParameter = new ComboParameter<String>(name, null, new String[0]);
        } else {
            throw new SAXException("Unknown parameter type: " + type);
        }
        logger.finest("Loading parameter " + name);
        currentOptions.clear();
        currentValues.clear();
    }
    // <VALUE>
    if (qName.equals(UserParameterElementName_2_5.VALUE.getElementName())) {
        currentDataFileID = attrs.getValue(UserParameterElementName_2_5.DATA_FILE.getElementName());
    }
}
Also used : StringParameter(net.sf.mzmine.parameters.parametertypes.StringParameter) DoubleParameter(net.sf.mzmine.parameters.parametertypes.DoubleParameter) SAXException(org.xml.sax.SAXException) ComboParameter(net.sf.mzmine.parameters.parametertypes.ComboParameter)

Aggregations

StringParameter (net.sf.mzmine.parameters.parametertypes.StringParameter)10 DoubleParameter (net.sf.mzmine.parameters.parametertypes.DoubleParameter)5 Window (java.awt.Window)4 SimpleParameterSet (net.sf.mzmine.parameters.impl.SimpleParameterSet)4 ComboParameter (net.sf.mzmine.parameters.parametertypes.ComboParameter)4 ExitCode (net.sf.mzmine.util.ExitCode)4 RawDataFile (net.sf.mzmine.datamodel.RawDataFile)3 UserParameter (net.sf.mzmine.parameters.UserParameter)2 MultiChoiceParameter (net.sf.mzmine.parameters.parametertypes.MultiChoiceParameter)2 IntRangeParameter (net.sf.mzmine.parameters.parametertypes.ranges.IntRangeParameter)2 RTRangeParameter (net.sf.mzmine.parameters.parametertypes.ranges.RTRangeParameter)2 SAXException (org.xml.sax.SAXException)2 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Hashtable (java.util.Hashtable)1 StringTokenizer (java.util.StringTokenizer)1 DefaultListModel (javax.swing.DefaultListModel)1 MZmineProject (net.sf.mzmine.datamodel.MZmineProject)1