use of cbit.vcell.matlab.MatlabOdeFileCoder in project vcell by virtualcell.
the class MatlabExtensionFilter method writeBioModel.
@Override
public void writeBioModel(DocumentManager documentManager, BioModel model, File exportFile, SimulationContext simulationContext) throws Exception {
VCAssert.assertValid(simulationContext);
// matlab from application; get application
// regenerate a fresh MathDescription
MathMapping mathMapping = simulationContext.createNewMathMapping();
MathDescription mathDesc = mathMapping.getMathDescription();
VCAssert.assertValid(mathDesc);
VCAssert.assertFalse(mathDesc.isSpatial(), "spatial");
VCAssert.assertFalse(mathDesc.isNonSpatialStoch(), "stochastic");
Simulation sim = new Simulation(mathDesc);
MatlabOdeFileCoder coder = new MatlabOdeFileCoder(sim);
java.io.StringWriter sw = new java.io.StringWriter();
java.io.PrintWriter pw = new java.io.PrintWriter(sw);
String functionName = exportFile.getName();
if (functionName.endsWith(".m")) {
functionName = functionName.substring(0, functionName.length() - 2);
}
coder.write_V6_MFile(pw, functionName);
pw.flush();
pw.close();
String resultString = sw.getBuffer().toString();
FileUtils.writeStringToFile(exportFile, resultString);
}
use of cbit.vcell.matlab.MatlabOdeFileCoder in project vcell by virtualcell.
the class ExportDocument method exportMatlab.
/**
* Insert the method's description here.
* Creation date: (7/26/2004 12:29:53 PM)
*/
private String exportMatlab(File exportFile, javax.swing.filechooser.FileFilter fileFilter, MathDescription mathDesc) throws ExpressionException, MathException {
Simulation sim = new Simulation(mathDesc);
MatlabOdeFileCoder coder = new MatlabOdeFileCoder(sim);
java.io.StringWriter sw = new java.io.StringWriter();
java.io.PrintWriter pw = new java.io.PrintWriter(sw);
String functionName = exportFile.getName();
if (functionName.endsWith(".m")) {
functionName = functionName.substring(0, functionName.length() - 2);
}
if (fileFilter.getDescription().equals(FileFilters.FILE_FILTER_MATLABV6.getDescription())) {
coder.write_V6_MFile(pw, functionName);
}
pw.flush();
pw.close();
return sw.getBuffer().toString();
}
Aggregations