Ok, I modified my script as in the example.
---- (script)
from modeller import * from modeller.automodel import * from modeller.scripts import complete_pdb from modeller.parallel import *
j = job() j.append(local_slave()) j.append(local_slave())
log.verbose()
class mymodel(allhmodel): def special_restraints(self, aln): s1 = selection(self.chains['A']) s2 = selection(self.chains['B']) self.restraints.symmetry.append(symmetry(s1, s2, 1.0)) def user_after_single_model(self): self.restraints.symmetry.report(1.0)
env = environ()
env.io_atom_files_directory = './'
a = mymodel(env, alnfile = 'HpUreE.ali', knowns = 'dimerBp', sequence = 'HpUreE', assess_methods=(assess.DOPE, assess.GA341))
a.starting_model = 1 a.ending_model = 25
a.use_parallel_job(j) a.make()
# Output data ok_models = filter(lambda x: x['failure'] is None, a.outputs) key = 'DOPE score' ok_models.sort(lambda a,b: cmp(a[key], b[key])) m = ok_models[0] print "Top model: %s (DOPE score %.3f)" % (m['name'], m[key])
env.libs.topology.read(file='$(LIB)/top_heav.lib') env.libs.parameters.read(file='$(LIB)/par.lib')
# read model file mdl = complete_pdb(env, m['name'])
# Assess with DOPE: s = selection(mdl) s.assess_dope(output='ENERGY_PROFILE NO_REPORT', file='HpUreE.best.profile', normalize_profile=True, smoothing_window=15) ---- (end)
i obtained this error:
---- (log)
Traceback (most recent call last): File "HpUreE.py", line 40, in ? a.make() File "/work/programs/MODELLER/modlib/modeller/automodel/automodel.py", line 109, in make self.multiple_models(atmsel) File "/work/programs/MODELLER/modlib/modeller/automodel/automodel.py", line 213, in multiple_models self.parallel_multiple_models(atmsel) File "/work/programs/MODELLER/modlib/modeller/automodel/automodel.py", line 233, in parallel_multiple_models self.outputs.extend(job.run_all_tasks()) File "/work/programs/MODELLER/modlib/modeller/parallel/job.py", line 110, in run_all_tasks self.finish_next_task() File "/work/programs/MODELLER/modlib/modeller/parallel/job.py", line 127, in finish_next_task self.process_event(obj, s) File "/work/programs/MODELLER/modlib/modeller/parallel/job.py", line 141, in process_event task = obj.task_results() File "/work/programs/MODELLER/modlib/modeller/parallel/slave.py", line 54, in task_results r = self.get_data(allow_heartbeat=True) File "/work/programs/MODELLER/modlib/modeller/parallel/communicator.py", line 81, in get_data (cmdtype, obj) = self._recv() File "/work/programs/MODELLER/modlib/modeller/parallel/communicator.py", line 119, in _recv raise RemoteError(obj.exc, self) modeller.parallel.communicator.RemoteError: AttributeError: 'module' object has no attribute 'mymodel' from <Slave on localhost>
---- (end)
in the .slave0 and .slave1 log file I have this error:
---- (log) Slave startup: connect to master at 127.0.1.1:59037:0:EABQEAKC Traceback (most recent call last): File "<string>", line 1, in ? File "/work/programs/MODELLER/modlib/modeller/parallel/slaveloop.py", line 63, in slaveloop handle_slave_io(master, slavedict) File "/work/programs/MODELLER/modlib/modeller/parallel/slaveloop.py", line 38, in handle_slave_io exec(cmdstr, slavedict) File "<string>", line 1, in ? File "/work/programs/MODELLER/modlib/modeller/parallel/communicator.py", line 81, in get_data (cmdtype, obj) = self._recv() File "/work/programs/MODELLER/modlib/modeller/parallel/communicator.py", line 117, in _recv (obj, self.buffer) = cmdtype.recv(self.buffer) File "/work/programs/MODELLER/modlib/modeller/parallel/data_types.py", line 71, in recv return (pickle.loads(obj), buffer[1+p.get_position():]) File "/usr/local/lib/python2.3/pickle.py", line 1394, in loads return Unpickler(file).load() File "/usr/local/lib/python2.3/pickle.py", line 872, in load dispatch[key](self) File "/usr/local/lib/python2.3/pickle.py", line 1104, in load_global klass = self.find_class(module, name) File "/usr/local/lib/python2.3/pickle.py", line 1140, in find_class klass = getattr(mod, name) AttributeError: 'module' object has no attribute 'mymodel'
---- (end)
running Modeller in the normal way do not produce any error.
Thanks
Francesco
--- Francesco Musiani francesco.musiani@unibo.it ---
Francesco Musiani wrote: > Ok, I modified my script as in the example. ... > class mymodel(allhmodel): > def special_restraints(self, aln): > s1 = selection(self.chains['A']) > s2 = selection(self.chains['B']) > self.restraints.symmetry.append(symmetry(s1, s2, 1.0)) > def user_after_single_model(self): > self.restraints.symmetry.report(1.0) ... > i obtained this error: ... > modeller.parallel.communicator.RemoteError: AttributeError: 'module' object has no attribute 'mymodel' from <Slave on localhost>
The parallel module uses Python's pickle module to send classes to slaves, so is subject to the same restrictions as regular pickle: see http://docs.python.org/lib/node317.html
In particular, this means that you can't define a subclass in your main script (because the slaves can't import it) - move your 'mymodel' class to a separate file, e.g. mymodel.py, and then import it into your main script ('from mymodel import mymodel').
See, for an example, examples/python/parallel-task.py
Ben Webb, Modeller Caretaker