def checkBoundsByModel(solution, model):
    """ check if the flux distribution 'solution' violates any flux bounds
        defined for the reactions in the given model

    Returns:  lbViolations, ubViolations - {reaction : flux, bound} dicts
    """
    lbViolations, ubViolations = {}, {}
    for rea in solution:
        if rea not in model.reactionDict:
            continue
        rea_index = model.reactionDict[rea]
        flux = solution[rea]
        lb, ub = model.reactions[rea_index].lb, model.reactions[rea_index].ub
        if flux < lb:
            lbViolations[rea] = flux, lb
        elif flux > ub:
            ubViolations[rea] = flux, ub
    return lbViolations, ubViolations
