def spectrophores(dataset, overwrite=True): """ Compute the spectrophores for a dataset """ try: print '\tSpectrophores' specs = spec.spectrophores(pybel.readfile('sdf', dataset)) dataset_root, dataset_name = op.split(dataset) dataset_name = op.splitext(dataset_name)[0] #numpy.savetxt(op.join(dataset_root, dataset_name + '-ob-spectrophores.csv'), #specs, fmt='%s %.6f', delimiter=',') destfile = op.join(dataset_root, dataset_name + '-ob-spectrophores.csv') if op.exists(destfile) and overwrite==False: print '%s is already there and not overwriting requested' % destfile return else: if op.exists(destfile) and overwrite==True: print '%s is already there but overwriting requested' % destfile os.remove(destfile) f= open(destfile, 'a') for molecule in specs: f.write(molecule[0]) f.write(",") for i in range(1,49): f.write(str(molecule[i])) f.write(",") f.write("\n") f.close() print '\tSpectrophores computed succesfully' return destfile except Exception, e: print 'Damn, there has been a problem computing the spectrophores...' print 'Research into this...' print e.message
def spectrophores(dataset): """ Compute the spectrophores for a dataset """ try: print '\tSpectrophores' specs = ob.spectrophores(pybel.readfile('sdf', dataset)) dataset_root, dataset_name = op.split(dataset) dataset_name = op.splitext(dataset_name)[0] numpy.savetxt(op.join(dataset_root, dataset_name + '-ob-spectrophores.csv'), specs, fmt='%.6f', delimiter=',') print '\tSpectrophores computed succesfully' except Exception, e: print 'Damn, there has been a problem computing the pharmacophores...' print 'Research into this...' print e.message