CDK-R / cdkr

Integrating R and the CDK
https://cdk-r.github.io/cdkr/
42 stars 27 forks source link

Add CxSMILES functionality to rcdk #50

Closed schymane closed 6 years ago

schymane commented 7 years ago

https://cdk.github.io/cdk/2.0/docs/api/index.html?org/openscience/cdk/smiles/SmiFlavor.html

https://cdk.github.io/cdk/2.0/docs/api/org/openscience/cdk/smiles/SmilesGenerator.html

I'll be very happy to test it out :-)

rajarshi commented 7 years ago

Try the latest version in Github (v 3.4.3). Example usage is

library(rcdk)
m <- parse.smiles('C1C=CCC1N(C)c1ccccc1')[[1]]
get.smiles(m)
get.smiles(m, smiles.flavor(c('Generic','UseAromaticSymbols', 'CxSMILES'))

See the smiles.flavor for possible flavor values.

Do you have examples where you can test out the CxSmiles flavor?

schymane commented 7 years ago

I added one example in https://github.com/rajarshi/cdkr/pull/51 If I have CxSmiles input, it reinterprets and exports CxSmiles (see examples). If I start from a non-CxSmiles, this stays:

get.smiles(parse.smiles("c1ccccc1")[[1]]) [1] "C1=CC=CC=C1" get.smiles(parse.smiles("c1ccccc1")[[1]],flavor = smiles.flavors(c("CxSmiles"))) [1] "C1=CC=CC=C1"

Haven't yet figured out how to get the coords if I don't start with them, any ideas? I'll send more examples by mail; can take a closer look later.

rajarshi commented 7 years ago

If the molecule doesn't have coordinates, the CxSmiles flavor won't generate them when writing the SMILES. However, if coordinates are there, use the Cx2dCoordinates flavor.

library(rcdk)
m <- parse.smiles('CCC')[[1]]
m <- generate.2d.coordinates(m)
get.smiles(m, smiles.flavors(c('CxSmiles')))
get.smiles(m, smiles.flavors(c('Cx2Coordinates')))