bool CEFMMethod::initialize() { CEFMTask * pTask = dynamic_cast< CEFMTask * >(getObjectParent()); if (pTask == NULL) { CCopasiMessage(CCopasiMessage::ERROR, MCEFMAnalysis + 1); return false; } CEFMProblem * pProblem = dynamic_cast< CEFMProblem *>(pTask->getProblem()); if (pProblem == NULL) { CCopasiMessage(CCopasiMessage::ERROR, MCEFMAnalysis + 2); return false; } mpFluxModes = & pProblem->getFluxModes(); mpReorderedReactions = & pProblem->getReorderedReactions(); mpReorderedReactions->clear(); mpFluxModes->clear(); return true; }
bool CBitPatternTreeMethod::initialize() { if (!CEFMMethod::initialize()) { return false; } pdelete(mpStepMatrix); mReactionForward.clear(); mContinueCombination = true; CEFMTask * pTask = dynamic_cast< CEFMTask *>(getObjectParent()); if (pTask == NULL) return false; mpModel = pTask->getProblem()->getModel(); if (mpModel == NULL) return false; // We first build the kernel matrix CMatrix< C_INT64 > KernelMatrix; buildKernelMatrix(KernelMatrix); #ifdef COPASI_DEBUG DebugFile << "Original Kernel Matrix:" << std::endl; DebugFile << KernelMatrix << std::endl; #endif // COPASI_DEBUG mMinimumSetSize = KernelMatrix.numCols() - 2; #ifdef COPASI_DEBUG DebugFile << "MinSetSize = " << mMinimumSetSize << std::endl; #endif // COPASI_DEBUG // Now we create the initial step matrix mpStepMatrix = new CStepMatrix(KernelMatrix); mProgressCounter = 0; mProgressCounterMax = mpStepMatrix->getNumUnconvertedRows(); if (mpCallBack) mhProgressCounter = mpCallBack->addItem("Current Step", CCopasiParameter::UINT, & mProgressCounter, & mProgressCounterMax); return true; }
void CEFMProblem::printResult(std::ostream * ostream) const { CEFMTask * pTask = dynamic_cast< CEFMTask * >(getObjectParent()); if (pTask) { const std::vector< CFluxMode > & FluxModes = pTask->getFluxModes(); // List *ostream << "\tNumber of Modes:\t" << FluxModes.size() << std::endl; // Column header *ostream << "#\t\tReactions\tEquations" << std::endl; std::vector< CFluxMode >::const_iterator itMode = FluxModes.begin(); std::vector< CFluxMode >::const_iterator endMode = FluxModes.end(); unsigned C_INT32 j; for (j = 0; itMode != endMode; ++itMode, j++) { *ostream << j + 1; if (itMode->isReversible() == true) *ostream << "\tReversible"; else *ostream << "\tIrreversible"; std::string Description = pTask->getFluxModeDescription(*itMode); CFluxMode::const_iterator itReaction = itMode->begin(); CFluxMode::const_iterator endReaction = itMode->end(); std::string::size_type start = 0; std::string::size_type end = 0; for (; itReaction != endReaction; ++itReaction) { if (itReaction != itMode->begin()) *ostream << "\t"; end = Description.find("\n", start); *ostream << "\t" << Description.substr(start, end - start); start = end + 1; *ostream << "\t" << pTask->getReactionEquation(itReaction) << std::endl; } } *ostream << std::endl; // Net Reactions // Column header *ostream << "#\tNet Reaction\tInternal Species" << std::endl; itMode = FluxModes.begin(); for (j = 0; itMode != endMode; ++itMode, j++) { *ostream << j + 1; *ostream << "\t" << pTask->getNetReaction(*itMode); *ostream << "\t" << pTask->getInternalSpecies(*itMode) << std::endl; } *ostream << std::endl; // EFM vs Reaction std::vector< const CReaction * >::const_iterator itReaction = mReorderedReactions.begin(); std::vector< const CReaction * >::const_iterator endReaction = mReorderedReactions.end(); // Column header *ostream << "#"; for (; itReaction != endReaction; ++itReaction) { *ostream << "\t" << (*itReaction)->getObjectName(); } *ostream << std::endl; itMode = FluxModes.begin(); size_t k; for (j = 0; itMode != endMode; ++itMode, j++) { itReaction = mReorderedReactions.begin(); *ostream << j + 1; for (k = 0; itReaction != endReaction; ++itReaction, k++) { *ostream << "\t" << itMode->getMultiplier(k); } *ostream << std::endl; } *ostream << std::endl; if (mpModel == NULL) return; // EFM vs Species std::vector< CMetab * >::const_iterator itSpecies = mpModel->getMetabolites().begin(); std::vector< CMetab * >::const_iterator endSpecies = mpModel->getMetabolites().end(); // Column header *ostream << "#"; for (; itSpecies != endSpecies; ++itSpecies) { *ostream << "\t" << CMetabNameInterface::getDisplayName(mpModel, **itSpecies); } *ostream << std::endl; itMode = FluxModes.begin(); for (j = 0; itMode != endMode; ++itMode, j++) { itSpecies = mpModel->getMetabolites().begin(); *ostream << j + 1; for (; itSpecies != endSpecies; ++itSpecies) { std::pair< C_FLOAT64, C_FLOAT64 > Changes = pTask->getSpeciesChanges(*itMode, **itSpecies); *ostream << "\t"; if (Changes.first > 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon() || Changes.second > 100.0 * std::numeric_limits< C_FLOAT64 >::epsilon()) { *ostream << "-" << Changes.first << " | +" << Changes.second; } } *ostream << std::endl; } *ostream << std::endl; } }
bool CEFMAlgorithm::initialize() { if (!CEFMMethod::initialize()) { return false; } CEFMTask * pTask = dynamic_cast< CEFMTask *>(getObjectParent()); if (pTask == NULL) return false; mpModel = pTask->getProblem()->getModel(); if (mpModel == NULL) return false; mpFluxModes->clear(); /* ModelStoi is the transpose of the models stoichiometry matrix */ const CTransposeView< CMatrix< C_FLOAT64 > > ModelStoi(mpModel->getStoi()); size_t row, numRows = ModelStoi.numRows(); size_t col, numCols = ModelStoi.numCols(); /* Size the stoichiometry matrix passed to the algorithm */ mStoi.resize(numRows); std::vector< std::vector< C_FLOAT64 > >::iterator it = mStoi.begin(); std::vector< std::vector< C_FLOAT64 > >::iterator end = mStoi.end(); for (; it != end; ++it) it->resize(numCols); /* Get the reactions from the model */ /* Note: We have as many reactions as we have rows in ModelStoi */ const CCopasiVectorNS < CReaction > & Reaction = mpModel->getReactions(); /* Vector to keep track of the rearrangements necessary to put the */ /* reversible reactions to the top of stoichiometry matrix */ mpReorderedReactions->resize(numRows); /* Reversible reaction counter */ mReversible = 0; size_t Insert; size_t InsertReversible = 0; size_t InsertIrreversible = numRows - 1; /* Build the transpose of the stoichiometry matrix, */ /* sort reversible reactions to the top, count them */ /* and keep track of the rearrangement */ for (row = 0; row < numRows; row++) { if (Reaction[row]->isReversible()) { Insert = InsertReversible++; mReversible++; } else Insert = InsertIrreversible--; (*mpReorderedReactions)[Insert] = Reaction[row]; for (col = 0; col < numCols; col++) mStoi[Insert][col] = ModelStoi(row, col); } mStep = 0; mStepProcess = 0; mMaxStep = (unsigned C_INT32) numCols; if (mpCallBack) mhSteps = mpCallBack->addItem("Current Step", mStepProcess, & mMaxStep); return true; }