Search in sources :

Example 1 with StringListParameter

use of com.genericworkflownodes.knime.parameter.StringListParameter in project GenericKnimeNodes by genericworkflownodes.

the class CTDConfigurationReaderTest method testReadTMTAnalyzer.

@Test
public void testReadTMTAnalyzer() throws Exception {
    CTDConfigurationReader reader = new CTDConfigurationReader();
    assertNotNull(reader);
    INodeConfiguration config = reader.read(TestDataSource.class.getResourceAsStream("TMTAnalyzer.ctd"));
    assertEquals("Quantitation", config.getCategory());
    assertEquals("1.11.0", config.getVersion());
    assertNotNull(config.getParameter("TMTAnalyzer.1.in"));
    assertTrue(config.getParameter("TMTAnalyzer.1.in") instanceof FileParameter);
    assertTrue(config.getParameter("TMTAnalyzer.1.algorithm.Extraction.channel_active") instanceof StringListParameter);
    StringListParameter slp = (StringListParameter) config.getParameter("TMTAnalyzer.1.algorithm.Extraction.channel_active");
    assertEquals(2, slp.getValue().size());
    assertEquals("126:liver", slp.getValue().get(0));
    assertEquals("131:lung", slp.getValue().get(1));
    assertTrue(config.getParameter("TMTAnalyzer.1.algorithm.Quantification.isotope_correction.tmt-6plex").isAdvanced());
    assertTrue(config.getParameter("TMTAnalyzer.1.algorithm.Quantification.isotope_correction.tmt-6plex").isOptional());
    assertFalse(config.getParameter("TMTAnalyzer.1.in").isAdvanced());
    assertFalse(config.getParameter("TMTAnalyzer.1.in").isOptional());
}
Also used : StringListParameter(com.genericworkflownodes.knime.parameter.StringListParameter) TestDataSource(com.genericworkflownodes.knime.test.data.TestDataSource) INodeConfiguration(com.genericworkflownodes.knime.config.INodeConfiguration) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) Test(org.junit.Test)

Example 2 with StringListParameter

use of com.genericworkflownodes.knime.parameter.StringListParameter in project GenericKnimeNodes by genericworkflownodes.

the class ParamHandler method handleStringList.

/**
 * Convert the current element into a {@link StringListParameter}.
 *
 * @param paramName
 *            The name of the Parameter
 * @param attributes
 *            Attributes of the Parameter.
 */
private void handleStringList(String paramName, Attributes attributes) {
    if (isPort(attributes)) {
        createPort(paramName, attributes, true);
    } else {
        m_currentParameter = new StringListParameter(paramName, new ArrayList<String>());
        String restrictions = attributes.getValue(ATTR_RESTRICTIONS);
        if (restrictions != null && !"".equals(restrictions.trim())) {
            ((StringListParameter) m_currentParameter).setRestrictions(Arrays.asList(restrictions.split(",")));
        }
    }
}
Also used : StringListParameter(com.genericworkflownodes.knime.parameter.StringListParameter) ArrayList(java.util.ArrayList)

Example 3 with StringListParameter

use of com.genericworkflownodes.knime.parameter.StringListParameter in project GenericKnimeNodes by genericworkflownodes.

the class CTDConfigurationReaderTest method testSeqAnCTD.

@Test
public void testSeqAnCTD() throws Exception {
    CTDConfigurationReader reader = new CTDConfigurationReader();
    assertNotNull(reader);
    INodeConfiguration config = reader.read(TestDataSource.class.getResourceAsStream("sam2matrix.ctd"));
    assertEquals("Metagenomics", config.getCategory());
    assertEquals("http://www.seqan.de", config.getDocUrl());
    // <ITEM name="out" value="" type="output-file"
    // description="Output file." supported_formats="*.tsv" required="true"
    // advanced="false" />
    FileParameter fp_out = (FileParameter) config.getParameter("sam2matrix.out");
    assertNotNull(fp_out);
    assertEquals("Output file.", fp_out.getDescription());
    assertEquals(1, fp_out.getPort().getMimeTypes().size());
    assertEquals("tsv", fp_out.getPort().getMimeTypes().get(0));
    assertFalse(fp_out.isOptional());
    assertFalse(fp_out.isAdvanced());
    // <ITEMLIST name="mapping" type="input-file"
    // description="File containing the mappings." supported_formats="*.sam"
    // required="true" advanced="false" >
    FileListParameter flp_mapping = (FileListParameter) config.getParameter("sam2matrix.mapping");
    assertNotNull(flp_mapping);
    assertEquals("File containing the mappings.", flp_mapping.getDescription());
    assertEquals(1, flp_mapping.getPort().getMimeTypes().size());
    assertEquals("sam", flp_mapping.getPort().getMimeTypes().get(0));
    assertFalse(flp_mapping.isOptional());
    assertFalse(flp_mapping.isAdvanced());
    // <ITEM name="reads" value="" type="input-file"
    // description="File containing the reads contained in the mapping file(s)."
    // supported_formats="*.fa,*.fasta,*.fq,*.fastq" required="true"
    // advanced="false" />
    FileParameter fp_reads = (FileParameter) config.getParameter("sam2matrix.reads");
    assertNotNull(fp_reads);
    assertEquals("File containing the reads contained in the mapping file(s).", fp_reads.getDescription());
    assertEquals(4, fp_reads.getPort().getMimeTypes().size());
    assertEquals("fa", fp_reads.getPort().getMimeTypes().get(0));
    assertEquals("fasta", fp_reads.getPort().getMimeTypes().get(1));
    assertEquals("fq", fp_reads.getPort().getMimeTypes().get(2));
    assertEquals("fastq", fp_reads.getPort().getMimeTypes().get(3));
    assertFalse(fp_reads.isOptional());
    assertFalse(fp_reads.isAdvanced());
    // <ITEMLIST name="reference" type="string"
    // description="Name of the file used as reference of the corresponding sam file. If not specified the names of the mapping files are taken"
    // required="false" advanced="false" >
    StringListParameter slp_reference = (StringListParameter) config.getParameter("sam2matrix.reference");
    assertNotNull(slp_reference);
    assertEquals("Name of the file used as reference of the corresponding sam file. If not specified the names of the mapping files are taken", slp_reference.getDescription());
    assertTrue(slp_reference.isOptional());
    assertFalse(slp_reference.isAdvanced());
    // the parameter following parameters were tagged with gkn-ignore and
    // hence should not be parsed
    assertNull(config.getParameter("sam2matrix.write-ctd-file-ext"));
    assertNull(config.getParameter("sam2matrix.out-file-ext"));
    assertNull(config.getParameter("sam2matrix.mapping-file-ext"));
    assertNull(config.getParameter("sam2matrix.reads-file-ext"));
}
Also used : FileListParameter(com.genericworkflownodes.knime.parameter.FileListParameter) StringListParameter(com.genericworkflownodes.knime.parameter.StringListParameter) TestDataSource(com.genericworkflownodes.knime.test.data.TestDataSource) INodeConfiguration(com.genericworkflownodes.knime.config.INodeConfiguration) FileParameter(com.genericworkflownodes.knime.parameter.FileParameter) Test(org.junit.Test)

Example 4 with StringListParameter

use of com.genericworkflownodes.knime.parameter.StringListParameter in project GenericKnimeNodes by genericworkflownodes.

the class ListCellEditor method getTableCellEditorComponent.

@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
    // store old value
    oldValue = value.toString();
    if (parameter instanceof StringListParameter) {
        StringListParameter slp = (StringListParameter) parameter;
        if (slp.getRestrictions() != null && slp.getRestrictions().length > 0) {
            choiceComboBox = new JComboBox(slp.getRestrictions());
            choiceComboBox.setSelectedItem(value);
            return choiceComboBox;
        } else {
            field = new JTextField(value.toString());
            return field;
        }
    } else {
        field = new JTextField(value.toString());
        return field;
    }
}
Also used : StringListParameter(com.genericworkflownodes.knime.parameter.StringListParameter) JComboBox(javax.swing.JComboBox) JTextField(javax.swing.JTextField)

Example 5 with StringListParameter

use of com.genericworkflownodes.knime.parameter.StringListParameter in project GenericKnimeNodes by genericworkflownodes.

the class ListEditorDialogModel method addValue.

public int addValue() {
    // choose reasonable value to insert
    String newValue = "";
    if (parameter instanceof DoubleListParameter) {
        DoubleListParameter dlp = (DoubleListParameter) parameter;
        if (dlp.getLowerBound() != Double.NEGATIVE_INFINITY || dlp.getUpperBound() != Double.POSITIVE_INFINITY) {
            newValue = (dlp.getLowerBound() != Double.NEGATIVE_INFINITY ? dlp.getLowerBound().toString() : dlp.getUpperBound().toString());
        } else {
            newValue = "0.0";
        }
    } else if (parameter instanceof IntegerListParameter) {
        IntegerListParameter ilp = (IntegerListParameter) parameter;
        if (ilp.getLowerBound() != Integer.MIN_VALUE || ilp.getUpperBound() != Integer.MAX_VALUE) {
            newValue = (ilp.getLowerBound() != Integer.MIN_VALUE ? ilp.getLowerBound().toString() : ilp.getUpperBound().toString());
        } else {
            newValue = "0";
        }
    } else if (parameter instanceof StringListParameter && ((StringListParameter) parameter).getRestrictions() != null) {
        String[] validValues = ((StringListParameter) parameter).getRestrictions();
        int i = 0;
        while ("".equals(newValue) && i < validValues.length) {
            newValue = validValues[i];
            ++i;
        }
    }
    values.add(newValue);
    fireTableRowsInserted(values.size(), values.size());
    return values.size() - 1;
}
Also used : StringListParameter(com.genericworkflownodes.knime.parameter.StringListParameter) IntegerListParameter(com.genericworkflownodes.knime.parameter.IntegerListParameter) DoubleListParameter(com.genericworkflownodes.knime.parameter.DoubleListParameter)

Aggregations

StringListParameter (com.genericworkflownodes.knime.parameter.StringListParameter)5 INodeConfiguration (com.genericworkflownodes.knime.config.INodeConfiguration)2 FileParameter (com.genericworkflownodes.knime.parameter.FileParameter)2 TestDataSource (com.genericworkflownodes.knime.test.data.TestDataSource)2 Test (org.junit.Test)2 DoubleListParameter (com.genericworkflownodes.knime.parameter.DoubleListParameter)1 FileListParameter (com.genericworkflownodes.knime.parameter.FileListParameter)1 IntegerListParameter (com.genericworkflownodes.knime.parameter.IntegerListParameter)1 ArrayList (java.util.ArrayList)1 JComboBox (javax.swing.JComboBox)1 JTextField (javax.swing.JTextField)1