-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.fsx
More file actions
70 lines (56 loc) · 1.73 KB
/
script.fsx
File metadata and controls
70 lines (56 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
(*
Date: XX.06.2023
Author:
*)
#if INTERACTIVE
// A relative path to MolecularProgrammingLib.dll
#r @"../bin/Debug/net6.0/MolecularProgrammingLib.dll"
#r @"../bin/Debug/net6.0/DrawingTreesLib.dll"
#r "nuget: FParsec"
#r "nuget: FsCheck"
#r "nuget: Plotly.NET"
#endif
open CrnTypes
open CrnString
open CrnParser
open CrnInterpreter
open CrnSimulator
open CrnExamples
open CrnGenerator
open CrnCompiler
open CrnTypeChecker
open CrnProperties
open CrnDrawTree
open FsCheck
printfn "Molecular Programming Library\n"
// Choose example CRN
let randIndex = System.Random().Next(examples.Length)
let example = examples.[randIndex]
printfn "Example CRN:\n%s\n" example
// Parse a CRN from a string
let exampleCrn = parse example
printfn "Parsed CRN: %s\n" (crnToString exampleCrn)
// Draw abstract syntax tree
let exampleSyntaxTree = crnToTree exampleCrn
printfn "Syntax tree:\n%O\n" exampleSyntaxTree
// Check that CRN is well-formed and that the dependency order property holds
assert (isWellFormedCrn false exampleCrn)
assert (dependencyOrderProp exampleCrn)
// Visualize CRN concentrations
let states = interpreter exampleCrn
let speciesNames =
State.getAllSpecies (Seq.head states) |> List.map (fun (Species name) -> name)
printfn "Plotting interpreter output...\n"
interPlot 200 exampleCrn speciesNames
// Compile CRN to reactions
let reactions, concs = compile 1.0 exampleCrn
reactionsPrettyPrint reactions
// Simulate reactions and plot results
printfn "\nPlotting simulator output...\n"
simPlot 1.0 0.01 10 exampleCrn speciesNames
// Validate compiled and interpreted sequences
validate 0.1 exampleCrn
// Property-based testing on generated CRNs
CrnGenerator.initialize ()
let _ = Check.Quick isWellFormedCrn
let _ = Check.Quick dependencyOrderProp