Hi Martin, > I use the following script to prepare small side chain fragment PDB > files of mutants in PyMOL: > http://pastebin.com/nDTZApHP > I use the PyMOL built-in mutagenesis wizard and the sculpting wizard to > locally optimize the side chains within the environment of the protein. > For large numbers of side chains, this starts to take a long amoutn of time. > Is it possible to parallelize the mutagenesis process? PyMOL is > non-responsive while executing the script. Can it be run in the > background of PyMOL?
This looks like an interesting problem, that if I had enough free time, I'd dig into. I don't so, let me at least offer a few comments. First, PyMOL can have more than one wizard at once: cmd.wizard("mutagenesis") w = cmd.get_wizard() cmd.wizard("mutagenesis") w2 = cmd.get_wizard() # Should print False print w1==w2 Next, if you can use the wizards via the "w" or "w2" handles then you could create a series of wizards like this, one for each CPU, that could operate on a certain residue in a safe multi-threaded way, maybe something like the following ad hoc scenario: (1) creating a function that takes as input a structure name, and residue target range, and a token (to get unique names) eg. def my_partial_mutate(str_name, sel, token): tmp_name = cmd.get_unused_name(token) cmd.create(tmp_name, str_name) # ... now run your mutation code on tmp_name cmd.save(unique_file_name, tmp_name) cmd.delete(tmp_name) (2) creating a pool of N threads where N=num_cpus that run the function from step 1 import multiprocessing ncpus = multiprocessing.cpu_count() (3) iteratively call the function from (1) using a thread from (2) where the function is passed a _new_ copy of the structure created with the "copy" or "create" commands. for x in range(get_mutation_list): while running_threads == ncpus: wait a sec t = Threading.thread(target=my_partial_mutate,args=(my_structure_name, x, tnum)) t.start() If you use separate wizards and objects I don't think you have to worry about locking -- you can just blow through the tasks being limited by CPUs. All this could be wrong as I haven't put too much time into it, but it might be a start. Check out the official Python docs for multithreaded programming. One last option is to divide the task into into N/M subtasks, where N=num residues to mutate and M=num CPUs, and run that script from the command line passing in residues ranges. This would require the least amount of effort, maximize CPU usage, and be thread-safe as you'd be running (N/M) separate processes. Good luck! Cheers, -- Jason -- Jason Vertrees, PhD PyMOL Product Manager Schrödinger, Inc. (e) jason.vertr...@schrodinger.com (o) +1 (603) 374-7120 ------------------------------------------------------------------------------ Don't let slow site performance ruin your business. Deploy New Relic APM Deploy New Relic app performance management and know exactly what is happening inside your Ruby, Python, PHP, Java, and .NET app Try New Relic at no cost today and get our sweet Data Nerd shirt too! http://p.sf.net/sfu/newrelic-dev2dev _______________________________________________ PyMOL-users mailing list (PyMOL-users@lists.sourceforge.net) Info Page: https://lists.sourceforge.net/lists/listinfo/pymol-users Archives: http://www.mail-archive.com/pymol-users@lists.sourceforge.net