import random


def create_contig_and_fragments(contig, overlap_size, fragment_size):
    """
    Creates a contig and overlapping fragments

    :param str contig: original sequence to create test data from
    :param int overlap_size: number of bases fragments should overlap
    :param int fragment_size: length of bases

    note:: returned contig is probably going to be smaller than the input contig so that the
    last fragment isn't too short
    """
    assert overlap_size < fragment_size
    assert fragment_size < len(contig)
    step_size = fragment_size - overlap_size

    fragments = []
    i = 0
    while i + fragment_size <= len(contig):
        fragments.append(contig[i: i + fragment_size])
        i += step_size

    random.shuffle(fragments)
    return contig[:i - step_size + fragment_size], fragments