Dear Quentin, On Tue, Apr 2, 2013 at 4:48 PM, Quentin Delettre <quentin.delet...@gmail.com> wrote: > Hi, > > I wanted to know if it was possible to do the same thing as in the cookbook > (1) but for conformer optimization : optimize each conformer generated but > in parallel.
Yep, it is. > I want to optimize conformer generation for one molecule, because it will be > a one molecule job script on a webserver. > > I tried with that (part of ) code : There are two logic problems in this code. See below. > > def optimize(mol, id): > AllChem.UFFOptimizeMolecule(mol, confId=id) > > def main (): > > global options, args > > max_workers=4 > > input_file = args.input > sdf_output_file = args.output > > n = args.nbconf > > writer = Chem.SDWriter(sdf_output_file) > > suppl = Chem.SDMolSupplier(input_file) > > for mol in suppl: > try: > mol = Chem.AddHs(mol) > ids = AllChem.EmbedMultipleConfs(mol, numConfs=n) > ids = list(ids) > # for id in ids: > # AllChem.UFFOptimizeMolecule(mol, confId=id) > except: > raise > > try: > with futures.ProcessPoolExecutor(max_workers=max_workers) as > executor: > # Submit a set of asynchronous jobs > jobs = [] > try: > for id in ids: > job = executor.submit(optimize, mol, id) > jobs.append(job) > except: > raise > > for job in futures.as_completed(jobs): > for id in ids: > writer.write(mol, confId=id) Here you are writing all conformations for each job. Since you've got 10 jobs and 10 conformers, you end up with 100 conformers in the output file. I'm not 100% comfortable with using the futures module, but you can probably do something like this instead: > writer.close() And this line closes the writer too early. You finish processing the first molecule and then you close the file. When you process the second molecule and it gets to this line, you will get an exception. You should change this to a writer.flush() call and then do the close() outside of your loop over the molecules in the input supplier. Make sense? -greg > except: > raise > > But with nbconf = 10, it generate 100 conformers. So i suspect something > wrong with the optimization function and the job management. > > > (1) http://www.rdkit.org/docs/Cookbook.html#parallel-conformation-generation > > Thank you. > > ------------------------------------------------------------------------------ > Own the Future-Intel(R) Level Up Game Demo Contest 2013 > Rise to greatness in Intel's independent game demo contest. Compete > for recognition, cash, and the chance to get your game on Steam. > $5K grand prize plus 10 genre and skill prizes. Submit your demo > by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2 > _______________________________________________ > Rdkit-discuss mailing list > Rdkit-discuss@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/rdkit-discuss > ------------------------------------------------------------------------------ Minimize network downtime and maximize team effectiveness. Reduce network management and security costs.Learn how to hire the most talented Cisco Certified professionals. Visit the Employer Resources Portal http://www.cisco.com/web/learning/employer_resources/index.html _______________________________________________ Rdkit-discuss mailing list Rdkit-discuss@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/rdkit-discuss