Vector along the Chain primitive (default is from N-terminus to C-terminus).

    Notes
    -----
    `start_index` and `end_index` can be changed to examine smaller
    sections of the Chain, or reversed to change the direction of
    the vector.

    Parameters
    ----------
    p : ampal.Polymer
        Reference `Polymer`.
    start_index : int, optional
        Default is 0 (start at the N-terminus of the Chain)
    end_index : int, optional
        Default is -1 (start at the C-terminus of the Chain)
    unit : bool
        If True, the vector returned has a magnitude of 1.

    Returns
    -------
    vector : a numpy.array
        vector has shape (1, 3)

def polypeptide_vector(p, start_index=0, end_index=-1, unit=True):
    """Vector along the Chain primitive (default is from N-terminus to C-terminus).

    Notes
    -----
    `start_index` and `end_index` can be changed to examine smaller
    sections of the Chain, or reversed to change the direction of
    the vector.

    Parameters
    ----------
    p : ampal.Polymer
        Reference `Polymer`.
    start_index : int, optional
        Default is 0 (start at the N-terminus of the Chain)
    end_index : int, optional
        Default is -1 (start at the C-terminus of the Chain)
    unit : bool
        If True, the vector returned has a magnitude of 1.

    Returns
    -------
    vector : a numpy.array
        vector has shape (1, 3)
    """
    if len(p) <= 1:
        raise ValueError(
            "Polymer should have length greater than 1. Polymer length = {0}".format(len(p)))
    try:
        prim_cas = p.primitive.coordinates
        direction_vector = prim_cas[end_index] - prim_cas[start_index]
    except ValueError:
        direction_vector = p[end_index]['CA'].array - \
            p[start_index]['CA'].array
    if unit:
        direction_vector = unit_vector(direction_vector)
    return direction_vector