Skip to content

Commit

Permalink
functionDefinition to HetaCode export
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Metelkin committed Sep 6, 2022
1 parent bb03c7f commit 6623825
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cases/24-define-function/src/index.heta
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,15 @@
math: sqrt(x1^2 + x2^2 + x3^2)
};

#defineFunction f4 {
arguments: [],
math: 15*2
};

#defineUnit u1 {
units: litre^2,
};

c1 @Compartment .= 2;
s1 @Species {compartment: c1} .= 100;
r1 @Reaction {actors: s1=} := k1 * pow7(s1) * c1;
Expand All @@ -25,6 +34,7 @@ k1 @Const = 0.1;
#export { format: XLSX, filepath: table, omitRows: 3, splitByClass: true };
#export { format: SBML, filepath: sbml, version: L2V4 };
#export { format: DBSolve, filepath: dbsolve };
#export { format: HetaCode, filepath: heta };
//#export { format: Simbio, filepath: simbio };
//#export { format: Mrgsolve, filepath: mrgsolve };
//#export { format: Matlab, filepath: matlab };
Expand Down
1 change: 1 addition & 0 deletions src/heta-code-export/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ class HetaCodeExport extends AbstractExport{
: [...container.namespaceStorage].filter((x) => this.spaceFilter.indexOf(x[0]) !== -1);

return {
functionDefStorage: [...container.functionDefStorage],
unitDefStorage: [...container.unitDefStorage],
namespaceStorage: filteredNamespaceStorage
};
Expand Down
8 changes: 8 additions & 0 deletions src/templates/heta-code.heta.njk
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@
{%- endif %}
{%- endfor %}
{%- for id, functionDef in functionDefStorage %}
{%- if not functionDef.isCore %}
{{ id }} #defineFunction { arguments: [{{ functionDef.arguments | join(', ') }}],
{%- if functionDef.math is defined %} math: {{ functionDef.math.toString() }}, {% endif -%}
};
{%- endif %}
{%- endfor %}
{%- for spaceId, namespace in namespaceStorage %}
{{ 'abstract ' if namespace.isAbstract }}namespace {{ spaceId }} begin
Expand Down
2 changes: 2 additions & 0 deletions src/templates/sbml.xml.njk
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
<listOfFunctionDefinitions>
{%- for functionDefinition in listOfFunctionDefinitions %}
<functionDefinition id="{{ functionDefinition.id }}">
{%- if functionDefinition.math is defined %}
<math xmlns="http://www.w3.org/1998/Math/MathML">
<lambda>
{%- for argument in functionDefinition.arguments %}
Expand All @@ -43,6 +44,7 @@
{{ functionDefinition.math.toCMathML(true) }}
</lambda>
</math>
{%- endif %}
</functionDefinition>
{%- endfor %}
</listOfFunctionDefinitions>
Expand Down

0 comments on commit 6623825

Please sign in to comment.