19 #include <sedml/SedTypes.h>
20 #include <sbml/SBMLTypes.h>
27 const std::map<CCopasiObject*, SBase*>& map,
29 const std::string& name)
31 std::map<CCopasiObject*, SBase*>::const_iterator it = map.begin();
33 std::string::size_type compartmentStart = name.find(
"{");
34 std::string nameOnly = name.substr(0, compartmentStart);
36 while (it != map.end())
38 SBase* current = it->second;
40 if (((current->getTypeCode() & typeCode) == typeCode) &&
41 current->getName() == name)
42 return current->getId();
44 if (typeCode == SBML_SPECIES && compartmentStart != std::string::npos)
46 if (((current->getTypeCode() & typeCode) == typeCode) &&
47 current->getName() == nameOnly)
49 std::string compName = name.substr(compartmentStart + 1, name.size() - compartmentStart - 2);
51 Species* species = (Species*) current;
53 if (species->getCompartment() == compId)
54 return species->getId();
66 const std::string &type,
70 std::vector<std::string> stringsContainer;
71 std::string targetXPathString;
73 const std::map<CCopasiObject*, SBase*>& copasi2sbmlmap =
75 std::string displayName = sbmlId;
77 if (copasi2sbmlmap.size() == 0)
83 std::map<CCopasiObject*, SBase*>::const_iterator pos;
85 if (type ==
"Concentration" || type ==
"InitialConcentration")
87 targetXPathString =
"/sbml:sbml/sbml:model/sbml:listOfSpecies/sbml:species[@id=\'";
91 if (type ==
"InitialConcentration")
93 displayName = displayName.substr(0, displayName.length() - 2);
100 return targetXPathString + sbmlId +
"\']";
106 else if (type ==
"Flux")
108 targetXPathString =
"/sbml:sbml/sbml:model/sbml:listOfReactions/sbml:reaction[@id=\'";
110 displayName = stringsContainer[0];
118 return targetXPathString + sbmlId +
"\']";
123 else if (type ==
"Value" || type ==
"InitialValue")
125 if (type ==
"InitialValue")
127 displayName = displayName.substr(0, displayName.find(
".InitialValue"));
130 targetXPathString =
"/sbml:sbml/sbml:model/sbml:listOfParameters/sbml:parameter[@id=\'";
133 if (stringsContainer.size() == 1)
139 if (stringsContainer.size() == 2)
141 sbmlId = stringsContainer[0] +
"_" + stringsContainer[1];
142 std::stringstream xpath;
143 xpath <<
"/sbml:sbml/sbml:model/sbml:listOfReactions/sbml:reaction[@id=\'";
144 xpath << stringsContainer[0];
145 xpath <<
"\']/sbml:kineticLaw/sbml:listOfParameters/sbml:parameter[@id=\'";
146 xpath << stringsContainer[1];
152 displayName = stringsContainer[1];
163 return targetXPathString + sbmlId +
"\']";
168 else if (type ==
"Volume" || type ==
"InitialVolume")
170 targetXPathString =
"/sbml:sbml/sbml:model/sbml:listOfCompartments/sbml:compartment[@id=\'";
172 displayName = stringsContainer[1];
174 if (type ==
"InitialVolume")
176 displayName = displayName.substr(0, displayName.find(
".InitialVolume"));
179 if (type ==
"Volume")
181 displayName = displayName.substr(0, displayName.find(
".Volume"));
190 return targetXPathString + sbmlId +
"\']";
195 else if (type ==
"Time" || type ==
"Initial Time")
199 return targetXPathString;
206 if (dataReference == NULL || dataReference->getNumVariables() < 1)
return NULL;
208 const SedVariable* var = dataReference->getVariable(0);
221 std::vector<std::string> xpathStrings;
222 std::string id, nextString;
225 nextString = xpathStrings[xpathStrings.size() - 1];
228 SBMLType = xpathStrings[0];
229 nextString = xpathStrings[xpathStrings.size() - 1];
232 nextString = xpathStrings[xpathStrings.size() - 1];
234 id = xpathStrings[0];
245 std::string SBMLType;
252 size_t pos = xpath.find(
"/sbml:kineticLaw/sbml:listOfParameters/");
254 if (pos != std::string::npos)
256 std::string reactionType;
263 std::string cn =
"ParameterGroup=Parameters,Parameter=" +
id +
",Reference=Value";
275 for (
unsigned int ii = 0; ii < characters.length(); ++ii)
277 str.erase(std::remove(str.begin(), str.end(), characters[ii]), str.end());
286 const std::string& type =
object.getObjectName();
291 return targetXPathString;
296 std::stringstream str; str << base << count;
301 std::string &fileName, std::string &fileContent)
345 std::vector<std::string> &xpathStrings)
347 std::string myPath = xpath;
348 xpathStrings.clear();
352 for (std::string::const_iterator it = xpath.begin(); it != xpath.end(); it++)
360 xpathStrings.push_back(next);
371 xpathStrings.push_back(next);
377 if (SBMLType ==
"Time")
380 if (SBMLType ==
"species")
384 for (iMet = 0; iMet < imax; ++iMet)
392 return pModel->
getMetabolites()[iMet]->getInitialConcentrationReference();
394 return pModel->
getMetabolites()[iMet]->getConcentrationReference();
398 else if (SBMLType ==
"reaction")
402 for (iMet = 0; iMet < imax; ++iMet)
409 return pModel->
getReactions()[iMet]->getFluxReference();
413 else if (SBMLType ==
"parameter")
417 for (iMet = 0; iMet < imax; ++iMet)
422 return pModel->
getModelValues()[iMet]->getInitialValueReference();
429 else if (SBMLType ==
"compartment")
433 for (iComp = 0; iComp < imax; ++iComp)
CCopasiDataModel * getObjectDataModel()
virtual std::string getObjectDisplayName(bool regular=true, bool richtext=false) const
const CCopasiVector< CMetab > & getMetabolites() const
const CCopasiVectorN< CModelValue > & getModelValues() const
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
static std::string translateTargetXpathInSBMLId(const std::string &xpath, std::string &SBMLType)
virtual size_t size() const
static const CCopasiObject * resolveDatagenerator(const CModel *model, const SedDataGenerator *dataReference)
static std::string getXPathAndName(std::string &sbmlId, const std::string &type, const CModel *pModel, const CCopasiDataModel &dataModel)
static const CCopasiObject * getObjectForSbmlId(const CModel *pModel, const std::string &id, const std::string &SBMLType, bool initial=false)
static std::string findIdByNameAndType(const std::map< CCopasiObject *, SBase * > &map, int typeCode, const std::string &name)
static void splitStrings(const std::string &xpath, char delim, std::vector< std::string > &stringsContainer)
static std::string getXPathForObject(const CCopasiObject &object)
CCopasiVectorNS< CCompartment > & getCompartments()
static const CCopasiObject * resolveXPath(const CModel *model, const std::string &xpath, bool initial=false)
CCopasiVectorNS< CReaction > & getReactions()
static std::string getNextId(const std::string &base, int count)
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
int processArchive(const std::string &archiveFile, std::string &fileName, std::string &fileContent)
static std::string & removeCharactersFromString(std::string &str, const std::string &characters)
CCopasiContainer * getObjectParent() const