def apply_directionality(tmodel,solution, inplace = True):
    """
    Takes a flux solution and transfers its reaction directionality as
    constraints for the cobra_model

    :param inplace:
    :param tmodel:
    :param solution:
    :return:
    """

    if inplace:
        _tmodel = tmodel
    else:
        _tmodel = tmodel.copy()

    for this_reaction in _tmodel.reactions:

        backward_use = _tmodel.backward_use_variable.get_by_id(this_reaction.id)
        forward_use = _tmodel.forward_use_variable.get_by_id(this_reaction.id)

        backward_use.variable.lb = round(solution.x_dict[backward_use.name])
        backward_use.variable.ub = round(solution.x_dict[backward_use.name])

        forward_use.variable.lb  = round(solution.x_dict[forward_use.name])
        forward_use.variable.ub  = round(solution.x_dict[forward_use.name])

    return _tmodel