def closestMedioidI(active_site, medioids, distD):
    """
    returns the index of the closest medioid in medioids to active_site

    input: active_site, an ActiveSite instance
           medioids, a list of ActiveSite instances
           distD, a dictionary of distances
    output: the index of the ActiveSite closest to active_site in medioids
    """
    closest = (float('Inf'), None)
    for i, medioid in enumerate(medioids):
        thisDist = distD[frozenset([active_site, medioid])]
        if thisDist < closest[0]:
            closest = (thisDist, i)
    return closest[1]