Skip to content

Commit

Permalink
prepare strings for Simbio
Browse files Browse the repository at this point in the history
  • Loading branch information
metelkin committed Jul 15, 2024
1 parent 5a41024 commit 7cb5e5c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/core/component.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,10 @@ class Component {
if (this.notes === undefined) {
return undefined;
}
let renderedOutput = md.render(this.notes);
return renderedOutput.trim();
let renderedOutput = md.render(this.notes)
.replace(/\n+\r*/g, ' ')
.trim();
return renderedOutput;
}
static isValid(q, logger){
let ind = q.space ? `${q.space}::${q.id}` : q.id;
Expand Down
18 changes: 9 additions & 9 deletions src/templates/simbio.m.njk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{{- model_id }}, '{{record.id}}', 'ConstantCapacity', false
{%- if record.assignments.start_.num!==undefined %}, 'Capacity', {{record.assignments.start_.num}}{% endif %}
{%- if record.units!==undefined %}, 'CapacityUnits', '{{ record.unitsRebased(legalUnits, true) }}'{% endif -%}
, 'Notes', '{{ record.notesHTML }}', 'Tag', '');
, 'Notes', '{{ record.notesHTML | replace("'", "''")}}', 'Tag', '');
{%- endfor %}
{% set listOfSpecies = population.selectByClassName('Species') -%}
Expand All @@ -28,7 +28,7 @@
{%- if record.assignments.start_.num!==undefined %}, 'InitialAmount', {{record.assignments.start_.num}}{% endif -%}
{%- if record.units!==undefined -%}, 'InitialAmountUnits', '{{ record.unitsRebased(legalUnits, true) }}'{% endif -%}
, 'BoundaryCondition', {{ record.boundary===true or record.isRule===true -}}
, 'Notes', '{{ record.notesHTML }}', 'Tag', '');
, 'Notes', '{{ record.notesHTML | replace("'", "''") }}', 'Tag', '');
{%- endfor %}
{% set listOfParameters = population.selectByClassName('Record') -%}
Expand All @@ -41,20 +41,20 @@
{{- model_id }}, '{{record.id}}', 'ConstantValue', false
{%- if record.assignments.start_.num!==undefined %}, 'Value', {{record.assignments.start_.num}}{% endif -%}
{%- if record.units!==undefined -%}, 'ValueUnits', '{{ record.unitsRebased(legalUnits, true) }}'{% endif -%}
, 'Notes', '{{ record.notesHTML }}', 'Tag', '');
, 'Notes', '{{ record.notesHTML | replace("'", "''") }}', 'Tag', '');
{%- endfor %}
{%- for con in listOfConstants %}
{{ storage_id }}.parameter.{{con.id}} = addparameter(
{{- model_id }}, '{{con.id}}', 'ConstantValue', true
{%- if con.num!==undefined %}, 'Value', {{con.num}}{% endif -%}
{%- if con.units!==undefined -%}, 'ValueUnits', '{{ con.unitsRebased(legalUnits, true) }}'{% endif -%}
, 'Notes', '{{ con.notesHTML }}', 'Tag', '');
, 'Notes', '{{ con.notesHTML | replace("'", "''") }}', 'Tag', '');
{%- endfor %}
{%- for ts in listOfTimeScales %}
{{ storage_id }}.parameter.{{ts.id}} = addparameter(
{{- model_id }}, '{{ts.id}}', 'ConstantValue', false
{%- if ts.units!==undefined -%}, 'ValueUnits', '{{ ts.unitsRebased(legalUnits, true) }}'{% endif -%}
, 'Notes', '{{ ts.notesHTML }}', 'Tag', '');
, 'Notes', '{{ ts.notesHTML | replace("'", "''") }}', 'Tag', '');
{%- endfor %}
{% set listOfReactions = population.selectByClassName('Reaction') -%}
Expand All @@ -63,7 +63,7 @@
{{ storage_id }}.reaction.{{record.id}} = addreaction(
{{- model_id }}, 'null -> null', 'Name', '{{record.id}}', 'Active', true, 'Reversible', {{ record.reversible!==false}}
{%- if record.assignments.ode_ %}, 'ReactionRate', '{{record.assignments.ode_.toMatlabString()}}'{% endif -%}
, 'Notes', '{{ record.notesHTML }}', 'Tag', '');
, 'Notes', '{{ record.notesHTML | replace("'", "''") }}', 'Tag', '');
{%- set fullActors = record.actors.concat(record.modifiers) -%}
{% set reactants = fullActors|getReactants %}
{%- if reactants|length > 0 %}
Expand Down Expand Up @@ -124,7 +124,7 @@ addrule(
', {
{%- for record in population.selectRecordsByContext(event.id) -%}
'{{- record.id }} = {{ record.assignments[event.id].toMatlabString() }}', {% endfor -%}
}, 'Active', {{ event.active }}, 'Notes', '{{ event.notesHTML }}', 'Tag', '');
}, 'Active', {{ event.active }}, 'Notes', '{{ event.notesHTML | replace("'", "''") }}', 'Tag', '');
{%- endfor %}
{% set listOfDEvents = population.selectByClassName("DSwitcher") %}
Expand All @@ -133,7 +133,7 @@ addrule(
{{ storage_id }}.event.{{event.id}} = addevent({{- model_id }}, '{{ event.trigger.toMatlabString() if event.trigger is defined else 'false' }}', {
{%- for record in population.selectRecordsByContext(event.id) -%}
'{{- record.id }} = {{ record.assignments[event.id].toMatlabString() }}', {% endfor -%}
}, 'Active', {{ event.active }}, 'Notes', '{{ event.notesHTML }}', 'Tag', '');
}, 'Active', {{ event.active }}, 'Notes', '{{ event.notesHTML | replace("'", "''") }}', 'Tag', '');
{%- endfor %}
{% set listOfCEvents = population.selectByClassName("CSwitcher") %}
Expand All @@ -142,7 +142,7 @@ addrule(
{{ storage_id }}.event.{{event.id}} = addevent({{- model_id }}, '{{ event.trigger.toMatlabString() + '>=0' if event.trigger is defined else 'false' }}', {
{%- for record in population.selectRecordsByContext(event.id) -%}
'{{- record.id }} = {{ record.assignments[event.id].toMatlabString() }}', {% endfor -%}
}, 'Active', {{ event.active }}, 'Notes', '{{ event.notesHTML }}', 'Tag', '');
}, 'Active', {{ event.active }}, 'Notes', '{{ event.notesHTML | replace("'", "''") }}', 'Tag', '');
{%- endfor %}
% Update simulation config
Expand Down

0 comments on commit 7cb5e5c

Please sign in to comment.