Skip to content

Commit d6ea5a6

Browse files
committed
Add annotate option to return annotation about the generated CellML as CellMLOutput.annotation.
1 parent bc5de4b commit d6ea5a6

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/bg2cellml/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,14 @@ import { getBgRdf } from './celldl'
2727
import { test as runTest } from './test'
2828

2929
export interface CellMLOutput {
30+
annotations?: Record<string, object>
3031
cellml?: string
3132
exception?: string
3233
issues?: string[]
3334
}
3435

3536
export type CellMLGenerationOptions = {
37+
annotate?: boolean
3638
debug?: boolean
3739
rdfSource?: boolean
3840
}
@@ -126,14 +128,16 @@ export async function initialisePython(pyodideApi: PyodideAPI, rdfInterface: Rdf
126128
const RUN_BG2CELLML = `
127129
from pyodide.ffi import to_js
128130
129-
def bg2cellml(uri: str, bg_rdf: str, debug: bool=False):
131+
def bg2cellml(uri: str, bg_rdf: str, annotate: bool=False, debug: bool=False):
130132
try:
131133
bgrdf_model = framework.make_bondgraph_model(uri, bg_rdf, debug=debug)
132134
if bgrdf_model.has_issues:
133135
result = { 'issues': get_issues(bgrdf_model.issues, debug) }
134136
else:
135137
cellml_model = bgrdf_model.make_cellml_model()
136138
result = { 'cellml': cellml_model.to_xml() }
139+
if annotate:
140+
result['annotations'] = cellml_model.annotations()
137141
return to_js(result)
138142
except Exception as e:
139143
return to_js({
@@ -158,7 +162,7 @@ export function celldl2cellml(uri: string, source: string, options: CellMLGenera
158162
if (pyodide) {
159163
const bgRdf = options?.rdfSource ? source : getBgRdf(source)
160164
const bg2cellml = pyodide.runPython(RUN_BG2CELLML)
161-
return bg2cellml(uri, bgRdf, options?.debug)
165+
return bg2cellml(uri, bgRdf, options?.annotate, options?.debug)
162166
}
163167
return {
164168
issues: ['CellML conversion service has not been initialised']

0 commit comments

Comments
 (0)