Select branch according to input file extension

Hello,

I would like to find a way to push data across different branches of a workflow, depending on the type of the data.

I have a File Upload node which limits the type of files to SD or to ones containing SMILES strings by setting the Valid File Extensions to "sdf, smi".

How could I send data to either an SDF Reader or Line Reader node, depending on the extension?

I have tried a CASE Switch node and managed to select the output according to the file extension. However, I have not found a node that could feed it the "raw" file content without interpreting it. Ideally, I would like to pass the content of the file to it, without having it split by line or by SD block first.

I have also tried feeding the data directly to both an SDF Reader and a Line Reader node, trying to join the output via a Joiner node with an outer join. This will not work because the Line Reader does return a table, even when SD file content is fed to it (expected behaviour, I am not complaining).

Instead of a Joiner node, I have tried an End If node (also tried with an End CASE) but I get an error: "The structures of both active input data tables are not compatible".

There must be a simple way I have not thought of yet... Anyone wishing to point me in the right direction?

Cheers,

Fred

Hi Fred, great example! It's tricky but possible. The problem is that the Reader nodes need to be part of the CASE Start - End construct and need to be controlled by a variable that is switched on/off depending on the file extension. This CASE Start node need to have some "fake" data as well as a variable to switch on/off the different out-ports. This variable is generated by the Java Edit Variable node. Please see the attached example that does exactly, hopefully, what you want.

Hello Thomas,

Thanks a lot for taking the time to provide me with an example. This made me realise that the trick was to feed the CASE a fake table and, of course, as you mentioned, to integrate the readers within the CASE structure.

I am sending you my implementation of an SD/SMILES file reader so that you can post it here if you think it may help others.

Thanks again,

Fred

Thanks Fred for providing the example switching SD/SMILES reading depending on the file extension. I am uploading your workflow with this post.

Hello,

One minor edit: I have added a Column Rename in the SMILES branch of the meta node, so that the output table always has a 'Molecule' column.

Thank you for your help,

Fred