def permute_bond(bond, cycle):
    """
    Permutes a bond indice if the bond indice is affected by the permutation cycle.

    Parameters
    ----------
    bond : list
        A list of length 2, a subscript of an interatom distance
    cycle : list
        A cycle-notation permutation operation.

    Returns
    -------
    bond : the permuted bond
    """
    count0 = 0
    count1 = 0
    # if the bond indice matches the cycle indice, set the bond indice equal to the next indice in the cycle
    # we count so we dont change a bond indice more than once.
    # If the cycle indice is at the end of the list, the bond indice should become the first element of the list since thats how cycles work.
    # theres probably a better way to have a list go back to the beginning
    for i, idx in enumerate(cycle):
        if (bond[0] == idx) and (count0 == 0):
            try:
                bond[0] = cycle[i+1]
            except:
                bond[0] = cycle[0]
            count0 += 1

        if (bond[1] == idx) and (count1 == 0):
            try:
                bond[1] = cycle[i+1]
            except:
                bond[1] = cycle[0]
            count1 += 1
    # sort if the permutation messed up the order. if you convert 1,2 to 2,1, for example    
    bond.sort()
    return bond