def get_atom_move(merge_temp, resname, residue, chiral_group, chiral_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])) return atom_move
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'): os.chdir(g_var.merged_directory) merge, merge_coords = read_in_merged_pdbs([], [], protein) 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 in g_var.np_residues: offset = fetch_start_of_residue_np(at_val, 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])) 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')
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