Skip to content

Commit

Permalink
rewrite heta compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
metelkin committed May 29, 2024
1 parent 1cc0bb4 commit 07f17fa
Show file tree
Hide file tree
Showing 13 changed files with 396 additions and 231 deletions.
File renamed without changes.
73 changes: 0 additions & 73 deletions .github/workflows/build-and-simulate.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/convert-to-heta.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: convert to Heta

on:
workflow_dispatch: {}
push:
branches: [ master, '*-result' ]

jobs:
convert-to-heta:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
persist-credentials: false

- name: Install Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16

- name: Installations
run: |
npm i -g heta-compiler
heta -v
- name: Create file structure
run: |
bash ./bash/make-description.sh
- name: copy static
run: |
cp -r static/* result/
- name: Commit changes to result branch
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
BRANCH: result # The branch the action should deploy to.
FOLDER: result # The folder the action should deploy.
CLEAN: false
File renamed without changes.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@

/cases/semantic/julia
/cases/semantic/json.json

/results
/result
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2020 Ivan Borisov
Copyright (c) 2024 Heta project

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
# SBML Heta Cases

The package is designed to test Simulation Software against [SBML Test Suite](https://github.com/sbmlteam/sbml-test-suite) cases in Julia.

See results here <https://insysbio.github.io/sbml-heta-cases/>
The package is designed to test different aspects of Heta formats on [SBML Test Suite](https://github.com/sbmlteam/sbml-test-suite).

[![Heta project](https://img.shields.io/badge/%CD%B1-Heta_project-blue)](https://hetalang.github.io/)
[![Copy visualization](https://github.com/insysbio/sbml-heta-cases/workflows/Copy%20visualization/badge.svg)](https://insysbio.github.io/sbml-heta-cases/)
![Build and simulate](https://github.com/insysbio/sbml-heta-cases/workflows/Build%20and%20simulate/badge.svg)
[![Build and simulate](https://github.com/insysbio/sbml-heta-cases/actions/workflows/convert-to-heta.yml/badge.svg)](https://github.com/insysbio/sbml-heta-cases/actions/workflows/convert-to-heta.yml)
[![GitHub issues](https://img.shields.io/github/issues/insysbio/sbml-heta-cases.svg)](https://GitHub.com/insysbio/sbml-heta-cases/issues/)
[![GitHub license](https://img.shields.io/github/license/insysbio/sbml-heta-cases.svg)](https://github.com/insysbio/sbml-heta-cases/blob/master/LICENSE)

## Overview

SBML Heta Cases contains:
1. Conversion of cases into Heta code and JSON format
2. Load models in SBML format and make simulations in

## File content

- [SBML Test Suite](https://github.com/sbmlteam/sbml-test-suite) cases in `cases_path = "./cases/semantic"`. The original Matlab models were converted to Julia with Heta compiler. Julia code for each model is stored in `./cases/semantic/<case_num>/julia`, while models' settings and tags are stored in `cases_db = "./cases.json"`.
- API (documented in the *Usage* section) to upload `cases_db`, run simulations, save results to `output_path = "./cases/output"` and update status in `results_db = "./results.json"`. A simulation can end with one of the three status: `success` indicates the output file has passed [tolerance test](https://github.com/sbmlteam/sbml-test-suite/blob/master/cases/semantic/README.md#tolerances-and-errors-for-timecourse-tests), `failure` signifies that tolerance test for a given simulation was not passed and `error` stands for any error during the simulation (error message is printed to the `message` field in `results_db`).

Currently SBML Heta Cases suport only one `SimSolver` Simulation Backend.

## Usage

SBML Heta Cases exports the following functions:
Expand Down
9 changes: 9 additions & 0 deletions bash/index.heta
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#defineUnit volume { units: metre^3 };
#defineUnit area { units: metre^2 };
#defineUnit length { units: metre };
#defineUnit substance { units: (1e-6 mole) };

#include { source: ./model-sbml-l2v5.xml, type: sbml };

#export { format: HetaCode };
#export { format: JSON };
54 changes: 54 additions & 0 deletions bash/make-description.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#!/bin/bash

echo Create of file structure
mkdir -p result
rm -rf result/*

echo Collect compiler information
echo "{" > result/summary.json
hetaCompilerVersion=$(heta --version)
echo " \"hetaCompilerVersion\": \"$hetaCompilerVersion\"," >> result/summary.json
started=$(date)
echo " \"started\": \"$started\"," >> result/summary.json
dirs=$(find ./cases/semantic/ -type d -regex '.*/[0-9]+' -print0 | xargs -0 -n1 basename ) # find all directories with numbers
#dirs=$(find ./cases/semantic/ -type f -name "*-sbml-l2v5.xml" -exec dirname {} \; | xargs -n1 basename )
totalCasesCount=$(echo "$dirs" | wc -l)
echo " \"totalCasesCount\": \"$totalCasesCount\"," >> result/summary.json

echo Copy files from cases and build models
echo " \"cases\": [" >> result/summary.json

counter=0
for dir in $dirs; do
counter=$((counter+1))
[ $counter==$totalCasesCount ] && delimiter="" || delimiter=","

mkdir -p result/$dir
cp bash/index.heta result/$dir/index.heta

# Extract line starting from "synopsis" until the end of line
synopsis=$(sed -n '/(\*/,/*)/p' cases/semantic/$dir/$dir-model.m | sed '1d;$d')
echo "$synopsis" > result/$dir/synopsis.txt

cp cases/semantic/$dir/$dir-sbml-l2v5.xml result/$dir/model-sbml-l2v5.xml > /dev/null 2>&1
if [ $? -ne 0 ]; then
echo " {\"id\": \"$dir\", \"retCode\": 9}$delimiter" >> result/summary.json
echo "$dir has no SBML file"
continue
fi

# supress logs
heta build --skip-updates --dist-dir . --log-mode error result/$dir > /dev/null 2>&1
retCode=$(echo $?)
echo " {\"id\": \"$dir\", \"retCode\": $retCode}$delimiter" >> result/summary.json
echo "$dir finished with $retCode"
done

echo " ]," >> result/summary.json
finished=$(date)
echo " \"finished\": \"$finished\"" >> result/summary.json
echo "}" >> result/summary.json

# Save list of directories in JSON file
# sudo apt-get install jq
# echo "$dirs" | jq -R . | jq -s . > result/dirs.json
3 changes: 2 additions & 1 deletion static/config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
window.config = {
results: './results.json',
figPath: './cases/output'
figPath: './cases/output',
summaryPath: '/result/summary.json',
};
Loading

0 comments on commit 07f17fa

Please sign in to comment.