def intramolecular_constraints(constraint_charge, constraint_groups):
    """Extracts intramolecular constraints from user constraint input

    Parameters
    ----------
    constraint_charge : list
        list of lists of charges and atom indices list
        e.g. [[0, [1, 2]], [1, [3, 4]]]
        The sum of charges on 1 and 2 will equal 0
        The sum of charges on 3 and 4 will equal 1
    constraint_group : list
        list of lists of indices of atoms to have equal charge
        e.g. [[1, 2], [3, 4]]
        atoms 1 and 2 will have equal charge
        atoms 3 and 4 will have equal charge

    Returns
    -------
    constrained_charges : list
        list of fixed charges
    constrained_indices : list
        list of lists of indices of atoms in a constraint
        negative number before an index means
        the charge of that atom will be subtracted.

    Notes
    -----
    Atom indices starts with 1 not 0.
    Total charge constraint is added by default for the first molecule.

    """
    constrained_charges = []
    constrained_indices = []
    for i in constraint_charge:
        constrained_charges.append(i[0])
        group = []
        for k in i[1]:
            group.append(k)
        constrained_indices.append(group)

    for i in constraint_groups:
        for j in range(1, len(i)):
            group = []
            constrained_charges.append(0)
            group.append(-i[j-1])
            group.append(i[j])
            constrained_indices.append(group)

    return constrained_charges, constrained_indices