#!/usr/bin/python import os, string, sys, time from openeye.oechem import * try: molfold = os.listdir(sys.argv[1]) molfold.sort() except IndexError: print '\Usage: a1_create_sdf_from_fold.py folder(unpacked from KEGG-website)\n' raise SystemExit() ifs = oemolistream() ifs.SetFormat(OEFormat_SDF) time_tup = time.gmtime() ofs = oemolostream() ofs.SetFormat(OEFormat_SDF) ofs.open('a1_'+sys.argv[1]+'_'+str(time_tup[1])+str(time_tup[0])+'.sdf') for file in molfold: ifs.open(sys.argv[1]+'/'+file) for mol in ifs.GetOEMols(): mol.SetTitle(file[:-4]) OEPerceiveChiral(mol) OEWriteMolecule(ofs, mol) ifs.close() ofs.close()