Column Rename node doesn't convert chemical structures to String

#1

The Column Rename node doesn't convert molecules to String.  For example, I'm trying to convert a SMILES column (which has been previously cast as such in order to perform calculations on it) back to type String. 

I select this column in 'Column Rename', keep the name identical, and select the drop down to change SmilesValue to StringValue.  It appears to work, as the output table has the String icon for this column; but in reality, it is changed to "Non-Native [interface org.knime.core.data.StringValue, interface org.knime.chem.types.SmilesValue, interface org.knime.core.data.DataValue]" and thus String operations cannot be performed on it.  I've spent a lot of time struggling with this, to no avail.  It would be nice if this, or some other node could cast a molecular structure back to String, kind of like an inverse of the 'Molecule Type Cast'.

I need this column of type String because there is already another column that is a molecular structure type, and 'JChem Update' doesn't allow more than one structure column in a table that is to be uploaded to a MySQL database.  So my plan is to keep it as "String" in the database until I need to use it later (by casting it back to molecule).

I've attached a simplified workflow which exemplifies the problem.

0 Likes

#2

You have to use string replacer

hope this help you

0 Likes

#3

I hope that you found a solution for that, i face the same problem

0 Likes

#4

The simplest way is a Java Snippet as shown (in this case, for an incoming Mol column, but the same works for any of the other molecule types - sdf, SMILES, SMARTS, Mol2, pdb etc):

The one thing you do need to watch out for is if your molecule column is in an adapter cell holding multiple representations.

Steve

1 Like

#5

Hi there,

you can also use String Manipulation node with string() function to convert it successfully.

And avoid using Column Rename node for changing column types…

Br,
Ivan

0 Likes

#6

Thank you i used column rename and after string replacer and it works but those solusions are convenient

0 Likes