Note: The examples described below work with version v2.14b and later. If using an earlier version then you must remember to add libantimony.wasm to your project as the libantimony.js and libantimony.wasm were not combined into one file.
../release/v#####
into a suitable subdirectory in your website.In the webpage where you want to load the libantimony library just insert the following lines into the page so that your code can find the library:
<script src="/your_location/libantimony.js" type="text/javascript"></script>
<script src="/your_location/antimony_wrap.js" type="text/javascript"></script>
<script type="text/javascript">
// Load library (asynchronous call):
var antimonyLibrary; // Holds libantimony
try {
libantimony().then((libantimony) => {
antimonyLibrary = new AntimonyWrapper(libantimony); // instantiates The AntimonyWrapper class with the libantimony library.
});
}
catch(err) {
console.log("Load libantimony error: ", err);
}
</script>
../docs/demo/index.html
../release/v#####
into a suitable subdirectory in your project.const libantimony = require( './your_location/libantimony.js');
var antimonyWrapper = require( './your_location/antimony_wrap.js');
// Load library (asynchronous call):
var antimonyLibrary; // Holds libantimony
try {
libantimony().then((libantimony) => {
antimonyLibrary = new AntimonyWrapper(libantimony); // instantiates The AntimonyWrapper class with the libantimony library.
});
}
catch(err) {
console.log("Load libantimony error: ", err);
}
../test/test_wrap_antimony.js
Below are the two basic methods of the AntimonyWrapper class used to get the translations:
var conversionResult = antimonyLibrary.convertAntimonyToSBML( antimonyString ) ;
if(conversionResult.isSuccess()) {
sbmlResult = conversionResult.getResult(); }
or convert SBML to Antimony:
conversionResult = antimonyLibrary.convertSBMLToAntimony( sbmlString );
if(conversionResult.isSuccess()) {
sbmlResult = conversionResult.getResult(); }
conversionResult.getResult()
: returns the translated string or the error message if isSuccess() is false.conversionResult.isSuccess()
: returns true if successfully translated model, false if error(s).conversionRresult.getWarnings()
: returns any warnings generated from the translation (Note: isSuccess() will often return true if there are only warnings.)