Skip to content

Commit

Permalink
update cases and math
Browse files Browse the repository at this point in the history
  • Loading branch information
Evgeny Metelkin committed Mar 15, 2020
1 parent 25fa17b commit 016d819
Show file tree
Hide file tree
Showing 10 changed files with 112 additions and 54 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ The example describes a simple model with two species and one mass-action reacti
comp1 @Compartment;
A @Species { compartment: comp1 };
B @Species { compartment: comp1 };
r1 @Reaction { actors: A->B };
r1 @Reaction { actors: A -> 2B };
comp1 .= 1;
A .= 10;
Expand All @@ -72,9 +72,9 @@ B @Species { compartment: comp1 };
```
This code creates two species: "A", "B" inside "comp1".
```heta
r1 @Reaction { actors: A->B };
r1 @Reaction { actors: A -> 2B };
```
This code creates reaction A->B
This code creates reaction A -> 2B, where one molecule of A transforms to two molecules of B.
```
comp1 .= 1;
```
Expand Down
15 changes: 13 additions & 2 deletions cases.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Cases

- [One compartment PK model example](cases/one-compartment)
*See also published [QSP platfortms](/implemented?id=open-source-qsp-platforms).*

*See also published [QSP platfortms](implemented?id=Open-source-QSP-platforms).*
| | |
|---|---|
| [one-compartment](cases/one-compartment) | One compartment PK model example. |
| [annotation](cases/annotation) | Annotation of components in MM model. |
| [time-switcher](cases/time-switcher) | Model describes one-reaction model with periodic event. |
| ~~[cond-switcher](cases/cond-switcher)~~ | Event with conditional switch |
| ~~[core units](cases/core-units)~~ | using core units |
| ~~[qsp units](cases/qsp-units)~~ | using qsp-units module |
| ~~[modules](cases/modules)~~ | Combining different modules to single platfrom. |
| ~~[namespaces](cases/several)~~ | Using namespaces to write several models in one platforms |
| ~~[auc](cases/auc)~~ | Using Process to add ODEs |
| | |
29 changes: 29 additions & 0 deletions cases/annotation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Annotation

Annotation of components in Michaelis-Menten model.

```Heta
include ./qsp-units.heta
Vmax @Const = 0.1;
Km @Const = 2.5;
'''Note for the Default compartment'''
default_comp @Compartment 'Default compartment' { units: L };
default_comp .= 1;
S @Species 'substrate' { compartment: default_comp, units: uM };
P @Species 'product' { compartment: default_comp, units: uM };
''' Transformation of __substate__ to __product__ '''
r1 @Reaction 'Michaelis-Menten reaction' {
actors: S -> P,
units: umole/min
};
r1 := Vmax*S/(Km+S)*default_comp; // S is used here but assigned below
S .= 10; // S should be initialialized after creation
P .= 0;
mm_sbml @SBMLExport 'Exported mm model' { filepath: sbml };
```
2 changes: 1 addition & 1 deletion cases/one-compartment.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ r_abs := kabs * a0;
r_el := kel * c1 * Vd;
// this creates SBML formatted file
sbml @SBMLExport;
sbml @SBMLExport { filepath: sbml_output };
```
40 changes: 0 additions & 40 deletions cases/syntax.heta

This file was deleted.

37 changes: 37 additions & 0 deletions cases/time-switcher.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Time switcher

Model describes one-reaction model with periodic event.

```Heta
/*
Simple model with one reaction
*/
comp1 @Compartment .= 1;
A @Species { compartment: comp1 };
B @Species { compartment: comp1 };
r1 @Reaction { actors: A => 2B };
// initialization
A .= 10;
B .= 0;
// rules
r1 := k1*A*comp1;
// constants
k1 @Const = 1.2e-1;
// This part describes periodic event
// starting from 0 and then each 12 time units infinitely
evt1 @TimeSwitcher {
start: 0,
period: 12
};
/*
event assignment
*/
// addition of 10 to A concentration (not amount)
A [evt1]= A + 10;
// exports
sbml1 @SBMLExport { filepath: sbml1_export };
```
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
- Rename UnitDefinition to UnitDef class
- Add class _Size
- Clarify namespaces usage: `#setNS`, `#importNS`, `#import`. Explain `abstact` namespace.
- Extend classes description
- add cases
- Multiple text corrections

## 0.2.4
Expand Down
14 changes: 7 additions & 7 deletions compilation.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

Heta code is transformed by the following steps:

1. **Parsing.** **Heta language code** from text files is translated to the collection of [Modules](modules).
1. **Parsing.** **Heta modules** are translated to the collection of components.

Parsing starts from single *index* file (it can have any name), then other files are added recursively based on `#import` actions. Each file represents one module.
Parsing starts from single *index* file (it can have any name), then other files are added recursively based on `#include` actions. Each file represents one module.

The errors which happen at the stage will be of types: `FileSystemError`, `ParsingError`.

1. **Files integration.** Collection of heta files are combined into a single structure **queue** which is sequence of queries for platform storage based on [include](include). The include must not have circular references.
1. **Files integration.** Collection of Heta modules are combined into a single structure **queue** which is sequence of queries for platform storage based on [include](include) statement. The include must not have circular references.

The errors which happen at the stage will be of type `ModuleError`.

Expand All @@ -18,9 +18,9 @@ Heta code is transformed by the following steps:

1. **Binding.** Binding Heta components based on internal cross references. Checking references. Checking required properties.

The errors which happen at the stage will be of types: `BindingError`, `ValidationError`.
The errors which happen at the stage will be of types: `BindingError`.

1. **Other steps.** The next steps depends on components in storage and setting of Heta-based builder. For example it is expected that `_Export` classes induce the creation of code for export.
1. **Other steps.** The next steps depends on components in storage and setting of **Heta compiler**. For example it is expected that `_Export` classes induce the creation of code for export.

The errors which happen at the stage will be of types: `ExportError`.

Expand Down Expand Up @@ -99,7 +99,7 @@ sbml @SBMLExport;
]
```

**Structure 4. Declarative Heta**
**Structure 4. Declarative Heta structure**

```json
{
Expand All @@ -120,7 +120,7 @@ sbml @SBMLExport;
```json
{
...
":s1": {
"s1": {
"class": "Species",
"compartment": "comp0",
"title": "Species number one",
Expand Down
13 changes: 12 additions & 1 deletion math.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Math expressions

All [@Record](./classes#record) instances includes `assimptions` property which is set of assignments for different cases: initial assignment `start_`, ode assignment `ode_` and any number of switcher assignments.
All [@Record](./classes#record) instances include `assimptions` property which is set of assignments for different cases: initial assignment `start_`, rule assignment `ode_` and any number of switcher assignments.

The right hand side (RHS) of assignments is string of specific format [MathExpr](./classes#mathexpr).

Expand All @@ -10,6 +10,17 @@ Expression may include: numbers, identifiers, operators, functions, parentheses.

All numbers in "math expression" are double. You can use any form of number: `0.001`, `1e-3`, `1E-3`, `1.0e-3`, etc.

The another possible values of double are:
- `Infinity` which means infinite value.
- `-Infinity` which negative infinit value.
- `NaN` which means infinite or negative infinite, i.e. `0/0`.

## Pre defined constants

There is a set of identifiers which can be used in `MathExpr` but they are not components of platform.
- `e` is the Euler's number, i.e. `exp(0)`.
- `pi` is π=3.141592... number.

## Identifiers

The identifiers inside expressions should be interpreted as references to the values of `Record` or `Const` instances.
Expand Down
8 changes: 8 additions & 0 deletions syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

The Heta code represents the sequence of statements which create and modify elements in modeling platform. The parsing and interpretation of the code results in creation of static (database-like) structure representing the modeling system. See [compilation](./compilation). There are many ways to write the same modeling system using Heta code. A developer has flexibility to make his code nice and readable.

## Reserved words

There is a list of words which cannot be used as identifiers because the are reserved for statements or specific object names.

`nameless`,
`NaN`, `Infinity`, `e`, `E`, `pi`, `PI`,
`include`, `block`, `namespace`, `abstract`, `concrete`, `begin`, `end`

## Base statements

1. Base statements are divided by semicolons. The line breakes do not matter but can be used for code decoration.
Expand Down

0 comments on commit 016d819

Please sign in to comment.