def rotate_single_mab(single_molecule, trial_molecule, groups, group_masks, number_of_groups, residues_in_groups, rotation_variables, dihedral_parameters, flexible_residues, residue_rotation_indices, residue_rotation_mask, step_parameters, first_last_resid, cutoff): frame = 0 seed = [1, 2] # if you want a set SEED seed = [0, 8] if (seed[0] == 1): from numpy.random import RandomState seed_object = RandomState(seed[1]) else: seed_object = -1 nonbondflag = False backward = True rotate_type = 'protein_backbone_dihedral' molecule_type = rotation_variables[0] temperature = rotation_variables[1] basis = rotation_variables[2] number_of_ranges = rotation_variables[3] reslow = rotation_variables[4] numcont = rotation_variables[5] dtheta = rotation_variables[6] kb = 1.380658E-23 # J/K beta = 1.0 / (temperature * kb) pairdat = ['dum', 1, 1.0] check = 1 all_atoms_basis = 'resid[i] < 100' error, all_atoms_mask = single_molecule.get_subset_mask(all_atoms_basis) check_error(error) while (check == 1): print ':', sys.stdout.flush() coor = single_molecule.coor() vdi, vdf, indices, this_mask = step_parameters.chooser( coor, trial_molecule, pairdat, dtheta, number_of_ranges, reslow, numcont, dihedral_parameters, beta, residue_rotation_indices, residue_rotation_mask, nonbondflag, first_last_resid, molecule_type, seed_object) angle = pairdat[0] residue_to_rotate = pairdat[1] theta = pairdat[2] # HARDWIRED if (residue_to_rotate < 7): this_group = groups[0] this_mask = group_masks[0] group_to_rotate = 0 else: this_group = groups[1] this_mask = group_masks[1] group_to_rotate = 1 group_rotation.rotate_a_group(this_group, rotate_type, residue_to_rotate, angle, theta, backward) check = check_ball_overlap(trial_molecule, this_group, group_to_rotate, cutoff) if (check == 1): trial_molecule.set_coor_using_mask(single_molecule, frame, all_atoms_mask) error = single_molecule.copy_molecule_using_mask( this_group, this_mask, frame) if (check == 0): trial_molecule.set_coor_using_mask(this_group, frame, this_mask) error = single_molecule.copy_molecule_using_mask( this_group, this_mask, frame) return
def rotate_single_mab(single_molecule, trial_molecule, groups, group_masks, number_of_groups, residues_in_groups, rotation_variables, dihedral_parameters, flexible_residues, residue_rotation_indices, residue_rotation_mask, step_parameters, first_last_resid, cutoff): frame = 0 seed = [1, 2] # if you want a set SEED seed = [0, 8] if(seed[0] == 1): from numpy.random import RandomState seed_object = RandomState(seed[1]) else: seed_object = -1 nonbondflag = False backward = True rotate_type = 'protein_backbone_dihedral' molecule_type = rotation_variables[0] temperature = rotation_variables[1] basis = rotation_variables[2] number_of_ranges = rotation_variables[3] reslow = rotation_variables[4] numcont = rotation_variables[5] dtheta = rotation_variables[6] kb = 1.380658E-23 # J/K beta = 1.0 / (temperature * kb) pairdat = ['dum', 1, 1.0] check = 1 all_atoms_basis = 'resid[i] < 100' error, all_atoms_mask = single_molecule.get_subset_mask(all_atoms_basis) check_error(error) while(check == 1): print ':', sys.stdout.flush() coor = single_molecule.coor() vdi, vdf, indices, this_mask = step_parameters.chooser(coor, trial_molecule, pairdat, dtheta, number_of_ranges, reslow, numcont, dihedral_parameters, beta, residue_rotation_indices, residue_rotation_mask, nonbondflag, first_last_resid, molecule_type, seed_object) angle = pairdat[0] residue_to_rotate = pairdat[1] theta = pairdat[2] # HARDWIRED if(residue_to_rotate < 7): this_group = groups[0] this_mask = group_masks[0] group_to_rotate = 0 else: this_group = groups[1] this_mask = group_masks[1] group_to_rotate = 1 group_rotation.rotate_a_group( this_group, rotate_type, residue_to_rotate, angle, theta, backward) check = check_ball_overlap( trial_molecule, this_group, group_to_rotate, cutoff) if(check == 1): trial_molecule.set_coor_using_mask( single_molecule, frame, all_atoms_mask) error = single_molecule.copy_molecule_using_mask( this_group, this_mask, frame) if(check == 0): trial_molecule.set_coor_using_mask(this_group, frame, this_mask) error = single_molecule.copy_molecule_using_mask( this_group, this_mask, frame) return
def simulate_single_mab(single_molecule, number_of_steps, groups, group_masks, number_of_groups, residues_in_groups, rotation_variables, dihedral_parameters, flexible_residues, residue_rotation_indices, residue_rotation_mask, step_parameters, first_last_resid, cutoff): frame = 0 seed = [1, 2] seed = [0, 2] if (seed[0] == 1): from numpy.random import RandomState seed_object = RandomState(seed[1]) else: seed_object = -1 nonbondflag = False backward = True rotate_type = 'protein_backbone_dihedral' molecule_type = rotation_variables[0] temperature = rotation_variables[1] basis = rotation_variables[2] number_of_ranges = rotation_variables[3] reslow = rotation_variables[4] numcont = rotation_variables[5] dtheta = rotation_variables[6] kb = 1.380658E-23 # J/K beta = 1.0 / (temperature * kb) pairdat = ['dum', 1, 1.0] dcdoutfile = single_molecule.open_dcd_write('adum.dcd') coor = single_molecule.coor() taccepted = 0 nsteps = 0 count = 0 # debugging da_outfile = open('dangles.txt', 'w') # end debugging for i in xrange(number_of_steps): print '.', sys.stdout.flush() vdi, vdf, indices, this_mask = step_parameters.chooser( coor, single_molecule, pairdat, dtheta, number_of_ranges, reslow, numcont, dihedral_parameters, beta, residue_rotation_indices, residue_rotation_mask, nonbondflag, first_last_resid, molecule_type, seed_object) angle = pairdat[0] residue_to_rotate = pairdat[1] theta = pairdat[2] # debugging #angle = 'psi' #residue_to_rotate = 5 #theta = 5.0 * numpy.pi/180.0 # end debugging # HARDWIRED if (residue_to_rotate < 7): this_group = groups[0] this_mask = group_masks[0] group_to_rotate = 0 else: this_group = groups[1] this_mask = group_masks[1] group_to_rotate = 1 group_rotation.rotate_a_group(this_group, rotate_type, residue_to_rotate, angle, theta, backward) check = check_ball_overlap(single_molecule, this_group, group_to_rotate, cutoff) if (check == 0): # debugging if (angle == 'psi'): basis = '(resid[i] == ' + str( residue_to_rotate ) + ' and (name[i] == "N" or name[i] == "CA" or name[i] == "C")) or (resid[i] == ' + str( residue_to_rotate + 1) + ' and (name[i] == "C") )' error, mask = single_molecule.get_subset_mask(basis) check_error(error) error, temp_coor = single_molecule.get_coor_using_mask( frame, mask) check_error(error) lcoor = temp_coor[0] d_angle = sasmath.dihedral_angle(lcoor[0], lcoor[1], lcoor[2], lcoor[3]) print 'initial dihedral angle = ', d_angle da_outfile.write("%lf\n" % (d_angle)) da_outfile.flush() # end debugging single_molecule.set_coor_using_mask(this_group, frame, this_mask) # debugging if (angle == 'psi'): error, temp_coor = single_molecule.get_coor_using_mask( frame, mask) check_error(error) lcoor = temp_coor[0] d_angle = sasmath.dihedral_angle(lcoor[0], lcoor[1], lcoor[2], lcoor[3]) print 'final dihedral angle = ', d_angle port = 54321 flag = 0 single_molecule.send_coordinates_to_vmd(port, flag) # end debugging single_molecule.write_dcd_step(dcdoutfile, 0, taccepted + 1) taccepted += 1 else: # if(count == 10): # print '.', # dcdfile2 = dum_molecule.open_dcd_read('adum.dcd') # nf=dcdfile2[2] # my_frame = random.randint(0,nf) # for j in xrange(my_frame): # dum_molecule.read_dcd_step(dcdfile2,my_frame) # dum_coor = dum_molecule.coor()[0] # single_molecule.coor()[0] = dum_coor # count = 0 count += 1 nsteps += 1 return
def simulate_single_mab(single_molecule, number_of_steps, groups, group_masks, number_of_groups, residues_in_groups, rotation_variables, dihedral_parameters, flexible_residues, residue_rotation_indices, residue_rotation_mask, step_parameters, first_last_resid, cutoff): frame = 0 seed = [1, 2] seed = [0, 2] if(seed[0] == 1): from numpy.random import RandomState seed_object = RandomState(seed[1]) else: seed_object = -1 nonbondflag = False backward = True rotate_type = 'protein_backbone_dihedral' molecule_type = rotation_variables[0] temperature = rotation_variables[1] basis = rotation_variables[2] number_of_ranges = rotation_variables[3] reslow = rotation_variables[4] numcont = rotation_variables[5] dtheta = rotation_variables[6] kb = 1.380658E-23 # J/K beta = 1.0 / (temperature * kb) pairdat = ['dum', 1, 1.0] dcdoutfile = single_molecule.open_dcd_write('adum.dcd') coor = single_molecule.coor() taccepted = 0 nsteps = 0 count = 0 # debugging da_outfile = open('dangles.txt', 'w') # end debugging for i in xrange(number_of_steps): print '.', sys.stdout.flush() vdi, vdf, indices, this_mask = step_parameters.chooser(coor, single_molecule, pairdat, dtheta, number_of_ranges, reslow, numcont, dihedral_parameters, beta, residue_rotation_indices, residue_rotation_mask, nonbondflag, first_last_resid, molecule_type, seed_object) angle = pairdat[0] residue_to_rotate = pairdat[1] theta = pairdat[2] # debugging #angle = 'psi' #residue_to_rotate = 5 #theta = 5.0 * numpy.pi/180.0 # end debugging # HARDWIRED if(residue_to_rotate < 7): this_group = groups[0] this_mask = group_masks[0] group_to_rotate = 0 else: this_group = groups[1] this_mask = group_masks[1] group_to_rotate = 1 group_rotation.rotate_a_group( this_group, rotate_type, residue_to_rotate, angle, theta, backward) check = check_ball_overlap( single_molecule, this_group, group_to_rotate, cutoff) if(check == 0): # debugging if(angle == 'psi'): basis = '(resid[i] == ' + str(residue_to_rotate) + ' and (name[i] == "N" or name[i] == "CA" or name[i] == "C")) or (resid[i] == ' + str( residue_to_rotate + 1) + ' and (name[i] == "C") )' error, mask = single_molecule.get_subset_mask(basis) check_error(error) error, temp_coor = single_molecule.get_coor_using_mask( frame, mask) check_error(error) lcoor = temp_coor[0] d_angle = sasmath.dihedral_angle( lcoor[0], lcoor[1], lcoor[2], lcoor[3]) print 'initial dihedral angle = ', d_angle da_outfile.write("%lf\n" % (d_angle)) da_outfile.flush() # end debugging single_molecule.set_coor_using_mask(this_group, frame, this_mask) # debugging if(angle == 'psi'): error, temp_coor = single_molecule.get_coor_using_mask( frame, mask) check_error(error) lcoor = temp_coor[0] d_angle = sasmath.dihedral_angle( lcoor[0], lcoor[1], lcoor[2], lcoor[3]) print 'final dihedral angle = ', d_angle port = 54321 flag = 0 single_molecule.send_coordinates_to_vmd(port, flag) # end debugging single_molecule.write_dcd_step(dcdoutfile, 0, taccepted + 1) taccepted += 1 else: # if(count == 10): # print '.', # dcdfile2 = dum_molecule.open_dcd_read('adum.dcd') # nf=dcdfile2[2] # my_frame = random.randint(0,nf) # for j in xrange(my_frame): # dum_molecule.read_dcd_step(dcdfile2,my_frame) # dum_coor = dum_molecule.coor()[0] # single_molecule.coor()[0] = dum_coor # count = 0 count += 1 nsteps += 1 return