Created
December 14, 2009 10:13
-
-
Save egonw/255955 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# process.groovy | |
# tested with CDK 1.2.3 | |
import org.openscience.cdk.interfaces.*; | |
import org.openscience.cdk.io.*; | |
import org.openscience.cdk.io.iterator.*; | |
import org.openscience.cdk.*; | |
import org.openscience.cdk.tools.manipulator.*; | |
iterator = new IteratingMDLReader( | |
new File("ChEBI_complete.sdf").newReader(), | |
DefaultChemObjectBuilder.getInstance() | |
) | |
i = 0 | |
iterator.each { mol -> | |
i++ | |
cml = new StringWriter(); | |
cmlWriter = new CMLWriter(cml); | |
try { | |
cmlWriter.write(mol); | |
cmlStr = cml.toString(); | |
} catch (Exception exception) { | |
println "\nFailed to convert to CML: " + mol.getProperty("ChEBI ID"); | |
} | |
if (i == 50) { | |
print "."; | |
i = 0 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment