Skip to content

Instantly share code, notes, and snippets.

@egonw
Created December 14, 2009 10:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egonw/255955 to your computer and use it in GitHub Desktop.
Save egonw/255955 to your computer and use it in GitHub Desktop.
# 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