def domains_to_samples(domains, sample_column='contig_id', target_column=None):
    """
    Group Domain DataFrame into a list of DataFrames and list of output states based on given sample_id column
    :param domains: Domain DataFrame with multiple sequences (samples), each marked by a unique ID in the sample_column
    :param sample_column: Sample ID column name
    :param target_column: Column name to consider as output value. If provided, will return tuple of (list of DataFrames, list of states Series).
    :return: list of DataFrames or tuple (list of DataFrames, list of states)
    """
    samples = domains.groupby(sample_column)
    sample_ids = list(samples.groups.keys())
    samples = [samples.get_group(i) for i in sample_ids]
    if target_column:
        targets = [sample[target_column] for sample in samples]
        return samples, targets
    return samples