Skip to content

Instantly share code, notes, and snippets.

@egonw
Created March 1, 2009 18:44
Show Gist options
  • Select an option

  • Save egonw/72430 to your computer and use it in GitHub Desktop.

Select an option

Save egonw/72430 to your computer and use it in GitHub Desktop.
var ons = rdf.createStore()
rdf.importURL(ons,
"http://github.com/egonw/onssolubility/raw/master/ons.solubility.rdf/ons.rdf")
var results = rdf.sparql(ons, "PREFIX ons: <http://spreadsheet.google.com/plwwufp30hfq0udnEmRD1aQ/onto#> " +
"PREFIX chemblog: <http://blueobelisk.sourceforge.net/chemistryblogs/>" +
"PREFIX dc: <http://purl.org/dc/elements/1.1/> " +
"SELECT DISTINCT ?title ?smiles WHERE { " +
" ?solvent dc:title ?title . " +
" ?solvent chemblog:smiles ?smiles ." +
"}"
)
mols = cdk.createMoleculeList()
for (i=0; i<results.size(); i++) {
var row = results.get(i);
var title = row.get(0);
var smiles = row.get(1);
mol = cdk.fromSMILES(smiles);
mol = cdk.generate2dCoordinates(mol)
mol.getAtomContainer().setProperty("title", title);
mols.add(mol)
}
cdk.saveSDFile("/Virtual/test.sdf", mols)
ui.open("/Virtual/test.sdf")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment