def read_samples_metadata(metadata_file, covarsToRead=[],
    interactionsToRead=[], condition_name='Condition'):
    """
      Filename -> ConditionMap
      ConditionMap :: {Filename: Condition}, [{Filename: Covar}], [{Filename: Interaction}]
      Condition :: String
      Covar :: String
      Interaction :: String
    """
    wigFiles = []
    conditionsByFile = {}
    covariatesByFileList = [{} for i in range(len(covarsToRead))]
    interactionsByFileList = [{} for i in range(len(interactionsToRead))]
    headersToRead = [condition_name.lower(), 'filename']
    orderingMetadata = {'condition': [], 'interaction': []}
    with open(metadata_file) as mfile:
        lines = mfile.readlines()
        headIndexes = [i for h in headersToRead for i, c in enumerate(lines
            [0].split()) if c.lower() == h.lower()]
        covarIndexes = [i for h in covarsToRead for i, c in enumerate(lines
            [0].split()) if c.lower() == h.lower()]
        interactionIndexes = [i for h in interactionsToRead for i, c in
            enumerate(lines[0].split()) if c.lower() == h.lower()]
        for line in lines[1:]:
            if line[0] == '#':
                continue
            vals = line.split()
            [condition, wfile] = vals[headIndexes[0]], vals[headIndexes[1]]
            conditionsByFile[wfile] = condition
            orderingMetadata['condition'].append(condition)
            for i, c in enumerate(covarsToRead):
                covariatesByFileList[i][wfile] = vals[covarIndexes[i]]
            for i, c in enumerate(interactionsToRead):
                interactionsByFileList[i][wfile] = vals[interactionIndexes[i]]
                orderingMetadata['interaction'].append(vals[
                    interactionIndexes[i]])
    return (conditionsByFile, covariatesByFileList, interactionsByFileList,
        orderingMetadata)
