Dear All,
I have tried to implement parallel job on mutate model optimization steps where I selected 457 atoms for optimization (I am doing this because of implement our own objective) and to do this I added the following lines in Mutate_Model.py:
from modeller.parallel import * j = job() j.append(local_slave()) j.append(local_slave()) j.append(local_slave()) j.append(local_slave()) j.queue_task(optimize(s,sched)) j.queue_task(refine(atmsel)) j.run_all_tasks()
I am not sure I am doing this in correct way but I am getting the following errors:
Running 4 tasks on 4 slaves /usr/bin/python2.7 /usr/lib/modeller9.14/bin/modslave.py -slave 172.16.35.74:48622:0:TPLDZNFC >& mutate_model.slave0 /usr/bin/python2.7 /usr/lib/modeller9.14/bin/modslave.py -slave 172.16.35.74:48622:1:INNJBKXG >& mutate_model.slave1 /usr/bin/python2.7 /usr/lib/modeller9.14/bin/modslave.py -slave 172.16.35.74:48622:2:XZYKJCXC >& mutate_model.slave2 /usr/bin/python2.7 /usr/lib/modeller9.14/bin/modslave.py -slave 172.16.35.74:48622:3:XJXTJMBR >& mutate_model.slave3 Traceback (most recent call last): File "/comptes/invite-u/PycharmProjects/untitled/3O26_050716_144858/R12H_A102C_F104A/mutate_model.py", line 104, in <module> j.run_all_tasks() File "/usr/lib/python2.7/dist-packages/modeller/parallel/job.py", line 156, in run_all_tasks for task in self._finish_all_tasks(): File "/usr/lib/python2.7/dist-packages/modeller/parallel/job.py", line 189, in _finish_all_tasks task = self._process_event(obj, s) File "/usr/lib/python2.7/dist-packages/modeller/parallel/job.py", line 201, in _process_event slave.run_task(self.tasks.pop(0)) File "/usr/lib/python2.7/dist-packages/modeller/parallel/slave.py", line 52, in run_task for transfer in task.input_files: AttributeError: 'NoneType' object has no attribute 'input_files' Identified slave <Slave on localhost>
My SCRIPT: ---------- import sys import os from modeller import * from modeller.optimizers import molecular_dynamics, conjugate_gradients from modeller.automodel import autosched from modeller.parallel import *
# Use 4 CPUs in a parallel job on this machine j = job() j.append(local_slave()) j.append(local_slave()) j.append(local_slave()) j.append(local_slave())
def optimize(atmsel, sched): for step in sched: step.optimize(atmsel, max_iterations=200, min_atom_shift=0.001) ########################################### j.queue_task(refine(atmsel)) ############################################## #refine.use_parallel_job(j) cg = conjugate_gradients() cg.optimize(atmsel, max_iterations=200, min_atom_shift=0.001)
def refine(atmsel): md = molecular_dynamics(cap_atom_shift=0.39, md_time_step=4.0, md_return='FINAL')
init_vel = True for (its, equil, temps) in ((200, 20, (150.0, 250.0, 400.0, 700.0, 1000.0)), (200, 600, (1000.0, 800.0, 600.0, 500.0, 400.0, 300.0))): for temp in temps: md.optimize(atmsel, init_velocities=init_vel, temperature=temp, max_iterations=its, equilibrate=equil) init_vel = False
def make_restraints(mdl1, aln): rsr = mdl1.restraints rsr.clear() s = selection(mdl1) for typ in ('stereo', 'phi-psi_binormal'): rsr.make(s, restraint_type=typ, aln=aln, spline_on_site=True) for typ in ('omega', 'chi1', 'chi2', 'chi3', 'chi4'): rsr.make(s, restraint_type=typ+'_dihedral', spline_range=4.0, spline_dx=0.3, spline_min_points = 5, aln=aln, spline_on_site=True)
log.verbose() env = environ(rand_seed=int(-4000)) env.io.hetatm = True env.edat.dynamic_sphere=False env.edat.dynamic_lennard=True env.edat.contact_shell = 4.0 env.edat.update_dynamic = 0.39
env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')
mdl1 = model(env, file = "3O26") ali = alignment(env) ali.append_model(mdl1, atom_files= "3O26.pdb", align_codes= "3O26") s1=selection(mdl1.chains['A'].residues['104']) s1.mutate(residue_type='ALA') s2=selection(mdl1.chains['A'].residues['102']) s2.mutate(residue_type='CYS') s3=selection(mdl1.chains['A'].residues['12']) s3.mutate(residue_type='HIS') ali.append_model(mdl1, align_codes="3O26") mdl1.clear_topology() mdl1.generate_topology(ali[-1])
mdl1.transfer_xyz(ali)
mdl1.build(initialize_xyz=False, build_method='INTERNAL_COORDINATES')
mdl2 = model(env, file="3O26.pdb")
mdl1.res_num_from(mdl2,ali)
mdl1.write(file="3O26"+'ALA'+'104'+'CYS'+'102'+'HIS'+'12'+"A"+'.tmp') mdl1.read(file="3O26"+'ALA'+'104'+'CYS'+'102'+'HIS'+'12'+"A"+'.tmp')
make_restraints(mdl1, ali) mdl1.env.edat.nonbonded_sel_atoms=1 sched = autosched.loop.make_for_model(mdl1)
s = selection(mdl1.atoms['CA:'+'104'+':'+'A'].select_sphere(10),mdl1.atoms['CA:'+'102'+':'+'A'].select_sphere(10),mdl1.atoms['CA:'+'12'+':'+'A'].select_sphere(10)).by_residue()
mdl1.restraints.unpick_all() mdl1.restraints.pick(s)
s.energy()
s.randomize_xyz(deviation=100)
mdl1.env.edat.nonbonded_sel_atoms=2 ####################################### j.queue_task(optimize(s,sched)) #######################################
mdl1.env.edat.nonbonded_sel_atoms=1
######################################### j.queue_task(optimize(s,sched)) ######################################### s.energy()
####################################### j.run_all_tasks() ####################################""
atmsel = selection(mdl1.chains["A"]) score = atmsel.assess_dope() mdl1.write(file="/comptes/invite-u/PycharmProjects/untitled/3O26_050716_144858/R12H_A102C_F104A/R12H_A102C_F104A.MM9999.pdb") os.remove("3O26"+'ALA'+'104'+'CYS'+'102'+'HIS'+'12'+"A"+'.tmp')
Kindly correct me If I am wrong and let me know that how to do this in correct way.
Thanking you in advance