import logging


def createStrainsUsed(t0tot, minT0Strain, central_insert_bool_list):
    """ Create the variable strainsUsed - uses existing var if not None

    Args:
        t0tot: A Dataframe which contains datesetname: [sum1, sum2, 
                    ...] for datesetname in expsT0.keys(),
                e.g. A dataframe with timezeros datesetnames
                The number of rows in the data frame is equal
                to the number of rows in all_df
                Does not contain cols besides datesetnames
        minT0Strain: int, minimum mean value for total number of
                    barcodes read for a sample name.
        central_insert_bool_list: A pandas series of booleans the length 
                       of all_df which marks which strains have
                       insertions in the central 80% of a gene
        strainsUsed: either list of booleans or None
    Returns:
        strainsUsed: list of boolean the length of total number of strains in all_df
    Description:
        We make strainsUsed a list which contains True or False values for 
          each strain in all_df such that both the strain has an insertion
          centrally in a gene (meaning .1<f<.9) AND that the average number 
          of insertions over the t0 totals is greater than the integer minT0Strain.
    """


    # strainsUsed will be a list of booleans with length being
    # total number of strains.
    nAllStrains = len(central_insert_bool_list)
    logging.info(f"Getting updated 'strainsUsed' boolean list. Num rows to parse: {nAllStrains}")
    strainsUsed = []
    for i in range(nAllStrains):
        if central_insert_bool_list[i] and t0tot.iloc[i,:].mean() >= minT0Strain:
            strainsUsed.append(True)
        else:
            strainsUsed.append(False)

    logging.info(f"Total number of strains used: {strainsUsed.count(True)}")

    return strainsUsed