void MetabolicNetworkTools::fillStoichiometricMatrix(boost::numeric::ublas::mapped_matrix& matrix, 00180 std::map& rowLabels, 00181 std::map& colLabels) 00182 { 00183 std::map< Molecule_sptr, std::vector > molRxnMap = MN.useTools).connectMetabolitesToReactions(); 00184 00185 typedef std::map MNMapType; // map for metabolite names -> rxn no. 00186 MNMapType mnMap; 00187 unsigned int metNo = molRxnMap.size(); 00188 unsigned int rxnNo = this->MN.size(); 00189 matrix.resize(metNo, rxnNo, false); 00190 00191 const std::vector & reactions = this->MN.getReactions(); 00192 00193 std::pair inserted; 00194 for (unsigned int reactionNo = 0; reactionNo < reactions.size(); ++reactionNo) { 00195 colLabels[reactions[reactionNo]->getName()] = reactionNo; 00196 // process educts 00197 SetOfMolecules_sptr edPr = reactions[reactionNo]->getEducts(); 00198 for (unsigned int k = 0; k < edPr->size(); ++k) { 00199 00200 const std::string& molName = edPr->getMolecule(k)->getName(); 00201 MNMapType::iterator iter = mnMap.find(molName); 00202 if (iter == mnMap.end()) { 00203 rowLabels[molName] = mnMap.size(); 00204 inserted = mnMap.insert(std::pair(molName, mnMap.size())); 00205 iter = inserted.first; 00206 } 00207 matrix(iter->second, reactionNo) = -edPr->getStoich(k); 00208 00209 } 00210 00211 // process products 00212 edPr = reactions[reactionNo]->getProducts(); 00213 for (unsigned int k = 0; k < edPr->size(); ++k) { 00214 00215 const std::string& molName = edPr->getMolecule(k)->getName(); 00216 MNMapType::iterator iter = mnMap.find(molName); 00217 if (iter == mnMap.end()) { 00218 rowLabels[molName] = mnMap.size(); 00219 inserted = mnMap.insert(std::pair(molName, mnMap.size())); 00220 iter = inserted.first; 00221 } 00222 matrix(iter->second, reactionNo) = edPr->getStoich(k); 00223 00224 } 00225 00226 } 00227 00228 }