def read_weights_file(weights_file):
    """

    Given a tab separated file with leaf names for a phylogenetic tree in column one and multipliers for that leaf's
    branch length in column two, will create a dictionary with leaf names as keys and multipliers as values

    :param weights_file: Path to a tab-separated text file described above.
    :return: dictionary with leaf names as keys and multipliers as values
    """
    weights = dict()
    with open(weights_file) as f:
        for line in f:
            stripped_line = line.rstrip()
            x = stripped_line.split('\t')
            if len(x) != 2 and stripped_line != '':
                raise RuntimeError('One of the lines in your weights file ({}) is not formatted correctly. '
                                   'Correct format is leafname\tweight, tab-separated. '
                                   'Offending line was: {}'.format(weights_file, stripped_line))
            elif len(x) == 2:
                try:
                    weight = float(x[1])
                except ValueError:
                    raise ValueError('The second column in your weights file ({}) must be a number. Please fix the '
                                     'following line: {}'.format(weights_file, stripped_line))
                weights[x[0]] = weight

    return weights