Skip to content

Commit

Permalink
set namespace as experimental feature
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Metelkin committed Nov 14, 2019
1 parent 820353e commit ae79404
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 98 deletions.
20 changes: 10 additions & 10 deletions actions.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,17 @@ When applying `insert` the class should be stated directly.

```heta
// first insert
#insert one::c1 @Compartment {title: first} := 1;
#insert c1 @Compartment {title: first} := 1;
// second insert with the same index
#insert one::c1 @Compartment {title: second};
#insert c1 @Compartment {title: second};
```
The compartment with the index `one::c1` will be replaced by the another compartment.
The compartment with the index `c1` will be replaced by the another compartment.
The result of two statements will be

```json
{
"one::c1" : {
"c1" : {
"title": "second",
"assignment": {}
}
Expand All @@ -46,7 +46,7 @@ The result of two statements will be
### Example 2

```heta
#insert one::S { compartment: comp1 };
#insert S { compartment: comp1 };
```

This statement should throw the error because class is not indicated.
Expand All @@ -60,16 +60,16 @@ If an updated property exists it will be rewritten by a new value. The current v
### Example 1
```heta
// first insert
#insert one::c1 @Compartment {title: first} := 1;
#insert c1 @Compartment {title: first} := 1;
// second insert with the same index
#update one::c1 { title: second };
#update c1 { title: second };
```

The result of two statements
```json
[{
"one::c1" : {
"c1" : {
"title": "second",
"assignment": { "ode_": 1 }
}
Expand All @@ -79,10 +79,10 @@ The result of two statements
### Example 2

```heta
#update one::S @Species { compartment: c1 };
#update S @Species { compartment: c1 };
```

The statement throws error because the component with index one::S has not been created before.
The statement throws error because the component with index `S` has not been created before.

### Example 3

Expand Down
150 changes: 150 additions & 0 deletions cases/all-classes.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@

pmid @ReferenceDefinition {
prefix: "https://pubmed.org",
suffix: /
};

pow @FunctionDefinition {
args: [x, y],
expr: x^y
};

kDa @UnitDefinition {components: [
{kind: g, multiplier: 1e3, exponent: 1},
{kind: mole, exponent: -1}
]};

avogadro @Const {
num: 6e23,
free: false
};

x @Record {
title: "This is x title",
units: items/mole,
boundary: true,
assignments: {
start_: 1
}
};

s @Species {
units: mM,
isAmount: false,
boundary: false,
assignments: {
start_: 0
},
compartment: comp1
};
comp1 @Compartment {
units: L,
assignments: {
start_: 5.3
}
};
r1 @Reaction {
units: mmole/min
assignments: {
ode_: k1*comp1*s
}
actors: 'a=>',
modifiers: ['b']
};

// simulations

simple_task1 @SimpleTask {
model: sp1, // reference to space
subtasks: [
{saveat: [1,2,3], output_ids: [A, B, C]}
{saveat: [4,5,6], output_ids: [C]}
],
type: simulation,
reassign: { // update constant values
const1: 3,
const2: 4.4
},
tspan: [0, 120], // time range
solver: {
alg: Rosenbrock23,
reltol: 1e-6,
abstol: 1e-12,
maxiters: 1e7,
dtmax: 0.1,
tstops: [] // force calculation in time points
},
data: {},
reduce: {}
};

simple_task2 @SimpleTask {
model: sp1,
subtasks: [
{saveat: [4,5,6]}
]
};

multi_task1 @MultiTask { // unscoped
task_vec: [simple_task1, simple_task2],
sizes: {k1: 1, k2: 2}
};

// === fitting ===
dts1 @SimpleData {
output_ids: [A, B, C], // depDataMarkers
indepData: ['t'], // indepDataMarker
t: [1, 2, 3], // indepData
val: [ // depData
[1, 1, 1],
[1, 1, 1],
[1, 1, 1]
],
evid: [0, 0, 0]
}

l1 @SimpleTask {
model: sp1,
sizes: {}
subtasks: [{
data: dts1
reduce: ln_loss2
}],
reduce: sum
};
l2 @SimpleTask {
model: sp1,
sizes: {dose: 1}
subtasks: [{
data: dts2
reduce: ln_loss2
}],
reduce: sum
};

likelihood_sum @MultiTask {
tasks: [l1, l2],
reduce: sum
};

fitting_task1 @FittingTask {
inter_task: likelihood_sum,
fit_sizes: [k1, k2, k3],
fitter_opt: {
alg: LN_NELDERMEAD
}
};

dts1 @Observation {
kind: KineticsObservation,
indepDataMarker: t,
indepData: [0.1, 0.2, 0.3, 0.4, 0.5],
depDataMarkers: [x, y, z, s],
depData: [
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0],
[0, 0, 0, 0]
]
};
36 changes: 17 additions & 19 deletions cases/one-compartment.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,23 @@ dose @Const = 10;
kabs @Const = 1e-2;
kel @Const = 1.2e-3;
namespace one begin
gut @Compartment .= 1;
Vd @Compartment .= 5;
a0 @Species {
compartment: gut,
isAmount: true
};
c1 @Species {
compartment: central
};
r_abs @Reaction { actors: a0 => c1 };
r_el @Reaction { actors: c1 => };
gut @Compartment .= 1;
Vd @Compartment .= 5;
a0 @Species {
compartment: gut,
isAmount: true
};
c1 @Species {
compartment: central
};
r_abs @Reaction { actors: a0 => c1 };
r_el @Reaction { actors: c1 => };
a0 .= F * dose;
c1 .= 0;
r_abs := kabs * a0;
r_el := kel * c1 * Vd;
end
a0 .= F * dose;
c1 .= 0;
r_abs := kabs * a0;
r_el := kel * c1 * Vd;
// this creates SBML formatted file based on namespace "one".
one::sbml @SBMLExport;
// this creates SBML formatted file
sbml @SBMLExport;
```
40 changes: 40 additions & 0 deletions cases/syntax.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

// base syntax

ns1::var1 @Type1 'some title' { key1: string value, key2: 1.2, key3: true };

// Component updates

// created component
mod1::A @Species { compartment: comp1 };
// can be updated with the following code
mod1::A { compartment: comp2, isAmount: true };

// Namespaces

mod1::A @Species { compartment: comp1 };
mod2::A @Record .= 1.1;

// Syntax sugar

one::c1 @Compartment;
one::c1 .= 10; // set initial value to 10
one::c1 := x*y; // calculates its value at each time point
one::c1 [sw1]= 4; // change its value to 4 after sw1 event

// blocks

namespace mod1 begin
A @Species { compartment: comp1 };
B @Species { compartment: comp1 };
end;

// comments

// Line comments
/* Multiline
comment */

// import

#import { source: module1.heta, type: heta };
Loading

0 comments on commit ae79404

Please sign in to comment.