Skip to content

Instantly share code, notes, and snippets.

@olas
Created May 5, 2009 15:20
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 olas/107008 to your computer and use it in GitHub Desktop.
Save olas/107008 to your computer and use it in GitHub Desktop.
Iterate over SDFile, calculates properties, and stores in new SDF.
//***************************************************************
// Script that iterates over a file, calculates properties
// and stores all in a new SDFile. Requires Sample Data installed.
//
// Author: Ola Spjuth
//****************************************************************
it = cdk.createMoleculeIterator("/Sample Data/SDF/Fragments2.sdf");
list=cdk.createMoleculeList();
while (it.hasNext()){
mol=it.next();
i=inchi.generate(mol);
ikey=inchi.generateKey(mol);
fp=mol.getFingerprint(true);
//Store properties for the mol
cdk.setProperty(mol, "inchi", i)
cdk.setProperty(mol, "inchikey", ikey)
cdk.setProperty(mol, "cdk:fingerprint", fp)
list.add(mol);
}
cdk.saveSDFile("Virtual/Fragment2_with_props.sdf", list);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment