- Author:
- Randall Britten <r.britten@auckland.ac.nz>
- Date:
- 2013-04-17 15:30:14+12:00
- Desc:
- To "clone" an imported component, the top level import element needs to be duplicated, not just the component reference within an existing import. The rationale is that all connections within a top-level import are kept intact, as dictated by the encapsulation in the imported model.
- Permanent Source URI:
- https://staging.physiomeproject.org/w/matthiaskoenig/MetabolicComponentLibrary/rawfile/702b54b45018b04ef1bc074677379dc20d983234/CellML-source/CellMLTools/src/cellmlexamples/TeLICeMTest.java
package cellmlexamples;
import java.io.File;
import sun.rmi.runtime.NewThreadAction;
import tools.CellMLReader;
import tools.CellMLWriter;
import cellml_api.CellMLBootstrap;
import cellml_api.Model;
import cellml_services.TeLICeMModelResult;
import cellml_services.TeLICeMService;
public class TeLICeMTest {
private CellMLBootstrap bootstrap;
private TeLICeMService ts;
public TeLICeMTest() {
System.loadLibrary("java_cellml");
bootstrap = cellml_bootstrap.CellMLBootstrap.createCellMLBootstrap();
System.loadLibrary("java_telicems");
ts = cellml_bootstrap.TeLICeMSService.createTeLICeMService();
}
public String getTeliFromURL(String url){
Model model = CellMLReader.loadFromURL(bootstrap, url);
return getTeliFromModel(model);
}
public String getTeliFromModel(Model model){
return ts.showModel(model);
}
public void writeModelFromTeliToFile(String teli, String fname){
Model model = getModelFromTeli(teli);
CellMLWriter.writeToFile(model, fname);
}
public Model getModelFromTeli(String teli){
TeLICeMModelResult tsRes = ts.parseModel(teli);
return tsRes.getModelResult();
}
public static void main(String[]args){
TeLICeMTest teliTools = new TeLICeMTest();
// Load CellML model
String url = "TestModelRDF.cellml";
String url2 = "test_import/Example_MassAction_1_flat.cellml";
String url3 = "test_import/Example_MassAction_1.cellml";
String teli = teliTools.getTeliFromURL(url3);
System.out.println(teli);
// Create new Model from Teli format
Model model_out = teliTools.getModelFromTeli(teli);
// Write model
CellMLWriter.writeToFile(model_out, "teli_test.cellml");
}
}