COPASI API  4.16.103
Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Private Attributes | List of all members
Copasi2SBMLTranslator Class Reference

#include <SBWTranslator.h>

Public Member Functions

 Copasi2SBMLTranslator ()
 
virtual ~Copasi2SBMLTranslator ()
 

Static Public Member Functions

static void registerMethods (SystemsBiologyWorkbench::MethodTable< Copasi2SBMLTranslator > &table)
 
static std::string translate (const std::string &sbmlString)
 
static std::string translateFileToSBML (const std::string &fileName)
 
static std::string translateToSBML (const std::string &copasiString)
 

Protected Member Functions

SystemsBiologyWorkbench::DataBlockWriter getAuthor (SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
 
SystemsBiologyWorkbench::DataBlockWriter getCopyright (SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
 
SystemsBiologyWorkbench::DataBlockWriter getDescription (SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
 
SystemsBiologyWorkbench::DataBlockWriter getFileExtension (SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
 
SystemsBiologyWorkbench::DataBlockWriter getFileType (SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
 
SystemsBiologyWorkbench::DataBlockWriter getName (SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
 
SystemsBiologyWorkbench::DataBlockWriter getURL (SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
 
SystemsBiologyWorkbench::DataBlockWriter getVersion (SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
 
SystemsBiologyWorkbench::DataBlockWriter translate (SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
 
SystemsBiologyWorkbench::DataBlockWriter translateFileToSBML (SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
 
SystemsBiologyWorkbench::DataBlockWriter translateToSBML (SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
 

Static Private Attributes

static int mLevel = 3
 
static int mVersion = 1
 

Detailed Description

Definition at line 16 of file SBWTranslator.h.

Constructor & Destructor Documentation

Copasi2SBMLTranslator::Copasi2SBMLTranslator ( )

Definition at line 35 of file SBWTranslator.cpp.

36 {
37 }
Copasi2SBMLTranslator::~Copasi2SBMLTranslator ( )
virtual

Definition at line 38 of file SBWTranslator.cpp.

39 {
40 }

Member Function Documentation

DataBlockWriter Copasi2SBMLTranslator::getAuthor ( SystemsBiologyWorkbench::Module  from,
SystemsBiologyWorkbench::DataBlockReader  reader 
)
protected

Definition at line 110 of file SBWTranslator.cpp.

Referenced by registerMethods().

111 {
112  static string author("Frank T. Bergmann");
113  return DataBlockWriter() << author;
114 }
DataBlockWriter Copasi2SBMLTranslator::getCopyright ( SystemsBiologyWorkbench::Module  from,
SystemsBiologyWorkbench::DataBlockReader  reader 
)
protected

Definition at line 120 of file SBWTranslator.cpp.

Referenced by registerMethods().

121 {
122  static string copy("(c) 2012 COPASI Team");
123  return DataBlockWriter() << copy;
124 }
DataBlockWriter Copasi2SBMLTranslator::getDescription ( SystemsBiologyWorkbench::Module  from,
SystemsBiologyWorkbench::DataBlockReader  reader 
)
protected

Definition at line 115 of file SBWTranslator.cpp.

Referenced by registerMethods().

116 {
117  static string description("This converter converts a COPASI model to an SBML file");
118  return DataBlockWriter();
119 }
DataBlockWriter Copasi2SBMLTranslator::getFileExtension ( SystemsBiologyWorkbench::Module  from,
SystemsBiologyWorkbench::DataBlockReader  reader 
)
protected

Definition at line 130 of file SBWTranslator.cpp.

Referenced by registerMethods().

131 {
132  static string extension(".cps");
133  return DataBlockWriter() << extension;
134 }
DataBlockWriter Copasi2SBMLTranslator::getFileType ( SystemsBiologyWorkbench::Module  from,
SystemsBiologyWorkbench::DataBlockReader  reader 
)
protected

Definition at line 135 of file SBWTranslator.cpp.

Referenced by registerMethods().

136 {
137  static string fileType("COPASI file");
138  return DataBlockWriter() << fileType;
139 }
DataBlockWriter Copasi2SBMLTranslator::getName ( SystemsBiologyWorkbench::Module  from,
SystemsBiologyWorkbench::DataBlockReader  reader 
)
protected

Definition at line 98 of file SBWTranslator.cpp.

Referenced by registerMethods().

99 {
100  static string name("Copasi2SBML Translator");
101  return DataBlockWriter();
102 }
DataBlockWriter Copasi2SBMLTranslator::getURL ( SystemsBiologyWorkbench::Module  from,
SystemsBiologyWorkbench::DataBlockReader  reader 
)
protected

Definition at line 125 of file SBWTranslator.cpp.

Referenced by registerMethods().

126 {
127  static string url("http://copasi.org");
128  return DataBlockWriter() << url;
129 }
DataBlockWriter Copasi2SBMLTranslator::getVersion ( SystemsBiologyWorkbench::Module  from,
SystemsBiologyWorkbench::DataBlockReader  reader 
)
protected

Definition at line 104 of file SBWTranslator.cpp.

References CVersion::VERSION.

Referenced by registerMethods().

105 {
106  static string version(CVersion::VERSION.getVersion());
107  return DataBlockWriter() << version;
108 }
SystemsBiologyWorkbench::DataBlockWriter getVersion(SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
static const CVersion VERSION
Definition: CVersion.h:164
void Copasi2SBMLTranslator::registerMethods ( SystemsBiologyWorkbench::MethodTable< Copasi2SBMLTranslator > &  table)
static

Definition at line 42 of file SBWTranslator.cpp.

References getAuthor(), getCopyright(), getDescription(), getFileExtension(), getFileType(), getName(), getURL(), getVersion(), translate(), translateFileToSBML(), and translateToSBML().

43 {
44  table.addMethod(&Copasi2SBMLTranslator::getName, "string getName()", false, "Return the name of this importer");
45  table.addMethod(&Copasi2SBMLTranslator::getVersion, "string getVersion()", false, "Return the version of this importer");
46  table.addMethod(&Copasi2SBMLTranslator::getAuthor, "string getAuthor()", false, "Return the corresponding author for this importer");
47  table.addMethod(&Copasi2SBMLTranslator::getDescription, "string getDescription()", false, "Return a description for this importer");
48  table.addMethod(&Copasi2SBMLTranslator::getName, "string getDisplayName()", false, "Return the display name for this importer.");
49  table.addMethod(&Copasi2SBMLTranslator::getCopyright, "string getCopyright()", false, "Return the copyright for this importer");
50  table.addMethod(&Copasi2SBMLTranslator::getURL, "string getURL()", false, "Return a URL for this reporter.");
51  table.addMethod(&Copasi2SBMLTranslator::getFileExtension, "string getFileExtension()", false, "Returns the file extension as a string");
52  table.addMethod(&Copasi2SBMLTranslator::getFileType, "string getFileType()", false, "Returns a string describing the type of file");
53  table.addMethod(&Copasi2SBMLTranslator::translate, "string translate(string)", false, "Translate SBML string to COPASI.");
54  table.addMethod(&Copasi2SBMLTranslator::translateToSBML, "string translateToSBML(string)", false, "Translate COPASI string to SBML.");
55  table.addMethod(&Copasi2SBMLTranslator::translateFileToSBML, "string translateFileToSBML(string)", false, "Translate COPASI string to SBML.");
56 }
SystemsBiologyWorkbench::DataBlockWriter getAuthor(SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
static std::string translateFileToSBML(const std::string &fileName)
static std::string translateToSBML(const std::string &copasiString)
SystemsBiologyWorkbench::DataBlockWriter getVersion(SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
SystemsBiologyWorkbench::DataBlockWriter getDescription(SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
SystemsBiologyWorkbench::DataBlockWriter getURL(SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
static std::string translate(const std::string &sbmlString)
SystemsBiologyWorkbench::DataBlockWriter getFileType(SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
SystemsBiologyWorkbench::DataBlockWriter getName(SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
SystemsBiologyWorkbench::DataBlockWriter getCopyright(SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
SystemsBiologyWorkbench::DataBlockWriter getFileExtension(SystemsBiologyWorkbench::Module from, SystemsBiologyWorkbench::DataBlockReader reader)
std::string Copasi2SBMLTranslator::translate ( const std::string &  sbmlString)
static

Definition at line 67 of file SBWTranslator.cpp.

References CCopasiRootContainer::addDatamodel(), CDirEntry::fileName(), COptions::getValue(), CCopasiDataModel::importSBMLFromString(), CCopasiRootContainer::init(), CDirEntry::makePathAbsolute(), CDirEntry::remove(), and CCopasiDataModel::saveModel().

Referenced by registerMethods().

68 {
71  pDataModel->importSBMLFromString(sbmlString);
72 
73  string tempDir;
74  COptions::getValue("Tmp", tempDir);
75  string tempFile = "tmp.cps";
76  CDirEntry::makePathAbsolute(tempFile, tempDir);
77  tempFile = CDirEntry::fileName(tempFile);
78  pDataModel->saveModel(tempFile, NULL, true);
79  std::ifstream ifs(tempFile.c_str());
80  std::string str((std::istreambuf_iterator<char>(ifs)), std::istreambuf_iterator<char>());
81  ifs.close();
82  CDirEntry::remove(tempFile);
83  return str;
84 }
static bool remove(const std::string &path)
Definition: CDirEntry.cpp:275
static std::string fileName(const std::string &path)
Definition: CDirEntry.cpp:119
bool saveModel(const std::string &fileName, CProcessReport *pProcessReport, bool overwriteFile=false, const bool &autoSave=false)
static void getValue(const std::string &name, CType &value)
Definition: COptions.h:124
static CCopasiDataModel * addDatamodel()
bool importSBMLFromString(const std::string &sbmlDocumentText, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
static void init(int argc, char *argv[], const bool &withGui=false)
static bool makePathAbsolute(std::string &relativePath, const std::string &absoluteTo)
Definition: CDirEntry.cpp:481
SystemsBiologyWorkbench::DataBlockWriter Copasi2SBMLTranslator::translate ( SystemsBiologyWorkbench::Module  from,
SystemsBiologyWorkbench::DataBlockReader  reader 
)
protected
std::string Copasi2SBMLTranslator::translateFileToSBML ( const std::string &  fileName)
static

Definition at line 58 of file SBWTranslator.cpp.

References CCopasiRootContainer::addDatamodel(), CCopasiDataModel::exportSBMLToString(), CCopasiRootContainer::init(), and CCopasiDataModel::loadModel().

Referenced by main(), and registerMethods().

59 {
62  pDataModel->loadModel(fileName, NULL);
63  string sbml = pDataModel->exportSBMLToString(NULL, mLevel, mVersion);
64  return sbml;
65 }
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
bool loadModel(std::istream &in, const std::string &pwd, CProcessReport *pProcessReport, const bool &deleteOldData=true)
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
SystemsBiologyWorkbench::DataBlockWriter Copasi2SBMLTranslator::translateFileToSBML ( SystemsBiologyWorkbench::Module  from,
SystemsBiologyWorkbench::DataBlockReader  reader 
)
protected
std::string Copasi2SBMLTranslator::translateToSBML ( const std::string &  copasiString)
static

Definition at line 86 of file SBWTranslator.cpp.

References CCopasiRootContainer::addDatamodel(), CCopasiDataModel::exportSBMLToString(), COptions::getPWD(), CCopasiRootContainer::init(), and CCopasiDataModel::loadModel().

Referenced by registerMethods().

87 {
90 
91  istringstream str(copasiString);
92 
93  pDataModel->loadModel(str, COptions::getPWD(), NULL);
94  string sbml = pDataModel->exportSBMLToString(NULL, mLevel, mVersion);
95  return sbml;
96 }
std::string exportSBMLToString(CProcessReport *pExportHandler, int sbmlLevel, int sbmlVersion)
static std::string getPWD(void)
Definition: COptions.cpp:338
bool loadModel(std::istream &in, const std::string &pwd, CProcessReport *pProcessReport, const bool &deleteOldData=true)
static CCopasiDataModel * addDatamodel()
static void init(int argc, char *argv[], const bool &withGui=false)
SystemsBiologyWorkbench::DataBlockWriter Copasi2SBMLTranslator::translateToSBML ( SystemsBiologyWorkbench::Module  from,
SystemsBiologyWorkbench::DataBlockReader  reader 
)
protected

Member Data Documentation

int Copasi2SBMLTranslator::mLevel = 3
staticprivate

Definition at line 44 of file SBWTranslator.h.

int Copasi2SBMLTranslator::mVersion = 1
staticprivate

Definition at line 45 of file SBWTranslator.h.


The documentation for this class was generated from the following files: