import random


def makeTarget(genomeSize, targetSize, numFeatures=1):
    """
    Make a target genome with total lengt of targetSize
    being a subset of genomeSize. Return a dictionary of
    start and end positions for each feature
    """
    target = {}
    featureSize = int (targetSize / numFeatures)
    while len(target) < numFeatures:
        start =  round(random.randint(0, genomeSize - featureSize))
        end = start + featureSize
        # Check if this feature overlaps with any other
        overlap = False
        for f in target:
            if start < f and end > target[f]:
                overlap = True
                break
        if not overlap:
            target[start] = end
    return target