def obtain_dihedral_angles(system_coords, bond_distance):
    ref_selection = system_coords[0]
    
    # Process bonds for reference frame (first)
    bonds = []
    sq_bond_distance = bond_distance**2
    for i in range(len(ref_selection)-1):
        for j in range(i+1, len(ref_selection)):
            if mathTools.sq_distance(ref_selection[i], ref_selection[j]) <= sq_bond_distance:
                bonds.append(tuple(sorted([i, j])))
                
    print "DBG: Found %d bonds"%(len(bonds))
    
    # Find angles
    angles = []
    for i in range(len(bonds)-1):
        for j in range(i+1, len(bonds)):
            if bonds_are_linked(bonds[i], bonds[j]):
                angles.append(tuple(sorted([bonds[i], bonds[j]])))
    print "DBG: Found %d angles"%(len(angles))
    
    # Finally, find dihedrals
    dihedrals = []
    for i in range(len(angles)-1):
        for j in range(i+1, len(angles)):
            if angles_share_bond(angles[i], angles[j]):
                dihedrals.append(tuple(sorted([angles[i], angles[j]])))
    print "DBG: Found %d dihedrals"%(len(dihedrals))

    # Now reorganize atoms in dihedrals so that 
    # they are consecutive and we can calculate the
    # actual dihedral angle
    r_dihedrals = []
    for dihedral in dihedrals:
        indices = get_dihedral_indices(dihedral)
        # Get permutation of minimum distance
        distances = []
        for perm in itertools.permutations(indices):
            #print dihedral, perm
            distances.append(( mathTools.sq_distance(ref_selection[perm[0]],ref_selection[perm[1]])+
                               mathTools.sq_distance(ref_selection[perm[1]],ref_selection[perm[2]])+
                               mathTools.sq_distance(ref_selection[perm[2]],ref_selection[perm[3]]),
                              perm))
        # We will pick the one which summed distances is smaller 
        distances.sort()
        r_dihedrals.append(distances[0][1])
    
    all_angles = []
    for ref in system_coords:
        #Calculate the angles for a ref
        angles = [] 
        for dihedral_indexes in r_dihedrals:
            atom1 = ref[dihedral_indexes[0]]
            atom2 = ref[dihedral_indexes[1]]
            atom3 = ref[dihedral_indexes[2]]
            atom4 = ref[dihedral_indexes[3]]
            
            angles.append( mathTools.calc_dihedral(atom1, atom2,  atom3, atom4))
        all_angles.append(angles)
    return numpy.array(all_angles)
alert when an IAM Object has a policy allowing 'iam:XxxxxXxxx'.
dataset/ETHPy150Open victor-gil-sepulveda/pyProCT/pyproct/data/matrix/protein/cases/euclidean/dihedralsCase.py/obtain_dihedral_angles--crossover with--dataset/ETHPy150Open Netflix/security_monkey/security_monkey/auditors/iam/managed_policy.py/ManagedPolicyAuditor.check_iam_privileges