@staticmethod
def rejoinFluxes(solutionSplit, reactionsSplit, reactions):
    """ rejoin the fluxes in the given solution by applying reactionsSplit

        This assumes that solutionSplit has been obtained by performing FBA on
        the split matrix corresponding to reactionsSplit. This function combines
        the split fluxes by subtracting the negative component from the positive
        one.

        Keyword arguments:

        solutionSplit  -- vector of non-negative fluxes
        reactionsSplit -- dictionary { name : tuple of indexes } - indexes can
                          be None; if both are not None, the first is the pos.
                          and the second is the neg. component (v = v[0] - v[1])
                          (as computed by FbAnalyzer.splitFluxes)
        reactions      -- dictionary of all reactions { name : original matrix
                                                                        column }

        Returns:  joined flux vector (indexed like original matrix columns)
        """
    if len(solutionSplit) == 0:
        return solutionSplit
    solution = [0.0] * len(reactions)
    for rea in reactionsSplit:
        rea_index_orig = reactions[rea]
        indexPos, indexNeg = reactionsSplit[rea]
        if indexPos is not None:
            solution[rea_index_orig] += solutionSplit[indexPos]
        if indexNeg is not None:
            solution[rea_index_orig] -= solutionSplit[indexNeg]
    return solution
