Dear Rafal,
that is fine :) Groovy can be tough sometimes. If you have a molecule already in the database, please see this button script for starters on how to read that particular molecule. You would be interested especially in those parts:
import
com.im.df.api.dml.*
import
com.im.df.api.*
import
com.im.df.api.support.SelectionDescription
import
com.im.ijc.core.api.util.IJCCoreUtils
import
chemaxon.struc.Molecule
import
chemaxon.formats.MolExporter
import
chemaxon.formats.MolImporter
import
com.im.df.api.chem.MarvinStructure
def
ety = dataTree.rootVertex.entity
// assumes you have reference to the data tree
def
edp = ety.schema.dataProvider.getEntityDataProvider(ety)
def
molFld = ety.fields.items.
find
{ it.name ==
'Structure'
}
// find the structure field
def
rs = ety.schema.dataProvider.getDefaultResultSet(dataTree, false, DFEnvironmentRO.DEV_NULL)
// find the ResultSet
def
rootVS = rs.getVertexState(dataTree.rootVertex)
// obtain the VertexState
List ids = rootVS.getSelectedRowsIds()
// get the selected IDs
Map rows = rootVS.getData(ids, DFEnvironmentRO.DEV_NULL)
// get the data
Map row = rows[ids[
0
]]
// get the first and only row
MarvinStructure mol = row[molFld.id]
// Get the Structure. Its a com.im.df.api.chem.MarvinStructure instance
Molecule cxnMol = mol.getNative()
// obtain the chemaxon.struc.Molecule instance
// convert chemaxon.struc.Molecule instance into canonical SMILES
molSmiles = cxnMol.toFormat(
"smiles:u"
)
As you can see, with the code above, you will access the molecule in the Structure field of the currently selected row, but that can be changed.
I hope this helps
Wishing all the best
David