-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
2,455 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
build.log | ||
dist | ||
node_modules | ||
package-lock.json | ||
package.json | ||
draft | ||
|
||
training.jsonl | ||
validation.jsonl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
Create reaction in Heta notation with one substrate and one product. | ||
*/ | ||
|
||
// reaction of s1 degradation | ||
r1 @Reaction {actors: s1 => p1} := k1 * s1 * comp1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
Add all necessary components: species, compartments, and constants. | ||
*/ | ||
// index.heta | ||
|
||
// reaction of s1 degradation | ||
r1 @Reaction {actors: s1 => p1} := k1 * s1 * comp1; | ||
|
||
// species | ||
s1 @Species {compartment: comp1} .= 10; | ||
p1 @Species {compartment: comp1} .= 0; | ||
|
||
// compartment of size 1 | ||
comp1 @Compartment .= 1; | ||
|
||
// constant of reaction | ||
k1 @Const = 0.01; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
Create reaction with no substrate and one product in Heta. | ||
*/ | ||
|
||
// reactions | ||
r1 @Reaction {actors: => p1} := k1 * comp1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
Add necessary species | ||
*/ | ||
|
||
// reactions | ||
r1 @Reaction {actors: => p1} := k1 * comp1; | ||
|
||
// species | ||
p1 @Species {compartment: comp1} .= 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
Create mass-action reaction in Heta notation by the stoicheometry: s1 => p1. | ||
*/ | ||
|
||
// reactions | ||
r1 @Reaction {actors: s1 => p1} := k1 * s1 * comp1; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
Create mass-action reaction in Heta notation by the stoicheometry: 2s1 => p1. | ||
*/ | ||
|
||
// reactions | ||
r1 @Reaction {actors: 2s1 => p1} := k1 * s1^2 * comp1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* | ||
Make reaction reversible | ||
*/ | ||
|
||
// reactions | ||
r1 @Reaction {actors: 2s1 <=> p1} := (k1 * s1^2 - k2 * p1) * comp2; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
Create mass-action reversible reaction in Heta notation by the stoicheometry: 2s1 => 2p1. | ||
*/ | ||
// index.heta | ||
|
||
// reactions | ||
r1 @Reaction {actors: 2s1 => p1} := (k1 * s1^2 - k2 * p1^2) * comp1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/* | ||
Create mass-action reversible reaction in Heta notation by the stoicheometry: s1 + 2s2 + 3s3 <=> p1 + 2p2 + 3p3. | ||
*/ | ||
// index.heta | ||
|
||
// reactions | ||
r1 @Reaction {actors: s1 + 2s2 + 3s3 <=> p1 + 2p2 + 3p3} := (k1 * s1 * s2^2 * s3^3 - k2 * p1 * p2^2 * p3^3) * comp1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
Create complete Heta model with two reactions with stoicheometry: A + 2B => C and C => D. | ||
*/ | ||
// index.heta | ||
|
||
// reactions | ||
r1 @Reaction {actors: A + 2B => C} := k1 * A * B^2 * comp1; | ||
r2 @Reaction {actors: C => D} := k2 * C * comp1; | ||
|
||
// species | ||
A @Species {compartment: comp1} .= 1; | ||
B @Species {compartment: comp1} .= 10; | ||
C @Species {compartment: comp1} .= 0; | ||
D @Species {compartment: comp1} .= 0; | ||
|
||
// compartments | ||
comp1 @Compartment .= 1; | ||
|
||
// parameters | ||
k1 @Const = 0.01; | ||
k2 @Const = 0.001; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const { globSync } = require('glob'); | ||
const systemPrompt = ` | ||
You will be provided with description of dynamic model, and your task is to create model in Heta format. | ||
Try not to create supplementary text, only model and comments. | ||
`; | ||
|
||
const directoryPath = './cases'; | ||
const validationPath = './validation'; | ||
const pattern = 'index*.heta'; | ||
|
||
const directories = fs.readdirSync(directoryPath, { withFileTypes: true }) | ||
.filter((dirent) => dirent.isDirectory()) | ||
.map((dirent) => dirent.name); | ||
|
||
let lines = directories.map((directory) => { | ||
const files = globSync(pattern, { cwd: path.join(directoryPath, directory) }).sort(); | ||
let messages = [{role: 'system', content: systemPrompt}]; | ||
|
||
files.forEach((file) => { | ||
const filePath = path.join(directoryPath, directory, file); | ||
const content = fs.readFileSync(filePath, 'utf8'); | ||
let matches = content.match(/\/\*([\s\S]*)\*\/([\s\S]*)/); | ||
let prompt = matches[1].replace(/\s+/g, ' '); | ||
let completion = matches[2].replace(/^[\s]+/, '').replace(/\r/g, ''); | ||
messages.push({role: 'user', content: prompt}); | ||
messages.push({role: 'assistant', content: completion}); | ||
}); | ||
|
||
return JSON.stringify({messages}); | ||
}).join('\n');; | ||
|
||
fs.writeFileSync('training.jsonl', lines); |
Oops, something went wrong.