def groupms_byiconf(microstates, iconfs):
    """
    This function takes in a list of microstates and a list of conformer indicies, divide microstates into two groups:
    the first one is those contain one of the given conformers, the second one is those contain none of the listed conformers.
    """
    ingroup = []
    outgroup = []
    for ms in microstates:
        contain = False
        for ic in iconfs:
            if ic in ms.state:
                ingroup.append(ms)
                contain = True
                break
        if not contain:
            outgroup.append(ms)

    return ingroup, outgroup