Clean3D Java snippet

Hi,

I would like to build a node that will run the Clean3D function on a molecule that I feed into it. I have found some sample code at https://www.chemaxon.com/forum/ftopic8409.html which I have adapted and entered into the 'Method body' pane of a Java snippet node. In the code below, $Molecule$ is the name of the column in which the structure is specified. The code is:


Dreiding d = new Dreiding();
d.init($Molecule$);
GradientOptimization g = new GradientOptimization(d);
g.setGradientRMSLimit(1e-3);
g.run();
if (!g.isOptimizationConverged()) {
  throw new IllegalStateException("Optimization was not converged");
}
return d.getMoleculeWithLastUsedCoordinates();

 


The node won't compile though, because it cannot resolve the Dreiding and GradientOptimization data types.

How can I make these available to the Java snippet? I have tried adding knime-marvin.jar and jchemlib.jar to the list of additional libraries, to no avail.

Any help would be gratefully received.

Thanks in advance,

Chris

First of all you need to specify the complete class names including packages since there are not automatic imports. However, even then it won't work because you cannot return a molecule from the Java Snippet node. Only primitive data types are supported.

Hi thor,

Thanks for your reply. I had wondered whether returning the atomic coordinates as a string in e.g. MOL format, followed by a subsequent conversion into molecule format might work.

I think it might be easier to create a new KNIME node using the Eclipse IDE to do this job, rather than using a snippet. This would enable me to return the data in molecule format.

Many thanks,

Chris

Is there a reason not to use the Clean3D step from the Standardizer node ?