def check_ringed_lipids(protein): print('Checking for ringed lipids') if not os.path.exists(g_var.merged_directory + 'checked_ringed_lipid_de_novo.pdb'): if not os.path.exists(g_var.merged_directory + 'merged_cg2at_threaded.pdb'): box_vec = g_var.box_vec.split()[1:4] r_b_vec, r_b_inv = read_in.real_box_vectors(g_var.box_vec) os.chdir(g_var.merged_directory) merge, merge_coords = read_in_merged_pdbs([], [], protein) resid_prev = 0 ringed = False lipid_atoms = [] with open(g_var.merged_directory + 'threaded_lipids.dat', 'w') as ring_ouput: for at_val, atom in enumerate(merge): resname = get_np_resname(at_val) if resname != None: if atom['residue_id'] != resid_prev: if 'offset' in locals() and len( g_var.heavy_bond[resname]) > 0: if at_val - offset > int( len(g_var.np_blocks[resname_prev]) / g_var.system[resname_prev]): offset = at_val else: offset = at_val resid_prev = atom['residue_id'] resname_prev = resname if atom['atom_number'] - offset in g_var.heavy_bond[ resname]: for at_bond in g_var.heavy_bond[resname][ atom['atom_number'] - offset]: at_bond -= 1 if merge[at_bond + offset]['atom_number'] > merge[ at_val]['atom_number']: merge[at_bond + offset]['x'], merge[ at_bond + offset]['y'], merge[ at_bond + offset]['z'] = np.array( read_in.brute_mic( merge_coords[at_val], merge_coords[at_bond + offset], r_b_vec)) merge_coords[at_bond + offset] = merge[ at_bond + offset]['x'], merge[ at_bond + offset]['y'], merge[at_bond + offset]['z'] dist = gen.calculate_distance( merge_coords[at_val], merge_coords[at_bond + offset]) if 2 < dist < 6: lipid_atoms.append([ at_val, at_bond + offset, (np.array(merge_coords[at_val]) + np.array(merge_coords[at_bond + offset])) / 2 ]) ring_ouput.write( '{0:6}{1:6}{2:2}{3:4}{4:2}{5:7}{6:5}{7:5}{8:5}{9:5}{10:5}{11:5}\n' .format( 'distance: ', str(np.round(dist, 2)), 'residue: ', merge[at_val]['residue_name'], merge[at_val]['residue_id'], ' atom_1: ', merge[at_val]['atom_name'], 'atom_2: ', merge[at_bond + offset]['atom_name'], 'rough line num: ', at_val, at_bond + offset)) ringed = True if ringed or os.path.exists(g_var.merged_directory + 'merged_cg2at_threaded.pdb'): print('Found ' + str(len(lipid_atoms)) + ' abnormal bonds, now attempting to fix.') print('See this file for a complete list: ' + g_var.merged_directory + 'threaded_lipids.dat') fix_threaded_lipids(lipid_atoms, merge, merge_coords) else: gen.file_copy_and_check( g_var.merged_directory + 'MIN/merged_cg2at_de_novo_minimised.pdb', g_var.merged_directory + 'checked_ringed_lipid_de_novo.pdb')
#### collects initial structures into INPUT folder gro.collect_input() #### saves flags used into INPUT folder gen.flags_used() g_var.tc['i_t_e'] = time.time() #### reads in CG file and separates into residue types box_vec_initial = read_in.read_initial_cg_pdb() #### box size update if g_var.args.box != None: print('box cutting only works for cubic boxes currently') g_var.box_vec, box_shift = gen.new_box_vec(box_vec_initial, g_var.args.box) else: g_var.box_vec = box_vec_initial box_shift = np.array([0, 0, 0]) read_in.real_box_vectors(g_var.box_vec) #### pbc fix and residue truncation if required read_in.fix_pbc(box_vec_initial, g_var.box_vec, box_shift) #### checks if fragment database and input files match at_mod.sanity_check() ### convert protein to atomistic representation g_var.tc['r_i_t'] = time.time() if 'PROTEIN' in g_var.cg_residues: g_var.coord_atomistic = at_mod_p.build_multi_residue_atomistic_system( g_var.cg_residues, 'PROTEIN') ## converts protein to atomistic if not g_var.user_at_input and g_var.args.v >= 1: ## prints protein sequences print(gen.print_sequnce_info('PROTEIN')) ## reads in user chain, runs a sequence alignment and finds existing disulphide bonds g_var.tc['p_d_n_t'] = time.time() if g_var.user_at_input: for file_num, file_name in enumerate(g_var.args.a):
def fix_chirality(merge, merge_temp, merged_coords, residue_type): #### fixes chiral groups r_b_vec, r_b_inv = read_in.real_box_vectors(g_var.box_vec) chiral_atoms, coord = fetch_chiral_coord(merge_temp, residue_type) for residue in chiral_atoms: if residue_type in ['PROTEIN', 'OTHER']: for atom in chiral_atoms[residue]: resname = merge_temp[chiral_atoms[residue] [atom]]['residue_name'] break else: resname = residue_type for chiral_group in g_var.res_top[resname]['CHIRAL']: if chiral_group != 'atoms': stat = merge_temp[chiral_atoms[residue][chiral_group]].copy() atom_move = { 'stat': np.array([stat['x'], stat['y'], stat['z']]), 'm': '', 'c1': '', 'c2': '', 'c3': '' } for chir_atom in atom_move: if chir_atom != 'stat': test = merge_temp[chiral_atoms[residue] [g_var.res_top[resname]['CHIRAL'] [chiral_group][chir_atom]]].copy() atom_move[chir_atom] = np.array( [test['x'], test['y'], test['z']]) if gen.calculate_distance(atom_move['stat'], atom_move[chir_atom]) > 10: atom_move[chir_atom] = np.array( read_in.brute_mic(atom_move['stat'], atom_move[chir_atom], r_b_vec)) S_M = atom_move['m'] - atom_move['stat'] rotation = align_to_vector(S_M, [0, 0, 1]) c1_coord = (atom_move['c1'] - atom_move['stat']).dot(rotation) c2_coord = (atom_move['c2'] - atom_move['stat']).dot(rotation) c3_coord = (atom_move['c3'] - atom_move['stat']).dot(rotation) if gen.angle_clockwise(c1_coord[0:2], c2_coord[0:2]) > gen.angle_clockwise( c1_coord[0:2], c3_coord[0:2]): for ax_val, axis in enumerate(['x', 'y', 'z']): merge_temp[chiral_atoms[residue][ g_var.res_top[resname]['CHIRAL'][chiral_group] ['m']]][axis] = merge_temp[chiral_atoms[residue][ g_var.res_top[resname]['CHIRAL'][chiral_group] ['m']]][axis] - (3 * S_M[ax_val]) merge_temp[chiral_atoms[residue] [chiral_group]][axis] = merge_temp[ chiral_atoms[residue] [chiral_group]][axis] - (S_M[ax_val]) coord[chiral_atoms[residue] [g_var.res_top[resname]['CHIRAL'][chiral_group] ['m']]] -= (2 * S_M) #move_coord - coord[chiral_atoms[residue][chiral_group]] -= ( 0.25 * S_M) #stat_coord - merge += merge_temp merged_coords += coord return merge, merged_coords