Search in sources :

Example 1 with CTDConfigurationReader

use of com.genericworkflownodes.knime.config.reader.CTDConfigurationReader in project GenericKnimeNodes by genericworkflownodes.

the class CTDConfigurationWriterTest method testWrite.

@Test
public void testWrite() throws Exception {
    CTDConfigurationReader reader = new CTDConfigurationReader();
    INodeConfiguration config = reader.read(TestDataSource.class.getResourceAsStream("FileFilter.ctd"));
    // write to test file
    File tmp = File.createTempFile("testing_", ".ini");
    tmp.deleteOnExit();
    BufferedWriter buffered_file_writer = new BufferedWriter(new FileWriter(tmp));
    CTDConfigurationWriter file_writer = new CTDConfigurationWriter(buffered_file_writer);
    file_writer.write(config);
    config = reader.read(new FileInputStream(tmp));
    StringParameter mz = (StringParameter) config.getParameter("FileFilter.1.mz");
    assertEquals("m/z range to extract (applies to ALL ms levels!)", mz.getDescription());
    assertEquals(":", mz.getValue());
    assertEquals("mz", mz.getKey());
    IntegerListParameter levels = (IntegerListParameter) config.getParameter("FileFilter.1.peak_options.level");
    assertNotNull(levels);
    assertEquals("MS levels to extract", levels.getDescription());
    assertEquals(3, levels.getValue().size());
    assertEquals(1, levels.getValue().get(0).intValue());
    assertEquals(2, levels.getValue().get(1).intValue());
    assertEquals(3, levels.getValue().get(2).intValue());
    assertEquals(false, levels.isAdvanced());
    assertEquals(Integer.valueOf(1), levels.getLowerBound());
    StringChoiceParameter int_precision = (StringChoiceParameter) config.getParameter("FileFilter.1.peak_options.int_precision");
    assertEquals("32", int_precision.getValue());
    assertEquals(3, int_precision.getAllowedValues().size());
    BoolParameter no_progress = (BoolParameter) config.getParameter("FileFilter.1.no_progress");
    assertEquals(false, no_progress.getValue());
    assertEquals(true, no_progress.isAdvanced());
    // Three inputs, one required, one optional with default, one optional without default
    assertEquals(2, config.getInputPorts().size());
    assertEquals("FileFilter.1.in", config.getInputPorts().get(0).getName());
}
Also used : CTDConfigurationReader(com.genericworkflownodes.knime.config.reader.CTDConfigurationReader) StringParameter(com.genericworkflownodes.knime.parameter.StringParameter) TestDataSource(com.genericworkflownodes.knime.test.data.TestDataSource) FileWriter(java.io.FileWriter) INodeConfiguration(com.genericworkflownodes.knime.config.INodeConfiguration) StringChoiceParameter(com.genericworkflownodes.knime.parameter.StringChoiceParameter) IntegerListParameter(com.genericworkflownodes.knime.parameter.IntegerListParameter) BoolParameter(com.genericworkflownodes.knime.parameter.BoolParameter) File(java.io.File) FileInputStream(java.io.FileInputStream) BufferedWriter(java.io.BufferedWriter) Test(org.junit.Test)

Example 2 with CTDConfigurationReader

use of com.genericworkflownodes.knime.config.reader.CTDConfigurationReader in project GenericKnimeNodes by genericworkflownodes.

the class DynamicGenericNodeSetFactory method getCategoryPath.

@Override
public String getCategoryPath(String id) {
    String category;
    File f = getPluginConfig().getBinaryManager().resolveToolDescriptorPath(m_idToFile.get(id));
    try (InputStream cfgStream = new FileInputStream(f)) {
        category = new CTDConfigurationReader().read(cfgStream).getCategory();
    } catch (Exception e) {
        logger.error("Could not read node category from CTD, using '/' instead.", e);
        category = "";
    }
    return getCategoryPath() + "/" + category + "/" + getPluginConfig().getPluginVersion();
}
Also used : CTDConfigurationReader(com.genericworkflownodes.knime.config.reader.CTDConfigurationReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) File(java.io.File) FileInputStream(java.io.FileInputStream)

Example 3 with CTDConfigurationReader

use of com.genericworkflownodes.knime.config.reader.CTDConfigurationReader in project GenericKnimeNodes by genericworkflownodes.

the class GenericToolWrapperTest method testCTDLoading.

@Test
public void testCTDLoading() throws Exception {
    CTDConfigurationReader reader = new CTDConfigurationReader();
    INodeConfiguration config = reader.read(TestDataSource.class.getResourceAsStream("test5.ctd"));
    assertEquals(2, config.getCLI().getCLIElement().size());
    CLIElement firstCLIElement = config.getCLI().getCLIElement().get(0);
    assertEquals("-i", firstCLIElement.getOptionIdentifier());
    assertEquals(false, firstCLIElement.isList());
    assertEquals(false, firstCLIElement.isRequired());
    assertEquals(1, firstCLIElement.getMapping().size());
    assertEquals("blastall.i", firstCLIElement.getMapping().get(0).getReferenceName());
    CLIElement secondCLIElement = config.getCLI().getCLIElement().get(1);
    assertEquals("-d", secondCLIElement.getOptionIdentifier());
    assertEquals(false, secondCLIElement.isList());
    assertEquals(false, secondCLIElement.isRequired());
    assertEquals(1, secondCLIElement.getMapping().size());
    assertEquals("blastall.d", secondCLIElement.getMapping().get(0).getReferenceName());
}
Also used : CTDConfigurationReader(com.genericworkflownodes.knime.config.reader.CTDConfigurationReader) TestDataSource(com.genericworkflownodes.knime.test.data.TestDataSource) CLIElement(com.genericworkflownodes.knime.cliwrapper.CLIElement) INodeConfiguration(com.genericworkflownodes.knime.config.INodeConfiguration) Test(org.junit.Test)

Aggregations

CTDConfigurationReader (com.genericworkflownodes.knime.config.reader.CTDConfigurationReader)3 INodeConfiguration (com.genericworkflownodes.knime.config.INodeConfiguration)2 TestDataSource (com.genericworkflownodes.knime.test.data.TestDataSource)2 File (java.io.File)2 FileInputStream (java.io.FileInputStream)2 Test (org.junit.Test)2 CLIElement (com.genericworkflownodes.knime.cliwrapper.CLIElement)1 BoolParameter (com.genericworkflownodes.knime.parameter.BoolParameter)1 IntegerListParameter (com.genericworkflownodes.knime.parameter.IntegerListParameter)1 StringChoiceParameter (com.genericworkflownodes.knime.parameter.StringChoiceParameter)1 StringParameter (com.genericworkflownodes.knime.parameter.StringParameter)1 BufferedWriter (java.io.BufferedWriter)1 FileWriter (java.io.FileWriter)1 InputStream (java.io.InputStream)1