Example #1
0
def fix_chirality(merge, merge_temp, merged_coords, residue_type):
#### fixes chiral groups
    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':
                atom_move = get_atom_move(merge_temp, resname, residue, chiral_group, chiral_atoms)

                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) 
    merge+=merge_temp
    merged_coords+=coord
    return merge, merged_coords
Example #2
0
def fix_chirality(merge, merge_temp, merged_coords):
    #### fixes chiral groups
    chiral_atoms, coord = fetch_chiral_coord(merge_temp)

    for residue in chiral_atoms:
        for atom in chiral_atoms[residue]:
            resname = merge_temp[chiral_atoms[residue][atom]]['residue_name']
            break
        for chiral_group in f_loc.chiral[resname]:
            if chiral_group != 'atoms':
                stat = merge_temp[chiral_atoms[residue][chiral_group]]
                move = merge_temp[chiral_atoms[residue][f_loc.chiral[resname]
                                                        [chiral_group]['m']]]
                c1 = merge_temp[chiral_atoms[residue][f_loc.chiral[resname]
                                                      [chiral_group]['c1']]]
                c2 = merge_temp[chiral_atoms[residue][f_loc.chiral[resname]
                                                      [chiral_group]['c2']]]
                c3 = merge_temp[chiral_atoms[residue][f_loc.chiral[resname]
                                                      [chiral_group]['c3']]]

                stat_coord = np.array([stat['x'], stat['y'], stat['z']])
                move_coord = np.array([move['x'], move['y'], move['z']])

                S_M = move_coord - stat_coord
                rotation = align_to_vector(S_M, [0, 0, 1])
                center = stat_coord

                c1_coord = (np.array([c1['x'], c1['y'], c1['z']]) -
                            center).dot(rotation)
                c2_coord = (np.array([c2['x'], c2['y'], c2['z']]) -
                            center).dot(rotation)
                c3_coord = (np.array([c3['x'], c3['y'], c3['z']]) -
                            center).dot(rotation)

                C1_C2_a = gen.angle_clockwise(c1_coord[0:2], c2_coord[0:2])
                C1_C3_a = gen.angle_clockwise(c1_coord[0:2], c3_coord[0:2])
                if C1_C2_a > C1_C3_a:
                    for ax_val, axis in enumerate(['x', 'y', 'z']):
                        merge_temp[chiral_atoms[residue][
                            f_loc.chiral[resname][chiral_group]
                            ['m']]][axis] = merge_temp[chiral_atoms[residue][
                                f_loc.chiral[resname][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][f_loc.chiral[resname][
                        chiral_group]['m']]] = move_coord - (3 * S_M)
                    coord[chiral_atoms[residue]
                          [chiral_group]] = stat_coord - (1.5 * S_M)
    merge += merge_temp
    merged_coords += coord

    return merge, merged_coords
Example #3
0
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