Adding ClassicGEC and FSBOL wrapper
This commit is contained in:
Родитель
8ab96b6df6
Коммит
4545f9489f
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<PublishChromeDriver>true</PublishChromeDriver>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="..\ClassicGECIntegrationTests\Tests.fs" Link="Tests.fs" />
|
||||
<Compile Include="Program.fs" />
|
||||
<None Include="paket.references" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\CRNEngine\CRNIntegrationTestLib\CRNIntegrationTestLib.fsproj" />
|
||||
<ProjectReference Include="..\ClassicGECHTML5\ClassicGECHTML5.csproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\.paket\Paket.Restore.targets" />
|
||||
|
||||
</Project>
|
|
@ -0,0 +1,35 @@
|
|||
module Program
|
||||
|
||||
open System
|
||||
open System.Diagnostics
|
||||
open Expecto
|
||||
open canopy
|
||||
open canopy.types
|
||||
open canopy.classic
|
||||
open Microsoft.Research.CRNIntegrationTestLib
|
||||
|
||||
[<EntryPoint>]
|
||||
let main args =
|
||||
let (dir,groups,timeout,args) = Program.separateArgsDist args
|
||||
|
||||
// Start a web server
|
||||
printfn "Starting 'dotnet serve' on %s" dir
|
||||
let serverProcess = Process.Start("dotnet", sprintf "serve -d %s" dir)
|
||||
printfn "'dotnet serve' started, PID = %d" serverProcess.Id
|
||||
|
||||
let result =
|
||||
try
|
||||
let url = "http://localhost:8080"
|
||||
BrowserSetup.configureCanopy timeout
|
||||
let tests = Tests.tests groups Tests.Worker url
|
||||
Program.run args tests
|
||||
finally
|
||||
printfn "Shutting down 'dotnet serve'..."
|
||||
try serverProcess.Kill() with _ -> ()
|
||||
canopy.classic.quit()
|
||||
|
||||
if System.Diagnostics.Debugger.IsAttached then
|
||||
printf "Press any key to exit"
|
||||
System.Console.ReadKey() |> ignore
|
||||
|
||||
result
|
|
@ -0,0 +1,9 @@
|
|||
group DOTNETCORE
|
||||
|
||||
Canopy
|
||||
Expecto
|
||||
FSharp.Core
|
||||
Selenium.WebDriver
|
||||
Selenium.WebDriver.ChromeDriver
|
||||
Selenium.WebDriver.GeckoDriver.Win64
|
||||
Selenium.WebDriver.MicrosoftWebDriver
|
|
@ -0,0 +1,103 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
|
||||
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.7.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="Dynamitey" publicKeyToken="cbf53ea3aeb972c6" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="2.0.10.189" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="Microsoft.Extensions.Primitives" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="3.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="Microsoft.Net.Http.Headers" publicKeyToken="adb9793829ddae60" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="2.2.8.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="12.0.0.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.3.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Collections.Concurrent" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.13.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Configuration.ConfigurationManager" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.IO.FileSystem.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Linq" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.1.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.1.1" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.1.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.5.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Runtime.Numerics" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Security.AccessControl" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.1.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Security.Cryptography.Primitives" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.1.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Security.Principal.Windows" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.1.2.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Text.Encodings.Web" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.4.0" />
|
||||
</dependentAssembly>
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="System.Threading" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.0.12.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding></runtime></configuration>
|
|
@ -0,0 +1,41 @@
|
|||
namespace ClassicGECCLI.AssemblyInfo
|
||||
|
||||
open System.Reflection
|
||||
open System.Runtime.CompilerServices
|
||||
open System.Runtime.InteropServices
|
||||
|
||||
// Le informazioni generali relative a un assembly sono controllate dal seguente
|
||||
// set di attributi. Modificare i valori di questi attributi per modificare le informazioni
|
||||
// associate a un assembly.
|
||||
[<assembly: AssemblyTitle("ClassicGECCLI")>]
|
||||
[<assembly: AssemblyDescription("")>]
|
||||
[<assembly: AssemblyConfiguration("")>]
|
||||
[<assembly: AssemblyCompany("")>]
|
||||
[<assembly: AssemblyProduct("ClassicGECCLI")>]
|
||||
[<assembly: AssemblyCopyright("Copyright © 2017")>]
|
||||
[<assembly: AssemblyTrademark("")>]
|
||||
[<assembly: AssemblyCulture("")>]
|
||||
|
||||
// Se si imposta ComVisible su false, i tipi in questo assembly non saranno visibili
|
||||
// ai componenti COM. Se è necessario accedere a un tipo in questo assembly da
|
||||
// COM, impostare su true l'attributo ComVisible per tale tipo.
|
||||
[<assembly: ComVisible(false)>]
|
||||
|
||||
// Se il progetto viene esposto a COM, il seguente GUID verrà utilizzato come ID della libreria dei tipi
|
||||
[<assembly: Guid("7b81a30f-f8a4-435d-a53a-9634c7a82686")>]
|
||||
|
||||
// Le informazioni sulla versione di un assembly sono costituite dai quattro valori seguenti:
|
||||
//
|
||||
// Versione principale
|
||||
// Versione secondaria
|
||||
// Numero di build
|
||||
// Revisione
|
||||
//
|
||||
// È possibile specificare tutti i valori oppure impostare valori predefiniti per i numeri relativi alla revisione e alla build
|
||||
// utilizzando l'asterisco (*) come illustrato di seguito:
|
||||
// [<assembly: AssemblyVersion("1.0.*")>]
|
||||
[<assembly: AssemblyVersion("1.0.0.0")>]
|
||||
[<assembly: AssemblyFileVersion("1.0.0.0")>]
|
||||
|
||||
do
|
||||
()
|
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Platforms>x64</Platforms>
|
||||
<HighEntropyVA>True</HighEntropyVA>
|
||||
<ServerGarbageCollection>true</ServerGarbageCollection>
|
||||
<AssemblyName>ClassicGEC</AssemblyName>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.fs" />
|
||||
<None Include="paket.references" />
|
||||
<Compile Include="Program.fs" />
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\CRNEngine\CliLibrary\CliLibrary.fsproj" />
|
||||
<ProjectReference Include="..\ClassicGECDotNet\ClassicGECDotNet.fsproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Oslo.FSharp">
|
||||
<HintPath>..\..\Lib\Oslo.FSharp\Oslo.FSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<Target Name="Copying Sundials" AfterTargets="AfterBuild" Condition="$(OS) == Windows_NT">
|
||||
<Exec Command="xcopy /y /q /d "$(SolutionDir)x64\$(Configuration)\SundialsSolver15.dll" "$(OutDir)"" />
|
||||
<Exec Command="xcopy /y /q /d "$(SolutionDir)x64\$(Configuration)\SundialsSolver15.pdb" "$(OutDir)"" />
|
||||
</Target>
|
||||
<Import Project="..\..\.paket\Paket.Restore.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,145 @@
|
|||
module Microsoft.Research.GEC.Classic
|
||||
|
||||
open Microsoft.Research.CliLibrary
|
||||
open Microsoft.Research.CRNEngine
|
||||
open Argu
|
||||
|
||||
type GECArgs =
|
||||
| Parts of string
|
||||
| Reactions of string
|
||||
| DE
|
||||
| MG of int
|
||||
| CE
|
||||
|
||||
with
|
||||
interface IArgParserTemplate with
|
||||
member s.Usage =
|
||||
match s with
|
||||
| Parts _ -> "Parts database"
|
||||
| Reactions _ -> "Reactions database"
|
||||
| DE -> "Enumerate possible constructs from the given parts and constraints."
|
||||
| MG _ -> "Generate CRN model for the nth device enumerated by GEC."
|
||||
| CE -> "Export the generated CRN model into an SVG image."
|
||||
|
||||
|
||||
let printSVG crn =
|
||||
printf """<svg xmlns="http://www.w3.org/2000/svg" height="100%%" width="100%%">
|
||||
<style>
|
||||
.crnsvgvalue {
|
||||
text-anchor: end;
|
||||
stroke: black;
|
||||
fill: black;
|
||||
stroke-width: 0;
|
||||
font-family: Verdana, Arial, sans-serif;
|
||||
font-size: 15px;
|
||||
}
|
||||
.crnsvgrate {
|
||||
text-anchor: middle;
|
||||
stroke: black;
|
||||
fill: black;
|
||||
stroke-width: 0;
|
||||
font-family: Verdana, Arial, sans-serif;
|
||||
font-size: 15px;
|
||||
}
|
||||
path.crnsvgrate { stroke-width: 2; fill: none; stroke-linejoin: round }
|
||||
.crnsvgplus { text-anchor: start }
|
||||
.crnsvgspeciestext { text-anchor: start }
|
||||
</style>
|
||||
|
||||
"""
|
||||
|
||||
crn
|
||||
|> Crn.reactions_to_svg
|
||||
|> Svg.to_element_string
|
||||
|> printfn "%s"
|
||||
|
||||
printfn "<text>"
|
||||
crn.all_species ()
|
||||
|> List.iter (fun s -> match crn.attributes.TryFind s.name with
|
||||
| None -> ()
|
||||
| Some a -> printfn "<tspan x=\"400\" dy=\"1.2em\" font-size=\"1.3em\">%s = %s</tspan>" a.name (System.Web.HttpUtility.HtmlEncode a.structure |> String.filter(fun c -> c <> '\"')))
|
||||
printfn "</text>"
|
||||
printfn "</svg>"
|
||||
|
||||
|
||||
[<EntryPoint>]
|
||||
let main args =
|
||||
// Enforce invariant culture (prevents issues with decimal separators on international systems).
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture <- System.Globalization.CultureInfo.InvariantCulture
|
||||
|
||||
// Start by extracting the parts and reactions databases from the argument list
|
||||
let gec_parser = ArgumentParser.Create(programName = "ClassicGEC")
|
||||
let gec_results = gec_parser.Parse(args, ignoreUnrecognized=true)
|
||||
let dbParts =
|
||||
match gec_results.TryGetResult Parts with
|
||||
| Some f -> System.IO.File.ReadAllText f
|
||||
| None -> Databases.defaultParts
|
||||
let dbReactions =
|
||||
match gec_results.TryGetResult Reactions with
|
||||
| Some f -> System.IO.File.ReadAllText f
|
||||
| None -> Databases.defaultReactions
|
||||
|
||||
// Here we assume that we are only interested in the first solution, equivalent to how the GUI handles inference from a GEC program
|
||||
let parser code =
|
||||
match Main.parse code with
|
||||
| Program.t.ClassicGec _ ->
|
||||
let solveResult = GECEngine.solveGEC (ref false) code dbParts dbReactions
|
||||
let firstSolution = GECEngine.getCrnAssignment solveResult.graph solveResult.solution 0
|
||||
firstSolution.model
|
||||
| Program.t.LogicGec bundle ->
|
||||
let cle = LogicGEC.cle
|
||||
if gec_results.Contains DE
|
||||
// generate all models
|
||||
then
|
||||
LogicGEC.enumerateDevices cle bundle.rules bundle.program
|
||||
|> List.map (fun p -> p |> List.map (LogicGEC.Instruction.ToString cle) |> String.concat " | ")
|
||||
|> List.iteri (fun i s -> printfn "Solution %i: %s" i s)
|
||||
|
||||
// return empty graph
|
||||
{ task = None
|
||||
nodes = Map.empty
|
||||
edges = Map.empty
|
||||
expanded =false }
|
||||
|
||||
elif gec_results.Contains MG
|
||||
then
|
||||
let i = gec_results.GetResult MG
|
||||
|
||||
// get ith model
|
||||
let solutions = LogicGEC.enumerateDevices cle bundle.rules bundle.program
|
||||
let max = solutions.Length
|
||||
if 0 <= i && i < max
|
||||
then
|
||||
// generate ith model
|
||||
let sol = solutions.Item i
|
||||
let crn = LogicGEC.generateCRN cle bundle.rules sol
|
||||
|
||||
// return IGraph with a single node
|
||||
let crnSettings = Crn_settings.defaults.from_default_directive_list bundle.settings.directives
|
||||
|
||||
if gec_results.Contains CE
|
||||
then printSVG crn
|
||||
else
|
||||
printf "%s" (crn.to_string ())
|
||||
printfn "\n"
|
||||
crn.all_species ()
|
||||
|> List.iter (fun s -> match crn.attributes.TryFind s.name with
|
||||
| None -> ()
|
||||
| Some a -> printfn "%s = %s" a.name (a.structure |> String.filter (fun c -> c <> '"')))
|
||||
{ task = None
|
||||
nodes = Map.ofList [sprintf "Model_%i" i, Model.create crnSettings [crn]]
|
||||
edges = Map.empty
|
||||
expanded =false }
|
||||
else failwithf "Input index %i is out of bound, the total number of solutions found is %i" i max
|
||||
else failwith "Please specify whether to do construct assembly or model generation for the given Logic GEC program."
|
||||
// Call generic CLI program
|
||||
try
|
||||
let ret = Program.main parser args
|
||||
ret
|
||||
with e ->
|
||||
match e with
|
||||
| :? Parser.Exception as e -> match e.Errors with
|
||||
| [| {row=r; column=c; text=t} |] -> printfn "Parsing error at %i, %i: expecting %s" r c t
|
||||
-1
|
||||
| _ -> raise e
|
||||
| _ -> raise e
|
|
@ -0,0 +1,8 @@
|
|||
group DOTNETCORE
|
||||
|
||||
#FsCheck
|
||||
#FsUnit.xUnit
|
||||
#xunit.core
|
||||
#xunit.runner.console
|
||||
#xunit.runner.visualstudio
|
||||
FSharp.Core
|
|
@ -0,0 +1,118 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30225.117
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CRNEngineDotNet", "..\CRNEngine\CRNEngineDotNet\CRNEngineDotNet.fsproj", "{AE45211A-A65D-4827-A1F9-07A20EB0F154}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Filzbach.FSharp.Portable", "..\Filzbach.FSharp\Filzbach.FSharp.Portable.fsproj", "{2849368F-AC32-4D1E-B6D6-9C52261A5F2D}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ParserCombinators", "..\ParserCombinators\ParserCombinators\ParserCombinators.fsproj", "{DD8FEC26-6D1D-4642-A706-04070B6D5494}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SundialsSolver15", "..\SundialsSolver\SundialsSolver15\SundialsSolver15.vcxproj", "{866880DC-BF1E-4C12-8238-72E7EFF44AFB}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ReactionDiffusion", "..\PDESolvers\ReactionDiffusion\ReactionDiffusion.fsproj", "{529BEDB7-C73A-4A77-BFD9-1628D75C321B}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CRNEngineTests", "..\CRNEngine\CRNEngineTests\CRNEngineTests.fsproj", "{8E0427CB-DD8F-46BE-A5BC-C02CF55F152D}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CliLibrary", "..\CRNEngine\CliLibrary\CliLibrary.fsproj", "{EEF843A3-43F8-4E6B-AB7F-9ADE3A5AF022}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ClassicGECDotNet", "ClassicGECDotNet\ClassicGECDotNet.fsproj", "{74DDCD31-9968-4B9B-8E5D-F07EDB7CE332}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ClassicGECCLI", "ClassicGECCLI\ClassicGECCLI.fsproj", "{7B81A30F-F8A4-435D-A53A-9634C7A82686}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{866880DC-BF1E-4C12-8238-72E7EFF44AFB} = {866880DC-BF1E-4C12-8238-72E7EFF44AFB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ClassicGECDotNetTests", "ClassicGECDotNetTests\ClassicGECDotNetTests.fsproj", "{EEBFA61A-4235-4C7C-B801-D44958F9D21C}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSBOLWrapper", "..\FSBOLWrapper\FSBOLWrapper\FSBOLWrapper.fsproj", "{7D875457-2116-4222-89E0-A048792E1213}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "MomentClosure", "..\MomentClosure\MomentClosure\MomentClosure.fsproj", "{40A82B6F-9447-4767-BD5B-8D870D3FACFF}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CRNEngineCloudLib", "..\CRNEngine\CRNEngineCloudLib\CRNEngineCloudLib.fsproj", "{B0C5BB1E-CC0C-4D9E-A56A-82891A09653E}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ClassicGECRunAllExamples", "ClassicGECRunAllExamples\ClassicGECRunAllExamples.fsproj", "{B9B04586-11D5-466C-8288-1BC62FC3C382}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ClassicGECTests", "ClassicGECTests\ClassicGECTests.fsproj", "{5B3B81C7-5B7C-460D-B109-5E063133C0AD}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "RulesDSD", "..\RulesDSD\RulesDSD\RulesDSD.fsproj", "{22DF9340-8F96-4FBE-8001-675E2E55CB54}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AE45211A-A65D-4827-A1F9-07A20EB0F154}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{AE45211A-A65D-4827-A1F9-07A20EB0F154}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{AE45211A-A65D-4827-A1F9-07A20EB0F154}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{AE45211A-A65D-4827-A1F9-07A20EB0F154}.Release|x64.Build.0 = Release|Any CPU
|
||||
{2849368F-AC32-4D1E-B6D6-9C52261A5F2D}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2849368F-AC32-4D1E-B6D6-9C52261A5F2D}.Debug|x64.Build.0 = Debug|x64
|
||||
{2849368F-AC32-4D1E-B6D6-9C52261A5F2D}.Release|x64.ActiveCfg = Release|x64
|
||||
{2849368F-AC32-4D1E-B6D6-9C52261A5F2D}.Release|x64.Build.0 = Release|x64
|
||||
{DD8FEC26-6D1D-4642-A706-04070B6D5494}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{DD8FEC26-6D1D-4642-A706-04070B6D5494}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{DD8FEC26-6D1D-4642-A706-04070B6D5494}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{DD8FEC26-6D1D-4642-A706-04070B6D5494}.Release|x64.Build.0 = Release|Any CPU
|
||||
{866880DC-BF1E-4C12-8238-72E7EFF44AFB}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{866880DC-BF1E-4C12-8238-72E7EFF44AFB}.Debug|x64.Build.0 = Debug|x64
|
||||
{866880DC-BF1E-4C12-8238-72E7EFF44AFB}.Release|x64.ActiveCfg = Release|x64
|
||||
{866880DC-BF1E-4C12-8238-72E7EFF44AFB}.Release|x64.Build.0 = Release|x64
|
||||
{529BEDB7-C73A-4A77-BFD9-1628D75C321B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{529BEDB7-C73A-4A77-BFD9-1628D75C321B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{529BEDB7-C73A-4A77-BFD9-1628D75C321B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{529BEDB7-C73A-4A77-BFD9-1628D75C321B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{8E0427CB-DD8F-46BE-A5BC-C02CF55F152D}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{8E0427CB-DD8F-46BE-A5BC-C02CF55F152D}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{8E0427CB-DD8F-46BE-A5BC-C02CF55F152D}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{8E0427CB-DD8F-46BE-A5BC-C02CF55F152D}.Release|x64.Build.0 = Release|Any CPU
|
||||
{EEF843A3-43F8-4E6B-AB7F-9ADE3A5AF022}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{EEF843A3-43F8-4E6B-AB7F-9ADE3A5AF022}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{EEF843A3-43F8-4E6B-AB7F-9ADE3A5AF022}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{EEF843A3-43F8-4E6B-AB7F-9ADE3A5AF022}.Release|x64.Build.0 = Release|Any CPU
|
||||
{74DDCD31-9968-4B9B-8E5D-F07EDB7CE332}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{74DDCD31-9968-4B9B-8E5D-F07EDB7CE332}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{74DDCD31-9968-4B9B-8E5D-F07EDB7CE332}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{74DDCD31-9968-4B9B-8E5D-F07EDB7CE332}.Release|x64.Build.0 = Release|Any CPU
|
||||
{7B81A30F-F8A4-435D-A53A-9634C7A82686}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{7B81A30F-F8A4-435D-A53A-9634C7A82686}.Debug|x64.Build.0 = Debug|x64
|
||||
{7B81A30F-F8A4-435D-A53A-9634C7A82686}.Release|x64.ActiveCfg = Release|x64
|
||||
{7B81A30F-F8A4-435D-A53A-9634C7A82686}.Release|x64.Build.0 = Release|x64
|
||||
{EEBFA61A-4235-4C7C-B801-D44958F9D21C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{EEBFA61A-4235-4C7C-B801-D44958F9D21C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{EEBFA61A-4235-4C7C-B801-D44958F9D21C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{EEBFA61A-4235-4C7C-B801-D44958F9D21C}.Release|x64.Build.0 = Release|Any CPU
|
||||
{7D875457-2116-4222-89E0-A048792E1213}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{7D875457-2116-4222-89E0-A048792E1213}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{7D875457-2116-4222-89E0-A048792E1213}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{7D875457-2116-4222-89E0-A048792E1213}.Release|x64.Build.0 = Release|Any CPU
|
||||
{40A82B6F-9447-4767-BD5B-8D870D3FACFF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{40A82B6F-9447-4767-BD5B-8D870D3FACFF}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{40A82B6F-9447-4767-BD5B-8D870D3FACFF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{40A82B6F-9447-4767-BD5B-8D870D3FACFF}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B0C5BB1E-CC0C-4D9E-A56A-82891A09653E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{B0C5BB1E-CC0C-4D9E-A56A-82891A09653E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{B0C5BB1E-CC0C-4D9E-A56A-82891A09653E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B0C5BB1E-CC0C-4D9E-A56A-82891A09653E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B9B04586-11D5-466C-8288-1BC62FC3C382}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{B9B04586-11D5-466C-8288-1BC62FC3C382}.Debug|x64.Build.0 = Debug|x64
|
||||
{B9B04586-11D5-466C-8288-1BC62FC3C382}.Release|x64.ActiveCfg = Release|x64
|
||||
{B9B04586-11D5-466C-8288-1BC62FC3C382}.Release|x64.Build.0 = Release|x64
|
||||
{5B3B81C7-5B7C-460D-B109-5E063133C0AD}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{5B3B81C7-5B7C-460D-B109-5E063133C0AD}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{5B3B81C7-5B7C-460D-B109-5E063133C0AD}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{5B3B81C7-5B7C-460D-B109-5E063133C0AD}.Release|x64.Build.0 = Release|Any CPU
|
||||
{22DF9340-8F96-4FBE-8001-675E2E55CB54}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{22DF9340-8F96-4FBE-8001-675E2E55CB54}.Debug|x64.Build.0 = Debug|x64
|
||||
{22DF9340-8F96-4FBE-8001-675E2E55CB54}.Release|x64.ActiveCfg = Release|x64
|
||||
{22DF9340-8F96-4FBE-8001-675E2E55CB54}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {CD1A1B77-DF19-4175-9D30-1B36C117F584}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,41 @@
|
|||
namespace ClassicGECDotNet.AssemblyInfo
|
||||
|
||||
open System.Reflection
|
||||
open System.Runtime.CompilerServices
|
||||
open System.Runtime.InteropServices
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[<assembly: AssemblyTitle("ClassicGECDotNet")>]
|
||||
[<assembly: AssemblyDescription("")>]
|
||||
[<assembly: AssemblyConfiguration("")>]
|
||||
[<assembly: AssemblyCompany("")>]
|
||||
[<assembly: AssemblyProduct("ClassicGECDotNet")>]
|
||||
[<assembly: AssemblyCopyright("Copyright © 2017")>]
|
||||
[<assembly: AssemblyTrademark("")>]
|
||||
[<assembly: AssemblyCulture("")>]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[<assembly: ComVisible(false)>]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[<assembly: Guid("74ddcd31-9968-4b9b-8e5d-f07edb7ce332")>]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [<assembly: AssemblyVersion("1.0.*")>]
|
||||
[<assembly: AssemblyVersion("1.0.0.0")>]
|
||||
[<assembly: AssemblyFileVersion("1.0.0.0")>]
|
||||
|
||||
do
|
||||
()
|
|
@ -0,0 +1,54 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.fs" />
|
||||
<None Include="paket.references" />
|
||||
<Compile Include="logicGEC.fs" />
|
||||
<Compile Include="options.fsi" />
|
||||
<Compile Include="options.fs" />
|
||||
<Compile Include="keywords.fs" />
|
||||
<Compile Include="ast.fs" />
|
||||
<Compile Include="subst.fsi" />
|
||||
<Compile Include="subst.fs" />
|
||||
<Compile Include="gecspecies.fs" />
|
||||
<Compile Include="gecreaction.fsi" />
|
||||
<Compile Include="gecreaction.fs" />
|
||||
<Compile Include="directivesParser.fs" />
|
||||
<Compile Include="settings.fs" />
|
||||
<Compile Include="database.fsi" />
|
||||
<Compile Include="database.fs" />
|
||||
<Compile Include="cssubst.fsi" />
|
||||
<Compile Include="cssubst.fs" />
|
||||
<Compile Include="solver.fsi" />
|
||||
<Compile Include="solver.fs" />
|
||||
<Compile Include="NumUtil.fs" />
|
||||
<Compile Include="trans.fs" />
|
||||
<Compile Include="hypothesis.fs" />
|
||||
<Compile Include="program.fs" />
|
||||
<Compile Include="main.fs" />
|
||||
<Compile Include="transCrn.fs" />
|
||||
<Compile Include="gec.fs" />
|
||||
<Compile Include="Databases.fs" />
|
||||
<Compile Include="jsapi.fs" />
|
||||
<Content Include="app.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\CRNEngine\CRNEngineDotNet\CRNEngineDotNet.fsproj" />
|
||||
<ProjectReference Include="..\..\Filzbach.FSharp\Filzbach.FSharp.Portable.fsproj" />
|
||||
<ProjectReference Include="..\..\FSBOLWrapper\FSBOLWrapper\FSBOLWrapper.fsproj" />
|
||||
<ProjectReference Include="..\..\ParserCombinators\ParserCombinators\ParserCombinators.fsproj" />
|
||||
<ProjectReference Include="..\..\PDESolvers\ReactionDiffusion\ReactionDiffusion.fsproj" />
|
||||
<ProjectReference Include="..\..\RulesDSD\RulesDSD\RulesDSD.fsproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Oslo.FSharp">
|
||||
<HintPath>..\..\Lib\Oslo.FSharp\Oslo.FSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\.paket\Paket.Restore.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,64 @@
|
|||
module Microsoft.Research.GEC.Databases
|
||||
|
||||
let defaultParts = "i723017,pcr,codes(xylR;0.001)
|
||||
i723024, pcr, codes(phzM;0.001)
|
||||
e0040, pcr, codes(gfp;0.01)
|
||||
c0099, pcr, codes(cviR;0.01)
|
||||
i723025, pcr, codes(phzS;0.001)
|
||||
i723028, pcr, codes(pca;0.001)
|
||||
c0051, pcr, codes(cI;0.01)
|
||||
c0040, pcr, codes(tetR;0.01)
|
||||
c0080, pcr, codes(araC;0.01)
|
||||
c0012, pcr, codes(lacI;0.01)
|
||||
cunknown2, pcr, codes(unknown2;0.001)
|
||||
c0061, pcr, codes(luxI;0.01)
|
||||
c0062, pcr, codes(luxR;0.01)
|
||||
c0079, pcr, codes(lasR;0.01)
|
||||
c0078, pcr, codes(lasI;0.01)
|
||||
cunknown3, pcr, codes(ccdB;0.005)
|
||||
cunknown4, pcr, codes(ccdA;0.1)
|
||||
i723020, prom, pos(toluene::xylR;0.001; 0.001; 1.0); con(0.0001)
|
||||
r0051, prom, neg(cI; 1.0; 0.5; 0.00005); con(0.12)
|
||||
r0040, prom, neg(tetR; 1.0; 0.5; 0.00005); con(0.09)
|
||||
runknown1, prom, neg(unknown1; 1.0; 0.005; 0.001); con(0.04)
|
||||
r0080, prom, neg(araC; 1.0; 0.000001; 0.0001); pos(araC::arabinose; 0.001; 0.001; 1.0); con(0.1)
|
||||
r0011, prom, neg(lacI; 1.0; 0.5; 0.00005); con(0.1)
|
||||
r0062, prom, pos(lasR::m3OC12HSL; 1.0; 0.8; 0.1); pos(luxR::m3OC6HSL; 1.0; 0.8; 0.1); con(0.01)
|
||||
r0090, prom, pos(lasR::m3OC12HSL; 1.0; 0.8; 0.1); con(0.01)
|
||||
r0099, prom, pos(cviR::m3OC6HSL; 1.0; 0.8; 0.1); con(0.01)
|
||||
b0034, rbs, rate(0.1)
|
||||
b0015, ter
|
||||
cunknown5, pcr, codes(ccdA2; 10.0)
|
||||
runknown5, prom, con(10.0)
|
||||
j06504, pcr, codes(mCherry; 0.1)
|
||||
prpr, device, components[pr; rbs34; eyfp; ter1; pr; rbs34; ecfp; ter1]
|
||||
drPcat, device, components[pCat; rbs34; luxR; rbs34; lasR; ter1; pLas81; rbs34; eyfp; ter1; plux76; rbs34; ecfp; ter1]
|
||||
drRS100S32, device, components[pTet; rbss100; luxR; ter1; pLac; rbs32; lasR; ter1; pLas81; rbs34; eyfp; ter1; plux76; rbs34; ecfp; ter1]
|
||||
drR33S32, device, components[pTet; rbs33; luxR; ter1; pLac; rbs32; lasR; ter1; pLas81; rbs34; eyfp; ter1; plux76; rbs34; ecfp; ter1]
|
||||
drR33S175, device, components[pTet; rbs33; luxR; ter1; pLac; rbsS175; lasR; ter1; pLas81; rbs34; eyfp; ter1; plux76; rbs34; ecfp; ter1]
|
||||
relayP76LasI, device, components[pLux76; rbs900; lasI; l3s2p21]
|
||||
relayP81LuxI, device, components[pLas81; rbs32; luxI; l3s2p21]
|
||||
pBadYFP, device, components[pBad; rbs34; eyfp; l3s2p21]
|
||||
lactonase, device, components[pBad; rbs34; aiia; l3s2p21]"
|
||||
|
||||
let defaultReactions = "toluene + xylR ->{1.0} toluene::xylR
|
||||
phzM ~ pca ->{1.0} metPCA
|
||||
phzS ~ metPCA ->{1.0} pyo
|
||||
luxR + m3OC6HSL ->{0.5} luxR::m3OC6HSL
|
||||
lasR + m3OC12HSL ->{0.5} lasR::m3OC12HSL
|
||||
cviR + m3OC6HSL ->{0.5} cviR::m3OC6HSL
|
||||
cviR + m3OC12HSL ->{0.5} cviR::m3OC12HSL
|
||||
luxI ~ ->{1.0} m3OC6HSL
|
||||
lasI ~ ->{1.0} m3OC12HSL
|
||||
ccdA ~ ccdB ->{1.0}
|
||||
c[m3OC6HSL] ->{0.5} m3OC6HSL
|
||||
m3OC6HSL ->{0.5} c[m3OC6HSL]
|
||||
c[m3OC12HSL] ->{0.5} m3OC12HSL
|
||||
m3OC12HSL ->{0.5} c[m3OC12HSL]
|
||||
luxR::m3OC6HSL ->{1.0} luxR + m3OC6HSL
|
||||
cviR::m3OC6HSL ->{1.0} cviR + m3OC6HSL
|
||||
cviR::m3OC12HSL ->{1.0} cviR + m3OC12HSL
|
||||
lasR::m3OC12HSL ->{1.0} lasR + m3OC12HSL
|
||||
ccdA2 ~ ccdB ->{0.00001}
|
||||
lacI + iptg ->{1.0} lacI::iptg
|
||||
tetR + aTc ->{1.0} tetR::aTc"
|
|
@ -0,0 +1,24 @@
|
|||
module Microsoft.Research.GEC.NumUtil
|
||||
|
||||
#if JavaScript
|
||||
|
||||
open WebSharper
|
||||
[<Inline "isFinite($0)">]
|
||||
#endif
|
||||
let isNum s = let d = ref 0.0 in (System.Double.TryParse(s, d))
|
||||
|
||||
#if JavaScript
|
||||
[<Inline "parseFloat($0)">]
|
||||
#endif
|
||||
let parse_double s =
|
||||
let d = ref 0.0 in
|
||||
if System.Double.TryParse(s, d)
|
||||
then !d
|
||||
else System.Double.NaN
|
||||
|
||||
[<JavaScript>]
|
||||
let case_double f v s =
|
||||
let d = parse_double s in
|
||||
if System.Double.IsNaN d
|
||||
then v
|
||||
else f d
|
|
@ -0,0 +1,186 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.TransCrn
|
||||
|
||||
open Microsoft.Research.GEC.Trans
|
||||
open Microsoft.Research.CRNEngine
|
||||
open Api
|
||||
|
||||
open Parser
|
||||
|
||||
let separator = "_"
|
||||
|
||||
let spReplace (str:string) =
|
||||
str.Replace("::","_")
|
||||
|
||||
let private newStr = // ref (fun () -> "Fixme")
|
||||
let count = ref 0
|
||||
(fun () -> count := !count + 1; string !count)
|
||||
|
||||
let rec newVar =
|
||||
"sp" + newStr() + "_"
|
||||
|
||||
let indexInitial (initial:Initial<Species,Expression.t<_>>) (str:string)=
|
||||
//let newSpeciesName = newVar + ((spReplace initial.species.name) + separator + (spReplace str))
|
||||
let newSpeciesName = ((spReplace initial.species.name) + separator + (spReplace str))
|
||||
let newSpecies = Species.create(newSpeciesName)
|
||||
let newInitial = {initial with species = newSpecies}
|
||||
newInitial
|
||||
|
||||
let indexReaction (reaction:Reaction<Species,_,_>) (str:string)=
|
||||
let ncatalysts = reaction.catalysts |> Mset.map (fun (x) ->
|
||||
//let newSpName = newVar + ((spReplace x.name) + separator + (spReplace str))
|
||||
let newSpName = ((spReplace x.name) + separator + (spReplace str))
|
||||
Species.create(newSpName))
|
||||
let nreactants = reaction.reactants |> Mset.map (fun (x) ->
|
||||
//let newSpName = newVar + ((spReplace x.name) + separator + (spReplace str))
|
||||
let newSpName = ((spReplace x.name) + separator + (spReplace str))
|
||||
Species.create(newSpName))
|
||||
let nproducts = reaction.products |> Mset.map (fun (x) ->
|
||||
//let newSpName = newVar + ((spReplace x.name) + separator + (spReplace str))
|
||||
let newSpName = ((spReplace x.name) + separator + (spReplace str))
|
||||
Species.create(newSpName))
|
||||
let nreaction = {reaction with catalysts = ncatalysts; reactants = nreactants; products=nproducts}
|
||||
nreaction
|
||||
|
||||
let compInitial (initial:Initial<Species,Expression.t<_>>) (str:string) =
|
||||
//let newSpName = newVar + ((spReplace str) + separator + (spReplace initial.species.name))
|
||||
let newSpName = ((spReplace str) + separator + (spReplace initial.species.name))
|
||||
let newSpecies = Species.create(newSpName)
|
||||
let newInitial = {initial with species = newSpecies}
|
||||
newInitial
|
||||
|
||||
let compReaction (reaction:Reaction<Species,_,_>) (str:string)=
|
||||
let ncatalysts = reaction.catalysts |> Mset.map (fun (x) ->
|
||||
//let newSpName = newVar + ((spReplace str) + separator + (spReplace x.name))
|
||||
let newSpName = ((spReplace str) + separator + (spReplace x.name))
|
||||
Species.create(newSpName))
|
||||
let nreactants = reaction.reactants |> Mset.map (fun (x) ->
|
||||
//let newSpName = newVar + ((spReplace str) + separator + (spReplace x.name))
|
||||
let newSpName = ((spReplace str) + separator + (spReplace x.name))
|
||||
Species.create(newSpName))
|
||||
let nproducts = reaction.products |> Mset.map (fun (x) ->
|
||||
//let newSpName = newVar + ((spReplace str) + separator + (spReplace x.name))
|
||||
let newSpName = ((spReplace str) + separator + (spReplace x.name))
|
||||
Species.create(newSpName))
|
||||
|
||||
let nreaction = {reaction with catalysts = ncatalysts; reactants = nreactants; products=nproducts}
|
||||
nreaction
|
||||
|
||||
|
||||
|
||||
|
||||
let createComplexSpecies (sp:string list) =
|
||||
if sp.IsEmpty then
|
||||
Species.create("")
|
||||
else
|
||||
//let species = sp |> List.reduce (fun a b -> (a + "-" + b)) |> Species.create
|
||||
let species = sp |> List.reduce (fun a b ->
|
||||
//newVar + ((spReplace a) + separator + (spReplace b))) |> Species.create
|
||||
((spReplace a) + separator + (spReplace b))) |> Species.create
|
||||
species
|
||||
|
||||
let createComplexSpeciesWithEmptyCheck (sp:string list) =
|
||||
if sp.IsEmpty then
|
||||
None
|
||||
else
|
||||
//let species = sp |> List.reduce (fun a b -> (newVar + ((spReplace a) + separator + (spReplace b)))) |> Species.create
|
||||
let species = sp |> List.reduce (fun a b -> (((spReplace a) + separator + (spReplace b)))) |> Species.create
|
||||
Some(species)
|
||||
|
||||
let createComplexSpeciesList (sp:string list list) =
|
||||
if sp.IsEmpty then
|
||||
[]
|
||||
else
|
||||
sp
|
||||
|> List.map (fun(x) -> createComplexSpeciesWithEmptyCheck(x))
|
||||
|> List.filter (fun x ->
|
||||
match x with
|
||||
| None -> false
|
||||
| Some(_) -> true)
|
||||
|> List.map (fun x -> x.Value)
|
||||
|
||||
let createComplexCompSpecies (sp:string list) (comp:string)=
|
||||
//let spName = sp |> List.reduce (fun a b -> (a + "-" + b))
|
||||
let spName = sp |> List.reduce (fun a b -> ((spReplace a) + separator + (spReplace b)))
|
||||
//let species = Species.create(comp + "[" + spName + "]")
|
||||
//let newSpName = newVar + ((spReplace comp) + separator + spName)
|
||||
let newSpName = ((spReplace comp) + separator + spName)
|
||||
let species = Species.create(newSpName)
|
||||
species
|
||||
|
||||
let rec createCrnReactions (lbsProg:tLBSProg) (reactions:Reaction<_,_,_> list) (initials:Initial<_,_> list) =
|
||||
match lbsProg with
|
||||
| LBSPar(prog1,prog2) ->
|
||||
let (reactions1,initials1) = createCrnReactions prog1 [] []
|
||||
let (reactions2,initials2) = createCrnReactions prog2 [] []
|
||||
((reactions1@reactions2@reactions),(initials1@initials2@initials))
|
||||
| LBSInitPop(initVal,value) ->
|
||||
//let species = initVal |> List.reduce (fun a b -> (newVar + (spReplace a) + separator + (spReplace b))) |> Species.create
|
||||
let species = initVal |> List.reduce (fun a b -> ((spReplace a) + separator + (spReplace b))) |> Species.create
|
||||
let initial = Initial.create(false, (Expression.Float value), species, None, None)
|
||||
(reactions,initial::initials)
|
||||
| LBSCopy(index,prog) ->
|
||||
let (reactions1,initials1) = createCrnReactions prog [] []
|
||||
let rinitials = initials1 |> List.map (fun(x) -> indexInitial x (index.ToString()))
|
||||
let rreactions = reactions1 |> List.map (fun(x) -> indexReaction x (index.ToString()))
|
||||
(rreactions@reactions,rinitials@initials)
|
||||
| LBSComp(comp,prog) ->
|
||||
let (reactions1,initials1) = createCrnReactions prog [] []
|
||||
let rinitials = initials1 |> List.map (fun(x) -> compInitial x comp)
|
||||
let rreactions = reactions1 |> List.map (fun(x) -> compReaction x comp)
|
||||
(rreactions@reactions,rinitials@initials)
|
||||
| LBSCompDec(comp,prog) ->
|
||||
let (reactions1,initials1) = createCrnReactions prog [] []
|
||||
let rinitials = initials1 |> List.map (fun(x) -> compInitial x comp)
|
||||
let rreactions = reactions1 |> List.map (fun(x) -> compReaction x comp)
|
||||
(rreactions@reactions,rinitials@initials)
|
||||
| LBSReac(enzymes,reactants,products,rate,massAction) ->
|
||||
let rreactants = createComplexSpeciesList(reactants) //|> Mset.from_list
|
||||
let renzymes = createComplexSpeciesList(enzymes) //|> Mset.from_list
|
||||
let rproducts = createComplexSpeciesList(products) //|> Mset.from_list
|
||||
if massAction then
|
||||
//check if anything is empty
|
||||
let reaction = Reaction.create(renzymes, rreactants, !-> (Expression.Key rate ), rproducts)
|
||||
(reaction:: reactions,initials)
|
||||
else
|
||||
(*let baseIdParserNoSpaces = (Parser.many1Satisfy Parser.isLetter .>>. Parser.manySatisfy (fun c -> Parser.isLetter c || Parser.isDigit c || c = '_'|| c = '-' || c = '\'') |>> fun (a,b) -> a + b) <?> "an identifier"
|
||||
let baseIdParser = baseIdParserNoSpaces .>> Parser.spaces
|
||||
let speciesparser = baseIdParser |>> fun (x) -> (Species.create(x))
|
||||
let speciesExpParser = Expression.parse speciesparser
|
||||
let exp_from_string (s:string) = Parser.from_string speciesExpParser s
|
||||
let exp = exp_from_string rate
|
||||
let reaction = Reaction.create_functional renzymes rreactants exp None rproducts
|
||||
(reaction:: reactions,initials)*)
|
||||
(reactions,initials)
|
||||
| LBSDegReac(reactants,rate) ->
|
||||
let rreactants = createComplexSpeciesList(reactants)
|
||||
let reaction = Reaction.create([], rreactants, !-> (Expression.Key rate), [])
|
||||
(reaction::reactions,initials)
|
||||
| LBSTrans(complex1,complex2,compartment,rate,direction) ->
|
||||
if direction = Ast.In then
|
||||
let reaction = Reaction.create([], [(createComplexSpecies complex1)], !-> (Expression.Key rate), [(createComplexCompSpecies complex2 compartment)])
|
||||
(reaction::reactions,initials)
|
||||
else
|
||||
let reaction = Reaction.create([], [(createComplexCompSpecies complex1 compartment)], !-> (Expression.Key rate), [(createComplexSpecies complex2)])
|
||||
(reaction::reactions,initials)
|
||||
| LBSReacAbstraction((enzymes,reactants,products,rate,massAction),prog1) ->
|
||||
let rreactants = createComplexSpeciesList(reactants) //|> Mset.from_list
|
||||
let renzymes = createComplexSpeciesList(enzymes) //|> Mset.from_list
|
||||
let rproducts = createComplexSpeciesList(products) //|> Mset.from_list
|
||||
let (reactions1,initials1) = createCrnReactions prog1 [] []
|
||||
if massAction then
|
||||
let reaction = Reaction.create(renzymes, rreactants, !-> (Expression.Key rate), rproducts)
|
||||
((reaction::reactions1)@reactions,initials1@initials)
|
||||
else
|
||||
(reactions1@reactions,initials1@initials)
|
||||
|
||||
| _ -> ([],[]) //This is basically LBSNil,
|
||||
|
||||
|
||||
|
||||
|
||||
let create (lbsProg:tLBSProg) =
|
||||
let (reactions,initials) = createCrnReactions lbsProg List.empty List.empty
|
||||
let (crn:Crn) = {Crn.empty with reactions = reactions; initials = initials}
|
||||
let gcrn = Crn.group_reactions crn
|
||||
gcrn
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.7.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding></runtime></configuration>
|
|
@ -0,0 +1,158 @@
|
|||
(*
|
||||
Defines the abstract syntax tree data types for GEC.
|
||||
Also defines compiler exceptions.
|
||||
|
||||
Author: Michael Pedersen.
|
||||
Copyright © Microsoft Research, 2009.
|
||||
*)
|
||||
|
||||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.Ast
|
||||
//open Microsoft.Research.ModellingEngine
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
// exceptions for compilation errors.
|
||||
//type pos = {l1 : int; c1 : int; l2 : int; c2 : int}
|
||||
//exception CompilerEx of string
|
||||
//exception CompilerExPos of string * pos
|
||||
|
||||
// values can be names or variables (collectively identifiers), floats or wild cards;
|
||||
// or more recently, algebraic expressions for functional rate expressions in promoter properties.
|
||||
type value =
|
||||
| IdVal of string
|
||||
| FloatVal of float
|
||||
| WildCardVal
|
||||
| AlgebraicExp of aexp
|
||||
|
||||
// in order to parse actual parameter lists without conflicts, we allow "abstract complexes"
|
||||
// to contain any value, including floats, and rely on a type system to filter out bad uses.
|
||||
and abstractComplex = value list
|
||||
|
||||
// properties:
|
||||
and prop = string * abstractComplex list
|
||||
|
||||
// arithmetic expressions (very basic for now):
|
||||
and aexp = //| ValAExp of value
|
||||
| FloatAExp of float
|
||||
| IdAExp of string
|
||||
| PlusAExp of aexp * aexp
|
||||
| MinusAExp of aexp * aexp
|
||||
| MulAExp of aexp * aexp
|
||||
| DivAExp of aexp * aexp
|
||||
| PowAExp of aexp * aexp
|
||||
|
||||
// direction for transport reactions (in or out of compartment):
|
||||
type direction = In | Out
|
||||
|
||||
// predicate operators for quantitative constraints:
|
||||
type op = Gt | Lt | Eq
|
||||
|
||||
// programmes:
|
||||
type prog =
|
||||
| Nil
|
||||
| Brick of value * string * prop list
|
||||
| Device of string
|
||||
| Reac of abstractComplex list * abstractComplex list * abstractComplex list * value * bool
|
||||
| Trans of abstractComplex * abstractComplex * string * value * bool * direction
|
||||
| TemplateInv of string * abstractComplex list
|
||||
| Seq of prog * prog
|
||||
| Par of prog * prog
|
||||
| Comp of string * prog
|
||||
| New of string * prog
|
||||
| TemplateDef of string * string list * prog * prog
|
||||
| Constraint of aexp * op * aexp
|
||||
| Rate of value * float
|
||||
| InitPop of abstractComplex * float
|
||||
| Copy of int * prog * bool * bool // first bool indicates par/seq, second bool indicates simonly
|
||||
|
||||
// directives:
|
||||
type gecSimpleSpecies = CompartmentSpecies of string * abstractComplex
|
||||
| SimpleSpecies of abstractComplex
|
||||
type gecSpecies = gecSimpleSpecies list
|
||||
type gecNumPoints = Default | IntPoints of int | AllPoints
|
||||
type kinetics =
|
||||
| Contextual_kinetics
|
||||
| Stochastic_kinetics
|
||||
| Deterministic_kinetics
|
||||
let string_of_kinetics = function
|
||||
| Contextual_kinetics -> "contextual"
|
||||
| Stochastic_kinetics -> "stochastic"
|
||||
| Deterministic_kinetics -> "deterministic"
|
||||
type directive =
|
||||
| SAMPLE of float * gecNumPoints
|
||||
| TIME of Time
|
||||
| CONCENTRATION of Concentration
|
||||
| ABSTOLERANCE of float
|
||||
| RELTOLERANCE of float
|
||||
| SCALE of float
|
||||
| PLOT of gecSimpleSpecies Key Expression.t list
|
||||
| KINETICS of kinetics
|
||||
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* String representation of a species complex. *)
|
||||
let complexString xs = Lib.string_of_list Lib.id "::" xs
|
||||
|
||||
(* String representation of a species in a compartment. *)
|
||||
let compartmentString c x = c + Lib.brack x
|
||||
|
||||
(* String representation of an operator. *)
|
||||
let stringOfOp = function
|
||||
| Gt -> ">"
|
||||
| Lt -> "<"
|
||||
| Eq -> "="
|
||||
|
||||
(* String representation of an expression. *)
|
||||
let rec stringOfAExp = function
|
||||
| FloatAExp f -> Lib.display_float f
|
||||
| IdAExp id -> id
|
||||
| PlusAExp (e1,e2) -> (stringOfAExp e1) + "+" + (stringOfAExp e2)
|
||||
| MinusAExp (e1,e2) -> (stringOfAExp e1) + "-" + (stringOfAExp e2)
|
||||
| MulAExp (e1,e2) -> (stringOfAExp e1) + "*" + (stringOfAExp e2)
|
||||
| DivAExp (e1,e2) -> (stringOfAExp e1) + "/" + (stringOfAExp e2)
|
||||
| PowAExp (e1,e2) -> (stringOfAExp e1) + "^" + (stringOfAExp e2)
|
||||
|
||||
|
||||
(* String representation of an expression. *)
|
||||
let rec lbsStringOfAExp = function
|
||||
| FloatAExp f -> Lib.display_float f
|
||||
| IdAExp id -> id
|
||||
| PlusAExp (e1,e2) -> "(" + (lbsStringOfAExp e1) + "+" + (lbsStringOfAExp e2) + ")"
|
||||
| MinusAExp (e1,e2) -> "(" + (lbsStringOfAExp e1) + "--" + (lbsStringOfAExp e2) + ")"
|
||||
| MulAExp (e1,e2) -> (lbsStringOfAExp e1) + "*" + (lbsStringOfAExp e2)
|
||||
| DivAExp (e1,e2) -> (lbsStringOfAExp e1) + "/" + (lbsStringOfAExp e2)
|
||||
| PowAExp (e1,e2) -> (lbsStringOfAExp e1) + "^" + (lbsStringOfAExp e2)
|
||||
|
||||
(* String representation of a value. *)
|
||||
let stringOfValue = function
|
||||
| IdVal x -> x
|
||||
| FloatVal f -> Lib.display_float f
|
||||
| WildCardVal -> "_"
|
||||
| AlgebraicExp aexp -> stringOfAExp aexp
|
||||
|
||||
(* String representation of an abstract complex. *)
|
||||
let abstractComplexString vs = Lib.string_of_list stringOfValue "::" vs
|
||||
|
||||
(* Are two complexes equal? *)
|
||||
let complexesEqual (xs:string list) (ys:string list) = Lib.is_permutation (=) xs ys
|
||||
|
||||
(* Produce a string representation of a "gecSpecies". *)
|
||||
let stringOfGecSimpleSpecies (g:gecSimpleSpecies) : string =
|
||||
(* Produce a string representation of a "gecSimpleSpecies". *)
|
||||
let stringOfGecSimpleSpecies (g:gecSimpleSpecies) : string =
|
||||
match g with
|
||||
| SimpleSpecies ac -> abstractComplexString ac
|
||||
| CompartmentSpecies (c,ac) -> compartmentString c (abstractComplexString ac)
|
||||
stringOfGecSimpleSpecies g
|
||||
|
||||
(* Produce the source code representation of a directive. *)
|
||||
let stringOfDirective (d:directive) : string =
|
||||
match d with
|
||||
| SAMPLE(f,io) -> "directive sample " + (Lib.display_float f) + (match io with Default -> "" | IntPoints i -> " " + (string i) | AllPoints -> " all")
|
||||
| TIME u -> "directive time " + u.to_string
|
||||
| CONCENTRATION u -> "directive concentration " + u.to_string
|
||||
| ABSTOLERANCE f -> "directive abstolerance " + (Lib.display_float f)
|
||||
| RELTOLERANCE f -> "directive reltolerance " + (Lib.display_float f)
|
||||
| SCALE f -> "directive scale " + (Lib.display_float f)
|
||||
| PLOT ps -> "directive plot " + (Lib.string_of_list (Expression.to_string (Key.to_string stringOfGecSimpleSpecies)) "; " ps)
|
||||
| KINETICS k -> "directive kinetics " + string_of_kinetics k
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,106 @@
|
|||
module GEC.Characterization
|
||||
|
||||
open System.Collections.Generic
|
||||
|
||||
type GrowthModels = Gompertz =0| Richards =1 | Logistic =2
|
||||
type GrowthModelType = {
|
||||
mu: float;
|
||||
lag: float;
|
||||
tm: float;
|
||||
K: float;
|
||||
res: int;
|
||||
model: (int * float -> float);
|
||||
}
|
||||
type DataTypes = Data | Gain | Blank | Negative
|
||||
type Well = {
|
||||
Row: char;
|
||||
Col: int;
|
||||
Content: string;
|
||||
Colony: string;
|
||||
DataType: DataTypes;
|
||||
Condition: Map<string,double>;
|
||||
Signals: double[][];
|
||||
SignalNames: string[];
|
||||
T: double[];
|
||||
GrowthModel: GrowthModelType option;
|
||||
Filter: int -> bool; //given an signal array index, is this part of the selection
|
||||
SteadyStates: Map<(string*string),(double*double)>;
|
||||
Activity: Map<(string*string),double>;
|
||||
}
|
||||
|
||||
type Plate = {
|
||||
Name: string;
|
||||
Data: seq<Well>;
|
||||
Blanks: Map<string,double>;
|
||||
|
||||
Conditions: Map<string,double[]>;
|
||||
Cname: string;
|
||||
C: double[]; //conditions
|
||||
Properties: double[][][]; //computed or measured properties
|
||||
PropertyNames: string[]; //name of properties
|
||||
|
||||
Gain: Map<string*string,double>;
|
||||
log: string;
|
||||
}
|
||||
|
||||
type ModelTypes =
|
||||
| Constitutive = 0
|
||||
| Linear = 1
|
||||
| Michaelis_Menten_Activation = 2
|
||||
| Michaelis_Menten_Repression = 3
|
||||
| Michaelis_Menten_General = 4
|
||||
| Dimer_Activation = 5
|
||||
| Dimer_Repression =6
|
||||
| Dimer_General = 7
|
||||
| Hill_Activation = 8
|
||||
| Hill_Repression = 9
|
||||
| Hill_General = 10
|
||||
| Sequential_Binding = 11
|
||||
|
||||
type ResponseTypes =
|
||||
| EYFP_ECFP = 0
|
||||
| EYFP_OD = 1
|
||||
| ECFP_OD = 2
|
||||
| mu = 3
|
||||
| K = 4
|
||||
| lag = 5
|
||||
| EYFP_mRFP1 = 6
|
||||
| ECFP_mRFP1 = 7
|
||||
| mRFP1_OD = 8
|
||||
|
||||
type Parameter = {
|
||||
pname: string;
|
||||
value: double;
|
||||
dist: double[];
|
||||
log: bool;
|
||||
}
|
||||
|
||||
type Model = {
|
||||
modelType: ModelTypes;
|
||||
AIC: double;
|
||||
BIC: double;
|
||||
CIC: double; //rename this information criterion to the right abbreviation
|
||||
model: int * double -> double;
|
||||
res: int;
|
||||
parameters: Parameter[];
|
||||
X: double[];
|
||||
bayestable: List<double[]>;
|
||||
}
|
||||
|
||||
val string_of_response: ResponseTypes -> string
|
||||
val LoadPlate: string -> Plate
|
||||
val getSignal: Well * string -> double[] * double[] //return signal over time
|
||||
val getSignals: Well * string * string -> double[] * double[] //return signal over time
|
||||
val getFluorescence: Well -> double[] * seq<string*double[]>
|
||||
val getFOd: Well -> double[] * seq<string*double[]>
|
||||
val getFF: Well*string -> double[] * seq<string*double[]>
|
||||
|
||||
val Characterize: Plate*GrowthModels -> Plate
|
||||
val ComputeProperties: string -> seq<string*double> -> Plate -> Plate
|
||||
val FilterByDevice : Plate -> string -> Plate
|
||||
val getKeys: Map<'a,'b> -> seq<'a>
|
||||
val CharacterizeModel: seq<double*double[]>*ModelTypes -> Model
|
||||
val getProperties: Plate*string -> seq<double*double[]>
|
||||
val MergePlates: Plate * Plate -> Plate
|
||||
val DataOutput: Plate -> string
|
||||
val EmptyPlate: Plate
|
|
@ -0,0 +1,92 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.Cssubst
|
||||
|
||||
open Microsoft.Research.GEC
|
||||
|
||||
//open Microsoft.Research.ModellingEngine
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* A "context-sensitive" substitution has four parts. *)
|
||||
type t = { theta:Subst.t; (* The actual substitution. *)
|
||||
rho: string list; (* The variables on which "theta" must be injective. *)
|
||||
sigma: string list list; (* Species names used in the current context. *)
|
||||
tau: string list list } (* Species names excluded for use. *)
|
||||
|
||||
(* The "empty" context-sensitive substitution. *)
|
||||
let empty = { theta=Subst.empty; rho=[]; sigma=[]; tau=[] }
|
||||
|
||||
(* Make a context-sensitive substitution. *)
|
||||
let make (theta:Subst.t) (rho:string list) (sigma:string list list) (tau:string list list) : t =
|
||||
{ theta=theta; rho=rho; sigma=sigma; tau=tau }
|
||||
|
||||
let printListDisplay (f:'a -> string) (xs:'a list) = "[" + (Lib.string_of_list f "; " xs) + "]"
|
||||
(* Produce a string representation of a context-sensitive substitution. *)
|
||||
let display (cs:t) =
|
||||
"{ theta = " + (Subst.display cs.theta) + ";" + Lib.newline +
|
||||
" rho = " + (printListDisplay Lib.id cs.rho) + ";" + Lib.newline +
|
||||
" sigma = " + (printListDisplay Ast.complexString cs.sigma) + ";" + Lib.newline +
|
||||
" tau = " + (printListDisplay Ast.complexString cs.tau) + " }"
|
||||
|
||||
(* Check that a given element of the "csSubst" type satisfies the 2 criteria for a context-sensitive substitution. *)
|
||||
let isOK (cs:t) =
|
||||
let check_ii () =
|
||||
// Assume that cs.rho contains no duplicates...
|
||||
match Lib.find_duplicate Subst.targetEq (List.map (fun x -> Subst.find x cs.theta) cs.rho) with
|
||||
| None -> true
|
||||
| Some _ -> false
|
||||
in
|
||||
let check_iii () = Lib.disjoint Ast.complexesEqual cs.sigma cs.tau in
|
||||
(check_ii ()) && (check_iii ())
|
||||
|
||||
(* Get the "normal" substitution out of a context-sensitive one. *)
|
||||
let getSubst (cs:t) : Subst.t = cs.theta
|
||||
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* "Merge" two context-sensitive substitutions together, and test to see if the result is
|
||||
also a context-sensitive substitution. *)
|
||||
let merge (cs1:t) (cs2:t) : t option =
|
||||
match (Subst.union cs1.theta cs2.theta) with
|
||||
| None -> None
|
||||
| Some theta ->
|
||||
let cs12 = { theta = theta;
|
||||
rho = Lib.remove_duplicates (=) (cs1.rho @ cs2.rho);
|
||||
sigma = Lib.remove_duplicates Ast.complexesEqual (cs1.sigma @ cs2.sigma);
|
||||
tau = Lib.remove_duplicates Ast.complexesEqual (cs1.tau @ cs2.tau) }
|
||||
in
|
||||
if isOK cs12 then Some cs12 else None
|
||||
|
||||
(* Compose two lists of context-sensitive substitutions by only retaining those elements of the
|
||||
"cartesian product" which satisfy the criteria. *)
|
||||
let compose (css1:t list) (css2:t list) : t list =
|
||||
(* NB: we don't form the entire cartesian product - it could get quite big.
|
||||
Instead, have two nested loops with an accumulator running through them.
|
||||
TO DO: this could be put into CPS to make it tail-recursive... *)
|
||||
let rec loop (acc:t list) (css1:t list) =
|
||||
match css1 with
|
||||
| [] -> acc
|
||||
| (cs1::css1) ->
|
||||
let rec loop2 (acc:t list) (css2:t list) =
|
||||
match css2 with
|
||||
| [] -> acc
|
||||
| (cs2::css2) ->
|
||||
match merge cs1 cs2 with
|
||||
| None -> loop2 acc css2
|
||||
| Some cs12 -> loop2 (acc@[cs12]) css2
|
||||
in
|
||||
let acc = loop2 acc css2 in
|
||||
loop acc css1
|
||||
in
|
||||
loop [] css1
|
||||
|
||||
(* Erase the "context" data in a context-sensitive substitution. *)
|
||||
let eraseContext (cs:t) : t = { theta=cs.theta; rho=[]; sigma=[]; tau=[] }
|
||||
|
||||
(* Check whether a context-sensitive substitution satisfies a list of arithmetic constraints. *)
|
||||
let satisfiesConstraints (cs:t) (ks:(Ast.aexp*Ast.op*Ast.aexp) list) : bool =
|
||||
Lib.forall (Subst.satisfiesConstraint cs.theta) ks
|
||||
|
||||
(* Produce a "varAss" (variable assignments) from a context-sensitive substitution. *)
|
||||
let mkVarAss (cs:t) = Subst.mkVarAss cs.theta
|
|
@ -0,0 +1,45 @@
|
|||
module Microsoft.Research.GEC.Cssubst
|
||||
|
||||
open Microsoft.Research.GEC
|
||||
|
||||
//open Microsoft.Research.ModellingEngine
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* Type for "context-sensitive" substitutions. *)
|
||||
type t
|
||||
|
||||
(* The "empty" context-sensitive substitution. *)
|
||||
val empty : t
|
||||
|
||||
(* Make a context-sensitive substitution. *)
|
||||
val make : Subst.t -> string list -> string list list -> string list list -> t
|
||||
|
||||
(* Produce a string representation of a context-sensitive substitution. *)
|
||||
val display : t -> string
|
||||
|
||||
(* Check that a given element of the "csSubst" type satisfies the 2 criteria for a context-sensitive substitution. *)
|
||||
val isOK : t -> bool
|
||||
|
||||
(* Get the "normal" substitution out of a context-sensitive one. *)
|
||||
val getSubst : t -> Subst.t
|
||||
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* "Merge" two context-sensitive substitutions together, and test to see if the result is
|
||||
also a context-sensitive substitution. *)
|
||||
val merge : t -> t -> t option
|
||||
|
||||
(* Compose two lists of context-sensitive substitutions by only retaining those elements of the
|
||||
"cartesian product" which satisfy the criteria. *)
|
||||
val compose : t list -> t list -> t list
|
||||
|
||||
(* Erase the "context" data in a context-sensitive substitution. *)
|
||||
val eraseContext : t -> t
|
||||
|
||||
(* Check whether a context-sensitive substitution satisfies a list of arithmetic constraints. *)
|
||||
val satisfiesConstraints : t -> (Ast.aexp * Ast.op * Ast.aexp) list -> bool
|
||||
|
||||
(* Produce a "varAss" (variable assignments) from a context-sensitive substitution. *)
|
||||
val mkVarAss : t -> (string * string) list * (string * string) list * (string * string) list
|
|
@ -0,0 +1,571 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.Database
|
||||
|
||||
open Microsoft.Research.GEC
|
||||
open Microsoft.Research.FSBOLWrapper
|
||||
open FSBOL
|
||||
open FSBOL.Annotation
|
||||
open FSBOL.ComponentDefinition
|
||||
open FSBOL.ModuleDefinition
|
||||
open FSBOL.FunctionalComponent
|
||||
open FSBOL.Participation
|
||||
open FSBOL.Interaction
|
||||
open FSBOL.SBOLDocument
|
||||
open FSBOL.TopLevel
|
||||
open Parser
|
||||
open System.Diagnostics
|
||||
|
||||
//open Microsoft.Research.ModellingEngine
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
(* ************************************************************************************************* *)
|
||||
|
||||
(* The different kinds of property that part types can have. *)
|
||||
|
||||
type device = string * string list
|
||||
|
||||
|
||||
type pcrProperty = CODES of string list * float
|
||||
type promProperty = POS of string list * float * float * float
|
||||
| NEG of string list * float * float * float
|
||||
| CON of float
|
||||
| FRATE of Ast.aexp
|
||||
type rbsProperty = RATE of float
|
||||
|
||||
(* An encoding of part types, along with their properties. *)
|
||||
type partType = PCR of pcrProperty
|
||||
| PROM of promProperty list
|
||||
| RBS of rbsProperty
|
||||
| TER
|
||||
|
||||
let fold_string_list (strList:string list) (folder:string) =
|
||||
match strList.Length with
|
||||
| 0 -> ""
|
||||
| 1 -> strList.Head
|
||||
| _ -> strList.Tail |> List.fold (fun f s -> (f + folder + s)) strList.Head
|
||||
|
||||
let device_to_string (d:device) =
|
||||
let (devname,deviceComps) = d
|
||||
devname + "[" + (fold_string_list deviceComps ";") + "]"
|
||||
|
||||
(* Produce a string representation of a part type. *)
|
||||
let string_of_partType (pt:partType) =
|
||||
let string_of_promProperty = function
|
||||
| POS(zs,q1,q2,q3) -> "pos(" + (Ast.complexString zs) + ", " + (Lib.display_float q1) + ", " + (Lib.display_float q2) + ", " + (Lib.display_float q3) + ")"
|
||||
| NEG(zs,q1,q2,q3) -> "neg(" + (Ast.complexString zs) + ", " + (Lib.display_float q1) + ", " + (Lib.display_float q2) + ", " + (Lib.display_float q3) + ")"
|
||||
| CON(q) -> "con(" + (Lib.display_float q) + ")"
|
||||
| FRATE(a) -> "frate(" + (Ast.stringOfAExp a) + ")"
|
||||
in
|
||||
match pt with
|
||||
| PCR(CODES(zs,q)) -> "pcr<codes(" + (Ast.complexString zs) + ", " + (Lib.display_float q) + ")>"
|
||||
| PROM(pps) -> "prom<" + (Lib.string_of_list string_of_promProperty ", " pps) + ">"
|
||||
| RBS(RATE(q)) -> "rbs<rate(" + (Lib.display_float q) + ")>"
|
||||
| TER -> "ter"
|
||||
|
||||
(* Compute FS(Q+t). *)
|
||||
let speciesInPartType (qt:partType) : string list list =
|
||||
let getPromPropertySpeciesNames = function POS(xs,_,_,_) | NEG(xs,_,_,_) -> [xs] | _ -> [] in
|
||||
let snames = match qt with
|
||||
| PCR(CODES(xs,_)) -> [xs]
|
||||
| PROM(pps) -> Lib.collect_union Ast.complexesEqual getPromPropertySpeciesNames pps
|
||||
| RBS _ | TER -> []
|
||||
in
|
||||
Lib.remove_duplicates (=) snames
|
||||
|
||||
|
||||
|
||||
(* ************************************************************************************************* *)
|
||||
|
||||
(* A "database" consists of a "parts database" and a "reaction database".
|
||||
A "parts database" is just a mapping of part identifiers (i.e. strings) to their part types.
|
||||
A "reaction database" is just a list of reactions. *)
|
||||
type 'a entry = { value:'a; enabled:bool; comments:string }
|
||||
type t = { parts:partType entry Stringmap.t; devices: device list; reactions:Gecreaction.t entry list }
|
||||
|
||||
let partTypeToSBOL (name:string) (p:partType entry)=
|
||||
|
||||
let role = match p.value with
|
||||
| PROM _ -> Role.Promoter
|
||||
| RBS _ -> Role.RBS
|
||||
| PCR _ -> Role.CDS
|
||||
| TER -> Role.Terminator
|
||||
|
||||
let renamedName = name.Replace("::","_")
|
||||
let gecSO = "www.microsoft.com/gec#"
|
||||
(*let RB = gecSO + "RB"
|
||||
let RUB = gecSO + "RUB"
|
||||
let RTB = gecSO + "RTB"
|
||||
let RT = gecSO + "RT"
|
||||
let R = gecSO + "R"
|
||||
let RD = gecSO + "RD"
|
||||
let P = gecSO + "P"*)
|
||||
|
||||
let RB = "RB"
|
||||
let RUB = "RUB"
|
||||
let RTB = "RTB"
|
||||
let RT = "RT"
|
||||
let R = "R"
|
||||
let RD = "RD"
|
||||
let P = "P"
|
||||
|
||||
|
||||
let annotations:Annotation list =
|
||||
match p.value with
|
||||
| PROM(a) ->
|
||||
let propAnnotations =
|
||||
a |> List.map(fun promprop ->
|
||||
match promprop with
|
||||
| POS(p,rb,rub,rtb) ->
|
||||
let compositeName = p |> List.reduce(fun a b -> a + "::" + b)
|
||||
[Helper.create_string_annotation (Name(P)) compositeName ;
|
||||
Helper.create_double_annotation (Name(RB)) rb;
|
||||
Helper.create_double_annotation (Name(RUB)) rub;
|
||||
Helper.create_double_annotation (Name(RTB)) rtb]
|
||||
| NEG(p,rb,rub,rtb) ->
|
||||
let compositeName = p |> List.reduce(fun a b -> a + "::" + b)
|
||||
[Helper.create_string_annotation (Name(P)) compositeName;
|
||||
Helper.create_double_annotation (Name(RB)) rb;
|
||||
Helper.create_double_annotation (Name(RUB)) rub;
|
||||
Helper.create_double_annotation (Name(RTB)) rtb]
|
||||
| CON(rt) ->
|
||||
[Helper.create_double_annotation (Name(RT)) rt]
|
||||
| _ -> [])
|
||||
[0..(propAnnotations.Length-1)]
|
||||
|> List.map (fun i ->
|
||||
let na = NestedAnnotation(Name("PromoterProperty" + i.ToString() + "Annotations"),gecSO + "PromoterProperties",propAnnotations.Item(i))
|
||||
Annotation(Name("PromoterProperty" + i.ToString()),AnnotationValue.NestedAnnotation(na)))
|
||||
| RBS(RATE(r)) -> [Helper.create_double_annotation (Name(R)) r]
|
||||
| PCR(CODES(codes,rd)) ->
|
||||
let compositeName = codes |> List.reduce(fun a b -> a + "::" + b)
|
||||
[Helper.create_string_annotation (Name(P)) compositeName;
|
||||
Helper.create_double_annotation (Name(RD)) rd]
|
||||
| TER -> []
|
||||
|
||||
let version = "1"
|
||||
let persistentId = "http://www.microsoft.com/gec/db/" + renamedName + "/"
|
||||
let uri = persistentId + renamedName + "/" + version + "/"
|
||||
let c = new ComponentDefinition(uri,Some(renamedName),Some(renamedName),Some(version),Some(persistentId),[],[ComponentDefinitionType.DNA],[role],[],[],[],[])
|
||||
c.annotations <- annotations
|
||||
c
|
||||
|
||||
|
||||
let createProteinCDs (tableList:((string*(partType entry))list)) =
|
||||
let partTypes = tableList
|
||||
|> List.map (fun (x,y) -> y.value)
|
||||
let promProts = partTypes
|
||||
|> List.choose ( fun x ->
|
||||
match x with
|
||||
| PROM(props) -> Some props
|
||||
| _ -> None)
|
||||
|> List.map (fun props ->
|
||||
props |> List.map(fun prop ->
|
||||
match prop with
|
||||
| POS(p,rb,rub,rtb) -> Some(p |> List.reduce(fun a b -> a + "::" + b))
|
||||
| NEG(p,rb,rub,rtb) -> Some(p |> List.reduce(fun a b -> a + "::" + b))
|
||||
| _ -> None
|
||||
)
|
||||
) |> List.concat
|
||||
|> List.filter (fun x->
|
||||
match x with
|
||||
| Some(_) -> true
|
||||
| None -> false
|
||||
) |> List.map (fun x -> x.Value)
|
||||
|
||||
let cdsProts = partTypes
|
||||
|> List.choose (fun x ->
|
||||
match x with
|
||||
| PCR(CODES(prots,r)) -> Some (prots,r)
|
||||
| _ -> None
|
||||
) |> List.map (fun (prots,r) ->
|
||||
prots |> List.reduce(fun a b -> a + "::" + b)
|
||||
)
|
||||
|
||||
let prots = (promProts@cdsProts) |> Set.ofList |> List.ofSeq
|
||||
prots |> List.map(fun protName ->
|
||||
let renamedProt = protName.Replace("::","_")
|
||||
let version = "1"
|
||||
let persistentId = "http://www.microsoft.com/gec/db/" + renamedProt + "/"
|
||||
let uri = persistentId + renamedProt + "/" + version + "/"
|
||||
new ComponentDefinition(uri,Some(renamedProt),Some(renamedProt),Some(version),Some(persistentId),[],[ComponentDefinitionType.Protein],[],[],[],[],[]))
|
||||
|
||||
|
||||
let createModuleDefinitions (cds:ComponentDefinition list) (tableList:((string*(partType entry))list))=
|
||||
let urlPrefix = "http://www.microsoft.com/gec/db/"
|
||||
let version = "1"
|
||||
|
||||
|
||||
let findCDwithURI (uri:string) =
|
||||
match cds |> List.tryFind (fun cd -> cd.uri = uri) with
|
||||
| Some (x) -> x
|
||||
| None -> failwith "Error. This CD should have been created in an earlier step"
|
||||
let findCDwithDisplayID (display:string) =
|
||||
let displayIdsMatch (cdDisplayId:string option) (display:string) =
|
||||
match cdDisplayId with
|
||||
| Some(d) -> (d=display)
|
||||
| None -> failwith "Error. This CD should have a displayId created in an earlier step"
|
||||
match cds |> List.tryFind (fun cd -> displayIdsMatch (cd.displayId) display) with
|
||||
| Some(x) -> x
|
||||
| None -> failwith "Error. This CD should have been created in an earlier step"
|
||||
let pcrs = tableList
|
||||
|> List.choose (fun (name,x) ->
|
||||
match x.value with
|
||||
| PCR(CODES(prots,r)) -> Some(name,prots,r)
|
||||
| _ -> None
|
||||
)
|
||||
|
||||
let proms = tableList
|
||||
|> List.choose (fun (name,x) ->
|
||||
match x.value with
|
||||
| PROM(props) -> Some(name,props)
|
||||
| _ -> None
|
||||
)
|
||||
|
||||
let mds =
|
||||
pcrs |> List.map (fun (pcrName,prots,r) ->
|
||||
let compositeName = prots |> List.reduce(fun a b -> a + "_" + b)
|
||||
let mdsinProms =
|
||||
proms |>
|
||||
List.map(fun (promName,props) ->
|
||||
let mdsInProps =
|
||||
props |> List.map(fun prop ->
|
||||
match prop with
|
||||
| POS(regList,_,_,_) ->
|
||||
let compositeReg = regList |> List.reduce(fun a b -> a + "_" + b)
|
||||
if compositeReg = compositeName then
|
||||
let pcr_cd = findCDwithDisplayID pcrName
|
||||
let prot_cd = findCDwithDisplayID compositeReg
|
||||
let prom_cd = findCDwithDisplayID promName
|
||||
|
||||
let compoundNameProd = pcrName + "_" + compositeName
|
||||
let mdProd_name = compoundNameProd + "_production_md"
|
||||
let mdProd_perId = urlPrefix + "/" + mdProd_name + "/"
|
||||
let mdProd_uri = mdProd_perId + version + "/"
|
||||
|
||||
let fc_pcr_name = pcrName + "_FC"
|
||||
let fc_pcr_perId = urlPrefix + fc_pcr_name + "/"
|
||||
let fc_pcr_uri = fc_pcr_perId + version + "/"
|
||||
|
||||
let fc_prot_name = compositeName + "_protein_FC"
|
||||
let fc_prot_perId = urlPrefix + fc_prot_name + "/"
|
||||
let fc_prot_uri = fc_pcr_perId + version + "/"
|
||||
|
||||
let fc_pcr = new FunctionalComponent(fc_pcr_uri,Some(fc_pcr_name),Some(fc_pcr_name),Some(version),Some(fc_pcr_perId),pcr_cd.uri,ComponentInstance.Access.Private,[],Direction.InOut)
|
||||
let fc_prot = new FunctionalComponent(fc_prot_uri,Some(fc_prot_name),Some(fc_prot_name),Some(version),Some(fc_prot_perId),prot_cd.uri,ComponentInstance.Access.Private,[],Direction.InOut)
|
||||
|
||||
let part_pcr_name = pcrName+"_participation"
|
||||
let part_pcr_perId = urlPrefix + part_pcr_name + "/"
|
||||
let part_pcr_uri = part_pcr_perId + version + "/"
|
||||
|
||||
let part_prot_name = compositeName+"prot_participation"
|
||||
let part_prot_perId = urlPrefix + part_prot_name + "/"
|
||||
let part_prot_uri = part_prot_perId + version + "/"
|
||||
|
||||
let part_pcr = new Participation(part_pcr_uri,Some(part_pcr_name),Some(part_pcr_name),Some(version),Some(part_pcr_perId),[ParticipationRole.Template],fc_pcr)
|
||||
let part_prot = new Participation(part_prot_uri, Some(part_prot_name),Some(part_prot_name),Some(version),Some(part_prot_perId),[ParticipationRole.Product],fc_prot)
|
||||
|
||||
let interactionProd_name = compoundNameProd + "_production_interaction"
|
||||
let interactionProd_perId = mdProd_perId + "/" + interactionProd_name + "/"
|
||||
let interactionProd_uri = interactionProd_perId + version + "/"
|
||||
|
||||
let interactionProd = new Interaction(interactionProd_uri,Some(interactionProd_name),Some(interactionProd_name),Some(version),Some(interactionProd_perId),[InteractionType.GeneticProduction],[part_pcr;part_prot])
|
||||
|
||||
|
||||
let mdProd = new ModuleDefinition(mdProd_uri,Some(mdProd_name),Some(mdProd_name),Some(version),Some(mdProd_perId),[],[],[],[interactionProd],[fc_pcr;fc_prot],[])
|
||||
|
||||
let compoundNameStim = compositeName + "_" + promName
|
||||
let mdStim_name = compoundNameStim + "_stimulation_md"
|
||||
let mdStim_perId = urlPrefix + "/" + mdStim_name + "/"
|
||||
let mdStim_uri = mdStim_perId + "/" + version + "/"
|
||||
|
||||
let fc_complex_name = compositeName + "_complex_FC"
|
||||
let fc_complex_perId = urlPrefix + fc_complex_name + "/"
|
||||
let fc_complex_uri = fc_pcr_perId + version + "/"
|
||||
|
||||
let fc_prom_name = promName + "_FC"
|
||||
let fc_prom_perId = urlPrefix + fc_prom_name + "/"
|
||||
let fc_prom_uri = fc_prom_perId + version + "/"
|
||||
|
||||
let fc_complex = new FunctionalComponent(fc_complex_uri,Some(fc_complex_name),Some(fc_complex_name),Some(version),Some(fc_complex_perId),prot_cd.uri,ComponentInstance.Access.Private,[],Direction.InOut)
|
||||
let fc_prom = new FunctionalComponent(fc_prom_uri,Some(fc_prom_name),Some(fc_prom_name),Some(version),Some(fc_prom_perId),prom_cd.uri,ComponentInstance.Access.Private,[],Direction.InOut)
|
||||
|
||||
let part_complex_name = compositeName+"complex_participation"
|
||||
let part_complex_perId = urlPrefix + part_complex_name + "/"
|
||||
let part_complex_uri = part_complex_perId + version + "/"
|
||||
|
||||
let part_prom_name = pcrName+"_participation"
|
||||
let part_prom_perId = urlPrefix + part_prom_name + "/"
|
||||
let part_prom_uri = part_prom_perId + version + "/"
|
||||
|
||||
let part_complex = new Participation(part_complex_uri,Some(part_complex_name),Some(part_complex_name),Some(version),Some(part_complex_perId),[ParticipationRole.Stimulator],fc_complex)
|
||||
let part_prom = new Participation(part_prom_uri,Some(part_prom_name),Some(part_prom_name),Some(version),Some(part_prom_perId),[ParticipationRole.Stimulated],fc_prom)
|
||||
|
||||
let interactionStim_name = compoundNameStim + "_stimulation_interaction"
|
||||
let interactionStim_perId = mdStim_perId + "/" + interactionStim_name + "/"
|
||||
let interactionStim_uri = interactionStim_perId + "/" + version + "/"
|
||||
|
||||
let interactionStim = new Interaction(interactionStim_uri,Some(interactionStim_name),Some(interactionStim_name),Some(version),Some(interactionStim_perId),[InteractionType.Stimulation],[part_complex;part_prom])
|
||||
|
||||
let mdStim = new ModuleDefinition(mdStim_uri,Some(mdStim_name),Some(mdStim_name),Some(version),Some(mdStim_perId),[],[],[],[interactionStim],[fc_complex;fc_prom],[])
|
||||
|
||||
Some([mdProd;mdStim])
|
||||
else
|
||||
None
|
||||
| NEG(regList,_,_,_) ->
|
||||
let compositeReg = regList |> List.reduce(fun a b -> a + "::" + b)
|
||||
if compositeReg = compositeName then
|
||||
let pcr_cd = findCDwithDisplayID pcrName
|
||||
let prot_cd = findCDwithDisplayID compositeReg
|
||||
let prom_cd = findCDwithDisplayID promName
|
||||
|
||||
let compoundNameProd = pcrName + "_" + compositeName
|
||||
let mdProd_name = compoundNameProd + "_production_md"
|
||||
let mdProd_perId = urlPrefix + "/" + mdProd_name + "/"
|
||||
let mdProd_uri = mdProd_perId + version + "/"
|
||||
|
||||
let fc_pcr_name = pcrName + "_FC"
|
||||
let fc_pcr_perId = urlPrefix + fc_pcr_name + "/"
|
||||
let fc_pcr_uri = fc_pcr_perId + version + "/"
|
||||
|
||||
let fc_prot_name = compositeName + "_protein_FC"
|
||||
let fc_prot_perId = urlPrefix + fc_prot_name + "/"
|
||||
let fc_prot_uri = fc_pcr_perId + version + "/"
|
||||
|
||||
let fc_pcr = new FunctionalComponent(fc_pcr_uri,Some(fc_pcr_name),Some(fc_pcr_name),Some(version),Some(fc_pcr_perId),pcr_cd.uri,ComponentInstance.Access.Private,[],Direction.InOut)
|
||||
let fc_prot = new FunctionalComponent(fc_prot_uri,Some(fc_prot_name),Some(fc_prot_name),Some(version),Some(fc_prot_perId),prot_cd.uri,ComponentInstance.Access.Private,[],Direction.InOut)
|
||||
|
||||
let part_pcr_name = pcrName+"_participation"
|
||||
let part_pcr_perId = urlPrefix + part_pcr_name + "/"
|
||||
let part_pcr_uri = part_pcr_perId + version + "/"
|
||||
|
||||
let part_prot_name = compositeName+"prot_participation"
|
||||
let part_prot_perId = urlPrefix + part_prot_name + "/"
|
||||
let part_prot_uri = part_prot_perId + version + "/"
|
||||
|
||||
let part_pcr = new Participation(part_pcr_uri,Some(part_pcr_name),Some(part_pcr_name),Some(version),Some(part_pcr_perId),[ParticipationRole.Template],fc_pcr)
|
||||
let part_prot = new Participation(part_prot_uri, Some(part_prot_name),Some(part_prot_name),Some(version),Some(part_prot_perId),[ParticipationRole.Product],fc_prot)
|
||||
|
||||
let interactionProd_name = compoundNameProd + "_production_interaction"
|
||||
let interactionProd_perId = mdProd_perId + "/" + interactionProd_name + "/"
|
||||
let interactionProd_uri = interactionProd_perId + version + "/"
|
||||
|
||||
let interactionProd = new Interaction(interactionProd_uri,Some(interactionProd_name),Some(interactionProd_name),Some(version),Some(interactionProd_perId),[InteractionType.GeneticProduction],[part_pcr;part_prot])
|
||||
|
||||
|
||||
let mdProd = new ModuleDefinition(mdProd_uri,Some(mdProd_name),Some(mdProd_name),Some(version),Some(mdProd_perId),[],[],[],[interactionProd],[fc_pcr;fc_prot],[])
|
||||
|
||||
|
||||
let compoundNameInh = compositeName + "_" + promName
|
||||
let mdInh_name = compoundNameInh + "_inhibition_md"
|
||||
let mdInh_perId = urlPrefix + "/" + mdInh_name + "/"
|
||||
let mdInh_uri = mdInh_perId + "/" + version + "/"
|
||||
|
||||
let fc_complex_name = compositeName + "_complex_FC"
|
||||
let fc_complex_perId = urlPrefix + fc_complex_name + "/"
|
||||
let fc_complex_uri = fc_pcr_perId + version + "/"
|
||||
|
||||
let fc_prom_name = promName + "_FC"
|
||||
let fc_prom_perId = urlPrefix + fc_prom_name + "/"
|
||||
let fc_prom_uri = fc_prom_perId + version + "/"
|
||||
|
||||
let fc_complex = new FunctionalComponent(fc_complex_uri,Some(fc_complex_name),Some(fc_complex_name),Some(version),Some(fc_complex_perId),prot_cd.uri,ComponentInstance.Access.Private,[],Direction.InOut)
|
||||
let fc_prom = new FunctionalComponent(fc_prom_uri,Some(fc_prom_name),Some(fc_prom_name),Some(version),Some(fc_prom_perId),prom_cd.uri,ComponentInstance.Access.Private,[],Direction.InOut)
|
||||
|
||||
let part_complex_name = compositeName+"complex_participation"
|
||||
let part_complex_perId = urlPrefix + part_complex_name + "/"
|
||||
let part_complex_uri = part_complex_perId + version + "/"
|
||||
|
||||
let part_prom_name = pcrName+"_participation"
|
||||
let part_prom_perId = urlPrefix + part_prom_name + "/"
|
||||
let part_prom_uri = part_prom_perId + version + "/"
|
||||
|
||||
let part_complex = new Participation(part_complex_uri,Some(part_complex_name),Some(part_complex_name),Some(version),Some(part_complex_perId),[ParticipationRole.Inhibitor],fc_complex)
|
||||
let part_prom = new Participation(part_prom_uri,Some(part_prom_name),Some(part_prom_name),Some(version),Some(part_prom_perId),[ParticipationRole.Inhibited],fc_prom)
|
||||
|
||||
let interactionInh_name = compoundNameInh + "_inhibition_interaction"
|
||||
let interactionInh_perId = mdInh_perId + "/" + interactionInh_name + "/"
|
||||
let interactionInh_uri = interactionInh_perId + "/" + version + "/"
|
||||
|
||||
let interactionInh = new Interaction(interactionInh_uri,Some(interactionInh_name),Some(interactionInh_name),Some(version),Some(interactionInh_perId),[InteractionType.Inhibition],[part_complex;part_prom])
|
||||
|
||||
let mdInh = new ModuleDefinition(mdInh_uri,Some(mdInh_name),Some(mdInh_name),Some(version),Some(mdInh_perId),[],[],[],[interactionInh],[fc_complex;fc_prom],[])
|
||||
|
||||
Some([mdProd;mdInh])
|
||||
else
|
||||
None
|
||||
| _ -> None)
|
||||
|> List.filter (fun optionX ->
|
||||
match optionX with
|
||||
| Some (_) -> true
|
||||
| None -> false)
|
||||
|> List.map( fun x -> x.Value)
|
||||
if mdsInProps.IsEmpty then
|
||||
[]
|
||||
else
|
||||
mdsInProps |> List.reduce (fun a b -> a@b)
|
||||
)
|
||||
if mdsinProms.IsEmpty then
|
||||
[]
|
||||
else
|
||||
mdsinProms |>List.reduce (fun a b -> a@b)
|
||||
)
|
||||
if mds.IsEmpty then
|
||||
[]
|
||||
else
|
||||
mds |>List.reduce (fun a b -> a@b)
|
||||
|
||||
let convertTableToSBOLDocument (table:t) =
|
||||
let cds = table.parts |> List.ofSeq |> List.map (fun (x) -> (x.Key,x.Value)) |> List.map (fun (name,part) -> partTypeToSBOL name part)
|
||||
|
||||
let protCds = createProteinCDs (table.parts |> List.ofSeq |> List.map (fun x -> (x.Key,x.Value)))
|
||||
let allCds = (cds@protCds)
|
||||
let mds = createModuleDefinitions allCds (table.parts |> List.ofSeq |> List.map (fun x -> (x.Key,x.Value)))
|
||||
let collections =
|
||||
(allCds |> List.map (fun x -> x :> TopLevel))
|
||||
@ (mds|> List.map (fun x -> x :> TopLevel))
|
||||
SBOLDocument(collections)
|
||||
|
||||
(* The "empty" database. *)
|
||||
let empty = { parts=Stringmap.empty; devices = []; reactions=[] }
|
||||
|
||||
(* Produce a string representation of a database entry. *)
|
||||
let string_of_entry (display:'a -> string) (entry:'a entry) : string =
|
||||
let enabledStr = if entry.enabled then "[*] " else "[ ] " in
|
||||
let valueStr = display entry.value in
|
||||
let commentsStr = if entry.comments = "" then "" else " (Comments: \"" + entry.comments + "\")" in
|
||||
enabledStr + valueStr + commentsStr
|
||||
|
||||
(* Produce a string representation of a database. *)
|
||||
let display (db:t) : string =
|
||||
let partsString = Stringmap.fold (fun str x entry -> str + Lib.newline + x + " : " + (string_of_entry string_of_partType entry)) "" db.parts in
|
||||
let reactionsString = Lib.fold_left (fun str entry -> str + Lib.newline + (string_of_entry Gecreaction.display entry)) "" db.reactions in
|
||||
"PARTS:" + partsString + Lib.newline + Lib.newline +
|
||||
"REACTIONS:" + reactionsString + Lib.newline
|
||||
|
||||
(* Find out the part type for an identifer (if it exists). *)
|
||||
let findPart (db:t) (id:string) : partType option =
|
||||
match Stringmap.tryFind id db.parts with
|
||||
| Some entry -> Some entry.value
|
||||
| None -> None
|
||||
|
||||
(* ************************************************************************************************* *)
|
||||
(* Functions for adding entries to the database. *)
|
||||
|
||||
(* Convert an abstractComplex into a string list, assuming it is "simple" (i.e. just strings...) *)
|
||||
let convertSimpleComplex (vs:Ast.abstractComplex) : string list =
|
||||
let convertSimpleValue (v:Ast.value) : string =
|
||||
match v with
|
||||
| Ast.IdVal x -> x
|
||||
| _ -> failwith ("Only strings are allowed in species names in the database " + Lib.paren("found " + Ast.stringOfValue v))
|
||||
in
|
||||
List.map convertSimpleValue vs
|
||||
|
||||
(* Get a float from an Ast.value. *)
|
||||
let getValueFloat (v:Ast.value) =
|
||||
match v with
|
||||
| Ast.FloatVal f -> f
|
||||
| _ -> failwith ("Only float rates are allowed in the database " + Lib.paren("found " + Ast.stringOfValue v))
|
||||
|
||||
|
||||
type parser = Parser.t<t>
|
||||
type partParser = Parser.t<t>
|
||||
|
||||
|
||||
|
||||
let createEntry (id:string, part:partType) =
|
||||
let entry:partType entry = {value = part;enabled = true;comments = ""}
|
||||
(id,entry)
|
||||
|
||||
|
||||
let createTable (partMapList:(string*partType)list) (devicelist:device list)=
|
||||
let tableMap = partMapList |> List.map createEntry
|
||||
{parts = Stringmap.of_list(tableMap); reactions=[]; devices = devicelist}
|
||||
|
||||
|
||||
|
||||
|
||||
let TAB = Parser.kw "\t"
|
||||
let COMMA = Parser.kw ","
|
||||
let SEMICOLON = Parser.kw ";"
|
||||
|
||||
let delimiter = COMMA //Primary delimiter
|
||||
let sDelimiter = SEMICOLON //Secondary Delimiter used to separate elements or values within a cell
|
||||
|
||||
let NEWLINE = Parser.newline
|
||||
|
||||
let lookaheadLinebreak = Parser.pTry (Parser.linebreak >>. Parser.failParser "" <|> Parser.satisfy Parser.isWhiteSpace >>. preturn ())
|
||||
let spacesnlb :t<string> = fun st ->
|
||||
match many (commentLine <|> commentMultiline () <|> lookaheadLinebreak) <| st with
|
||||
| OkEmpty (_, st') -> OkEmpty ("", st')
|
||||
| OkConsumed (_, st') -> OkEmpty ("", st')
|
||||
| FailEmpty _ -> OkEmpty ("", st)
|
||||
| FailConsumed (e, p) -> FailConsumed (e, p)
|
||||
let kwnlb s = pstring s .>> spacesnlb
|
||||
let bracketnlb l r = Parser.between (Parser.kw l) (Parser.spaces >>. kwnlb r)
|
||||
|
||||
let bracketNoSpace l r = Parser.between (Parser.pstring l) (Parser.spaces >>. Parser.pstring r)
|
||||
let sqbracketNoSpace a = bracketnlb "[" "]" a
|
||||
let parenNoSpace a = bracketnlb "(" ")" a
|
||||
//let nameGEC = (Parser.many1Satisfy Parser.isLetter .>>. Parser.manySatisfy (fun c -> Parser.isLetter c || Parser.isDigit c || c = '_'|| c = '-' || c = '\'') |>> fun (a,b) -> a + b) <?> "an identifier"
|
||||
|
||||
let parsePos = Parser.kw "pos" >>. parenNoSpace(GecSpecies.parse_species .>> sDelimiter .>>. Parser.pfloat .>> sDelimiter .>>. Parser.pfloat .>> sDelimiter .>>. Parser.pfloat) |>> fun(((regBy,rb),rub),rtb) -> POS(regBy,rb,rub,rtb)
|
||||
let parseNeg = Parser.kw "neg" >>. parenNoSpace(GecSpecies.parse_species .>> sDelimiter .>>. Parser.pfloat .>> sDelimiter .>>. Parser.pfloat .>> sDelimiter .>>. Parser.pfloat) |>> fun(((regBy,rb),rub),rtb) -> NEG(regBy,rb,rub,rtb)
|
||||
let parseCon = Parser.kw "con" >>. parenNoSpace (Parser.pfloat) |>> fun (rt:float) -> CON(rt)
|
||||
|
||||
let parsePromProperties = Parser.choice[
|
||||
parsePos
|
||||
parseNeg
|
||||
parseCon
|
||||
]
|
||||
|
||||
let parseCodes = Parser.kw "codes" >>. parenNoSpace (GecSpecies.parse_species .>> sDelimiter .>>. Parser.pfloat) |>> fun ((codes:string list), rd:float) -> CODES(codes,rd)
|
||||
(*let parseConstitutiveProm = parseCon |>> fun (con:promProperty) -> PROM([con])
|
||||
let parseRegulatedProm = (Parser.kw "pos" <|> Parser.kw "neg") .>>. parenNoSpace (nameGEC .>> sDelimiter .>>. Parser.pfloat .>> sDelimiter .>>. Parser.pfloat .>> sDelimiter .>>. Parser.pfloat) .>> sDelimiter .>>. parseCon |>> fun ((regType:string,((((regBy:string list),rb:float),rub:float),rtb:float)),conProp:promProperty) ->
|
||||
match regType with
|
||||
| "pos" -> PROM([POS(regBy,rb,rub,rtb);conProp])
|
||||
| "neg" -> PROM([NEG(regBy,rb,rub,rtb);conProp])
|
||||
| _ -> failwith ""*)
|
||||
|
||||
let parseRate = Parser.kw "rate" >>. parenNoSpace (Parser.pfloat) |>> fun(r:float) -> RATE(r)
|
||||
|
||||
|
||||
let pdevicedelim = Parser.kw "|" <|> Parser.kw ";"
|
||||
let (parse_device:t<device>) = Parser.name .>> Parser.spaces .>> Parser.kw "=" .>>. Parser.sqBrackets( Parser.sepBy (Parser.name .>> Parser.spaces) pdevicedelim)
|
||||
let deviceParser = Parser.kw "devices" >>.
|
||||
(Parser.sqBrackets (Parser.many parse_device)) .>> Parser.spaces
|
||||
|
||||
|
||||
|
||||
type dnacomponent =
|
||||
| Part of string * partType
|
||||
| Device of device
|
||||
|
||||
let parse_deviceComponents = Parser.kw "components" >>. sqbracketNoSpace (Parser.sepBy (Parser.name .>> Parser.spaces) pdevicedelim)
|
||||
|
||||
|
||||
let partParser =
|
||||
Parser.name .>> delimiter >>= fun n ->
|
||||
Parser.choice [
|
||||
Parser.kw "prom" >>. delimiter >>. (Parser.sepBy parsePromProperties sDelimiter) |>> fun(props) -> Part(n,PROM(props))
|
||||
Parser.kw "rbs" >>. delimiter >>. parseRate |>> fun(rate) -> Part(n,RBS(rate))
|
||||
Parser.kw "pcr" >>. delimiter >>. parseCodes |>> fun(codes) -> Part(n,PCR(codes))
|
||||
pstring "ter" |>> fun (_) -> Part(n, TER)
|
||||
Parser.kw "device" >>. delimiter >>. parse_deviceComponents |>> fun (components) -> Device(n,components)
|
||||
]
|
||||
|
||||
|
||||
let fileParser = (Parser.sepBy partParser NEWLINE)
|
||||
|
||||
|
||||
let parse = fileParser .>> Parser.eof |>> fun(components) ->
|
||||
let partComponents = components |> List.choose
|
||||
(fun x ->
|
||||
match x with
|
||||
| Part(x,y) -> Some(x,y)
|
||||
| _ -> None)
|
||||
let deviceList = components |> List.choose
|
||||
(fun x ->
|
||||
match x with
|
||||
| Device(x) -> Some(x)
|
||||
| _ -> None)
|
||||
|
||||
createTable partComponents deviceList
|
|
@ -0,0 +1,67 @@
|
|||
module Microsoft.Research.GEC.Database
|
||||
|
||||
open Microsoft.Research.GEC
|
||||
open FSBOL.ComponentDefinition
|
||||
open FSBOL.ModuleDefinition
|
||||
open FSBOL.SBOLDocument
|
||||
//open Microsoft.Research.ModellingEngine
|
||||
open Microsoft.Research.CRNEngine
|
||||
open Parser
|
||||
|
||||
|
||||
(* ************************************************************************************************* *)
|
||||
|
||||
(* Devices. *)
|
||||
type device = string * string list
|
||||
|
||||
(* The different kinds of property that part types can have. *)
|
||||
type pcrProperty = CODES of string list * float
|
||||
type promProperty = POS of string list * float * float * float
|
||||
| NEG of string list * float * float * float
|
||||
| CON of float
|
||||
| FRATE of Ast.aexp
|
||||
type rbsProperty = RATE of float
|
||||
|
||||
|
||||
(* An encoding of part types, along with their properties. *)
|
||||
type partType = PCR of pcrProperty
|
||||
| PROM of promProperty list
|
||||
| RBS of rbsProperty
|
||||
| TER
|
||||
|
||||
(* Compute FS(Q^t). *)
|
||||
val speciesInPartType : partType -> string list list
|
||||
|
||||
(* ************************************************************************************************* *)
|
||||
|
||||
(* A "database" consists of a "parts database" and a "reaction database".
|
||||
A "parts database" is just a mapping of part identifiers (i.e. strings) to their part types.
|
||||
A "reaction database" is just a list of reactions. *)
|
||||
type 'a entry = { value:'a; enabled:bool; comments:string }
|
||||
type t = { parts:partType entry Stringmap.t; devices: device list; reactions:Gecreaction.t entry list }
|
||||
|
||||
val partTypeToSBOL: string -> (partType entry) -> ComponentDefinition
|
||||
val createModuleDefinitions: (ComponentDefinition list) -> ((string*(partType entry))list) -> (ModuleDefinition list)
|
||||
val convertTableToSBOLDocument: t -> SBOLDocument
|
||||
val createProteinCDs: (string * (partType entry)) list -> ComponentDefinition list
|
||||
(* The "empty" database. *)
|
||||
val empty : t
|
||||
|
||||
(* Produce a string representation of a database. *)
|
||||
val display : t -> string
|
||||
|
||||
(* Add a part to the database (part id must be unique). *)
|
||||
//val addPart : t -> bool -> string -> string -> string -> string -> t
|
||||
|
||||
(* Add a reaction to the database. *)
|
||||
//val addReaction : t -> bool -> string -> string -> t
|
||||
|
||||
type parser = Parser.t<t>
|
||||
val parse : parser
|
||||
|
||||
type dnacomponent =
|
||||
| Part of string * partType
|
||||
| Device of device
|
||||
|
||||
val partParser: Parser.t<dnacomponent>
|
||||
|
|
@ -0,0 +1,580 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.DirectivesParser
|
||||
|
||||
open Microsoft.Research.CRNEngine
|
||||
open Parser
|
||||
|
||||
(**********************************************************************)
|
||||
(**********************************************************************)
|
||||
(************* Legacy CRN parser **************************************)
|
||||
(**********************************************************************)
|
||||
(**********************************************************************)
|
||||
(* The code to parse directives in this section is duplicated from
|
||||
SLConversion in Classic DSD. The original Lex grammar for the
|
||||
Silver Light version of CRN and DSD were also duplicated
|
||||
(ModellingEngineDotNet had its own parser.mly file, which was copied
|
||||
and modified over in SLDNADotNet). The grammar for CRN directives
|
||||
and species should be the same, but since there might
|
||||
be subtle differences in the two copies of the mly files,
|
||||
the conversion tool is also duplicated here. *)
|
||||
(**********************************************************************)
|
||||
|
||||
// utilities
|
||||
let spaces = Parser.spaces
|
||||
let choice = Parser.choice
|
||||
let kw = Parser.kw
|
||||
let preturn = Parser.preturn
|
||||
let spFloat = Parser.pfloat .>> spaces
|
||||
let spInt = Parser.pint32 .>> spaces
|
||||
let spBool = choice [ kw "true" >>. preturn true
|
||||
; kw "false" >>. preturn false] .>> spaces
|
||||
let spName = Parser.name .>> spaces
|
||||
let paren = Parser.paren
|
||||
let braces = Parser.braces
|
||||
let sqBrackets = Parser.sqBrackets
|
||||
let sepBy = Parser.sepBy
|
||||
let sepBy1 = Parser.sepBy1
|
||||
|
||||
let fpMsg = "Floating point conversion not supported"
|
||||
|
||||
type crnModuleDefinition = (string * string list)
|
||||
type crnInstructions = ((crnModuleDefinition * Instruction list) list) * Instruction list
|
||||
|
||||
type settings = {settings:Crn_settings<Functional>; crn: crnInstructions option; overrideCrn: bool}
|
||||
|
||||
type oldSimMode = JIT
|
||||
| SSA
|
||||
| OSLO of bool (* is stiff? *)
|
||||
| SPACIAL_PERIODIC of int32
|
||||
| SUNDIALS of bool (* is stiff? *)
|
||||
| CME_OSLO_OR_SUNDIALS of bool (* is stiff? *) (* the parser is ambiguous on "cme" *)
|
||||
| LNA_OSLO of bool (* is stiff? *)
|
||||
|
||||
type SpParam = Burnin of int32
|
||||
| SpSamples of int32
|
||||
| Thin of int32
|
||||
| SeparateNoise of bool
|
||||
| NoiseModel of int
|
||||
| Prune of bool
|
||||
|
||||
type CoreElem = CoreW of float
|
||||
| CoreI of float
|
||||
| CoreO of float
|
||||
|
||||
type PointElem = PointX of float
|
||||
| PointY of float
|
||||
| PointW of float
|
||||
| PointV of float
|
||||
|
||||
type ParSpace = ParReal | ParLog
|
||||
type ParVar = ParFixed | ParRandomized | ParInitVal
|
||||
type ParItem = ParAssign of string * float * float * float
|
||||
| ParItem of string * float * float * float * ParSpace * ParVar
|
||||
|
||||
type SweepVar = SweepVar of string list * Value list list
|
||||
|
||||
type SweepItem = NamedSweep of string * SweepVar list
|
||||
| UnnamedSweep of SweepVar
|
||||
|
||||
type KMode = KContextual | KStochastic | KDeterministic
|
||||
|
||||
type VerMode = Encoding of int32
|
||||
| Abstraction of int32
|
||||
| Enumeration of int32
|
||||
| PopBound of int32
|
||||
| DummyRxn of bool
|
||||
| EnfInitial of bool
|
||||
|
||||
type oldDirective = Samples of float option * float option * int32 option // start, end, points
|
||||
| DurationPoints of float option * float option * int32 option // start, end, points
|
||||
| Scale of float
|
||||
| Plot of Expression.t<Species> list
|
||||
| Simulation of oldSimMode
|
||||
| RelTolerance of float
|
||||
| Tolerance of float // maps to abstolerance in deterministic
|
||||
| Seed of int32
|
||||
// | SpecMax of Species.t * int32
|
||||
| OldTime of Time
|
||||
| Concentration of Concentration
|
||||
| Dt of float
|
||||
| XMax of float
|
||||
| Nx of int32
|
||||
| Theta of float
|
||||
| Params of ParItem list
|
||||
| Sweeps of SweepItem list
|
||||
| FitRun of SpParam list
|
||||
| Kinectics of KMode
|
||||
| Crn of crnInstructions * bool
|
||||
// | Verification of VerMode
|
||||
// | StabilityCorrection of float
|
||||
// | CoaxialDAngle of float
|
||||
// | DoubleCoaxialDAngle of float
|
||||
// | Temperature of float
|
||||
// | TerminalDAngle of float
|
||||
|
||||
// Tokens
|
||||
let SAMPLE = kw "sample"
|
||||
let ALL = kw "all"
|
||||
let PLOT = kw "plot"
|
||||
let POINTS = kw "points"
|
||||
let DURATION = kw "duration"
|
||||
let SCALE = kw "scale"
|
||||
let SEED = kw "seed"
|
||||
let SIMULATION = kw "simulation"
|
||||
let DETERMINISTICSTIFF = kw "deterministicstiff"
|
||||
let RELTOLERANCE = kw "reltolerance"
|
||||
let TOLERANCE = kw "tolerance" <|> kw "abstolerance"
|
||||
let EVENT = kw "event"
|
||||
let SPECMAX = kw "specmax"
|
||||
let TIME = kw "time"
|
||||
let CONCENTRATION = kw "concentration"
|
||||
let DT = kw "dt"
|
||||
let XMAX = kw "xmax"
|
||||
let NX = kw "nx"
|
||||
let THETA = kw "theta"
|
||||
let COAXIALDANGLE = kw "coaxialDangle"
|
||||
let DOUBLECOAXIALDANGLE = kw "doubleCoaxialDangle"
|
||||
let COAXIALCORRECTION = kw "coaxialCorrection"
|
||||
let TEMPERATURE = kw "temperature"
|
||||
let TERMINALDANGLE = kw "terminalDangle"
|
||||
let SPATIALIC = kw "spatialic"
|
||||
let SPATIALBC = kw "spatialbc"
|
||||
let SPATIALPLOT = kw "spatialplot"
|
||||
//let COMPILATION = kw "compilation"
|
||||
let DECLARE = kw "declare"
|
||||
let DEFAULTDIFFUSION = kw "defaultdiffusion"
|
||||
let DIFFUSION = kw "diffusion"
|
||||
let LEAKS = kw "leaks"
|
||||
let PINLEAK = kw "pinleak"
|
||||
let PINLEAKS = kw "pinleaks"
|
||||
let LENGTHS = kw "lengths"
|
||||
let MIGRATE = kw "migrate"
|
||||
let LOCALCONCENTRATIONS = kw "localconcentrations"
|
||||
let POLYMERS = kw "polymers"
|
||||
let SEQUENCERATES = kw "sequenceRates"
|
||||
let STABILITYCORRECTION = kw "stabilityCorrection"
|
||||
let TAU = kw "tau"
|
||||
let TOEHOLDS = kw "toeholds"
|
||||
let UNPRODUCTIVE = kw "unproductive"
|
||||
let VERIFICATION = kw "verification"
|
||||
let FIT = kw "fit"
|
||||
let FITRUN = kw "fit_run"
|
||||
let KINETICS = kw "kinetics"
|
||||
let PARAMETERS = kw "parameters"
|
||||
let PLOTWINDOW = kw "plotwindow"
|
||||
let PREDICATES = kw "predicates"
|
||||
let SWEEP = kw "sweep"
|
||||
let CRN = kw "crn"
|
||||
let OVERRIDE = kw "override"
|
||||
|
||||
let COMMA = kw ","
|
||||
let SEMI = kw ";"
|
||||
let AT = kw "@"
|
||||
let UNDERSCORE = kw "_"
|
||||
let SUM = kw "sum"
|
||||
let SUB = kw "sub"
|
||||
let DIFF = kw "diff"
|
||||
let PROD = kw "prod"
|
||||
let DIV = kw "div"
|
||||
let EQUAL = kw "="
|
||||
let DLBRACKET = kw "[["
|
||||
let DRBRACKET = kw "]]"
|
||||
let BAR = kw "|"
|
||||
|
||||
(* each function below parses a specific "directive" string *)
|
||||
// samples directive
|
||||
let dirSamples =
|
||||
SAMPLE >>. Expression.parse spFloat >>= fun x ->
|
||||
choice [ COMMA >>. Expression.parse spFloat >>= fun y ->
|
||||
choice [ ALL >>. preturn (Some (Expression.eval id x), Some (Expression.eval id y), Some 0)
|
||||
; spInt >>= fun z -> preturn (Some (Expression.eval id x), Some (Expression.eval id y), Some z)
|
||||
; preturn (Some (Expression.eval id x), Some (Expression.eval id y), None) ]
|
||||
; ALL >>. preturn (None, Some (Expression.eval id x), Some 0)
|
||||
; spInt >>= fun y -> preturn (None, Some (Expression.eval id x), Some y)
|
||||
; preturn (None, Some (Expression.eval id x), None) ]
|
||||
>>= (Samples >> preturn) // wraps the result inside Samples
|
||||
|
||||
// duration directive
|
||||
let dirDuration =
|
||||
DURATION >>. spFloat >>= fun x ->
|
||||
choice [ COMMA >>. spFloat >>= fun y ->
|
||||
choice [ POINTS >>.
|
||||
choice [ ALL >>. preturn (Some x, Some y, Some 0)
|
||||
; spInt >>= fun z -> preturn (Some x, Some y, Some z) ]
|
||||
; preturn (Some x, Some y, None) ]
|
||||
; POINTS >>. choice [ ALL >>. preturn (None, Some x, Some 0)
|
||||
; spInt >>= fun y -> preturn (None, Some x, Some y) ]
|
||||
; preturn (None, Some x, None) ]
|
||||
>>= (DurationPoints >> preturn )
|
||||
|
||||
// seed directive
|
||||
let dirSeed = SEED >>. spInt >>= (Seed >> preturn)
|
||||
|
||||
// old molecule parser
|
||||
// TODO: double check that "--(cogs)" | "--(+ cogs)" | "--(cogs+)" is not used anymore
|
||||
|
||||
// plots
|
||||
// TODO check empty plot "()" is parsed correctly with many or sepBy, double check that many1 or sepBy1 is not misused
|
||||
let pPlot pSpecies = Expression.parse pSpecies
|
||||
|
||||
|
||||
// plots directive
|
||||
let pPlots pSpecies sp = Parser.sepBy1 (pPlot pSpecies) SEMI sp
|
||||
let dirPlot pSpecies = PLOT >>. pPlots pSpecies >>= (Plot >> preturn)
|
||||
|
||||
|
||||
let curry f (a, b) = f a b
|
||||
|
||||
//let dirSpecMax = SPECMAX >>. DSDParser.speciesParser .>>. spInt >>= (SpecMax >> preturn)
|
||||
let dirTime =
|
||||
let s = Time.Seconds 1.0
|
||||
let m = Time.Seconds 6.0
|
||||
let h = Time.Seconds 3.6
|
||||
let d = Time.Seconds 8.64
|
||||
let ret = OldTime >> preturn
|
||||
TIME >>. choice [ kw "seconds" >>. ret s
|
||||
; kw "s" >>. ret s
|
||||
; kw "minutes" >>. ret m
|
||||
; kw "m" >>. ret m
|
||||
; kw "hours" >>. ret h
|
||||
; kw "h" >>. ret h
|
||||
; kw "days" >>. ret d
|
||||
; kw "d" >>. ret d ]
|
||||
|
||||
let dirConcentration =
|
||||
let m = Concentration.Molar 0
|
||||
let mM = Concentration.Molar -3
|
||||
let uM = Concentration.Molar -6
|
||||
let nM = Concentration.Molar -9
|
||||
let pM = Concentration.Molar -12
|
||||
let fM = Concentration.Molar -15
|
||||
let aM = Concentration.Molar -18
|
||||
let zM = Concentration.Molar -21
|
||||
let yM = Concentration.Molar -24
|
||||
let ret = Concentration >> preturn
|
||||
CONCENTRATION >>. choice [ kw "molar" >>. ret m
|
||||
; kw "M" >>. ret m
|
||||
; kw "milimolar" >>. ret mM
|
||||
; kw "mM" >>. ret mM
|
||||
; kw "millimolar" >>. ret mM
|
||||
; kw "micromolar" >>. ret uM
|
||||
; kw "uM" >>. ret uM
|
||||
; kw "nanomolar" >>. ret nM
|
||||
; kw "nM" >>. ret nM
|
||||
; kw "picomolar" >>. ret pM
|
||||
; kw "pM" >>. ret pM
|
||||
; kw "femtomolar" >>. ret fM
|
||||
; kw "fM" >>. ret fM
|
||||
; kw "attomolar" >>. ret aM
|
||||
; kw "aM" >>. ret aM
|
||||
; kw "zeptomolar" >>. ret zM
|
||||
; kw "zM" >>. ret zM
|
||||
; kw "yoctomolar" >>. ret yM
|
||||
; kw "yM" >>. ret yM ]
|
||||
let dirRelativeTolerance = RELTOLERANCE >>. spFloat >>= (RelTolerance >> preturn)
|
||||
let dirTolerance = TOLERANCE >>. spFloat >>= (Tolerance >> preturn)
|
||||
let dirScale = SCALE >>. spFloat >>= (Scale >> preturn)
|
||||
|
||||
// simulation
|
||||
let dirSimulation =
|
||||
SIMULATION >>. choice [ kw "jit" >>. preturn (Simulation JIT)
|
||||
; kw "stochastic" >>. preturn (Simulation SSA)
|
||||
; kw "deterministicstiff" >>. preturn (Simulation (OSLO true))
|
||||
; kw "deterministic" >>. preturn (Simulation (OSLO false))
|
||||
; kw "spatial1d" >>. preturn (Simulation (SPACIAL_PERIODIC 1))
|
||||
; kw "spatial2d" >>. preturn (Simulation (SPACIAL_PERIODIC 2))
|
||||
; kw "sundials" >>. preturn (Simulation (SUNDIALS false))
|
||||
; kw "sundialsstiff" >>. preturn (Simulation (SUNDIALS true))
|
||||
; kw "cme" >>. preturn (Simulation (CME_OSLO_OR_SUNDIALS false))
|
||||
; kw "cmestiff" >>. preturn (Simulation (CME_OSLO_OR_SUNDIALS true))
|
||||
; kw "lna" >>. preturn (Simulation (LNA_OSLO false))
|
||||
; kw "lnastiff" >>. preturn (Simulation (LNA_OSLO true)) ]
|
||||
|
||||
let dirDT = DT >>. spFloat >>= (Dt >> preturn)
|
||||
let dirXMax = XMAX >>. spFloat >>= (XMax >> preturn)
|
||||
let dirNX = NX >>. spInt >>= (Nx >> preturn)
|
||||
let dirTheta = THETA >>. spFloat >>= (Theta >> preturn)
|
||||
|
||||
// spatial directives
|
||||
// TODO: Add spatial directives
|
||||
let spatialErrorMsg _ = failwith "spatial directives not supported"
|
||||
let dirSpatialic = SPATIALIC >>= spatialErrorMsg
|
||||
|
||||
|
||||
|
||||
let dirSpatialbc = SPATIALBC >>= spatialErrorMsg
|
||||
let dirSpatialPlot = SPATIALPLOT >>= spatialErrorMsg
|
||||
|
||||
let dirDiffusion = DIFFUSION >>= spatialErrorMsg
|
||||
let dirDefaultDiffusion = DEFAULTDIFFUSION >>= spatialErrorMsg
|
||||
|
||||
// parameters
|
||||
let paramP =
|
||||
let f n x y z pType = choice
|
||||
[ kw "fixedvar" >>. preturn (ParItem (n, x, y, z, pType, ParFixed))
|
||||
; kw "fixed" >>. preturn (ParItem (n, x, y, z, pType, ParFixed))
|
||||
; kw "randomized" >>. preturn (ParItem (n, x, y, z, pType, ParRandomized))
|
||||
; kw "random" >>. preturn (ParItem (n, x, y, z, pType, ParRandomized))
|
||||
; kw "init" >>. preturn (ParItem (n, x, y, z, pType, ParInitVal))
|
||||
; kw "initval" >>. preturn (ParItem (n, x, y, z, pType, ParInitVal)) ]
|
||||
spName >>= fun n ->
|
||||
choice [ EQUAL >>. spFloat >>= fun f -> preturn (ParAssign (n, f, f, f))
|
||||
; COMMA >>. Parser.paren (spFloat .>> COMMA .>>. spFloat) .>> COMMA .>>. spFloat .>> COMMA
|
||||
>>= fun ((x,y), z) ->
|
||||
choice [ kw "realspace" >>. COMMA >>. f n x y z ParReal
|
||||
; kw "real" >>. COMMA >>. f n x y z ParReal
|
||||
; kw "log" >>. COMMA >>. f n x y z ParLog
|
||||
; kw "logspace" >>. COMMA >>. f n x y z ParLog ] ]
|
||||
|
||||
let dirParameters = PARAMETERS >>. Parser.sqBrackets (sepBy1 paramP SEMI) >>= (Params >> preturn)
|
||||
|
||||
// sweeps
|
||||
let namesList = Parser.sepBy1 spName COMMA
|
||||
|
||||
let valList = Parser.sepBy1 (Expression.parse spName) COMMA
|
||||
let valListP = Parser.paren valList
|
||||
let valTuples = Parser.sepBy1 valListP COMMA
|
||||
|
||||
let varSweep = choice [ Parser.paren namesList .>> EQUAL .>>. Parser.sqBrackets valTuples
|
||||
>>= (SweepVar >> preturn)
|
||||
; spName .>> EQUAL .>>. Parser.sqBrackets valList >>= fun (n, xs) ->
|
||||
preturn (SweepVar ([n], List.map (fun x -> [x]) xs)) ]
|
||||
let combSweep = Parser.sepBy1 varSweep COMMA
|
||||
|
||||
let dirSweep =
|
||||
SWEEP >>.
|
||||
choice [ paren namesList .>> EQUAL .>>. sqBrackets valTuples >>=
|
||||
(SweepVar >> UnnamedSweep >> (fun x -> [x]) >> Sweeps >> preturn)
|
||||
; spName .>> EQUAL >>= fun n ->
|
||||
choice [ braces combSweep >>= (fun x -> preturn (Sweeps [NamedSweep (n, x)]))
|
||||
; sqBrackets valList >>= (fun x -> preturn (Sweeps [UnnamedSweep (SweepVar ([n], [x]))])) ] ]
|
||||
|
||||
|
||||
let dirCrn =
|
||||
CRN >>. Parser.choice[
|
||||
OVERRIDE >>. Parser.braces (Instruction.parse Species.parse Crn_settings.defaults) |>> fun x -> Crn(x,true)
|
||||
Parser.braces (Instruction.parse Species.parse Crn_settings.defaults) |>> fun x -> Crn(x,false)
|
||||
]
|
||||
|
||||
// fit
|
||||
let dirFit = FIT >>= fun _ -> failwith "fit not supported"
|
||||
|
||||
// fit run
|
||||
let fitElem =
|
||||
choice [ kw "burnin" >>. EQUAL >>. spInt >>= (Burnin >> preturn)
|
||||
; kw "samples" >>. EQUAL >>. spInt >>= (SpSamples >> preturn)
|
||||
; kw "thin" >>. EQUAL >>. spInt >>= (Thin >> preturn) // TODO: default = findintdef "thin" 10 t
|
||||
; kw "separatenoise" >>. EQUAL >>. spBool >>= (SeparateNoise >> preturn) // TODO: default = findbooldef true t
|
||||
; kw "noisemodel" >>. EQUAL >>. spInt >>= (NoiseModel >> preturn) // TODO: Constant t
|
||||
; kw "prune" >>. EQUAL >>. spBool >>= (Prune >> preturn) // TODO: default true t }
|
||||
]
|
||||
let fitRecord = braces (sepBy1 fitElem SEMI)
|
||||
let dirFitRun sp = (FITRUN >>. fitRecord >>= (FitRun >> preturn)) sp
|
||||
|
||||
// plot window, kinectics
|
||||
let dirPlotWindow = PLOTWINDOW >>= fun _ -> failwith "plot window not supported"
|
||||
let dirKinectics = KINETICS >>. choice [ kw "contextual" >>. preturn (Kinectics KContextual)
|
||||
; kw "stochastic" >>. preturn (Kinectics KStochastic)
|
||||
; kw "deterministic" >>. preturn (Kinectics KDeterministic) ]
|
||||
|
||||
// verification
|
||||
let dirVerification = VERIFICATION >>= fun _ -> failwith "verification not supported"
|
||||
|
||||
|
||||
let pOldDirectives pSpecies = [ dirConcentration
|
||||
; dirDT
|
||||
; dirDefaultDiffusion
|
||||
; dirDiffusion
|
||||
; dirDuration
|
||||
; dirFit
|
||||
; dirFitRun
|
||||
; dirKinectics
|
||||
; dirNX
|
||||
; dirParameters
|
||||
; dirPlot pSpecies
|
||||
; dirPlotWindow
|
||||
; dirRelativeTolerance
|
||||
; dirSamples
|
||||
; dirScale
|
||||
; dirSeed
|
||||
; dirSimulation
|
||||
; dirSpatialbc
|
||||
; dirSpatialic
|
||||
; dirSpatialPlot
|
||||
; dirSweep
|
||||
; dirTheta
|
||||
; dirTime
|
||||
; dirTolerance
|
||||
; dirVerification
|
||||
; dirXMax
|
||||
; dirCrn]
|
||||
let oldDirective pSpecies = choice (pOldDirectives pSpecies)
|
||||
|
||||
let oldToCrnParam param =
|
||||
match param with
|
||||
| ParAssign (n, f1, f2, f3) ->
|
||||
let par : Parameter =
|
||||
{ name = n
|
||||
; value = f3
|
||||
; prior = Some { interval = Interval.Real
|
||||
; variation = Variation.Fixed
|
||||
; distribution = Distribution.Uniform {min = f1; max = f2} } }
|
||||
par
|
||||
| ParItem (n, f1, f2, f3, parSpace, parVar) ->
|
||||
let pr : Prior = { interval = match parSpace with
|
||||
| ParReal -> Interval.Real
|
||||
| ParLog -> Interval.Log
|
||||
; variation = match parVar with
|
||||
| ParFixed -> Variation.Fixed
|
||||
| ParRandomized -> Variation.Random
|
||||
| ParInitVal -> Variation.Initial2
|
||||
; distribution = Distribution.Uniform {min = f1; max = f2}}
|
||||
let par : Parameter = { name = n
|
||||
; value = f3
|
||||
; prior = Some pr }
|
||||
par
|
||||
|
||||
|
||||
let oldToCrnSweepVar (SweepVar (names, values)) : Assignment =
|
||||
{ variables = names
|
||||
; values = values }
|
||||
|
||||
|
||||
let sweep_id = ref 0
|
||||
let new_sweep_name () =
|
||||
let id = !sweep_id + 1 in
|
||||
sweep_id := id
|
||||
"sweep_" + id.ToString() // the hard-coded "sweep_" is from the old DNA solution
|
||||
|
||||
let oldToCrnSweep (sweep:SweepItem) =
|
||||
match sweep with
|
||||
| UnnamedSweep sweep -> let newName = new_sweep_name()
|
||||
Sweep.create(newName,[oldToCrnSweepVar sweep])
|
||||
| NamedSweep (n, sweeps) -> let asns = List.map oldToCrnSweepVar sweeps
|
||||
Sweep.create(n,asns)
|
||||
|
||||
|
||||
let fromOpt m x = match m with
|
||||
| None -> x
|
||||
| Some y -> y
|
||||
|
||||
let updateSettings (cs : settings ) oldDir =
|
||||
match oldDir with
|
||||
| Samples (startOpt, endOpt, pointsOpt)
|
||||
| DurationPoints (startOpt, endOpt, pointsOpt) ->
|
||||
{cs with settings = {cs.settings with simulation = {cs.settings.simulation with points = fromOpt pointsOpt cs.settings.simulation.points
|
||||
; initial = fromOpt startOpt cs.settings.simulation.initial
|
||||
; final = fromOpt endOpt cs.settings.simulation.final}}}
|
||||
| Scale f -> { cs with settings = {cs.settings with stochastic = { cs.settings.stochastic with scale = f }}}
|
||||
| Plot ps -> { cs with settings = {cs.settings with simulation = { cs.settings.simulation with plots = List.map (Expression.map Key.Species) ps @ cs.settings.simulation.plots}}}
|
||||
| Simulation smode ->
|
||||
{cs with settings = {cs.settings with simulator =
|
||||
match smode with
|
||||
| JIT -> Simulator.SSA
|
||||
| SSA -> Simulator.SSA
|
||||
| OSLO _ -> Simulator.Oslo
|
||||
| SPACIAL_PERIODIC _ -> Simulator.PDE
|
||||
| SUNDIALS _ -> Simulator.Sundials
|
||||
| CME_OSLO_OR_SUNDIALS _ -> Simulator.CME
|
||||
| LNA_OSLO _ -> Simulator.LNA
|
||||
; deterministic = {
|
||||
cs.settings.deterministic with
|
||||
stiff = match smode with
|
||||
| OSLO isStiff -> isStiff
|
||||
| LNA_OSLO isStiff -> isStiff
|
||||
| SUNDIALS isStiff -> isStiff
|
||||
| CME_OSLO_OR_SUNDIALS isStiff -> isStiff
|
||||
| SPACIAL_PERIODIC _ -> false
|
||||
| SSA -> false
|
||||
| JIT -> false
|
||||
}
|
||||
; simulation = cs.settings.simulation
|
||||
}} // TODO: add dimensions to spatial settings
|
||||
| RelTolerance f -> { cs with settings = {cs.settings with deterministic = { cs.settings.deterministic with reltolerance = f }}}
|
||||
| Tolerance f -> { cs with settings = {cs.settings with deterministic = { cs.settings.deterministic with abstolerance = f }}}
|
||||
| Seed i -> { cs with settings = {cs.settings with simulation = { cs.settings.simulation with seed = Some i}}}
|
||||
| OldTime _ -> cs
|
||||
| Concentration _ -> cs
|
||||
| Dt f -> { cs with settings = {cs.settings with spatial = { cs.settings.spatial with dt = f }}}
|
||||
| XMax f -> { cs with settings = {cs.settings with spatial = { cs.settings.spatial with xmax = f }}}
|
||||
| Nx i -> { cs with settings = {cs.settings with spatial = { cs.settings.spatial with nx = i }}}
|
||||
| Theta _ -> failwith "theta directive not supported in the spatial simulator"
|
||||
| Params ps -> { cs with settings = {cs.settings with parameters = List.map oldToCrnParam ps }}
|
||||
| Sweeps ss -> { cs with settings = {cs.settings with sweeps = List.map oldToCrnSweep ss }}
|
||||
| FitRun ps ->
|
||||
let updateSpSet (inf:Inference_settings) spParam =
|
||||
match spParam with
|
||||
| Burnin i -> { inf with burnin = i}
|
||||
| SpSamples i -> { inf with samples = i}
|
||||
| Thin i -> { inf with thin = i }
|
||||
| SeparateNoise b -> { inf with noise_parameter = if b
|
||||
then Noise_parameter.Multiple
|
||||
else Noise_parameter.Random}
|
||||
| NoiseModel i -> { inf with noise_model = match i with
|
||||
| 0 -> Noise_model.Constant
|
||||
| 1 -> Noise_model.Proportional
|
||||
| _ -> failwith "Unrecognised noise model. Use linear or proportional." }
|
||||
| Prune b -> { inf with prune = b}
|
||||
{ cs with settings = {cs.settings with inference = List.fold updateSpSet cs.settings.inference ps }}
|
||||
| Kinectics kmode ->
|
||||
{ cs with settings =
|
||||
{cs.settings with
|
||||
simulation =
|
||||
{cs.settings.simulation with
|
||||
kinetics =
|
||||
match kmode with
|
||||
| KContextual -> Kinetics.Contextual
|
||||
| KStochastic -> Kinetics.Stochastic
|
||||
| KDeterministic -> Kinetics.Deterministic } }}
|
||||
| Crn (instructions,ovveride) -> {cs with crn = Some(instructions); overrideCrn = ovveride}
|
||||
|
||||
let parseOldDirectives pSpecies : Parser.t<settings> =
|
||||
Parser.many (Parser.kw "directive" >>. oldDirective pSpecies)
|
||||
.>> spaces
|
||||
>>= (fun oldSettings -> let def : settings = {settings=Crn_settings.defaults;crn=None;overrideCrn=false}
|
||||
let settings = List.fold updateSettings def oldSettings
|
||||
preturn settings)
|
||||
|
||||
(* legacy CRN parser, parses the body of a CRN written in the Silver Light tool's syntax.
|
||||
The parser is parametric to the species, to allow species names such as '"<a b c>"'
|
||||
for testing purposes in Classic DSD. *)
|
||||
(*type instruction =
|
||||
| Reaction of Reaction<Species,Value,Functional>
|
||||
| Initial of Initial<Species,Value>
|
||||
|
||||
let convert_instructions (instructions:instruction list) =
|
||||
let f (reactions,initials) command =
|
||||
match command with
|
||||
| Reaction reaction -> reaction::reactions, initials
|
||||
| Initial initial -> reactions, initial::initials
|
||||
let reactions, initials = List.fold f ([],[]) instructions
|
||||
List.rev reactions, List.rev initials
|
||||
|
||||
let create_from_instructions (settings:Crn_settings<Functional>) (instructions:instruction list) =
|
||||
let reactions,initials = convert_instructions instructions
|
||||
Crn.create "" settings reactions initials Stringmap.empty
|
||||
|
||||
let parse_legacy_SL pSpecies =
|
||||
let zeroVal (init : float) = Expression.Float init
|
||||
let zero = Expression.Float 0.0
|
||||
let unitVal = Expression.Float 1.0
|
||||
|
||||
// base parsers
|
||||
let pValue = Expression.parse (Parser.name .>> Parser.spaces)
|
||||
let pExpr = Expression.parse (Key.parse pSpecies)
|
||||
|
||||
// crn parsers
|
||||
let pInitial iv = Initial.parse pSpecies pValue zero (zeroVal iv) |>> Initial
|
||||
let pConstant iv = Parser.kw "constant" >>. pSpecies .>>. pValue >>= fun (sp, v) ->
|
||||
Parser.preturn (Initial.create(true, v, sp, (zeroVal iv), None) |> Initial)
|
||||
let pEvent = Parser.kw "event" >>. pSpecies .>>. pValue .>> Parser.kw "@" .>>. pValue
|
||||
>>= fun ((sp, amount), time) -> Parser.preturn (Initial.create(false, amount, sp, time, None) |> Initial)
|
||||
let pReaction = Reaction.parse pSpecies pValue pExpr unitVal |>> Reaction
|
||||
let pLine iv = (pConstant iv <|> pEvent <|> pInitial iv) <|> pReaction
|
||||
let pBar = Parser.kw "|"
|
||||
|
||||
// full CRN parser
|
||||
parseOldDirectives pSpecies >>= fun settings ->
|
||||
Parser.spaces >>. Parser.opt pBar
|
||||
>>. Parser.sepBy (pLine settings.settings.simulation.initial) pBar
|
||||
|>> create_from_instructions settings.settings*)
|
|
@ -0,0 +1,783 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.GECEngine
|
||||
|
||||
open System
|
||||
open Microsoft.Research.GEC
|
||||
open Microsoft.Research.CRNEngine
|
||||
//open Microsoft.Research.ModellingEngine
|
||||
open Microsoft.Research.CRNEngine
|
||||
open FSBOL
|
||||
open FSBOL.JsonSerializer
|
||||
open FSBOL.SBOLDocument
|
||||
open FSBOL.TopLevel
|
||||
open FSBOL.ComponentDefinition
|
||||
open Microsoft.Research.CRNEngine.InferenceSiteGraph
|
||||
open Microsoft.Research.GEC.Trans
|
||||
open Microsoft.Research.GEC.Settings
|
||||
open Microsoft.Research.GEC.Program
|
||||
open Microsoft.Research.FSBOLWrapper
|
||||
|
||||
(* Main GUI datatype. *)
|
||||
type t = {
|
||||
options:Options.t;
|
||||
database:Database.t;
|
||||
solution:(Ast.directive list * Main.tSolution * Trans.gecConstraint list * Trans.tArithmeticConstraints * string list) option
|
||||
}
|
||||
let empty = {options = Options.default_options; database = Database.empty; solution = None}
|
||||
|
||||
(******************************************************************************)
|
||||
(* *** Get/set GUI options. *)
|
||||
|
||||
(* Get or set the "options" part of the GUI data structure. *)
|
||||
let getOptions (gec:t) = gec.options
|
||||
let setOptions (opts:Options.t) (gec:t) = {gec with options = opts}
|
||||
|
||||
(* Get, set or erase the "solution" part of the GUI data structure. *)
|
||||
let setSolution (ds:Ast.directive list) (sol:Main.tSolution) (prologConstraints:Trans.gecConstraint list) (arithmeticConstraints:Trans.tArithmeticConstraints)
|
||||
(log:string list) (gec:t) = {gec with solution = Some (ds, sol,prologConstraints,arithmeticConstraints,log)}
|
||||
let getSolution (gec:t) = gec.solution
|
||||
let eraseSolution (gec:t) = {gec with solution = None}
|
||||
|
||||
(* Access the parts and reactions database. *)
|
||||
let getDatabase (gec:t) = gec.database
|
||||
let setDatabase (db:Database.t) (gec:t) = {gec with database = db}
|
||||
|
||||
(* Produce a string representation of the results of the translation process, for debugging purposes... *)
|
||||
let getDebuggingOutput (g:t) =
|
||||
match (getSolution g) with
|
||||
| None -> ""
|
||||
| Some (ds, sol,prologConstraints,arithmeticConstraints,log) ->
|
||||
let bbTemplatesDebug = Lib.string_of_list (fun xs -> "[" + (Lib.string_of_list Lib.id "; " xs) + "]") Lib.newline sol.bbDevices in
|
||||
let prologConstraintsDebug = Lib.string_of_list Trans.printConstraint Lib.newline prologConstraints in
|
||||
let arithmeticConstraintsDebug = Lib.string_of_list Trans.stringOfArithmeticConstraint Lib.newline arithmeticConstraints in
|
||||
let lbsProgDebug = Trans.lbsProgToStr sol.lbsProgram [] in // is empty list OK here for varDefs?
|
||||
let rateDecsDebug = Lib.string_of_list (fun (r,f) -> r + " |==> " + (Lib.display_float f)) Lib.newline sol.rateDecs in
|
||||
let varAssDebug = sol.getVarAssString() in
|
||||
let databaseDebug = Database.display (getDatabase g) in
|
||||
let logDebug = Lib.string_of_list Lib.id Lib.newline log in
|
||||
let directivesDebug = match ds with [] -> "" | ds -> Lib.string_of_list Ast.stringOfDirective Lib.newline ds in
|
||||
"bbTemplates:" + Lib.newline +
|
||||
"============" + Lib.newline +
|
||||
bbTemplatesDebug + Lib.newline + Lib.newline +
|
||||
"rateDecs:" + Lib.newline +
|
||||
"=========" + Lib.newline +
|
||||
rateDecsDebug + Lib.newline + Lib.newline +
|
||||
"varAss:" + Lib.newline +
|
||||
"=======" + Lib.newline +
|
||||
varAssDebug + Lib.newline + Lib.newline +
|
||||
"Arithmetic constraints:" + Lib.newline +
|
||||
"=======================" + Lib.newline +
|
||||
arithmeticConstraintsDebug + Lib.newline + Lib.newline +
|
||||
"Database:" + Lib.newline +
|
||||
"=========" + Lib.newline +
|
||||
databaseDebug + Lib.newline + Lib.newline +
|
||||
"lbsProg:" + Lib.newline +
|
||||
"========" +
|
||||
lbsProgDebug + Lib.newline + Lib.newline +
|
||||
"directives:" + Lib.newline +
|
||||
directivesDebug + Lib.newline + Lib.newline +
|
||||
"PROLOG Constraints:" + Lib.newline +
|
||||
"============" + Lib.newline +
|
||||
prologConstraintsDebug + Lib.newline + Lib.newline +
|
||||
"log:" + Lib.newline +
|
||||
"====" + Lib.newline +
|
||||
logDebug + Lib.newline
|
||||
|
||||
(* LBS program text. *)
|
||||
let getGECProgramText (g:t) = Options.getGECProgramText (getOptions g)
|
||||
let setGECProgramText (s:string) (g:t) = setOptions (Options.setGECProgramText s (getOptions g)) g
|
||||
|
||||
(* Option to enable simulation-only reactions. *)
|
||||
let getSimulationOnlyReactionsOption (g:t) = Options.getSimulationOnlyReactions (getOptions g)
|
||||
let setSimulationOnlyReactionsOption (b:bool) (g:t) = setOptions (Options.setSimulationOnlyReactions b (getOptions g)) g
|
||||
|
||||
(******************************************************************************)
|
||||
(* *** Access other information from the datatypes. *)
|
||||
|
||||
(* Have the options changed enough to warrant recompilation? *)
|
||||
let identicalOptions (gold:t) (gnew:t) =
|
||||
((getGECProgramText gold) = (getGECProgramText gnew)) &&
|
||||
((getSimulationOnlyReactionsOption gold) = (getSimulationOnlyReactionsOption gnew)) &&
|
||||
((getDatabase gold) = (getDatabase gnew))
|
||||
|
||||
(* Maybe prefix some directives onto an LBS program. *)
|
||||
let prefixDirectives (ds:Ast.directive list) (body:string) =
|
||||
match ds with
|
||||
| [] -> body
|
||||
| ds -> (Lib.string_of_list Ast.stringOfDirective Lib.newline ds) + Lib.newline + Lib.newline + body
|
||||
|
||||
(* Get the "default" LBS program, i.e. with general reactions (no substitution applied). *)
|
||||
let getDefaultLBSProgram (g:t) =
|
||||
match (getSolution g) with
|
||||
| Some(ds,sol,_,_,_) -> Some(prefixDirectives ds (sol.getProgramDefault()))
|
||||
| None -> None
|
||||
|
||||
(* Get a particular LBS program instance, corresponding to a particular set of variable instantiations. *)
|
||||
let getLBSProgramInstance (num:int) (g:t) =
|
||||
match (getSolution g) with
|
||||
| Some(ds,sol,_,_,_) ->
|
||||
let ds = List.map (Subst.applyToDirective (List.item num sol.substs)) ds in
|
||||
Some(prefixDirectives ds (sol.getProgramInstance(num)))
|
||||
| None -> None
|
||||
|
||||
(* Get a particular species instance. *)
|
||||
let getSpeciesAssignment (num:int) (g:t) =
|
||||
match (getSolution g) with
|
||||
| Some(_,sol,_,_,_) -> sol.getSpecAss(num)
|
||||
| None -> ""
|
||||
|
||||
(* Get a particular devices instance. *)
|
||||
let getDevicesInstance (num:int) (g:t) =
|
||||
match (getSolution g) with
|
||||
| Some(_,sol,_,_,_) -> sol.getDevicesInstance(num)
|
||||
| None -> ""
|
||||
|
||||
(* Get a particular devices instance as a string list list *)
|
||||
let getDevicesInstanceStructured (num:int) (g:t) =
|
||||
match (getSolution g) with
|
||||
| Some(_,sol,_,_,_) -> sol.getDevicesInstanceStructured(num)
|
||||
| None -> List.toArray([])
|
||||
|
||||
(* Get the number of solutions. *)
|
||||
let getNumSolutions (g:t) =
|
||||
match (getSolution g) with
|
||||
| Some(_,sol,_,_,_) -> sol.numSolutions
|
||||
| None -> 0
|
||||
|
||||
(* Get the directives text (if any). *)
|
||||
let getDirectives (g:t) =
|
||||
match (getSolution g) with
|
||||
| Some(ds,_,_,_,_) -> Some ds
|
||||
| None -> None
|
||||
|
||||
(******************************************************************************)
|
||||
(* Process a GEC program. *)
|
||||
|
||||
let reduce_gecprog (prog:Ast.prog) =
|
||||
let rec reduce (p:Ast.prog)=
|
||||
match p with
|
||||
| Ast.Par(p1,p2) ->
|
||||
let rp1 = reduce p1
|
||||
let rp2 = reduce p2
|
||||
match rp1 with
|
||||
| Ast.Nil ->
|
||||
match rp2 with
|
||||
| Ast.Nil -> Ast.Nil
|
||||
| _ -> rp2
|
||||
| _ ->
|
||||
match rp2 with
|
||||
| Ast.Nil -> rp1
|
||||
| _ -> Ast.Par(rp1,rp2)
|
||||
| Ast.Seq(p1,p2) ->
|
||||
let rp1 = reduce p1
|
||||
let rp2 = reduce p2
|
||||
match rp1 with
|
||||
| Ast.Nil ->
|
||||
match rp2 with
|
||||
| Ast.Nil -> Ast.Nil
|
||||
| _ -> rp2
|
||||
| _ ->
|
||||
match rp2 with
|
||||
| Ast.Nil -> rp1
|
||||
| _ -> Ast.Seq(rp1,rp2)
|
||||
| Ast.Comp(c,p1) -> Ast.Comp(c,reduce p1)
|
||||
| Ast.New(n,p1) -> Ast.New(n,reduce p1)
|
||||
| Ast.TemplateDef(tname,targs,p1,p2) -> Ast.TemplateDef(tname,targs,reduce p1, reduce p2)
|
||||
| Ast.Copy(i,p1,b1,b2) -> Ast.Copy(i,reduce p1,b1,b2)
|
||||
| _ -> p
|
||||
reduce prog
|
||||
|
||||
|
||||
let unroll_gecprog (gecprog:ClassicProgram) =
|
||||
let template_prog = gecprog.templates
|
||||
let rec unroll_templates (prog:Ast.prog) =
|
||||
match prog with
|
||||
| Ast.TemplateDef(tempname,tempargs,body,next) ->
|
||||
match next with
|
||||
| Ast.TemplateDef(_) -> [(tempname,tempargs,body)]@(unroll_templates next)
|
||||
| Ast.Nil -> [(tempname,tempargs,body)]
|
||||
| _ -> failwith "Top Templates should not have anything other than TemplateDef and Nil in the recursive structure."
|
||||
| Ast.Nil -> []
|
||||
| _ -> failwith "Top Templates should not have anything other than TemplateDef and Nil in the recursive structure."
|
||||
|
||||
let templates = unroll_templates template_prog
|
||||
|
||||
let find_key (map) key=
|
||||
map |> List.tryFind(fun (x,y:Ast.abstractComplex) -> x = key)
|
||||
|
||||
let rec sub_exp (e:Ast.aexp) (map) =
|
||||
match e with
|
||||
| Ast.FloatAExp _ -> e
|
||||
| Ast.IdAExp(s) ->
|
||||
match (find_key (map) s) with
|
||||
| Some(mkey,mval_list) ->
|
||||
match mval_list with
|
||||
| [mval] ->
|
||||
match mval with
|
||||
| Ast.IdVal(id) -> Ast.IdAExp(id)
|
||||
| Ast.FloatVal(f) -> Ast.FloatAExp(f)
|
||||
| Ast.AlgebraicExp(exp) -> exp
|
||||
| _ -> failwith "Shouldn't really see a wild card in template invocation?"
|
||||
| _ -> failwith "Improper Template Invocation"
|
||||
| None -> e
|
||||
| Ast.PlusAExp(p1,p2) -> Ast.PlusAExp(sub_exp p1 map,sub_exp p2 map)
|
||||
| Ast.MinusAExp(p1,p2) -> Ast.MinusAExp(sub_exp p1 map,sub_exp p2 map)
|
||||
| Ast.MulAExp(p1,p2) -> Ast.MulAExp(sub_exp p1 map,sub_exp p2 map)
|
||||
| Ast.DivAExp(p1,p2) -> Ast.DivAExp(sub_exp p1 map,sub_exp p2 map)
|
||||
| Ast.PowAExp(p1,p2) -> Ast.PowAExp(sub_exp p1 map,sub_exp p2 map)
|
||||
|
||||
let sub_value (v:Ast.value) (map) =
|
||||
match v with
|
||||
| Ast.IdVal (x) ->
|
||||
match (find_key map x) with
|
||||
| Some(mkey,mval_list) ->
|
||||
match mval_list with
|
||||
| [mval] -> mval
|
||||
| _ -> failwith "Improper Template Invocation"
|
||||
| None -> v
|
||||
| Ast.FloatVal f -> v
|
||||
| Ast.WildCardVal -> v
|
||||
| Ast.AlgebraicExp exp -> Ast.AlgebraicExp(sub_exp exp map)
|
||||
|
||||
let sub_abstractcomplex (ac:Ast.abstractComplex) (map) =
|
||||
match ac with
|
||||
| [Ast.IdVal(id)] ->
|
||||
match (find_key map id) with
|
||||
| Some(mkey,mval) -> mval
|
||||
| None -> ac
|
||||
| _ -> ac
|
||||
|
||||
let sub_string (s:string) (map) =
|
||||
match (find_key map s) with
|
||||
| Some(mkey,mval) ->
|
||||
match mval with
|
||||
| [Ast.IdVal(id)] -> id
|
||||
| _ -> failwith "Improper Template Invocation - Compartment name"
|
||||
| None -> s
|
||||
|
||||
let rec sub_prog (prog:Ast.prog) (map) =
|
||||
match prog with
|
||||
| Ast.Brick(v,btype,props) ->
|
||||
let sv = sub_value v map
|
||||
let sprops =
|
||||
props |> List.map (fun (x,y) ->
|
||||
let sy = y |> List.map (fun z ->
|
||||
match z with
|
||||
| [Ast.IdVal(id)] ->
|
||||
match (find_key (map) id) with
|
||||
| Some(mkey,mval) -> mval
|
||||
| None -> z
|
||||
| _ -> z)
|
||||
(x,sy))
|
||||
Ast.Brick(sv,btype,sprops)
|
||||
| Ast.Reac(enz,reac,prod,rate,sim) ->
|
||||
let senz = enz |> List.map (fun x -> sub_abstractcomplex x map)
|
||||
let sreac = reac |> List.map (fun x -> sub_abstractcomplex x map)
|
||||
let sprod = prod |> List.map (fun x -> sub_abstractcomplex x map)
|
||||
Ast.Reac(senz,sreac,sprod,sub_value rate map,sim)
|
||||
| Ast.Trans(reac,prod,comp,rate,sim,dir) -> Ast.Trans(sub_abstractcomplex reac map,sub_abstractcomplex prod map,sub_string comp map,sub_value rate map,sim,dir)
|
||||
| Ast.TemplateInv(tname,targs) -> //This maybe a corner case
|
||||
let sargs = targs |> List.map (fun x -> sub_abstractcomplex x map)
|
||||
Ast.TemplateInv(tname,sargs)
|
||||
| Ast.Seq(s1,s2) -> Ast.Seq(sub_prog s1 map,sub_prog s2 map)
|
||||
| Ast.Par(s1,s2) -> Ast.Par(sub_prog s1 map,sub_prog s2 map)
|
||||
| Ast.Comp(s,cprog) -> Ast.Comp(sub_string s map,sub_prog cprog map)
|
||||
| Ast.New(n,nprog) -> Ast.New(sub_string n map,sub_prog nprog map)
|
||||
| Ast.Constraint(c1,op,c2) -> Ast.Constraint(sub_exp c1 map,op,sub_exp c2 map)
|
||||
| Ast.Rate(v,rate) -> Ast.Rate(sub_value v map,rate)
|
||||
| Ast.Copy(i,cprog,b1,b2) -> Ast.Copy(i,sub_prog cprog map,b1,b2)
|
||||
| _ -> prog
|
||||
|
||||
let rec unroll_prog (prog:Ast.prog) (templates)=
|
||||
match prog with
|
||||
| Ast.TemplateInv(tempname,args) ->
|
||||
match (templates |> List.tryFind (fun(x,y,z) -> x = tempname)) with
|
||||
| Some(tname,targs,tprog) ->
|
||||
let subs = List.zip targs args
|
||||
let sprog = sub_prog tprog subs
|
||||
unroll_prog sprog templates
|
||||
| None ->
|
||||
failwith ("Template " + tempname + " not defined")
|
||||
| Ast.TemplateDef(name,args,body,next) ->
|
||||
let unroll_body = unroll_prog body templates //This maybe optional?
|
||||
unroll_prog next ((name,args,unroll_body)::templates)
|
||||
| Ast.Seq(s1,s2) ->
|
||||
let u_s1 = unroll_prog s1 templates
|
||||
let u_s2 = unroll_prog s2 templates
|
||||
Ast.Seq(u_s1,u_s2)
|
||||
| Ast.Par(p1,p2) ->
|
||||
let u_p1 = unroll_prog p1 templates
|
||||
let u_p2 = unroll_prog p2 templates
|
||||
Ast.Par(u_p1,u_p2)
|
||||
| Ast.Comp (name,prog) ->
|
||||
let u_prog = unroll_prog prog templates
|
||||
Ast.Comp(name,u_prog)
|
||||
| Ast.New(n,prog) ->
|
||||
let u_prog = unroll_prog prog templates
|
||||
Ast.New(n,u_prog)
|
||||
| Ast.Copy(i,prog,b1,b2) ->
|
||||
let u_prog = unroll_prog prog templates
|
||||
Ast.Copy(i,u_prog,b1,b2)
|
||||
| _ -> prog
|
||||
|
||||
let unrolled_top = reduce_gecprog (unroll_prog gecprog.prog templates)
|
||||
let unrolled_systems = gecprog.systems |> List.map(fun x -> {x with prog = reduce_gecprog (unroll_prog x.prog templates)})
|
||||
{gecprog with prog = unrolled_top; systems = unrolled_systems}
|
||||
|
||||
|
||||
let translate_systems_to_prog (gecprog:ClassicProgram) =
|
||||
let systems = gecprog.systems |> List.map (fun x -> Ast.Comp(x.name,x.prog))
|
||||
let parsystems = Program.fold_parallel systems
|
||||
let top_prog = gecprog.prog
|
||||
|
||||
match parsystems with
|
||||
| Ast.Nil -> top_prog
|
||||
| _ ->
|
||||
match top_prog with
|
||||
| Ast.Nil -> parsystems
|
||||
| _ -> Ast.Par(top_prog,parsystems)
|
||||
|
||||
|
||||
|
||||
exception CompileException of string * exn
|
||||
|
||||
let modify_crn (crn:Crn) (settings:Gec_settings) crnSettings=
|
||||
let instructions = settings.crn
|
||||
let overrideCrn = settings.overrideCrn
|
||||
if overrideCrn then
|
||||
(None,instructions)
|
||||
//Crn.create_from_instructions crnSettings instructions
|
||||
else
|
||||
Some(crn),instructions
|
||||
(*let basecrn = {crn with settings=crnSettings}.saturate_initials()
|
||||
let instCrn = Crn.create_from_instructions crnSettings instructions
|
||||
let reactions' = basecrn.reactions@instCrn.reactions
|
||||
//let attributes = instCrn.attributes
|
||||
let attributes' = instCrn.attributes
|
||||
|> Map.toList
|
||||
|> List.fold (fun (acc:Stringmap.t<Attributes>) (x,y) -> acc.Add(x,y)) basecrn.attributes
|
||||
let initials' = basecrn.initials@instCrn.initials
|
||||
{basecrn with reactions=reactions';attributes=attributes';initials=initials'}*)
|
||||
|
||||
type solve_result = { solution : t
|
||||
; graph : InferenceSiteGraph.IGraph
|
||||
; sbol : SBOLDocument
|
||||
; crnString: string}
|
||||
|
||||
let getLBSSystems (gecprog:ClassicProgram) (lbs:tLBSProg) =
|
||||
let systems = gecprog.systems
|
||||
let system_names = systems |> List.map (fun x -> x.name)
|
||||
|
||||
let rec lbsSystem lbs =
|
||||
match lbs with
|
||||
| LBSComp(comp,prog) ->
|
||||
if (system_names |> List.contains comp) then
|
||||
[lbs]
|
||||
else
|
||||
[]
|
||||
| LBSPar(p1,p2) ->
|
||||
(lbsSystem p1)@(lbsSystem p2)
|
||||
| LBSReacAbstraction(_,prog) -> lbsSystem prog
|
||||
| LBSCompDec(comp,prog) -> lbsSystem prog
|
||||
| LBSCopy(i,prog) -> lbsSystem prog
|
||||
| _ -> []
|
||||
|
||||
let rec lbsTop lbs =
|
||||
match lbs with
|
||||
| LBSComp(comp,prog) ->
|
||||
if (system_names |> List.contains comp) then
|
||||
Trans.LBSNil
|
||||
else
|
||||
lbs
|
||||
| LBSPar(p1,p2) ->
|
||||
LBSPar(lbsTop p1,lbsTop p2)
|
||||
| LBSReacAbstraction(x,prog) -> LBSReacAbstraction(x,lbsTop prog)
|
||||
| LBSCompDec(comp,prog) -> LBSCompDec(comp,lbsTop prog)
|
||||
| LBSCopy(i,prog) -> LBSCopy(i,lbsTop prog)
|
||||
| _ -> lbs
|
||||
|
||||
(lbsTop lbs,lbsSystem lbs)
|
||||
|
||||
let create_inference_graph (crnSettings:Crn_settings<Functional>) (gecprog:ClassicProgram) (top_crn:(Crn option * crnInstructions)) (system_crn_map) (db)=
|
||||
let dir_str = Program.crnSettings_to_string crnSettings
|
||||
let modules_str = Program.modules_to_string crnSettings.simulation.initial gecprog.modules
|
||||
let devices_str = Lib.string_of_list (fun x -> Program.deviceDefinition_to_string x) "\n" gecprog.devices
|
||||
let top_prog_str = Program.crn_contents_to_string crnSettings.simulation.initial top_crn
|
||||
|
||||
let system_strings = gecprog.systems
|
||||
|> List.map (fun sys ->
|
||||
match (system_crn_map |> List.tryFind(fun (x,crn) -> x = sys.name)) with
|
||||
| Some(_,crn) -> Program.system_to_string crn gecprog.modules gecprog.devices sys db
|
||||
| None -> failwith ("Unexpected error. System name not found in to_string method for: " + sys.name)
|
||||
)
|
||||
let system_str = Lib.string_of_list (fun x -> x) "\n" system_strings
|
||||
|
||||
let ig_str =
|
||||
match gecprog.graph with
|
||||
| [] ->
|
||||
match system_crn_map with
|
||||
| [] -> "" //"node node0 { }"
|
||||
| _ ->
|
||||
let system_names = system_crn_map |> List.map (fun (x,y) -> x)
|
||||
"node node0 { systems = [" + (Lib.string_of_list (fun x -> x) ";" system_names) + "] }"
|
||||
| _ -> Lib.string_of_list (fun x -> Program.igElement_to_string x) "\n" gecprog.graph
|
||||
|
||||
|
||||
dir_str + modules_str + devices_str + top_prog_str + system_str + ig_str
|
||||
|
||||
|
||||
let getSBOLAssignment (bbTemplates:Trans.tBbDevices) (table:Database.t) (substs:Subst.t list) (index:int)=
|
||||
let assignment = substs.Item(index)
|
||||
|
||||
let findPart (id:string) =
|
||||
match Stringmap.tryFind id table.parts with
|
||||
| Some entry -> Some entry.value
|
||||
| None -> None
|
||||
|
||||
let IdExists (id:string) =
|
||||
match findPart id with
|
||||
| Some(_) -> true
|
||||
| None -> false
|
||||
|
||||
let createTUAssignment (tu:string list) =
|
||||
let createCDAssignment (p:string) =
|
||||
let partName =
|
||||
match (IdExists p) with
|
||||
| true ->
|
||||
p
|
||||
| false ->
|
||||
match assignment.Item(p) with
|
||||
| Subst.PART(partVal) -> partVal
|
||||
| _ -> failwith "Can't find the part in the substitution. Some error occurred."
|
||||
let part =
|
||||
match Stringmap.tryFind partName table.parts with
|
||||
| Some entry -> entry
|
||||
| None -> failwith "Can't find the part in the database. Some error occurred."
|
||||
|
||||
let cd = Database.partTypeToSBOL partName part
|
||||
(cd,(partName,part))
|
||||
let cdList = tu |> List.map (fun x -> (createCDAssignment x))
|
||||
cdList
|
||||
let urlPrefix = "http://www.microsoft.com/gec/db"
|
||||
let tuList = [0..(bbTemplates.Length-1)] |>
|
||||
List.map (fun indx ->
|
||||
let a = (createTUAssignment (bbTemplates.Item(indx)))
|
||||
let cdList = a |> List.map (fun (x,y) -> x)
|
||||
let partEntryList = a |> List.map (fun(x,y) -> y)
|
||||
let tu =
|
||||
let tuName = ("tu" + indx.ToString())
|
||||
let perId = urlPrefix + "/" + tuName
|
||||
let version = "1"
|
||||
GECHelper.createHigherFunction tuName perId version cdList
|
||||
(cdList,tu,partEntryList)
|
||||
)
|
||||
let partCDList = tuList |> List.map(fun (x,y,z) -> x)
|
||||
let partCDs = match partCDList.Length with
|
||||
| 0 -> []
|
||||
| 1 -> partCDList.Head
|
||||
| _ -> partCDList |> List.reduce (fun a b -> a@b)
|
||||
|
||||
let tuCDs = tuList |> List.map(fun (x,y,z) -> y)
|
||||
|
||||
let partsUsedList =
|
||||
let a = tuList |> List.map (fun (x,y,z) -> z)
|
||||
match a.Length with
|
||||
| 0 -> []
|
||||
| 1 -> a.Head
|
||||
| _ -> a |> List.reduce (fun b c -> b@c)
|
||||
|
||||
|
||||
let partIdList = partsUsedList |> List.map(fun (x,y) -> x) |> Seq.ofList |> List.ofSeq
|
||||
let partEntryList =
|
||||
partIdList |> List.map(fun (x) ->
|
||||
partsUsedList |> List.find (fun (a,b) -> a=x)
|
||||
)
|
||||
|
||||
(*let protList = partEntryList
|
||||
|> List.map (fun (x,y) -> y)
|
||||
|> List.map (fun entry -> entry.value)
|
||||
|> List.filter (fun partEntry ->
|
||||
match partEntry with
|
||||
| Database.PCR(_) -> true
|
||||
| _ -> false
|
||||
)
|
||||
|> List.map (fun (Database.PCR(x))-> x)*)
|
||||
|
||||
let protCDs = Database.createProteinCDs partEntryList
|
||||
|
||||
let mdList = Database.createModuleDefinitions (partCDs@protCDs) partEntryList //|> List.map (fun x -> TopLevel.ModuleDefinition(x))
|
||||
|
||||
let device =
|
||||
let name = "device"
|
||||
let perid = urlPrefix + "/" + name
|
||||
let version = "1"
|
||||
//GECHelper.createHigherFunction name perid version tuCDs
|
||||
GECHelper.createHigherFunction name perid version partCDs
|
||||
|
||||
//let allCDs = List.rev(device::( List.rev(tuCDs) @ List.rev(partCDs@protCDs)))
|
||||
let allCDs = List.rev(device::( (*List.rev(tuCDs) @*) List.rev(partCDs@protCDs)))
|
||||
|
||||
let s = SBOLDocument(
|
||||
(allCDs |> List.map (fun x -> x :> TopLevel))
|
||||
//@ (mdList |> List.map (fun x -> x :> TopLevel))
|
||||
)
|
||||
s
|
||||
|
||||
|
||||
let solveGEC (cancel_flag:bool ref) (program:string) (dbParts:string) (dbReactions:string) : solve_result =
|
||||
let db_from_string (s:string) = Parser.from_string Database.parse s
|
||||
let partstable =
|
||||
try
|
||||
db_from_string dbParts
|
||||
with e ->
|
||||
raise (CompileException ("parts", e))
|
||||
|
||||
let reactionListParser = Parser.sepBy Gecreaction.parseReaction Parser.newline
|
||||
let reactiondb_from_string (s:string) = Parser.from_string reactionListParser s
|
||||
|
||||
let createReactionEntry reaction =
|
||||
let (reactionEntry:Gecreaction.t Database.entry) ={value=reaction;enabled=true;comments=""}
|
||||
reactionEntry
|
||||
|
||||
let reactiondb =
|
||||
try
|
||||
reactiondb_from_string dbReactions |> List.map (fun(x) -> createReactionEntry(x))
|
||||
with e ->
|
||||
raise (CompileException ("reactions", e))
|
||||
|
||||
try
|
||||
let table = {partstable with reactions = reactiondb}
|
||||
let options = Options.setGECProgramText program Options.default_options
|
||||
let guioptions = setOptions options empty
|
||||
let gui = setDatabase table guioptions
|
||||
match Main.parse (getGECProgramText gui) with
|
||||
| LogicGec _ -> failwith "Logic GEC program not supported yet."
|
||||
| ClassicGec gecprog ->
|
||||
let ugecprog = unroll_gecprog gecprog
|
||||
let prog = translate_systems_to_prog ugecprog
|
||||
let ds = ugecprog.settings.directives |> Settings.convert_crn_to_gec_directives
|
||||
let (bbTemplates, prologConstraints, lbsProg, rateDecs, substitutions, arithmeticConstraints, log) =
|
||||
Trans.translate0 prog (getSimulationOnlyReactionsOption gui) (getDatabase gui)
|
||||
|
||||
let varAss = List.map Cssubst.mkVarAss substitutions
|
||||
let substs = List.map Cssubst.getSubst substitutions
|
||||
(* Put the results into a Main.tSolution data structure. *)
|
||||
let sol = { Main.bbDevices = bbTemplates;
|
||||
Main.lbsProgram = lbsProg;
|
||||
Main.rateDecs = rateDecs;
|
||||
Main.varAss = varAss;
|
||||
Main.substs = substs;
|
||||
Main.error = None;
|
||||
Main.numSolutions = List.length varAss }
|
||||
|
||||
let solution = setSolution ds sol prologConstraints arithmeticConstraints log gui
|
||||
|
||||
|
||||
let (toplbs,lbsSystems) = getLBSSystems ugecprog lbsProg
|
||||
|
||||
let crnSettings = Crn_settings.defaults.from_default_directive_list ugecprog.settings.directives
|
||||
|
||||
let top_crn = TransCrn.create toplbs |> (fun x -> modify_crn x ugecprog.settings crnSettings)
|
||||
let system_crn_map = lbsSystems
|
||||
|> List.map (fun x ->
|
||||
let systems = ugecprog.systems
|
||||
match x with
|
||||
| Trans.LBSComp(compname,prog) ->
|
||||
let crn = TransCrn.create x
|
||||
match (systems |> List.tryFind (fun y -> y.name = compname)) with
|
||||
| Some(res) -> (compname,modify_crn crn res.settings crnSettings)
|
||||
| None -> failwith ("Unexpected error. System " + compname + " not found.")
|
||||
| _ -> failwith "Unexpected LBS Comparment encountered")
|
||||
|
||||
let crnString = create_inference_graph crnSettings ugecprog top_crn system_crn_map table
|
||||
let igraph = Parser.from_string InferenceSiteGraph.parse crnString
|
||||
|
||||
let (varAss',subst') =
|
||||
match sol.numSolutions with
|
||||
| 0 ->
|
||||
match igraph.nodes.Count with
|
||||
| 0 -> failwith "This should never happen"
|
||||
| 1 ->
|
||||
let model = igraph.nodes |> Map.toSeq |> Seq.head |> snd
|
||||
match (model.top.initials.IsEmpty) && (model.systems.IsEmpty) with
|
||||
| true -> ([],[])
|
||||
| false -> ([[],[],[]],[Map.empty])
|
||||
| _ -> ([[],[],[]],[Map.empty])
|
||||
| _ -> (sol.varAss,sol.substs)
|
||||
|
||||
let solution' =
|
||||
match solution.solution with
|
||||
| Some(a,sol,b,c,d) ->
|
||||
let sol' = {sol with Main.varAss = varAss'; Main.numSolutions = varAss'.Length; Main.substs = subst'}
|
||||
Some(a,sol',b,c,d)
|
||||
| None -> None
|
||||
|
||||
|
||||
let sbol =
|
||||
match solution' with
|
||||
| Some(dir,sol,gecConst,arthConst,_) -> getSBOLAssignment sol.bbDevices table sol.substs 0
|
||||
| None -> Database.convertTableToSBOLDocument table
|
||||
{ solution = {solution with solution = solution'}
|
||||
; graph = igraph
|
||||
; sbol = sbol
|
||||
; crnString = crnString}
|
||||
|
||||
|
||||
with e ->
|
||||
raise (CompileException ("code", e))
|
||||
|
||||
(******************************************************************************)
|
||||
|
||||
let rec evaluateExpression (exp:Expression.t<_>) (smap:Subst.t) =
|
||||
match exp with
|
||||
| Expression.Key(key) ->
|
||||
if key = "RMRNADeg" then
|
||||
0.001
|
||||
else
|
||||
if not (smap.ContainsKey(key)) then
|
||||
try
|
||||
float key
|
||||
with e ->
|
||||
failwith "Key not found in substitution"
|
||||
raise(CompileException ("code", e))
|
||||
else
|
||||
match smap.Item(key) with
|
||||
| Subst.NUMBER(fl) -> fl
|
||||
| _ -> failwith "Unexpected format in the map"
|
||||
| Expression.Float(fl) -> fl
|
||||
| Expression.Times(times) ->
|
||||
times |> List.fold (fun acc x -> acc*(evaluateExpression x smap)) 1.0
|
||||
| Expression.Divide(divide) ->
|
||||
let d1 = evaluateExpression divide.div1 smap
|
||||
let d2 = evaluateExpression divide.div2 smap
|
||||
if d2 = 0.0 then
|
||||
failwith "Divide by 0 error."
|
||||
(d1)/(d2)
|
||||
| Expression.Power(pow) ->
|
||||
let b = evaluateExpression pow.base_ smap
|
||||
let pow = evaluateExpression pow.exponent smap
|
||||
Math.Pow(b,pow)
|
||||
| Expression.Plus(plus) ->
|
||||
plus |> List.fold (fun acc x -> acc+(evaluateExpression x smap)) 0.0
|
||||
| Expression.Minus(minus) ->
|
||||
let sub1 = evaluateExpression minus.sub1 smap
|
||||
let sub2 = evaluateExpression minus.sub2 smap
|
||||
sub1 - sub2
|
||||
| Expression.Absolute(abs) ->
|
||||
let vabs = evaluateExpression abs smap
|
||||
if vabs < 0.0 then
|
||||
(vabs * (-1.0))
|
||||
else
|
||||
vabs
|
||||
| Expression.Log(log) ->
|
||||
let l = evaluateExpression log smap
|
||||
Math.Log(l)
|
||||
| Expression.Modulo(modulo) ->
|
||||
let div = evaluateExpression modulo.div smap
|
||||
let modul = evaluateExpression modulo.modulo smap
|
||||
div%modul
|
||||
| Expression.If(bexp1,bexp2,bexp3) ->
|
||||
failwith "unexpected expression type"
|
||||
|
||||
|
||||
let assignReverseRate (rxn:Reaction<Species,Value,Functional>) (smap:Subst.t) =
|
||||
|
||||
match rxn.reverse with
|
||||
| Some(Rate.MassAction(exp:Expression.t<string>)) ->
|
||||
match exp with
|
||||
| Expression.Key(rate) ->
|
||||
if rate = "RMRNADeg" then
|
||||
{rxn with reverse = Some(Rate.MassAction(Expression.Float(0.001)))}
|
||||
else
|
||||
if not (smap.ContainsKey(rate)) then
|
||||
let mfloat = ref 0.0f
|
||||
match Single.TryParse(rate, mfloat) with
|
||||
| true -> {rxn with reverse = Some(Rate.MassAction (Expression.Float(float !mfloat)))}
|
||||
| false -> rxn
|
||||
(*try
|
||||
let mfloat = float rate
|
||||
{rxn with reverse = Some(Rate.MassAction (Expression.Float(mfloat)))}
|
||||
with e ->
|
||||
failwith "Key not found in substitution"
|
||||
raise(CompileException ("code", e))*)
|
||||
else
|
||||
match smap.Item(rate) with
|
||||
| Subst.NUMBER(fl) ->
|
||||
{rxn with reverse = Some(Rate.MassAction(Expression.Float(fl)))}
|
||||
| _ -> failwith "Unexpected format in the map"
|
||||
|
||||
| _ ->
|
||||
try
|
||||
let value = evaluateExpression exp smap
|
||||
{rxn with reverse = Some(Rate.MassAction(Expression.Float(value)))}
|
||||
with e ->
|
||||
raise(CompileException ("code", e))
|
||||
| Some(Rate.Function(e)) -> rxn //This case is encountered when userdefined CRNs are substituted.
|
||||
| None -> rxn
|
||||
|
||||
|
||||
let assignReaction (rxn:Reaction<Species,Value,Functional>) (smap:Subst.t) =
|
||||
match rxn.rate with
|
||||
| Rate.MassAction(exp:Expression.t<string>) ->
|
||||
match exp with
|
||||
| Expression.Key(rate) ->
|
||||
if rate = "RMRNADeg" then
|
||||
let newRxn = {rxn with rate = (Rate.MassAction (Expression.Float(0.001)))}
|
||||
assignReverseRate newRxn smap
|
||||
else
|
||||
if not (smap.ContainsKey(rate)) then
|
||||
let mfloat = ref 0.0f
|
||||
match Single.TryParse(rate, mfloat) with
|
||||
| true ->
|
||||
let newRxn = {rxn with reverse = Some(Rate.MassAction (Expression.Float(float !mfloat)))}
|
||||
assignReverseRate newRxn smap
|
||||
| false -> rxn
|
||||
|
||||
(*try
|
||||
let mfloat = float rate
|
||||
let newRxn = {rxn with rate = (Rate.MassAction (Expression.Float(mfloat)))}
|
||||
assignReverseRate newRxn smap
|
||||
with e ->
|
||||
failwith "Key not found in substitution"
|
||||
raise(CompileException ("code", e))*)
|
||||
else
|
||||
let newRate = match smap.Item(rate) with
|
||||
| Subst.NUMBER(fl) -> fl
|
||||
| _ -> failwith "Unexpected format in the map"
|
||||
|
||||
let newRxn = {rxn with rate = (Rate.MassAction (Expression.Float(newRate)))}
|
||||
assignReverseRate newRxn smap
|
||||
| _ ->
|
||||
try
|
||||
let value = evaluateExpression exp smap
|
||||
let newRxn = {rxn with rate = (Rate.MassAction(Expression.Float(value)))}
|
||||
assignReverseRate newRxn smap
|
||||
with e ->
|
||||
raise(CompileException ("code", e))
|
||||
| Rate.Function(e) -> rxn //This case is encountered when userdefined CRNs are substituted.
|
||||
|
||||
|
||||
type solution_result = { model : InferenceSiteGraph.IGraph
|
||||
; sbol : SBOLDocument }
|
||||
|
||||
let getCrnAssignment (igraph:InferenceSiteGraph.IGraph) (gecSol:t) (index:int) : solution_result =
|
||||
if gecSol.solution.IsNone then
|
||||
failwith "No solution found"
|
||||
|
||||
let (dirlist,sol,constraints,aritconstraints,d) = gecSol.solution.Value
|
||||
let substitution = sol.substs.Item(index)
|
||||
|
||||
//SBOL
|
||||
let sbol = getSBOLAssignment sol.bbDevices gecSol.database sol.substs index
|
||||
|
||||
//CRN
|
||||
let assign_crn (crn:Crn) =
|
||||
let assignedReactions = crn.reactions |> List.map(fun x -> assignReaction x substitution)
|
||||
{crn with reactions = assignedReactions}
|
||||
|
||||
let nodes' = igraph.nodes |> Map.map (fun k node ->
|
||||
{node with top = (assign_crn node.top); systems = (node.systems |> List.map (fun x -> assign_crn x))})
|
||||
|
||||
|
||||
{ model = {igraph with nodes = nodes'} ; sbol = sbol }
|
||||
|
|
@ -0,0 +1,124 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.Gecreaction
|
||||
|
||||
open Microsoft.Research.GEC
|
||||
open Parser
|
||||
|
||||
//open Microsoft.Research.ModellingEngine
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
open System.Diagnostics
|
||||
|
||||
(* A type for "database reactions", which records some of the structure of complexes. *)
|
||||
type normalReacData = { catalysts: string list list;
|
||||
reactants: string list list;
|
||||
products: string list list;
|
||||
rate: float }
|
||||
type transportReacData = { reactant: string list;
|
||||
product: string list;
|
||||
rate: float;
|
||||
compartment: string;
|
||||
direction: Ast.direction }
|
||||
type t = Normal of normalReacData
|
||||
| Transport of transportReacData
|
||||
|
||||
(* Functions to create GEC reaction datatypes. *)
|
||||
let makeNormal (catalysts:string list list) (reactants:string list list) (products:string list list) (rate:float) =
|
||||
Normal {catalysts=catalysts; reactants=reactants; products=products; rate=rate}
|
||||
let makeTransport (reactant:string list) (product:string list) (rate:float) (compartment:string) (direction:Ast.direction) =
|
||||
Transport {reactant=reactant; product=product; rate=rate; compartment=compartment; direction=direction}
|
||||
|
||||
(* Decide whether a reaction is a normal or a transport reaction... *)
|
||||
let isNormal (r:t) = match r with Normal r -> Some (r.catalysts, r.reactants, r.products, r.rate) | _ -> None
|
||||
let isTransport (r:t) = match r with Transport r -> Some (r.reactant, r.product, r.rate, r.compartment, r.direction) | _ -> None
|
||||
|
||||
(* Produce a string representation of a GEC reaction. *)
|
||||
let display (r:t) : string =
|
||||
let mkStr xss = Lib.string_of_list Ast.complexString " + " xss in
|
||||
match r with
|
||||
| Normal r -> let prefix = match r.catalysts with [] -> "" | _ -> (mkStr r.catalysts) + " ~ " in
|
||||
prefix + (mkStr r.reactants) + " ->{" + (Lib.display_float r.rate) + "} " + (mkStr r.products)
|
||||
| Transport r -> let reactantStr,productStr =
|
||||
match r.direction with
|
||||
| Ast.In -> Ast.complexString r.reactant, Ast.compartmentString r.compartment (Ast.complexString r.product)
|
||||
| Ast.Out -> Ast.compartmentString r.compartment (Ast.complexString r.reactant), Ast.complexString r.product
|
||||
in
|
||||
reactantStr + " ->{" + (Lib.display_float r.rate) + "} " + productStr
|
||||
|
||||
(* Are two reactions equal? Must consider reordering of reactions/products/catalysts and the ordering of species within complexes themselves... *)
|
||||
let equal (r1:t) (r2:t) =
|
||||
match r1,r2 with
|
||||
| Normal r1, Normal r2 -> (Lib.is_permutation Ast.complexesEqual r1.catalysts r2.catalysts) &&
|
||||
(Lib.is_permutation Ast.complexesEqual r1.reactants r2.reactants) &&
|
||||
(Lib.is_permutation Ast.complexesEqual r1.products r2.products) &&
|
||||
(r1.rate = r2.rate)
|
||||
| Transport r1, Transport r2 -> (Ast.complexesEqual r1.reactant r2.reactant) &&
|
||||
(Ast.complexesEqual r1.product r2.product) &&
|
||||
(r1.rate = r2.rate) &&
|
||||
(r1.compartment = r2.compartment) &&
|
||||
(r1.direction = r2.direction)
|
||||
| _,_ -> false
|
||||
|
||||
(* Get all species names from a GEC reaction. *)
|
||||
let species (r:t) : string list list =
|
||||
let allRawSpecies =
|
||||
match r with
|
||||
| Normal r -> r.catalysts @ r.reactants @ r.products
|
||||
| Transport r -> [r.reactant; r.product]
|
||||
in
|
||||
Lib.remove_duplicates Ast.complexesEqual allRawSpecies
|
||||
|
||||
(* Apply a substitution to a GEC reaction. *)
|
||||
let applySubst (theta:Subst.t) (r:t) : t =
|
||||
match r with
|
||||
| Normal r -> Normal { r with catalysts = List.map (Subst.applyToComplex theta) r.catalysts;
|
||||
reactants = List.map (Subst.applyToComplex theta) r.reactants;
|
||||
products = List.map (Subst.applyToComplex theta) r.products }
|
||||
| Transport r -> Transport { r with reactant = Subst.applyToComplex theta r.reactant;
|
||||
product = Subst.applyToComplex theta r.product }
|
||||
|
||||
|
||||
let lookaheadLinebreak = Parser.pTry (Parser.linebreak >>. Parser.failParser "" <|> Parser.satisfy Parser.isWhiteSpace >>. preturn ())
|
||||
let lookaheadDashSeparator = Parser.pTry(Parser.pstring "->" >>. failParser "" <|> Parser.pstring "-")
|
||||
// Parser.satisfy (fun c -> Parser.isWhiteSpace c && c <> '\n')
|
||||
//let whiteSpacenlb : t<unit> = skipChar isWhiteSpace <?> "a white space"
|
||||
|
||||
let spacesnlb :t<string> = fun st ->
|
||||
match many (commentLine <|> commentMultiline () <|> lookaheadLinebreak) <| st with
|
||||
| OkEmpty (_, st') -> OkEmpty ("", st')
|
||||
| OkConsumed (_, st') -> OkEmpty ("", st')
|
||||
| FailEmpty _ -> OkEmpty ("", st)
|
||||
| FailConsumed (e, p) -> FailConsumed (e, p)
|
||||
|
||||
let kwnlb s = pstring s .>> spacesnlb
|
||||
|
||||
let gecName = (Parser.sepBy Parser.name (Parser.pstring "::")) .>> spacesnlb
|
||||
let bracketnlb l r = Parser.between (Parser.pstring l) (Parser.spaces >>. kwnlb r)
|
||||
let parennlb a = bracketnlb "(" ")" a
|
||||
let sqBracketnlb a = bracketnlb "[" "]" a
|
||||
let bracesnlb a = bracketnlb "{" "}" a
|
||||
let compartmentParser = (sqBracketnlb gecName)
|
||||
let rateParser = bracesnlb Parser.pfloat
|
||||
let chainNames = Parser.sepBy gecName (Parser.kw "+")
|
||||
|
||||
let parseReaction = chainNames >>= fun n ->
|
||||
Parser.choice[
|
||||
compartmentParser .>> Parser.kw "->" .>>. rateParser .>>. gecName |>> fun(((reactant:string list),rate:float),(product:string list)) -> Transport {reactant = reactant; product=product;rate = rate;compartment = n.Head.Head; direction = Ast.direction.Out}
|
||||
Parser.skw "~" >>.
|
||||
Parser.choice[
|
||||
Parser.kw "->" >>. rateParser .>>. chainNames |>> fun((rate:float),(products:string list list)) -> Normal {catalysts=n;reactants = [];rate=rate;products=products}
|
||||
chainNames .>> Parser.kw "->" .>>. rateParser .>>. chainNames |>> fun(((reactants:string list list),rate:float),(products:string list list)) -> Normal {catalysts=n;reactants = reactants;rate=rate;products=products}
|
||||
]
|
||||
Parser.kw "->" >>. rateParser .>>. chainNames >>= fun (r,x) ->
|
||||
Parser.choice[
|
||||
compartmentParser |>> fun(product) -> Transport {reactant = n.Head;product=product;rate=r;compartment=x.Head.Head;direction=Ast.direction.In}
|
||||
Parser.preturn (Normal {catalysts=[];reactants = n;products=x;rate=r})
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
|
||||
//let parseTransportOut = compartmentParser .>> Parser.kw "->" .>>. rateParser .>>. gecName |>> fun ( ((compartment:string, (reactant:string list)), rate:float), (product: string list)) -> Transport {reactant=reactant; product=product; rate=rate; compartment=compartment; direction=Ast.direction.Out}
|
||||
//let parseTransportIn = gecName .>> Parser.kw "->" .>>. rateParser .>>. compartmentParser |>> fun(((reactant:string list),rate:float),(compartment:string,(product:string list))) -> Transport {reactant=reactant; product=product; rate=rate; compartment=compartment; direction=Ast.direction.In}
|
||||
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
module Microsoft.Research.GEC.Gecreaction
|
||||
|
||||
open Microsoft.Research.GEC
|
||||
|
||||
(* Opaque reaction datatype. *)
|
||||
type t
|
||||
|
||||
(* Functions to create GEC reaction datatypes. *)
|
||||
val makeNormal : string list list -> string list list -> string list list -> float -> t
|
||||
val makeTransport : string list -> string list -> float -> string -> Ast.direction -> t
|
||||
|
||||
(* Decide whether a reaction is a normal or a transport reaction... *)
|
||||
val isNormal : t -> (string list list * string list list * string list list * float) option
|
||||
val isTransport : t -> (string list * string list * float * string * Ast.direction) option
|
||||
|
||||
(* Produce a string representation of a GEC reaction. *)
|
||||
val display : t -> string
|
||||
|
||||
(* Are two reactions equal? *)
|
||||
val equal : t -> t -> bool
|
||||
|
||||
(* Get all species names from a GEC reaction. *)
|
||||
val species : t -> string list list
|
||||
|
||||
(* Apply a substitution to a GEC reaction. *)
|
||||
val applySubst : Subst.t -> t -> t
|
||||
|
||||
val parseReaction : Parser.t<t>
|
|
@ -0,0 +1,61 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.GecSpecies
|
||||
|
||||
open Parser
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
type species = string list
|
||||
|
||||
let species_to_gecAbstractComplex (sp:species) =
|
||||
sp |> List.map (fun x ->
|
||||
match x with
|
||||
| "_" -> Ast.WildCardVal
|
||||
| _ -> Ast.IdVal(x))
|
||||
|
||||
type t = {
|
||||
compartment: string option
|
||||
species:species
|
||||
}
|
||||
with
|
||||
static member empty_Species =
|
||||
{species = []; compartment=None}
|
||||
member s.to_string() =
|
||||
match s.compartment with
|
||||
| Some(comp) -> comp + "[" + (Lib.string_of_list (fun x -> x) "::" s.species) + "]"
|
||||
| None -> (Lib.string_of_list (fun x -> x) "::" s.species)
|
||||
member s.to_crn_string() =
|
||||
match s.compartment with
|
||||
| Some(comp) -> comp + "_" + (Lib.string_of_list (fun x -> x) "_" s.species)
|
||||
| None -> (Lib.string_of_list (fun x -> x) "_" s.species)
|
||||
member s.to_crn_species() = Species.create(s.to_crn_string())
|
||||
member s.to_ast_gecSpecies() =
|
||||
match s.compartment with
|
||||
| Some(x) -> Ast.CompartmentSpecies(x,species_to_gecAbstractComplex s.species)
|
||||
| None -> Ast.SimpleSpecies(species_to_gecAbstractComplex s.species)
|
||||
|
||||
let SPECIES_SEP = Parser.pstring "::"
|
||||
|
||||
let pName = Parser.name_kw Keywords.kwList
|
||||
|
||||
let parse_species_ns = Parser.sepBy (pName) SPECIES_SEP
|
||||
let parse_species = parse_species_ns .>> Parser.spaces
|
||||
|
||||
let parse_kw (keywords:string list) =
|
||||
Parser.plookAheadWith(
|
||||
Parser.choice[
|
||||
Parser.pTry((Parser.name_kw keywords) .>> Parser.pstring "[" >>= fun _ -> Parser.preturn true)
|
||||
Parser.preturn false
|
||||
])
|
||||
>>=
|
||||
fun (hasCompartment) ->
|
||||
if hasCompartment then
|
||||
pName .>> Parser.pstring "[" .>>. parse_species_ns .>> Parser.pstring "]" .>> Parser.spaces |>> fun(x,y) -> {species=y;compartment=Some(x)}
|
||||
else
|
||||
parse_species |>> fun y -> {species=y;compartment=None}
|
||||
|
||||
let parse = parse_kw Keywords.kwList
|
||||
|
||||
|
||||
let parse_crn_species = parse |>> fun x -> x.to_crn_string() |> Species.create
|
||||
let parse_gec_to_crn_species = parse_species |>> fun x -> Lib.string_of_list (fun x -> x) "_" x |> Species.create
|
||||
|
|
@ -0,0 +1,360 @@
|
|||
module Microsoft.Research.GEC.Hypothesis
|
||||
|
||||
open Parser
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
|
||||
type parser<'a> = Parser.t<'a>
|
||||
|
||||
|
||||
type HypothesisDirective =
|
||||
| Devices of (string list)
|
||||
|
||||
|
||||
|
||||
type HypothesisSettings =
|
||||
{
|
||||
devices : string list
|
||||
}
|
||||
static member defaults = {
|
||||
devices = []
|
||||
}
|
||||
member setting.from_directive (directive:HypothesisDirective) =
|
||||
match directive with
|
||||
| Devices(x) -> {setting with devices=x}
|
||||
member setting.from_directiveList (directives:HypothesisDirective list) =
|
||||
directives |> List.fold (fun (s:HypothesisSettings) (d:HypothesisDirective) -> setting.from_directive d) setting
|
||||
|
||||
|
||||
|
||||
type arguments = (string list)
|
||||
type crndirective = string
|
||||
type crnmodule = string * arguments * string
|
||||
//type device = string * arguments * string
|
||||
|
||||
type crnModules = ((string * string list) * Instruction list) list * Instruction list
|
||||
|
||||
type igPriorType =
|
||||
| Fixed
|
||||
| Normal
|
||||
| TruncatedNormal
|
||||
|
||||
type igPriorOption =
|
||||
| HasPrior of igPriorType
|
||||
| NoPrior
|
||||
|
||||
type igPrior = string * igPriorOption
|
||||
|
||||
type igName = string list
|
||||
|
||||
type igedge = igName * (igPrior list) * igName
|
||||
type ignode = string * (string list) * (Inference_settings option)
|
||||
|
||||
|
||||
|
||||
type igraphElement =
|
||||
| Node of ignode
|
||||
| Edge of igedge
|
||||
|
||||
type moduleDefinition = string * (arguments)
|
||||
|
||||
type deviceDefinition = moduleDefinition * (moduleDefinition list)
|
||||
|
||||
type systemReference =
|
||||
| System of string
|
||||
| NoSystem
|
||||
|
||||
type crnSystem = string * systemReference * Crn_settings<Functional> * HypothesisSettings * crnModules
|
||||
|
||||
type hypothesis = Crn_settings<Functional> * (crnModules) * (deviceDefinition list) * (crnSystem list) * (igraphElement list)
|
||||
|
||||
|
||||
let kwList = ["module";"system";"inference";"directive";"device"]
|
||||
|
||||
//Parsers Start here:
|
||||
|
||||
let parse_species = Parser.(|>>) (Parser.name_kw kwList) Species.create
|
||||
|
||||
let pcomma = Parser.kw ","
|
||||
let pPipe = Parser.kw "|"
|
||||
let pDot = Parser.kw "."
|
||||
|
||||
let argumentsParser = Parser.paren (Parser.sepBy Parser.name pcomma)
|
||||
|
||||
let parse_crnDirective = Directive<Functional>.parse Functional2.parse Functional2.parse_plot
|
||||
|
||||
|
||||
let parse_hypothesisDirective = Parser.kw "device" >>. Parser.list_of Parser.name .>> Parser.opt (Parser.kw ";") |>> Devices
|
||||
|
||||
let parse_crnSettings = Crn_settings<Functional>.parse Functional2.parse Functional2.parse_plot
|
||||
|
||||
|
||||
let parse_moduleInvocation = Parser.name .>> Parser.spaces .>>. argumentsParser
|
||||
|
||||
let parse_device = Parser.kw "device" >>. parse_moduleInvocation .>> Parser.kw "="
|
||||
.>>. Parser.braces (Parser.sepBy parse_moduleInvocation pPipe)
|
||||
|
||||
|
||||
|
||||
let parse_instructions pspecies settings =
|
||||
let zero = Expression.zero
|
||||
let unitVal = Expression.one
|
||||
|
||||
let pname = Parser.name_kw kwList .>> Parser.spaces
|
||||
let pvalue = Expression.parse pname
|
||||
let pexpr = Expression.parse (Key.parse pspecies)
|
||||
let pcomma = Parser.kw ","
|
||||
|
||||
// crn parsers
|
||||
let pinitial = Initial<Species,Value>.parse pspecies pvalue zero |>> Instruction.Initial2
|
||||
let preaction = Reaction.parse pspecies pvalue pexpr unitVal |>> Instruction.Reaction
|
||||
let pinvoke = Parser.pTry( pname .>> Parser.kw "(")
|
||||
.>>. Parser.sepBy pvalue pcomma
|
||||
.>> Parser.kw ")"
|
||||
|>> Module
|
||||
let pline = pinvoke <|> preaction <|> pinitial
|
||||
let pbar = Parser.kw "|"
|
||||
|
||||
// module definitions parser
|
||||
let pmodule =
|
||||
Parser.kw "module"
|
||||
>>. Parser.name .>>. Parser.paren (Parser.sepBy Parser.name pcomma) // module_name(comma-separated args)
|
||||
.>> Parser.kw "="
|
||||
.>>. Parser.braces (Parser.opt pbar >>. Parser.sepBy pline pbar)
|
||||
|
||||
// full CRN parser
|
||||
Parser.spaces
|
||||
>>. Parser.many pmodule
|
||||
.>> Parser.opt pbar
|
||||
.>>. Parser.sepBy pline pbar
|
||||
|
||||
let parse_crnModules crnSettings = parse_instructions parse_species crnSettings
|
||||
|
||||
let crnDirectiveChoice = parse_crnDirective |>> Choice1Of2
|
||||
let hypothesisDirectiveChoice = parse_hypothesisDirective |>> Choice2Of2
|
||||
|
||||
|
||||
let pfixed = Parser.kw "Fixed" |>> fun _ -> Fixed
|
||||
let pnormal = Parser.kw "Normal" |>> fun _ -> Normal
|
||||
let ptruncatedNormal = Parser.kw "TruncatedNormal" |>> fun _ -> TruncatedNormal
|
||||
|
||||
let parse_priorType = pfixed <|> pnormal <|> ptruncatedNormal
|
||||
|
||||
let parse_priorOption:Parser.t<igPriorOption> = (Parser.plookAheadWith (
|
||||
Parser.choice[
|
||||
Parser.pTry (Parser.kw "=" >>. parse_priorType >>= fun _ -> Parser.preturn true)
|
||||
Parser.preturn false
|
||||
])
|
||||
>>= fun hasPriorType ->
|
||||
if hasPriorType
|
||||
then Parser.kw "=" >>. parse_priorType |>> fun (x:igPriorType) -> HasPrior(x)
|
||||
else Parser.preturn(NoPrior)
|
||||
)
|
||||
|
||||
let parse_prior:t<igPrior> = Parser.name .>> Parser.spaces .>>. parse_priorOption
|
||||
|
||||
|
||||
let parse_igInferenceSettings = Parser.kw ";" >>. Parser.kw "inference" >>. Parser.kw "=" >>. (Inference_settings.parse)
|
||||
|
||||
let parse_igName = Parser.sepBy (Parser.name .>> Parser.spaces) pDot
|
||||
|
||||
let parse_edge = Parser.kw "edge" >>. parse_igName .>> Parser.kw "->" .>>.
|
||||
Parser.list_of parse_prior .>>. parse_igName |>> fun ((x,y),z) -> Edge(x,y,z)
|
||||
|
||||
let parse_node = Parser.kw "node" >>. (Parser.name .>> Parser.spaces) .>>
|
||||
Parser.kw "{" .>>. (Parser.kw "systems" >>. Parser.kw "=" >>.
|
||||
Parser.list_of (Parser.name .>> Parser.spaces)) >>= fun (x,y) ->
|
||||
Parser.plookAheadWith(
|
||||
Parser.choice[
|
||||
Parser.pTry(Parser.kw ";" >>. Parser.kw "inference" >>= fun _ -> Parser.preturn true)
|
||||
Parser.preturn false
|
||||
])
|
||||
>>= fun hasInference ->
|
||||
if hasInference
|
||||
then
|
||||
parse_igInferenceSettings .>> Parser.kw "}" |>> fun (z) -> Node(x,y,Some(z))
|
||||
else
|
||||
Parser.kw "}" |>> fun _ -> Node(x,y,None)
|
||||
|
||||
|
||||
|
||||
let parse_igraphElement = parse_edge <|> parse_node
|
||||
|
||||
|
||||
let parse_withSystem = (Parser.plookAheadWith (
|
||||
Parser.choice [
|
||||
Parser.pTry(Parser.name .>> Parser.spaces .>> Parser.kw "with" >>= fun _ -> Parser.preturn true)
|
||||
Parser.preturn false
|
||||
])
|
||||
>>= fun hasWith ->
|
||||
if hasWith
|
||||
then Parser.name .>> Parser.spaces .>> Parser.kw "with" |>> fun x -> System(x)
|
||||
else Parser.preturn(NoSystem))
|
||||
|
||||
|
||||
|
||||
|
||||
let parse_hybridDirective = Parser.many (Parser.kw "directive" >>. (crnDirectiveChoice <|> hypothesisDirectiveChoice)) |>>
|
||||
(fun hybridList ->
|
||||
let crnList = hybridList |>
|
||||
List.filter (fun x ->
|
||||
match x with
|
||||
| Choice1Of2 t -> true
|
||||
| _ -> false) |>
|
||||
List.map (fun x ->
|
||||
match x with
|
||||
| Choice1Of2 t -> t
|
||||
| _ -> failwith "Unexpected choice2 in parse_hybridDirective")
|
||||
let hypList = hybridList |>
|
||||
List.filter (fun x ->
|
||||
match x with
|
||||
| Choice2Of2 t -> true
|
||||
| _ -> false) |>
|
||||
List.map (fun x ->
|
||||
match x with
|
||||
| Choice2Of2 t -> t
|
||||
| _ -> failwith "Unexpected choice1 in parse_hybridDirective")
|
||||
let crn_settings = Crn_settings.defaults.from_directive_list crnList
|
||||
let hypothesis_settings = HypothesisSettings.defaults.from_directiveList hypList
|
||||
(crn_settings,hypothesis_settings)
|
||||
)
|
||||
|
||||
let (parse_crn_system:t<crnSystem>) = Parser.kw "system" >>. Parser.name .>> Parser.spaces .>> Parser.kw "="
|
||||
.>> Parser.kw "{" .>>. parse_withSystem .>>. parse_hybridDirective >>= fun((systemName,withSystem),(crnSettings,hypothesisSettings)) ->
|
||||
parse_crnModules crnSettings .>> (Parser.kw "}") >>= fun y -> Parser.preturn(systemName,withSystem,crnSettings,hypothesisSettings,y)
|
||||
|
||||
|
||||
|
||||
|
||||
let (parse_hypothesis_content:t<hypothesis>) =
|
||||
parse_crnSettings >>= fun (crnSettings) ->
|
||||
(parse_crnModules crnSettings)
|
||||
.>>. (Parser.many parse_device)
|
||||
.>>. (Parser.many parse_crn_system)
|
||||
.>>. (Parser.many parse_igraphElement)
|
||||
|>> fun (((modulelist:crnModules,deviceDefinitions: deviceDefinition list),systemlist:crnSystem list),igraph) -> (crnSettings,modulelist,deviceDefinitions,systemlist,igraph)
|
||||
|
||||
|
||||
//To String Methods
|
||||
let fold_string_list (strList:string list) (folder:string) =
|
||||
match strList.Length with
|
||||
| 0 -> ""
|
||||
| 1 -> strList.Head
|
||||
| _ -> strList.Tail |> List.fold (fun f s -> (f + folder + s)) strList.Head
|
||||
|
||||
let crnDirectives_to_string (crnSettings:Crn_settings<Functional>) = crnSettings.to_string Functional2.to_string Functional2.to_string_plot
|
||||
|
||||
let args_to_string (args: arguments) = fold_string_list args ","
|
||||
|
||||
let modules_to_string initial_time (modules:crnModules) =
|
||||
let moduleList,externalInstructions = modules
|
||||
let instructionList_to_string (instructions:Instruction list) =
|
||||
let instructionStringList = instructions |> List.map (fun x -> ("| " + (Instruction.to_string initial_time x)))
|
||||
fold_string_list instructionStringList "\n"
|
||||
let module_to_string (((moduleName:string),(moduleArgs:string list)),(instructions:Instruction list)) =
|
||||
let str = "module " + moduleName + "(" + (args_to_string moduleArgs) + ") = {\n" +
|
||||
(instructionList_to_string instructions) + "\n}\n"
|
||||
str
|
||||
let str =
|
||||
let moduleListString = moduleList |> List.map (fun x -> (module_to_string x))
|
||||
let moduleStr = fold_string_list moduleListString ""
|
||||
moduleStr + (instructionList_to_string externalInstructions)
|
||||
str
|
||||
|
||||
let moduleDefinition_to_string (moduleDef:moduleDefinition) =
|
||||
let (moduleName,moduleArgs) = moduleDef
|
||||
moduleName + "(" + (args_to_string moduleArgs) + ")"
|
||||
|
||||
let deviceDefinition_to_string (device:deviceDefinition) =
|
||||
let ((deviceDef),deviceBody) = device
|
||||
let deviceBodyString = "{" + (fold_string_list (deviceBody |> List.map (fun x -> moduleDefinition_to_string x)) " | ") + "}"
|
||||
let str = "module " + (moduleDefinition_to_string deviceDef) + " = " + deviceBodyString
|
||||
str
|
||||
|
||||
|
||||
let igNode_to_string (node:ignode) =
|
||||
let (nodeName,nodeSystems,iSettings) = node
|
||||
let str = "node " + nodeName + " { systems = [" + (fold_string_list nodeSystems ";") + "]"
|
||||
match iSettings with
|
||||
| Some(x) -> str + ";" + "inference " + "=" + (Inference_settings.to_string(x)) + "}"
|
||||
| None -> str + "}"
|
||||
|
||||
|
||||
|
||||
let igEdge_to_string (edge:igedge) =
|
||||
let edgeNameString edgelist = fold_string_list edgelist "."
|
||||
let priorType_to_string (ptype:igPriorType) =
|
||||
match ptype with
|
||||
| Fixed -> "Fixed"
|
||||
| Normal -> "Truncated"
|
||||
| TruncatedNormal -> "TruncatedNormal"
|
||||
let prior_to_string ((p,ptype):igPrior) =
|
||||
match ptype with
|
||||
| HasPrior(x) -> p + "=" + (priorType_to_string x)
|
||||
| NoPrior -> p
|
||||
let (fromNode,priorlist,toNode) = edge
|
||||
let str = "edge " + (edgeNameString fromNode) + " -> " + "["+
|
||||
(fold_string_list (priorlist |> List.map (fun x-> prior_to_string x)) ";") +
|
||||
"]" + (edgeNameString toNode)
|
||||
str
|
||||
|
||||
let igElement_to_string (elem:igraphElement) =
|
||||
match elem with
|
||||
| Node(x) -> igNode_to_string x
|
||||
| Edge(x) -> igEdge_to_string x
|
||||
|
||||
let hypothesisSettings_to_string (hypSettings:HypothesisSettings) (devices:Database.device list) (deviceDefs:moduleDefinition list) (moduleDefs:moduleDefinition list) =
|
||||
let deviceList = hypSettings.devices
|
||||
let rec device_unroll (dev:string) (devices:Database.device list) (deviceDefs:moduleDefinition list) (moduleDefs:moduleDefinition list) =
|
||||
let deviceDefOpt = deviceDefs |> List.tryFind (fun (x,y) -> x=dev)
|
||||
match deviceDefOpt with
|
||||
| Some(a) -> [a]
|
||||
| None ->
|
||||
let modOpt = (moduleDefs |> List.tryFind (fun (x,y) -> x=dev))
|
||||
match modOpt with
|
||||
| Some(a) -> [a]
|
||||
| None ->
|
||||
let devOpt = (devices |> List.tryFind (fun (x,y) -> x=dev ))
|
||||
match devOpt with
|
||||
| Some (devName,devComps) ->
|
||||
let deflist = devComps |> List.map (fun x -> device_unroll x devices deviceDefs moduleDefs)
|
||||
match deflist.Length with
|
||||
| 0 -> []
|
||||
| _ -> deflist |> List.reduce (fun x y -> x@y)
|
||||
| None ->
|
||||
raise (System.ArgumentException("Device in System Directive must be defined."))
|
||||
let mdeflistlist = deviceList |> List.map (fun x -> device_unroll x devices deviceDefs moduleDefs)
|
||||
let mdeflist =
|
||||
match mdeflistlist.Length with
|
||||
| 0 -> []
|
||||
| _ -> mdeflistlist |> List.reduce (fun x y -> x@y)
|
||||
fold_string_list (mdeflist |> List.map (fun x -> "| " + (moduleDefinition_to_string x))) "\n"
|
||||
|
||||
|
||||
|
||||
let system_to_string (sys:crnSystem) (devices:Database.device list) (deviceDefs:moduleDefinition list) (moduleDefs:moduleDefinition list)=
|
||||
let (sysName,sysRef,crnSettings,hypSettings,crnMods) = sys
|
||||
let sysRef_to_string (sysRef:systemReference) =
|
||||
match sysRef with
|
||||
| System(x) -> x + " with "
|
||||
| NoSystem -> ""
|
||||
|
||||
let str = "system " + sysName + " = { " + (sysRef_to_string sysRef) + "\n" +
|
||||
(crnDirectives_to_string crnSettings) + "\n" +
|
||||
hypothesisSettings_to_string hypSettings devices deviceDefs moduleDefs +
|
||||
(modules_to_string crnSettings.simulation.initial crnMods) + "\n" + "}\n"
|
||||
|
||||
str
|
||||
|
||||
let hypothesis_to_crn_program (h:hypothesis) (devicelib:Database.device list)=
|
||||
let (crnSettings,moduleDefs,deviceDefs,systemDefs,igraph) = h
|
||||
let (modules,_) = moduleDefs
|
||||
let moduleDefinitions = modules |> List.map fst
|
||||
let deviceDefinitions = deviceDefs |> List.map fst
|
||||
let str = crnDirectives_to_string crnSettings + "\n" +
|
||||
(modules_to_string crnSettings.simulation.initial moduleDefs) + "\n" +
|
||||
(fold_string_list (deviceDefs |> List.map deviceDefinition_to_string) "\n") + "\n" +
|
||||
(fold_string_list (systemDefs |> List.map (fun x -> system_to_string x devicelib deviceDefinitions moduleDefinitions)) "\n") + "\n" +
|
||||
(fold_string_list (igraph |> List.map igElement_to_string) "\n")
|
||||
|
||||
str
|
|
@ -0,0 +1,68 @@
|
|||
[<JavaScriptExport>]
|
||||
module Microsoft.Research.GEC.JSAPI
|
||||
|
||||
open Microsoft.Research.GEC.GECEngine
|
||||
|
||||
#if JavaScript
|
||||
open WebSharper
|
||||
#endif
|
||||
|
||||
open Microsoft.Research.CRNEngine
|
||||
open Microsoft.Research.CRNEngine.JSAPI
|
||||
open FSBOL
|
||||
open FSBOL.Component
|
||||
open FSBOL.ComponentDefinition
|
||||
open FSBOL.Sequence
|
||||
open FSBOL.Range
|
||||
open FSBOL.Location
|
||||
open FSBOL.SequenceAnnotation
|
||||
open FSBOL.FunctionalComponent
|
||||
open FSBOL.Interaction
|
||||
open FSBOL.ModuleDefinition
|
||||
open FSBOL.Participation
|
||||
open FSBOL.TopLevel
|
||||
open FSBOL.SBOLDocument
|
||||
open FSBOL.JsonSerializer
|
||||
|
||||
|
||||
type ClassicResult = { solution : t
|
||||
; solutionCount: int
|
||||
; model : GuiIG
|
||||
; jsbol : rSBOLDocument
|
||||
; sbol : SBOLDocument }
|
||||
|
||||
type LogicResult = { solution : t
|
||||
; solutionCount: int
|
||||
; model : GuiIG
|
||||
; jsbol : rSBOLDocument
|
||||
; sbol : SBOLDocument }
|
||||
|
||||
type solve_result = ClassicGEC of ClassicResult | LogicGEC of LogicResult
|
||||
|
||||
let compile (program:string) (dbParts:string) (dbReactions:string) : solve_result =
|
||||
let output = GECEngine.solveGEC (ref false) program dbParts dbReactions
|
||||
let graph = GuiIG.from_ig output.graph
|
||||
let jsbol = JsonSerializer.sbolToJson output.sbol
|
||||
let scount =
|
||||
match output.solution.solution with
|
||||
| Some(_,sol,_,_,_) -> sol.numSolutions
|
||||
| None -> failwith "Output of solution is null"
|
||||
ClassicGEC { model = graph; solution = output.solution; solutionCount= scount; jsbol = jsbol; sbol = output.sbol }
|
||||
|
||||
type solution_result = { model : GuiIG
|
||||
; jsbol : rSBOLDocument
|
||||
; sbol : SBOLDocument
|
||||
; crnstring : string}
|
||||
|
||||
let get_solution (so:solve_result) (i:int) : solution_result =
|
||||
match so with
|
||||
| ClassicGEC o ->
|
||||
let model = o.model.to_ig()
|
||||
|
||||
//let model = o.model.nodes |> Map.toSeq |> Seq.head |> snd
|
||||
//let gmodel = model.to_model()
|
||||
let result = GECEngine.getCrnAssignment model o.solution (i-1)
|
||||
let model = GuiIG.from_ig result.model
|
||||
let jsbol = JsonSerializer.sbolToJson result.sbol
|
||||
{ model = model ; jsbol = jsbol ; sbol = result.sbol ; crnstring = result.model.to_string()}
|
||||
| LogicGEC o -> failwith "Logic GEC solution selection not implemented yet."
|
|
@ -0,0 +1,18 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.Keywords
|
||||
|
||||
let kwList = [
|
||||
"module";
|
||||
"prom";
|
||||
"rbs";
|
||||
"pcr";
|
||||
"ter";
|
||||
"pos";
|
||||
"con";
|
||||
"initPop";
|
||||
"directive";
|
||||
"rate";
|
||||
"codes";
|
||||
"new";
|
||||
"system";
|
||||
"template"]
|
|
@ -0,0 +1,911 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.LogicGEC
|
||||
|
||||
open RulesDSD.Syntax
|
||||
open RulesDSD.Substitution
|
||||
open RulesDSD.Resolution
|
||||
open Microsoft.Research.CRNEngine
|
||||
open Parser
|
||||
|
||||
// variable, wildcard or identifier parser
|
||||
let pname = (name .>> spaces) <|> kw "_"
|
||||
let noTypePart = "%NoTypePart"
|
||||
|
||||
|
||||
type Element = Part of Part // e.g. r0040::prom<neg(tetR)>
|
||||
| Var of Var // X
|
||||
with static member wildcard = Var (-1, "_")
|
||||
static member doParse domainKeywords postParsingDisambigation idProvider : Parser.t<Element> =
|
||||
Parser.plookAheadWith (pname >>= fun str ->
|
||||
if domainKeywords |> List.contains str
|
||||
then preturn None
|
||||
else choice [ kw "(" >>. preturn None
|
||||
kw "[" >>. preturn None
|
||||
kw "[[" >>. preturn None
|
||||
kw "::" >>. preturn (Some true)
|
||||
preturn (if str = "_" || System.Char.IsUpper (str.Chars 0) then Some false else Some true) ])
|
||||
>>= fun isPart ->
|
||||
match isPart with
|
||||
| None -> failParser ""
|
||||
| Some isConcrete -> if isConcrete
|
||||
then Part.doParse idProvider domainKeywords postParsingDisambigation |>> Element.Part
|
||||
else pname |>> fun x -> Element.Var (idProvider x)
|
||||
static member parse domainKeywords idProvider = Element.doParse idProvider false domainKeywords
|
||||
static member ToString e =
|
||||
match e with
|
||||
| Element.Var v -> printVar v
|
||||
| Element.Part p -> Part.ToString p
|
||||
and Part = { name : Term<Element> // either a variable or a string. CS: I set Element as parametric value just to make unification and resolution more uniform
|
||||
; type_ : Term<Element> } // either a variable or a string
|
||||
with static member Create (name : Term<Element>, type_ : Term<Element>) = { name = name; type_ = type_ }
|
||||
static member CreateByName (name:string) = Part.Create(Term.Const name, Term.wildcard)
|
||||
static member CreateByType (type_:string) = Part.Create(Term.wildcard, Term.Const type_)
|
||||
static member doParse idProvider domainKeywords postParsingDisambiguation : Parser.t<Part> =
|
||||
Parser.plookAheadWith (pname >>= fun str ->
|
||||
if domainKeywords |> List.contains str
|
||||
then preturn None
|
||||
else choice [ kw "(" >>. preturn None
|
||||
kw "[" >>. preturn None
|
||||
kw "[[" >>. preturn None
|
||||
kw "::" >>. preturn (Some true)
|
||||
preturn (Some false)])
|
||||
>>= fun isPart ->
|
||||
match isPart with
|
||||
| None -> failParser ""
|
||||
| Some isConcrete ->
|
||||
let toTerm (s) : Term<Element> =
|
||||
if s = "_" then Term.wildcard
|
||||
elif System.Char.IsUpper (s.Chars 0)
|
||||
then idProvider s |> Term.Var
|
||||
else Term.Const s
|
||||
// let pterm = RulesDSD.Parser.pterm (Element.parse domainKeywords idProvider) idProvider domainKeywords
|
||||
|
||||
pname >>= fun partName ->
|
||||
let nameTerm = toTerm partName
|
||||
if isConcrete
|
||||
then kw "::" >>. pname >>= fun partType ->
|
||||
let typeTerm = toTerm partType
|
||||
preturn (Part.Create(nameTerm, typeTerm) )
|
||||
else preturn (Part.Create(nameTerm, if postParsingDisambiguation then Term.Const noTypePart
|
||||
else Term.wildcard))
|
||||
static member parse idProvider domainKeywords : Parser.t<Part> = Part.doParse idProvider domainKeywords false
|
||||
static member ToString p = // TODO: add cle
|
||||
let stringTerm t =
|
||||
match t with
|
||||
| Term.Const x -> x
|
||||
| _ -> Term.ToString t
|
||||
stringTerm p.name + "::" + stringTerm p.type_
|
||||
type Engine = RulesDSD.Syntax.CLE<Element, unit>
|
||||
type Semantics = RulesDSD.Syntax.RulesProgram<Element>
|
||||
|
||||
// find all concrete parts mentioned in the semantics (concrete meaning no open Prolog variable, each term is ground)
|
||||
let getParts (s:Semantics) : Part list =
|
||||
s.Values
|
||||
|> Seq.collect(Set.toList >> List.collect Clause.Species >> List.distinct)
|
||||
|> Seq.distinct
|
||||
|> Seq.choose (fun e ->
|
||||
match e with
|
||||
| Element.Part p -> match p.name, p.type_ with
|
||||
| Term.Var _, _
|
||||
| _, Term.Var _ -> None
|
||||
| _ -> Some p
|
||||
| Element.Var _ -> None)
|
||||
|> Seq.toList
|
||||
|
||||
|
||||
let PREDEFINED_PART_TYPE_NAMES = ["ter"; "prom"; "rbs"; "pcr"; "cds"]
|
||||
let PREDEFINED_PART_TYPES : Term<Element> list = PREDEFINED_PART_TYPE_NAMES |> List.map Term.Const
|
||||
|
||||
type Rate = Term<Element>
|
||||
type Complex = Element Mset
|
||||
let toComplex x : Complex = [1, x]
|
||||
let mapComplex (f:Element -> Element) (c:Complex) : Complex =
|
||||
// let g = Process.Map f
|
||||
let g = Term.Map f
|
||||
c |> List.map (fun (i, t) -> i, t |> Term.Map f) // |> Term.Map g)
|
||||
|
||||
|
||||
let termToDevice cle t : Element list =
|
||||
let err x = failwithf "Unexpected term %s is not a device (a list of parts <p1 ... pN>)." (Term.ToStringWith cle x)
|
||||
match t with
|
||||
| Term.Proc p -> match Process.ToList p with
|
||||
| [x] -> x
|
||||
| _ -> err t
|
||||
| _ -> err t
|
||||
|
||||
|
||||
type Instruction = Device of Element list
|
||||
| Constraint of Literal<Element>
|
||||
| Reaction of Complex option * Complex * Complex * Rate * Rate option // cata, react, prod, rate, bw rate
|
||||
| Initial of Term<Element> * Complex // concentration, molecule
|
||||
with
|
||||
static member Map (f:Element -> Element) i =
|
||||
match i with
|
||||
| Device d -> d |> List.map f |> Device
|
||||
| Constraint c -> c |> Literal.Map (Term.Map f) |> Constraint
|
||||
| Reaction (a,b,c,d,e) -> let g = mapComplex f
|
||||
let h = Rate.Map f
|
||||
Reaction (a |> Option.map g, g b, g c, h d, Option.map h e)
|
||||
| Initial (pop, t) -> Initial ((pop |> Term.Map f), mapComplex f t)
|
||||
static member Species i : Element list =
|
||||
let f = List.collect (snd >> Term.Species)
|
||||
match i with
|
||||
| Device d -> d
|
||||
| Constraint c -> Literal.Species c
|
||||
| Reaction (a,b,c,d,e) -> let s1 = a |> Option.toList |> List.collect f
|
||||
let s2 = f b
|
||||
let s3 = f c
|
||||
|
||||
let s4 = d |> Term.Species
|
||||
let s5 = e |> Option.toList |> List.collect Term.Species
|
||||
s1 @ s2 @ s3 @ s4 @ s5 |> List.distinct
|
||||
|
||||
| Initial (pop, t) -> (Term.Species pop @ f t) |> List.distinct
|
||||
static member Apply (cle:CLE<Element, unit>) (Sub s:Substitution<Element, unit>) i =
|
||||
match i with
|
||||
| Device d -> Device (d |> List.map (fun x -> cle.applySub s x))
|
||||
| Constraint c -> Constraint (c |> applyL cle (Sub s))
|
||||
| Reaction (a,b,c,d,e) -> failwith "Reactions not supported yet"
|
||||
| Initial (pop, t) -> let pop' = Substitution.Apply(Sub s, pop, cle)
|
||||
let t' = t |> List.map (fun (i,x) -> i, Substitution.Apply(Sub s, x, cle))
|
||||
Initial (pop', t')
|
||||
static member ToString (cle:CLE<Element, unit>) i : string =
|
||||
let printDevice d = d |> List.map Element.ToString |> String.concat " " |> sprintf "<%s>"
|
||||
match i with
|
||||
| Instruction.Device d -> printDevice d
|
||||
| Instruction.Constraint c -> Literal.ToStringWith cle c
|
||||
| Reaction (a,b,c,d,e) -> failwith "Reactions not supported yet"
|
||||
| Initial (pop, t) -> sprintf "%s %s" (Term.ToStringWith cle pop) (Term.ToStringWith cle (TMSet t))
|
||||
|
||||
static member GetParts (i:Instruction) =
|
||||
let f e = match e with
|
||||
| Element.Part p -> match p.name, p.type_ with
|
||||
| Term.Var _, _
|
||||
| _, Term.Var _ -> None
|
||||
| _ -> Some p
|
||||
| Element.Var _ -> None
|
||||
|
||||
match i with
|
||||
| Device d -> d |> List.choose f
|
||||
| Constraint c -> c |> Literal.Species |> List.choose f
|
||||
| Initial (c, i) -> let x = c |> Term.Species |> List.choose f
|
||||
let y = i |> List.collect (snd >> Term.Species >> List.choose f)
|
||||
x @ y
|
||||
| Reaction _ -> failwith "Reactions are not supported yet"
|
||||
|> List.distinct
|
||||
|
||||
// Disambiguation step:
|
||||
// if X is both a term var and an element var, turn Term.Var X into Term.Pattern [Pattern.Inner [Element.Var X, Locatiom.wildcard]]
|
||||
// create var to assignments map
|
||||
let rec updateMap (m:Map<Var, bool * bool * Term<Element> option * bool * bool>) // what has v been used for so far? As a term, a part, a part name (store the part type if so, so that var and part type can reconstruvct the full type), a part type, a location?
|
||||
(v:Var)
|
||||
(arg:Choice<unit, unit, Term<Element>, unit, unit>) = // what is v being used for?
|
||||
if m.ContainsKey v
|
||||
then m.Add (v, (match m.[v] with
|
||||
(a,b,c,d,e) ->
|
||||
match arg with
|
||||
| Choice1Of5 _ -> (true,b,c,d,e)
|
||||
| Choice2Of5 _ -> (a,true,c,d,e)
|
||||
| Choice3Of5 t ->
|
||||
// TODO: check if c or t are Term.wildcard
|
||||
(a,b,Some t,d,e)
|
||||
| Choice4Of5 _ -> (a,b,c,true,e)
|
||||
| Choice5Of5 _ -> (a,b,c,d,true) ))
|
||||
else m.Add (v, match arg with
|
||||
| Choice1Of5 _ -> (true,false,None,false,false)
|
||||
| Choice2Of5 _ -> (false,true,None,false,false)
|
||||
| Choice3Of5 t -> (false,false,Some t,false,false)
|
||||
| Choice4Of5 _ -> (false,false,None,true,false)
|
||||
| Choice5Of5 _ -> (false,false,None,false,true)
|
||||
)
|
||||
//
|
||||
and getMapElement m (e:Element) =
|
||||
match e with
|
||||
| Element.Var v -> updateMap m v (Choice2Of5 ())
|
||||
| Element.Part p ->
|
||||
let m' = match p.name with
|
||||
| Term.Var (i,v) -> updateMap m (i, v) (Choice3Of5 p.type_)
|
||||
| _ -> getMapTerm m p.name
|
||||
match p.type_ with
|
||||
| Term.Var (i,v) -> updateMap m' (i, v) (Choice4Of5 ())
|
||||
| _ -> getMapTerm m' p.name
|
||||
|
||||
and getMapLocation m l =
|
||||
match l with
|
||||
| Location.Var (x, y) -> let v = (x,y) in updateMap m v (Choice5Of5 ())
|
||||
| Location.Loc _ -> m
|
||||
|
||||
and getMapHole m (s:Element, l:Location) = getMapLocation (getMapElement m s) l
|
||||
|
||||
and getMapPattern m =
|
||||
function
|
||||
| Pattern.Inner hs -> hs |> List.fold getMapHole m
|
||||
| Pattern.Nihil -> m
|
||||
| Pattern.FivePrime hs -> hs |> List.fold getMapHole m
|
||||
| Pattern.ThreePrime hs -> hs |> List.fold getMapHole m
|
||||
| Pattern.Nicking(hs1, hs2) -> let m' = hs1 |> List.fold getMapHole m
|
||||
hs2 |> List.fold getMapHole m'
|
||||
| Pattern.Strand hs -> hs |> List.fold getMapHole m
|
||||
|
||||
and getMapProcess m =
|
||||
function
|
||||
| Process.Proc strandsMap -> strandsMap
|
||||
|> Map.toList
|
||||
|> List.map snd
|
||||
|> List.fold (fun acc s -> s |> List.fold getMapElement acc) m
|
||||
and getMapComplex m (c:Complex) =
|
||||
c |> List.fold (fun acc x -> getMapTerm acc (snd x)) m
|
||||
and getMapTerm m =
|
||||
function
|
||||
| Term.Var (x, y) -> updateMap m (x, y) (Choice1Of5 ())
|
||||
| Term.Const _
|
||||
| Term.Float _ -> m
|
||||
| Func (_, ts)
|
||||
| TList ts -> ts |> List.fold getMapTerm m
|
||||
| TCons (t1, t2) -> let m' = getMapTerm m t1
|
||||
getMapTerm m' t2
|
||||
| Proc p -> getMapProcess m p
|
||||
| Pat p -> getMapPattern m p
|
||||
| Term.TMSet ts -> ts |> List.fold (fun acc (_,v) -> getMapTerm acc v) m
|
||||
| Term.TCRN ts -> ts |> List.fold getMapTerm m
|
||||
|
||||
and getMapPredicate m = function
|
||||
| Predicate.Pred(_, args) -> args |> List.fold getMapTerm m
|
||||
|
||||
and getMapLit m = function
|
||||
| Pos p -> getMapPredicate m p
|
||||
| Neg p -> getMapPredicate m p
|
||||
|
||||
(*
|
||||
let zzz (cle:Engine) m xmap xapply =
|
||||
m
|
||||
|>
|
||||
Map.fold (fun x varName assignments ->
|
||||
// disambiguate each variable
|
||||
if varName = (-1, "_")
|
||||
then x // skip wildcards
|
||||
else
|
||||
match assignments with
|
||||
// skip unambiguous variables
|
||||
| false, false, None, false, false
|
||||
| true, false, None, false, false
|
||||
| false, true, None, false, false
|
||||
| false, false, Some _, false, false
|
||||
| false, false, None, true, false
|
||||
| false, false, None, false, true -> x
|
||||
| _(*hasTVar*), hasEVar, nameVar, hasTypeVar, hasLocVar ->
|
||||
let hasNameVar = Option.isSome nameVar
|
||||
let p' = match nameVar with
|
||||
| Some ty -> { name = Term.Var varName; type_ = ty }
|
||||
| None -> { name = Term.wildcard; type_ = Term.Var varName }
|
||||
if hasLocVar
|
||||
then
|
||||
if hasEVar || hasNameVar || hasTypeVar
|
||||
then failwith <| sprintf "Cannot unify location variable \"%s\" with a %s variable" (snd varName)
|
||||
(if hasTypeVar then "part type"
|
||||
elif hasNameVar then "part name"
|
||||
else "part")
|
||||
else // must be TVar too
|
||||
let pattern = Term.Pat <| Pattern.Inner [Element.Var (-1,"_"), Location.Var varName]
|
||||
let sub = Substitution<Element,_>.Create(varName, pattern).Add(varName, Choice2Of4 <| Location.Var varName, cle)
|
||||
xapply x sub
|
||||
// disambiguate variable <varName>
|
||||
elif hasNameVar || hasTypeVar
|
||||
then
|
||||
if hasEVar
|
||||
then
|
||||
// Consider this example: P = C[X], P = [X::Y]
|
||||
// Disambiguation interprets X in the first term a part with name X and type Y
|
||||
x
|
||||
|> xmap (fun t ->
|
||||
t
|
||||
|> Term.Map (fun e ->
|
||||
match e with
|
||||
| Element.Var (x,y) -> if (x,y) = varName then Part p' else e
|
||||
| Element.Part p'' -> Part <| if hasNameVar && p''.name = p'.name then p' else p''
|
||||
))
|
||||
else x // if it's a TVar, nothing to do
|
||||
else // not a LocVar, NameVar or TypeVar: must be a TVar and EVar
|
||||
let rec f (term:Term<Element>) =
|
||||
match term with
|
||||
| Term.Var (x,y) -> if (x,y) = varName
|
||||
then Term.Pat <| Pattern.Inner [Part p', Location.wildcard]
|
||||
else term
|
||||
| Term.Const _
|
||||
| Term.Float _
|
||||
| Term.Pat _
|
||||
| Term.Proc _ -> term
|
||||
| Term.Func (n, ts) -> Term.Func (n, ts |> List.map f)
|
||||
| Term.TCons (t1, t2) -> Term.TCons (f t1, f t2)
|
||||
| Term.TList ts -> Term.TList (ts |> List.map f)
|
||||
| Term.TCRN ts -> Term.TCRN (ts |> List.map f)
|
||||
| Term.TMSet ts -> Term.TMSet (ts |> List.map (fun (i, x) -> i, f x))
|
||||
x |> xmap f
|
||||
)
|
||||
*)
|
||||
|
||||
///////////////////////////////////
|
||||
// Logic GEC Custom Logic Engine //
|
||||
///////////////////////////////////
|
||||
and fvPart (p:Part) =
|
||||
[p.name; p.type_]
|
||||
|> List.map (fvt cle)
|
||||
|> Set.unionMany
|
||||
|
||||
and fvElement (e:Element) =
|
||||
let rec fv t =
|
||||
match t with
|
||||
| Term.Var (-1, "_") -> Set.empty
|
||||
| Term.Var (x,y) -> Set.singleton (TVar (x,y))
|
||||
| Term.Const _ -> Set.empty
|
||||
| Term.Float _ -> Set.empty
|
||||
| Term.Func (_, ts) -> ts |> unionFold fv
|
||||
| Term.TList ts -> ts |> unionFold fv
|
||||
| Term.TCons (t,t') -> [t;t'] |> unionFold fv
|
||||
| Term.Pat _ -> Set.empty // p |> fvPattern cle
|
||||
| Term.Proc _ -> Set.empty // TODO
|
||||
| Term.TCRN ts -> ts |> unionFold fv
|
||||
| Term.TMSet ts -> ts |> List.map snd |> unionFold fv
|
||||
match e with
|
||||
| Part p -> fvPart p
|
||||
| Var x -> if x = (-1, "_") then Set.empty else Set.singleton (SVar (x, e))
|
||||
|
||||
and elemToString (x : Element) : string =
|
||||
let toString t = match t with
|
||||
| Term.Const x -> x
|
||||
| _ -> Term.ToStringWith cle t
|
||||
match x with
|
||||
| Part p -> let typ = match p.type_ with
|
||||
| Term.Var (-1, "_") -> ""
|
||||
| _ -> " : " + toString p.type_
|
||||
toString p.name // + typ
|
||||
| Var (_, y) -> y
|
||||
|
||||
and elemCompare (x:Element) (y:Element) =
|
||||
match x, y with
|
||||
| Part _, Var _ -> RulesDSD.Syntax.LT
|
||||
| Var _, Part _ -> RulesDSD.Syntax.GT
|
||||
| Part p1, Part p2 -> Term.Compare cle p1.name p2.name
|
||||
| Var (v1, _), Var (v2, _) -> compare v1 v2
|
||||
|
||||
and elemCanonicalForm (x:Element) = x
|
||||
|
||||
and elemUnderscore () = Var (-1, "_")
|
||||
|
||||
and elemRefresh (idProvider : string -> int) e =
|
||||
match e with
|
||||
| Part p ->
|
||||
let refresher = Term.refresh cle idProvider
|
||||
let n = refresher p.name
|
||||
let t = refresher p.type_
|
||||
|
||||
Part (Part.Create(n, t))
|
||||
| Var (_, y) -> Var (idProvider y, y)
|
||||
|
||||
and unimplemented _ = failwith ""
|
||||
|
||||
and deviceComposition p q = Process.ToList p @ Process.ToList q |> Process.OfList
|
||||
|
||||
and elemResolveGoal (p, args) _ =
|
||||
match (p, args) with
|
||||
| _ -> None
|
||||
|
||||
|
||||
and elemDisambiguateVarsWith m (c:Clause<Element>) : Clause<Element> =
|
||||
// TODO: is this still necessary?
|
||||
|
||||
// remove "noTypePart" types from parts (in patterns and processes)
|
||||
let g(e:Element) =
|
||||
match e with
|
||||
| Element.Var _ -> e
|
||||
| Element.Part p -> if p.type_ = Term.Const noTypePart
|
||||
then { p with type_ = Term.wildcard }
|
||||
else p
|
||||
|> Element.Part
|
||||
|
||||
// turn all other "noTypePart" parts into (Term.Const part.name)
|
||||
let rec f (e:Term<Element>) =
|
||||
match e with
|
||||
| Term.Pat (Pattern.Inner [Element.Part ({ name = n; type_ = Term.Const "%NoTypePart"}), Location.Var (-1, "_")]) -> n
|
||||
| Term.Float _
|
||||
| Term.Const _
|
||||
| Term.Var _ -> e
|
||||
| Term.Pat p -> p |> Pattern.Map (fun (x, y) -> g x, y) |> Term.Pat
|
||||
| Term.Proc p -> p |> RulesDSD.Syntax.Process.Map g
|
||||
|> Term.Proc
|
||||
| Term.TList ts -> ts |> List.map f |> Term.TList
|
||||
| Term.TCons (t1, t2) -> Term.TCons (f t1, f t2)
|
||||
| Term.TCRN ts -> ts |> List.map f |> Term.TCRN
|
||||
| Term.TMSet ts -> ts |> List.map (fun (i, t) -> i, f t) |> Term.TMSet
|
||||
| Term.Func (n, ts) -> Term.Func (n, ts |> List.map f)
|
||||
|
||||
let c' = c |> Clause.Map f
|
||||
match c'.head with
|
||||
| Pred (_, lits) ->
|
||||
// collect how each variable is used
|
||||
c'.body
|
||||
|> List.fold getMapLit (lits |> List.fold getMapTerm Map.empty)
|
||||
// m
|
||||
|> Map.fold (fun (clause:Clause<Element>) varName assignments ->
|
||||
// disambiguate each variable
|
||||
if varName = (-1, "_")
|
||||
then clause // skip wildcards
|
||||
else
|
||||
match assignments with
|
||||
// skip unambiguous variables
|
||||
| false, false, None, false, false
|
||||
| true, false, None, false, false
|
||||
| false, true, None, false, false
|
||||
| false, false, Some _, false, false
|
||||
| false, false, None, true, false
|
||||
| false, false, None, false, true -> clause
|
||||
| _(*hasTVar*), hasEVar, nameVar, hasTypeVar, hasLocVar ->
|
||||
let hasNameVar = Option.isSome nameVar
|
||||
let p' = match nameVar with
|
||||
| Some ty -> { name = Term.Var varName; type_ = ty }
|
||||
| None -> { name = Term.wildcard; type_ = Term.Var varName }
|
||||
if hasLocVar
|
||||
then
|
||||
if hasEVar || hasNameVar || hasTypeVar
|
||||
then failwith <| sprintf "Cannot unify location variable \"%s\" with a %s variable" (snd varName)
|
||||
(if hasTypeVar then "part type"
|
||||
elif hasNameVar then "part name"
|
||||
else "part")
|
||||
else // must be TVar too
|
||||
let pattern = Term.Pat <| Pattern.Inner [Element.Var (-1,"_"), Location.Var varName]
|
||||
let sub = Substitution<Element,_>.Create(varName, pattern).Add(varName, Choice2Of4 <| Location.Var varName, cle)
|
||||
sub.Apply(clause,cle)
|
||||
// disambiguate variable <varName>
|
||||
elif hasNameVar || hasTypeVar
|
||||
then
|
||||
if hasEVar
|
||||
then
|
||||
// Consider this example: P = C[X], P = [X::Y]
|
||||
// Disambiguation interprets X in the first term a part with name X and type Y
|
||||
clause
|
||||
|> Clause<Element>.Map (fun t ->
|
||||
t
|
||||
|> Term.Map (fun e ->
|
||||
match e with
|
||||
| Element.Var (x,y) -> if (x,y) = varName then Part p' else e
|
||||
| Element.Part p'' -> Part <| if hasNameVar && p''.name = p'.name then p' else p''
|
||||
))
|
||||
else clause // if it's a TVar, nothing to do
|
||||
else // not a LocVar, NameVar or TypeVar: must be a TVar and EVar
|
||||
let rec f (term:Term<Element>) =
|
||||
match term with
|
||||
| Term.Var (x,y) -> if (x,y) = varName
|
||||
then Term.Pat <| Pattern.Inner [Part p', Location.wildcard]
|
||||
else term
|
||||
| Term.Const _
|
||||
| Term.Float _
|
||||
| Term.Pat _
|
||||
| Term.Proc _ -> term
|
||||
| Term.Func (n, ts) -> Term.Func (n, ts |> List.map f)
|
||||
| Term.TCons (t1, t2) -> Term.TCons (f t1, f t2)
|
||||
| Term.TList ts -> Term.TList (ts |> List.map f)
|
||||
| Term.TCRN ts -> Term.TCRN (ts |> List.map f)
|
||||
| Term.TMSet ts -> Term.TMSet (ts |> List.map (fun (i, x) -> i, f x))
|
||||
clause |> Clause.Map f
|
||||
) c'
|
||||
//) c
|
||||
|
||||
and elemDisambiguateVars (c:Clause<Element>) : Clause<Element> =
|
||||
let m = match c.head with Pred (_, lits) -> c.body |> List.fold getMapLit (lits |> List.fold getMapTerm Map.empty)
|
||||
elemDisambiguateVarsWith m c
|
||||
|
||||
and elemApplySub (theta:Sub<Element, unit>) (e:Element) : Element =
|
||||
match e with
|
||||
| Var (-1, "_") -> e
|
||||
| Var v -> if theta.ContainsKey v
|
||||
then match theta.[v] with
|
||||
| Choice1Of4 _ -> failwith ""
|
||||
| Choice2Of4 _ -> failwith ""
|
||||
| Choice3Of4 x -> x
|
||||
| Choice4Of4 _ -> failwith ""
|
||||
else e
|
||||
| Part p -> let applier (x:Term<Element>) = Substitution.Apply(Sub theta, x, cle)
|
||||
let n = applier p.name
|
||||
let t = applier p.type_
|
||||
Part (Part.Create(n, t))
|
||||
|
||||
and elemApplyAll (theta:Sub<Element, unit>) (x:Choice<Element, unit>) =
|
||||
match x with
|
||||
| Choice1Of2 e -> elemApplySub theta e
|
||||
| Choice2Of2 () -> failwith ""
|
||||
|
||||
and elemUnify (x:Element, y:Element) : Sub<Element, unit> list =
|
||||
match x, y with
|
||||
| Part p, Var x
|
||||
| Var x, Part p -> [Map.ofList [x, Choice3Of4 <| Part p]]
|
||||
| Var x, Var y -> [Map.ofList [y, Choice3Of4 <| Var x]]
|
||||
| Part p1, Part p2 ->
|
||||
let eq1 = RulesDSD.Unification.TEq (p1.name, p2.name)
|
||||
let eq2 = RulesDSD.Unification.TEq (p1.type_, p2.type_)
|
||||
let eqs = [eq1; eq2]
|
||||
RulesDSD.Unification.unify cle eqs
|
||||
|
||||
|> List.map (fun (Sub x) -> x)
|
||||
|
||||
and cle : Engine =
|
||||
{ toString = elemToString // print 's
|
||||
toStringTempVar = unimplemented // print 'a
|
||||
compare = elemCompare // compare two 's, used for sorting; the actual ordering is unimportant, as long as it is a partial order
|
||||
cast = unimplemented // cast a 'a into a 's (e.g. a bond X can be cast into a site _!X); used in substitutions
|
||||
toCanonicalForm = elemCanonicalForm // find the canonical form of 's
|
||||
toCanonicalFormProcess = id // find the canonical form of a process. Since species 's might reference each other (e.g. as in bonds), it is necessary to have a Process level canonical form function
|
||||
unify = elemUnify // species unification. The core algorithm that finds a 's and 'a variable substitution such that two species are equivalent after applying it
|
||||
underscore = elemUnderscore // wildcard "_" for 's
|
||||
applyAll = elemApplyAll // apply a substitution to a species or subspecies
|
||||
applySub = elemApplySub // apply a species substitution
|
||||
applySubVar = unimplemented // apply a substitution to a subspecies
|
||||
fvs = fvElement // free variables in 's
|
||||
refresh = elemRefresh // provide a copy of 's where variables have been renamed by an ID provider. Used in resolution
|
||||
disambiguateVars = elemDisambiguateVars // post-parsing step applied to each parsed clause. In Logic DSD this is used to disambiguate the use of domain variables (e.g. in P = C[D][D!i], D can be cast down to an unbound domain rather than a generic site)
|
||||
ComposeProcesses = deviceComposition // compose two processes together (possibly forming a complex in Logic DSD)
|
||||
resolveGoal = elemResolveGoal // species-specific predicates resolution. The core resolution algorithm that executes custom predicates for species (e.g. "compl(D, E)" is a custom predicate in Logic DSD to find the complement E of a domain D)
|
||||
domainKeywords = [] }
|
||||
|
||||
|
||||
// free variables
|
||||
let fvi (i:Instruction) =
|
||||
let rec fvElement (e:Element) =
|
||||
match e with
|
||||
| Element.Part p ->
|
||||
let f x = fvt cle x
|
||||
Set.union (f p.name) (f p.type_)
|
||||
| Element.Var v -> Set.singleton (Variable.SVar (v, e))
|
||||
|
||||
let rec fvComplex (c:Complex) =
|
||||
c |> List.fold (fun acc (_, tp) ->
|
||||
let t = tp |> Term.Species // |> List.collect (Process.ToList >> List.concat) |> List.distinct
|
||||
Set.union acc (Set.unionMany (t |> List.map fvElement))) Set.empty
|
||||
|
||||
match i with
|
||||
| Device d -> d |> List.map fvElement |> List.fold (Set.union) Set.empty
|
||||
| Constraint c -> fvl cle c
|
||||
| Initial (n,c) -> Set.union (fvt cle n) (fvComplex c)
|
||||
| Reaction(a,b,c,d,e) ->
|
||||
let av = a |> Option.toList |> List.map fvComplex
|
||||
let ev = e |> Option.toList |> List.map (fvt cle)
|
||||
let fvs = av @ ([b;c] |> List.map fvComplex) @ [fvt cle d] @ ev
|
||||
Set.unionMany fvs
|
||||
|
||||
type Program = Instruction list
|
||||
|
||||
let enumerateDeviceSubstitutions (cle:Engine) (db:Semantics) (prog:Program) =
|
||||
let freevars =
|
||||
prog
|
||||
|> List.map fvi
|
||||
|> Set.unionMany
|
||||
let maxVar =
|
||||
freevars
|
||||
|> Set.map (fun x ->
|
||||
match x with
|
||||
| Variable.SVar ((n,_), _)
|
||||
| Variable.IVar ((n,_), _)
|
||||
| Variable.LVar (n,_)
|
||||
| Variable.TVar (n,_) -> n)
|
||||
|> fun s -> if s.IsEmpty then 0 else Set.maxElement s
|
||||
let counter = ref (maxVar + 1)
|
||||
|
||||
let deviceEnumeration d sols =
|
||||
d |> List.fold (fun acc elem ->
|
||||
match acc with
|
||||
| None -> None
|
||||
| Some solutions ->
|
||||
solutions
|
||||
|> List.collect (fun (s:RulesDSD.Substitution.Substitution<Element, unit>) ->
|
||||
match elem with
|
||||
| Part part ->
|
||||
// prepare device query
|
||||
let pName = s.Apply(part.name , cle)
|
||||
let pType = s.Apply(part.type_, cle)
|
||||
let qPart = Part { name = pName; type_ = pType }
|
||||
let query = [ Pos (Pred ("part", [Term.Pat (Pattern.Inner [qPart, Location.wildcard]) ])) ]
|
||||
|
||||
// interrogate DB
|
||||
let goal = RulesDSD.Resolution.Goal<Element, unit>.Create(query, cle)
|
||||
match RulesDSD.Resolution.resolveInner [goal] cle counter db [] RulesDSD.Resolution.Mode.AllAnswers with
|
||||
| None -> []
|
||||
| Some newSols -> if solutions = [Substitution.id]
|
||||
then newSols
|
||||
else newSols |> List.map (fun s' -> RulesDSD.Substitution.Substitution.Compose s s' cle)
|
||||
| Var v ->
|
||||
// look for any part in the DB
|
||||
let query = [ Pos (Pred ("part", [Term.Pat (Pattern.Inner [Var v, Location.wildcard]) ])) ]
|
||||
let goal = RulesDSD.Resolution.Goal<Element, unit>.Create(query, cle)
|
||||
match RulesDSD.Resolution.resolveInner [goal] cle counter db [] RulesDSD.Resolution.Mode.AllAnswers with
|
||||
| None -> []
|
||||
| Some newSols -> if solutions = [Substitution.id]
|
||||
then newSols
|
||||
else newSols |> List.map (fun s' -> RulesDSD.Substitution.Substitution.Compose s s' cle) )
|
||||
|> fun x -> if x.IsEmpty then None else Some (x |> List.distinct)
|
||||
) (Some sols)
|
||||
|
||||
prog |> List.fold (fun (solutionsSet:RulesDSD.Substitution.Substitution<Element, unit> list option) i ->
|
||||
match solutionsSet with
|
||||
| None -> None // some constraint is unsatisfiable; abort enumeration
|
||||
| Some sols ->
|
||||
match i with
|
||||
| Initial (_, [1, Term.Proc p]) -> match p |> Process.ToList with
|
||||
| [d] -> deviceEnumeration d sols
|
||||
| _ -> failwithf "Unexpected multiple devices in initial %s." (Instruction.ToString cle i)
|
||||
| Device d -> deviceEnumeration d sols
|
||||
|
||||
| Constraint c -> let sols' =
|
||||
sols
|
||||
|> List.collect (fun (s:RulesDSD.Substitution.Substitution<Element, unit>) ->
|
||||
let c' = s.Apply(c, cle)
|
||||
let g = RulesDSD.Resolution.Goal<Element, unit>.Create([c'], cle)
|
||||
match RulesDSD.Resolution.resolveInner [g] cle counter db [] RulesDSD.Resolution.Mode.AllAnswers with
|
||||
| None -> []
|
||||
| Some newSols -> if sols.IsEmpty
|
||||
then newSols
|
||||
else newSols |> List.map (fun s' -> RulesDSD.Substitution.Substitution.Compose s s' cle) )
|
||||
match sols' with
|
||||
| [] -> None
|
||||
| _ -> Some sols'
|
||||
|
||||
| Reaction _ -> solutionsSet // TODO: check that the interaction is in the DB?
|
||||
| Initial _ -> solutionsSet
|
||||
) (Some [Substitution.id])
|
||||
|
||||
let enumerateDevices (cle:Engine) (db:Semantics) (prog:Program) : Program list =
|
||||
let maxVar =
|
||||
prog
|
||||
|> List.map fvi
|
||||
|> Set.unionMany
|
||||
|> Set.map (fun x ->
|
||||
match x with
|
||||
| Variable.SVar ((n,_), _)
|
||||
| Variable.IVar ((n,_), _)
|
||||
| Variable.LVar (n,_)
|
||||
| Variable.TVar (n,_) -> n)
|
||||
|> fun s -> if s.IsEmpty then 0 else Set.maxElement s
|
||||
|> ref
|
||||
|
||||
let fullProgram =
|
||||
prog
|
||||
|> List.map (Instruction.Map (fun e ->
|
||||
match e with
|
||||
| Element.Var _ -> e
|
||||
| Element.Part p -> if p.name = Term.wildcard
|
||||
then
|
||||
let x = !maxVar
|
||||
maxVar := !maxVar + 1
|
||||
let freshVar = Term.Var(x, sprintf "X_%i" x)
|
||||
Element.Part { p with name = freshVar}
|
||||
else e))
|
||||
|
||||
|
||||
let devs =
|
||||
fullProgram
|
||||
|> List.filter (fun i -> match i with
|
||||
| Instruction.Device _ -> true
|
||||
| Instruction.Initial _ -> true
|
||||
| _ -> false)
|
||||
|
||||
match enumerateDeviceSubstitutions cle db fullProgram with
|
||||
| None -> []
|
||||
| Some sols ->
|
||||
sols
|
||||
|> List.map (fun (RulesDSD.Substitution.Substitution.Sub s) ->
|
||||
devs
|
||||
|> List.map (Instruction.Map (cle.applySub s)))
|
||||
|> List.distinct
|
||||
|
||||
|
||||
|
||||
(* GEC calculus*)
|
||||
let makeGecCalculus (db:Semantics) : Calculus<Term<Element>> =
|
||||
// prepare the set of "reaction" predicates to run in the calculus
|
||||
|
||||
// collect all "reactions" signatures
|
||||
// find all reactions predicate
|
||||
let reactionsSigs = seq { for kv in db.Keys do
|
||||
if fst kv = "reactions" then yield kv else () }
|
||||
|> Seq.sortWith (fun (_, x) (_, y) -> compare x y)
|
||||
|> Seq.toList
|
||||
|> Seq.map (fun x -> x, db.Item x)
|
||||
|
||||
{ react = fun (oldElements:Term<Element> list) (newElement:Term<Element>) ->
|
||||
// find all query combos: reactions(CRN), reactions(newElement, CRN), reactions (newElement, oldElem, CRN), reactions (newElement, oldElem1, oldElem2, ..., CRN) ...
|
||||
// run all queries
|
||||
// create new reactions
|
||||
let newProc = newElement |> Term.Canonical cle
|
||||
let oldProcs = oldElements |> List.map (Term.Canonical cle)
|
||||
let rec combo n i : Term<Element> list list =
|
||||
if n <= 0
|
||||
then []
|
||||
else let ccombo = if n = i
|
||||
then [[newProc]]
|
||||
else combo (n-1) i
|
||||
if ccombo.IsEmpty
|
||||
then [oldProcs]
|
||||
else
|
||||
oldProcs
|
||||
|> List.collect (fun p ->
|
||||
ccombo
|
||||
|> List.map (fun ps -> p :: ps))
|
||||
|
||||
let queries =
|
||||
reactionsSigs
|
||||
|> Seq.filter (fun ((_, numberOfArguments), _) -> numberOfArguments >= 2 ) // take reactions(E1, ...., En, CRN) predicates
|
||||
|> Seq.collect (fun ((queryName, numberOfArguments), preds) ->
|
||||
match numberOfArguments with
|
||||
| 2 -> preds |> Set.map (fun p -> match p.head.Args with [_; x] -> Pos (Pred(queryName, [newProc; x])) | _ -> failwith "") |> Set.toSeq
|
||||
| n -> let allElementArgs = [1..n-1] |> List.collect (fun i -> combo (n-1) i)
|
||||
preds
|
||||
|> Set.map (fun (p:Clause<Element>) -> allElementArgs
|
||||
|> List.map (fun args -> Pos (Pred(queryName, args @ [p.head.Args |> List.last] ))))
|
||||
|> Set.toSeq
|
||||
|> Seq.concat)
|
||||
|> Seq.distinct
|
||||
|
||||
// query the Prolog engine and create CRN reactions if any "reactions()" predicate matched
|
||||
queries
|
||||
|> Seq.choose (fun query ->
|
||||
match RulesDSD.Resolution.resolveAll query db cle with
|
||||
| None -> None
|
||||
| Some sols ->
|
||||
sols
|
||||
|> List.collect (fun theta ->
|
||||
match theta.Apply(query, cle) with
|
||||
| Pos p ->
|
||||
// reactants are already in canonical form by construction
|
||||
match p.Args |> List.last with
|
||||
| Term.TCRN ts -> ts
|
||||
|> List.map (Term.Canonical cle)
|
||||
|> List.collect Term.ToReactions
|
||||
| _ -> let str = query |> Literal.ToStringWith cle
|
||||
failwithf "Error: enumeration predicate %s generated a non-CRN term." str
|
||||
| _ -> failwith "" )
|
||||
|> Some
|
||||
)
|
||||
|> List.concat
|
||||
|> List.distinct
|
||||
|> List.filter (fun r -> r.reactants <> r.products)
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////
|
||||
///////////////////////////
|
||||
//// Parser
|
||||
///////////////////////////
|
||||
///////////////////////////
|
||||
|
||||
let pInstruction (idProvider : string -> RulesDSD.Syntax.Var) =
|
||||
let pElement = Element.doParse cle.domainKeywords true idProvider
|
||||
let pDevice = Parser.between (kw "<") (kw ">") (Parser.many1 pElement)
|
||||
let pDeviceAst = pDevice |>> Instruction.Device
|
||||
let pConstraintAst = RulesDSD.Parser.pliteral cle pElement idProvider cle.domainKeywords |>> Instruction.Constraint
|
||||
let pInitialAst = RulesDSD.Parser.pterm pElement cle idProvider cle.domainKeywords .>>.
|
||||
choice [ pDevice |>> Choice1Of2
|
||||
RulesDSD.Parser.pterm pElement cle idProvider cle.domainKeywords |>> Choice2Of2 ]
|
||||
>>= fun (i, x) ->
|
||||
match x with
|
||||
| Choice1Of2 x -> preturn (Instruction.Initial (i, x |> List.singleton |> Process.OfList |> Term.Proc |> toComplex))
|
||||
| Choice2Of2 x -> preturn (Instruction.Initial (i, x |> toComplex))
|
||||
|
||||
|
||||
Parser.plookAheadWith
|
||||
(choice [
|
||||
// device
|
||||
kw "<" >>. preturn (Choice1Of4 ())
|
||||
// constraint
|
||||
kw "not" >>. pname >>. kw "(" >>. preturn (Choice2Of4 ())
|
||||
pname >>. kw "(" >>. preturn (Choice2Of4 ())
|
||||
// reaction
|
||||
// choice [ pdevice >>. choice [kw "+"; kw "->"; preturn Choice1Of4 ()] // last case is actually a device
|
||||
// kw "->" ] // no reactants reaction
|
||||
|
||||
// initial
|
||||
Expression.parse pname >>. preturn (Choice4Of4 ())
|
||||
]) >>=
|
||||
fun next ->
|
||||
match next with
|
||||
| Choice1Of4 _ -> pDeviceAst
|
||||
| Choice2Of4 _ -> pConstraintAst
|
||||
| Choice3Of4 _ -> failParser "Reactions not supported yet"
|
||||
| Choice4Of4 _ -> pInitialAst
|
||||
|
||||
|
||||
let generateCRN (cle:Engine) (db:Semantics) (prog:Program) =
|
||||
// collect devices, initials and reactions // TODO: merge devices and initials into a single field initials of type (Term<Element> * Process<Element>)
|
||||
let ps, is, rs =
|
||||
prog |> List.fold (fun (ps, is, rs) instruction ->
|
||||
match instruction with
|
||||
| Constraint _ -> (ps, is, rs) // skip constraints
|
||||
| Reaction (a,b,c,d,e) -> (ps, is, (a,b,c,d,e) :: rs)
|
||||
| Device d -> (Process.OfList [d] :: ps, is, rs)
|
||||
| Initial (a,b) -> if a <> Term.Float 0.0
|
||||
then (ps, (a,b)::is, rs)
|
||||
else (ps, is, rs)) ([], [], [])
|
||||
|
||||
// species namer
|
||||
let default_namer () : (Term<Element> -> string) =
|
||||
let cache = new System.Collections.Generic.Dictionary<Term<Element>, string>()
|
||||
let names = new System.Collections.Generic.HashSet<string>()
|
||||
let namer species : string =
|
||||
let sp = species |> Term.Canonical cle
|
||||
if cache.ContainsKey sp then
|
||||
cache.Item sp
|
||||
else
|
||||
let mutable unique_name = ""
|
||||
let mutable c = names.Count + 1
|
||||
while unique_name = "" do
|
||||
if not (names.Contains ("sp" + string c)) then
|
||||
unique_name <- "sp" + string c
|
||||
else c <- c + 1
|
||||
let name = unique_name
|
||||
|
||||
cache.Add(sp, name)
|
||||
ignore(names.Add(name))
|
||||
name
|
||||
namer
|
||||
let namer = default_namer ()
|
||||
|
||||
|
||||
// prepare initials and reactions for CRN enumeration
|
||||
// TODO: get the initial concentration from the core GEC program after merging process and initials
|
||||
let inits = (is |> List.map (fun (n, i) -> let t = match i with
|
||||
| [1, x] -> x
|
||||
| _ -> Term.TMSet i
|
||||
let c : Value =
|
||||
match n with
|
||||
| Term.Float x -> Expression.Float x
|
||||
| Term.Const x -> Expression.Key x
|
||||
| Term.Var (_, x) -> Expression.Key x
|
||||
| _ -> failwithf "Initial condition %s must be a float, const or a variable." (Term.ToStringWith cle n)
|
||||
c, t))
|
||||
@ (ps |> List.map (fun p -> Expression.Float 1.0, p |> Term.Proc))
|
||||
|> List.map Initial.create
|
||||
|
||||
let toMSet (x:Complex) : Microsoft.Research.CRNEngine.Mset.t<Term<Element>> =
|
||||
x |> List.map (fun (i, sp) -> { Microsoft.Research.CRNEngine.Mset.element = sp
|
||||
; Microsoft.Research.CRNEngine.Mset.multiplicity = i})
|
||||
let reacts = rs |> List.choose ( fun (catalysts,reactants,products,fwRate,bwRate) ->
|
||||
let r = reactants |> toMSet
|
||||
let p = products |> toMSet
|
||||
match Term.ToRate fwRate with
|
||||
| None -> None
|
||||
| Some fr ->
|
||||
let br = match bwRate with
|
||||
| None -> None
|
||||
| Some b -> Term.ToRate b
|
||||
match catalysts with
|
||||
| None -> Reaction.create([], r, br, fr, p) |> Some
|
||||
| Some c -> Reaction.create(c |> toMSet, r, br, fr, p) |> Some )
|
||||
|
||||
// expand the GEC program into a CRN using the GEC calculus
|
||||
let equalsSpecies p q = Term.Compare cle (p |> Term.Canonical cle) (q|> Term.Canonical cle) = EQ
|
||||
let plotMatcher p q = Term.Compare cle p q = EQ
|
||||
let gecCalculus = makeGecCalculus db
|
||||
|
||||
let gecRenderer (s:Term<Element>) : Attributes =
|
||||
{ name = namer s
|
||||
; structure = Term.ToStringWith cle s
|
||||
; svg = "" }
|
||||
|
||||
|
||||
|
||||
let crn = Crn.from_calculus_translated
|
||||
(fun p -> namer p |> Species.create)
|
||||
gecRenderer
|
||||
equalsSpecies
|
||||
plotMatcher
|
||||
(fun sp -> (fvt cle sp).IsEmpty)
|
||||
""
|
||||
Microsoft.Research.CRNEngine.Crn_settings.defaults
|
||||
gecCalculus
|
||||
inits
|
||||
reacts
|
||||
false
|
||||
true
|
||||
true
|
||||
|> Crn.group_reactions
|
||||
|
||||
crn
|
||||
|
||||
let pGecProgram : Parser.t<Semantics> = RulesDSD.Parser.pprogram cle (Element.doParse cle.domainKeywords true)
|
|
@ -0,0 +1,140 @@
|
|||
(*
|
||||
Provides top-level access to LSB translation. Functions in this module
|
||||
will invoke the LSB compiler, invoke the Prolog engine and parse the results
|
||||
in to an appropriate .NET data structure.
|
||||
|
||||
Author: Michael Pedersen.
|
||||
Copyright © Microsoft Research, 2008-2009.
|
||||
*)
|
||||
|
||||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.Main
|
||||
|
||||
open Microsoft.Research.GEC.Ast
|
||||
open Microsoft.Research.GEC.Trans
|
||||
open Microsoft.Research.CRNEngine
|
||||
open Microsoft.Research.GEC.DirectivesParser
|
||||
|
||||
open Parser
|
||||
//open Microsoft.FSharp.Compatibility.OCaml
|
||||
//open Microsoft.Research.ModellingEngine
|
||||
open System.IO
|
||||
open Printf
|
||||
|
||||
|
||||
|
||||
// make LBS rate definition strings
|
||||
let mkSingleLBSRateDef (r,f) = "rate " + r + " = " + (Lib.display_float f) + ";"
|
||||
let mkLBSRateDefs rateDecs =
|
||||
(Lib.string_of_list mkSingleLBSRateDef Lib.newline (expandRateDecs rateDecs)) + Lib.newline
|
||||
|
||||
// produce a string representation of an assignment...
|
||||
let stringOfAss (xs:(string * string) list) =
|
||||
Lib.brack (Lib.string_of_list (fun (x,y) -> Lib.paren(Lib.quote x + ", " + Lib.quote y)) "; " xs)
|
||||
|
||||
/// Input position range, this will likely be replaced by something from FParsec
|
||||
type pos = {l1 : int; c1 : int; l2 : int; c2 : int}
|
||||
|
||||
// a solution type for passing back to a C# client:
|
||||
type tSolution =
|
||||
{
|
||||
bbDevices : tBbDevices;
|
||||
lbsProgram : tLBSProg;
|
||||
rateDecs : tRateDecs;
|
||||
|
||||
// variable assignments represent solutions to constraints:
|
||||
varAss : ((string * string) list * (string * string) list * (string * string) list) list;
|
||||
substs : Subst.t list;
|
||||
|
||||
// an error option for reporting errors:
|
||||
error : (string * pos option) option;
|
||||
|
||||
// the number of solutions to constraints:
|
||||
numSolutions : int;
|
||||
}
|
||||
|
||||
// get a specific instance of the device of a solution:
|
||||
member v.getDevicesInstance(num) =
|
||||
let devices = v.bbDevices
|
||||
let (subst,_,_) = List.item num v.varAss
|
||||
//let devices' = devices |> List.map (fun device -> device |> List.map (fun var -> if (List.mem_assoc var subst) then List.assoc var subst else var))
|
||||
let devices' = devices |> List.map (fun device -> device |> List.map (fun var -> match Lib.try_assoc var subst with | Some x -> x | None -> var))
|
||||
Lib.brack (Lib.string_of_list (fun xs -> Lib.brack(Lib.string_of_list Lib.id "; " xs)) ";\r " devices')
|
||||
|
||||
// get a specific instance of the device of a solution as a string list list:
|
||||
member v.getDevicesInstanceStructured(num) =
|
||||
let devices = v.bbDevices
|
||||
let (subst,_,_) = List.item num v.varAss
|
||||
let devices' = devices |> List.map (fun device -> device |> List.map (fun var -> match Lib.try_assoc var subst with | Some x -> x | None -> var))
|
||||
let devicesArray = List.toArray(List.map (fun lst -> List.toArray(lst)) devices' )
|
||||
devicesArray
|
||||
|
||||
// get a specific instance of the program of a solution:
|
||||
member v.getProgramInstance(num) =
|
||||
let prog = v.lbsProgram
|
||||
let (_,substSpec,substRates) = List.item num v.varAss
|
||||
let lbsProgStr = lbsProgToStr prog (substSpec@substRates)
|
||||
(mkLBSRateDefs v.rateDecs) + lbsProgStr
|
||||
// add a default declaration for mrna degradation:
|
||||
//let mrnaDegRate = "rate RMRNADeg = " + (Lib.display_float default_RMRNADeg) + ";\n"
|
||||
//mrnaDegRate + lbsProgStr
|
||||
|
||||
// get the program instance with declared rates assigned:
|
||||
member v.getProgramDefault() =
|
||||
//let lbsProgStr = lbsProgToStr v.lbsProgram v.rateDecs
|
||||
//lbsProgStr
|
||||
let lbsProgStr = lbsProgToStr v.lbsProgram []
|
||||
(mkLBSRateDefs v.rateDecs) + lbsProgStr
|
||||
|
||||
// get a specific instance of a species assignment:
|
||||
member v.getSpecAss(num) =
|
||||
let (l1, specVarAss, l3) = List.item num v.varAss
|
||||
stringOfAss specVarAss
|
||||
|
||||
// get a specific instance of a species assignment:
|
||||
member v.getRateAss(num) =
|
||||
let (_, _, rateVars) = List.item num v.varAss
|
||||
stringOfAss rateVars
|
||||
|
||||
member v.getVarAssString() =
|
||||
Lib.brack (Lib.string_of_list (fun (xs,ys,zs) -> Lib.paren (stringOfAss xs + ", " + stringOfAss ys + "; " + stringOfAss zs )) ",\r " v.varAss)
|
||||
|
||||
// define an empty solution:
|
||||
let emptySolution = { bbDevices = [];
|
||||
lbsProgram = LBSNil
|
||||
rateDecs = [];
|
||||
varAss = [];
|
||||
substs = [];
|
||||
error = None;
|
||||
numSolutions = 0; }
|
||||
|
||||
(*
|
||||
#if JavaScript
|
||||
let Lexing_from_string = Microsoft.FSharp.Text.Lexing.LexBuffer<_>.FromString
|
||||
#else
|
||||
let Lexing_from_string = Lexing.from_string
|
||||
#endif
|
||||
|
||||
(* Parse the LSB program from the given string. *)
|
||||
let parse (text:string) =
|
||||
let prog =
|
||||
// Create the lexer, presenting the bytes to the lexer as ASCII regardless of the original
|
||||
// encoding of the string (the lexer specification is designed to consume ASCII)
|
||||
let lexbuf = Lexing_from_string text
|
||||
|
||||
// Call the parser
|
||||
try
|
||||
let prog = GEC.Pars.start Lex.token lexbuf
|
||||
prog
|
||||
|
||||
with e ->
|
||||
let bufPos1 = lexbuf.StartPos
|
||||
let bufPos2 = lexbuf.EndPos
|
||||
let pos = (bufPos1, bufPos2)
|
||||
let err = "Parse error near line " + bufPos1.Line.ToString() + ", character " + bufPos2.Column.ToString() + "\n\n"
|
||||
raise (LBS.Error.CompilerExPos(err, Some pos))
|
||||
prog
|
||||
*)
|
||||
|
||||
|
||||
let parse (text:string) = Parser.from_string Program.parse text
|
|
@ -0,0 +1,15 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.Options
|
||||
|
||||
type t = { gecProgram:string
|
||||
; simulationOnlyReactions:bool }
|
||||
|
||||
let default_options = { gecProgram=""
|
||||
; simulationOnlyReactions=false }
|
||||
|
||||
let keep_ui_options (opts:t) = opts
|
||||
|
||||
let getGECProgramText (opts:t) = opts.gecProgram
|
||||
let setGECProgramText (s:string) (opts:t) = {opts with gecProgram=s}
|
||||
let getSimulationOnlyReactions (opts:t) = opts.simulationOnlyReactions
|
||||
let setSimulationOnlyReactions (b:bool) (opts:t) = {opts with simulationOnlyReactions=b}
|
|
@ -0,0 +1,11 @@
|
|||
module Microsoft.Research.GEC.Options
|
||||
|
||||
type t
|
||||
val default_options : t
|
||||
|
||||
val keep_ui_options : t -> t
|
||||
|
||||
val getGECProgramText : t -> string
|
||||
val setGECProgramText : string -> t -> t
|
||||
val getSimulationOnlyReactions : t -> bool
|
||||
val setSimulationOnlyReactions : bool -> t -> t
|
|
@ -0,0 +1,3 @@
|
|||
group NETSTANDARD
|
||||
|
||||
FSharp.Core
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,145 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.Settings
|
||||
open Microsoft.Research.CRNEngine
|
||||
open Microsoft.Research.GEC.Ast
|
||||
open Parser
|
||||
//open FsCheck
|
||||
|
||||
type crnModuleDefinition = (string * string list)
|
||||
type crnInstructions = ((crnModuleDefinition * Instruction list) list) * Instruction list
|
||||
|
||||
|
||||
let pSpecies = GecSpecies.parse_crn_species
|
||||
|
||||
type Directive =
|
||||
| Crn of crnInstructions
|
||||
| Override of crnInstructions
|
||||
| RmrnaDeg of float
|
||||
| Rules of LogicGEC.Semantics
|
||||
static member parse_defaults (settings:Crn_settings<'e>) =
|
||||
//let parse_species = pSpecies - Clashes with key words...
|
||||
let parse_species = (GecSpecies.parse_kw Microsoft.Research.CRNEngine.Keywords.kwList) |>> fun x -> x.to_string() |> Species.create
|
||||
let CRN = Parser.kw "crn"
|
||||
let OVERRIDE = Parser.kw "override"
|
||||
let RMRNADEG = Parser.kw "RMRNADeg"
|
||||
let RULES = Parser.kw "rules"
|
||||
let parse_crn = CRN
|
||||
Parser.choice[
|
||||
CRN >>. Parser.braces (Instruction.parse parse_species settings) |>> fun x -> Crn x
|
||||
OVERRIDE >>. Parser.braces (Instruction.parse parse_species settings) |>> fun x -> Override x
|
||||
RMRNADEG >>. Parser.pfloat .>> Parser.spaces |>> fun x -> RmrnaDeg x
|
||||
RULES >>. Parser.braces (LogicGEC.pGecProgram) |>> Rules
|
||||
]
|
||||
static member parse =
|
||||
Directive.parse_defaults Crn_settings.defaults
|
||||
|
||||
type Gec_settings = {directives:Directive<Functional> list; crn:crnInstructions; overrideCrn:bool; rmrnadeg:float; rules:LogicGEC.Semantics option}
|
||||
with
|
||||
static member default_settings = {directives=[]; crn=([],[]); overrideCrn=false;rmrnadeg=0.001;rules=None}
|
||||
member default_settings.from_directive (gecDirective:Directive)=
|
||||
match gecDirective with
|
||||
| Crn (x) -> {default_settings with crn = x; overrideCrn = false}
|
||||
| Override(x) -> {default_settings with crn = x; overrideCrn = true}
|
||||
| RmrnaDeg(x) -> {default_settings with rmrnadeg = x}
|
||||
| Rules x -> {default_settings with rules = Some x}
|
||||
member default_settings.from_directive_list (ds:Directive list) =
|
||||
ds |> List.fold (fun (acc:Gec_settings) s -> (acc.from_directive s)) default_settings
|
||||
|
||||
|
||||
let parse_species:Parser.t<Functional> = Expression.parse (Key.parse pSpecies)
|
||||
///Special case: a single name x is interpreted as a species instead of a parameter
|
||||
///e.g. "plots = [x]"
|
||||
let parse__species_plot:Parser.t<Functional> =
|
||||
let species_from_string = Parser.from_string pSpecies
|
||||
Expression.parse (Key.parse pSpecies)
|
||||
|>> fun exp ->
|
||||
match exp with
|
||||
| Expression.Key (Key.Parameter s) -> Expression.Key (Key.Species (species_from_string s))
|
||||
| _ -> exp
|
||||
|
||||
type directiveType =
|
||||
| CRNDir of Microsoft.Research.CRNEngine.Directive<Functional>
|
||||
| GECDir of Directive
|
||||
|
||||
let parseCrnDir = Directive<Functional>.parse parse_species parse__species_plot |>> CRNDir
|
||||
|
||||
let parseGecDir_defaults (settings:Crn_settings<Functional>) = Directive.parse_defaults settings |>> GECDir
|
||||
let parseGecDir = parseGecDir_defaults Crn_settings.defaults
|
||||
|
||||
let parse_defaults (default_crn_settings:Crn_settings<Functional>) =
|
||||
Parser.many (Parser.kw "directive" >>. ( (parseGecDir_defaults default_crn_settings) <|> parseCrnDir))
|
||||
|>> fun(dirlist) ->
|
||||
let crnlist = dirlist |> List.choose(fun elem ->
|
||||
match elem with
|
||||
| CRNDir(x) -> Some(x)
|
||||
| _ -> None)
|
||||
let geclist = dirlist |> List.choose(fun elem ->
|
||||
match elem with
|
||||
| GECDir(x) -> Some(x)
|
||||
| _ -> None)
|
||||
//let crnSettings = default_crn_settings.from_default_directive_list crnlist
|
||||
let settings = { Gec_settings.default_settings with directives = crnlist}
|
||||
settings.from_directive_list geclist
|
||||
|
||||
|
||||
let parse = parse_defaults Crn_settings.defaults
|
||||
|
||||
|
||||
let convertExprToAst (exp:Functional) =
|
||||
|
||||
|
||||
let gecExp = Parser.from_string (GecSpecies.parse)
|
||||
let f s = gecExp (Species.to_string s) |> fun x -> x.to_ast_gecSpecies()
|
||||
Expression.map (Key.map f) exp
|
||||
(*match exp with
|
||||
| Expression (Key.Species s) ->
|
||||
let gecExp = Parser.from_string (GecSpecies.parse)
|
||||
let gecSpecies = gecExp (Species.to_string s) |> fun x -> x.to_ast_gecSpecies()
|
||||
Expression.Key(gecSpecies)
|
||||
|
||||
| _ -> failwith "Unexpected expression encountered in directive functional"*)
|
||||
|
||||
|
||||
|
||||
let convertCRNdirToGECdir (directive:Directive<Functional>) =
|
||||
match directive with
|
||||
| Simulation x ->
|
||||
let plotSpecies = x.plots |> List.map convertExprToAst
|
||||
let plots = Ast.PLOT(plotSpecies)
|
||||
let kinetics =
|
||||
match x.kinetics with
|
||||
| Kinetics.Contextual -> Ast.KINETICS(Ast.Contextual_kinetics)
|
||||
| Kinetics.Stochastic -> Ast.KINETICS(Ast.Stochastic_kinetics)
|
||||
| Kinetics.Deterministic -> Ast.KINETICS(Ast.Deterministic_kinetics)
|
||||
[Ast.SAMPLE(x.final,Ast.IntPoints(x.points));kinetics;plots]
|
||||
| Units x -> [Ast.TIME(x.time);Ast.CONCENTRATION(x.concentration)]
|
||||
| Microsoft.Research.CRNEngine.Directive.Deterministic x -> [Ast.ABSTOLERANCE(x.abstolerance);Ast.RELTOLERANCE(x.reltolerance)]
|
||||
| Microsoft.Research.CRNEngine.Directive.Stochastic x -> [Ast.SCALE(x.scale)]
|
||||
| _ -> []
|
||||
(*| Samples(startVal,endVal,inc) ->
|
||||
if(inc.IsSome) then
|
||||
if(inc.Value = 0) then
|
||||
Ast.SAMPLE(endVal.Value,Ast.AllPoints)
|
||||
else
|
||||
Ast.SAMPLE(endVal.Value,Ast.IntPoints(inc.Value))
|
||||
else
|
||||
Ast.SAMPLE(endVal.Value,Ast.Default)
|
||||
| OldTime(sec) -> Ast.TIME(sec)
|
||||
| Concentration(conc) -> Ast.CONCENTRATION(conc)
|
||||
| Tolerance(value) -> Ast.ABSTOLERANCE(value)
|
||||
| RelTolerance(value) -> Ast.RELTOLERANCE(value)
|
||||
| Scale(value) -> Ast.SCALE(value)
|
||||
| Kinectics(mode) ->
|
||||
match mode with
|
||||
| KContextual -> Ast.KINETICS(Ast.Contextual_kinetics)
|
||||
| KStochastic -> Ast.KINETICS(Ast.Stochastic_kinetics)
|
||||
| KDeterministic -> Ast.KINETICS(Ast.Deterministic_kinetics)
|
||||
| Plot(expList) ->
|
||||
let gecExpList = expList |> List.map convertExprToAst
|
||||
Ast.PLOT(gecExpList)
|
||||
| _ -> failwith "Unknown Directive encountered"*)
|
||||
|
||||
|
||||
let convert_crn_to_gec_directives (directives :Directive<Functional> list) =
|
||||
let list = directives |> List.map convertCRNdirToGECdir
|
||||
list |> List.fold (fun acc x -> acc@x) []
|
|
@ -0,0 +1,288 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.Solver
|
||||
|
||||
open Microsoft.Research.GEC
|
||||
//open Microsoft.Research.ModellingEngine
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* Some helper functions. *)
|
||||
|
||||
(* NB: copied from trans.fs... NB: altered to handle complexes! *)
|
||||
//let getComplexNamesFromStrings (prop:string * (string list list)) : string list = match prop with
|
||||
// | (pname, x::xs) when pname = "pos" || pname = "neg" || pname = "pcr" || pname = "codes" -> [Ast.complexString x]
|
||||
// | _ -> []
|
||||
|
||||
(* Get the COMPLEXES which exist in a list of part properties. *)
|
||||
let getComplexesFromStrings (prop:string * (string list list)) : string list list =
|
||||
match prop with
|
||||
| (pname, x::xs) when pname = "pos" || pname = "neg" || pname = "pcr" || pname = "codes" -> [x]
|
||||
| _ -> []
|
||||
|
||||
(* Compare a string and a partType to see if they match... *)
|
||||
let typesAgree (t:string) (partTy:Database.partType) =
|
||||
match t,partTy with
|
||||
| "pcr", Database.PCR _ | "prom", Database.PROM _ | "rbs", Database.RBS _ | "ter", Database.TER _ -> true
|
||||
| _,_ -> false
|
||||
|
||||
(* Find all substitutions that can unify two complexes, in any order... *)
|
||||
let unifyComplexes ((*variables*)xs:string list) ((*species*)zs:string list) : Subst.t list =
|
||||
let zs = List.map (fun z -> Subst.SPECIES [z]) zs in
|
||||
if not(List.length xs = List.length zs) then [] else
|
||||
let assocLsts = List.map (fun perm -> List.zip xs perm) (Lib.permutations zs) in
|
||||
Lib.maybemap Subst.multiple assocLsts
|
||||
|
||||
(* Unify two (possibly empty) lists of complexes. *)
|
||||
let unifyComplexLists ((*variables*)xss:string list list) ((*species*)zss:string list list) : Subst.t list =
|
||||
match xss,zss with
|
||||
| [],[] -> [Subst.empty]
|
||||
| _::_,_::_ ->
|
||||
if not(List.length xss = List.length zss) then [] else
|
||||
let rec loop (thetas:Subst.t list) ((*variables*)qss:string list list) ((*species*)wss:string list list) =
|
||||
match qss,wss with
|
||||
| [],[] -> thetas
|
||||
| (qs::qss, ws::wss) ->
|
||||
let thetas' = Lib.collect (fun theta -> let qs' = Subst.applyToComplex theta qs in
|
||||
let ws' = Subst.applyToComplex theta ws in
|
||||
let thetas' = unifyComplexes qs' ws' in
|
||||
let thetas' = Lib.maybemap (Subst.union theta) thetas' in
|
||||
let str =
|
||||
"Trying to unify " + (Ast.complexString qs) + " with " + (Ast.complexString ws) +
|
||||
" when theta = " + (Subst.display theta) + " *** "+
|
||||
" got thetas' = " + (Lib.string_of_list Subst.display " ~~ " thetas')
|
||||
in
|
||||
thetas') thetas
|
||||
in
|
||||
//let newLog = [] in
|
||||
loop thetas' qss wss
|
||||
| _,_ -> failwith "unifyComplexLists: outer lists must be the same length"
|
||||
in
|
||||
Lib.collect (fun zss -> loop [Subst.empty] xss zss) (Lib.permutations zss)
|
||||
| _,_ -> []
|
||||
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* Scan the database for matching parts. *)
|
||||
|
||||
(* Try to find substitutions which make a string-based promoter property match a ground one from the database. *)
|
||||
let tryFindPromoterSubsts (theta_original:Subst.t) (bp:string * (string list list)) (pp:Database.promProperty) : Subst.t list =
|
||||
let bp = Subst.applyToPartTypeStrings theta_original bp in
|
||||
let unifyPP (xs,q1,q2,q3) (zs,r1,r2,r3) =
|
||||
match Subst.multiple [(q1,Subst.NUMBER r1);(q2,Subst.NUMBER r2);(q3,Subst.NUMBER r3)] with
|
||||
| None -> []
|
||||
| Some theta' ->
|
||||
match Subst.union theta_original theta' with
|
||||
| None -> []
|
||||
| Some theta''' -> Lib.maybemap (fun theta'' -> Subst.union theta'' theta''') (unifyComplexes xs zs)
|
||||
in
|
||||
match bp, pp with
|
||||
| ("frate", [[q]]), Database.FRATE(a) ->
|
||||
begin match (Subst.unify q (Subst.ALGEBRAIC_EXPRESSION a)) with
|
||||
| None -> []
|
||||
| Some theta ->
|
||||
begin match Subst.union theta_original theta with
|
||||
| None -> []
|
||||
| Some theta' -> [theta']
|
||||
end
|
||||
end
|
||||
| ("pos", [xs;[q1];[q2];[q3]]), Database.POS(zs,r1,r2,r3) //
|
||||
| ("neg", [xs;[q1];[q2];[q3]]), Database.NEG(zs,r1,r2,r3) -> unifyPP (xs,q1,q2,q3) (zs,r1,r2,r3)
|
||||
| ("con", [[q]]), Database.CON(r) ->
|
||||
begin match (Subst.unify q (Subst.NUMBER r)) with
|
||||
| None -> []
|
||||
| Some theta ->
|
||||
begin match Subst.union theta_original theta with
|
||||
| None -> []
|
||||
| Some theta' -> [theta']
|
||||
end
|
||||
end
|
||||
| _,_ -> []
|
||||
|
||||
(* Try to find substitutions which make a string-based PCR property match a ground one from the database. *)
|
||||
let tryFindPCRSubsts (theta_original:Subst.t) (bp:string * (string list list)) (pp:Database.pcrProperty) : Subst.t list =
|
||||
let bp = Subst.applyToPartTypeStrings theta_original bp in
|
||||
match bp, pp with
|
||||
| ("codes", [xs;[q]]), Database.CODES(zs,r) ->
|
||||
begin match (Subst.unify q (Subst.NUMBER r)) with
|
||||
| None -> []
|
||||
| Some theta ->
|
||||
begin match Subst.union theta_original theta with
|
||||
| None -> []
|
||||
| Some theta' -> Lib.maybemap (fun theta'' -> Subst.union theta'' theta') (unifyComplexes xs zs)
|
||||
end
|
||||
end
|
||||
| _,_ -> []
|
||||
|
||||
(* Try to find substitutions which make a string-based RBS property match a ground one from the database. *)
|
||||
let tryFindRBSSubsts (theta_original:Subst.t) (bp:string * (string list list)) (rp:Database.rbsProperty) : Subst.t list =
|
||||
let bp = Subst.applyToPartTypeStrings theta_original bp in
|
||||
match bp, rp with
|
||||
| ("rate", [[q]]), Database.RATE(r) ->
|
||||
begin match (Subst.unify q (Subst.NUMBER r)) with
|
||||
| None -> []
|
||||
| Some theta ->
|
||||
begin match Subst.union theta_original theta with
|
||||
| None -> []
|
||||
| Some theta' -> [theta']
|
||||
end
|
||||
end
|
||||
| _,_ -> []
|
||||
|
||||
(* Try to find substitutions which make a string-based RBS property match a ground one from the database.
|
||||
NB: this always returns an empty list because terminators don't have properties associated with them
|
||||
(at least the one in the default database doesn't...) *)
|
||||
let tryFindTerSubsts (theta_original:Subst.t) (bp:string * (string list list)) : Subst.t list = []
|
||||
|
||||
(* Compute a set of context-sensitive substitutions for a brick, relative to a database. *)
|
||||
let matchParts (db:Database.t) (brick:string) (t:string) (props:(string * (string list list)) list) : Cssubst.t list * string list =
|
||||
|
||||
(* Recursive function for searching the parts database. *)
|
||||
let find ((res,log):Cssubst.t list * string list) (partId:string) (entry:Database.partType Database.entry) : Cssubst.t list * string list =
|
||||
let partTy = entry.value in
|
||||
if not entry.enabled then (res,log) else
|
||||
// NB: If we limited the input, could we make this simpler???
|
||||
// NB: Should we avoid converting everything to strings in trans.fs???
|
||||
// NB: Should we convert the "database" to use a string-based system so it's more flexible for the future?
|
||||
let init = if not(typesAgree t partTy) then [] else
|
||||
match (Subst.unify brick (Subst.PART partId)) with Some init -> [init] | None -> []
|
||||
in
|
||||
let rec expand ((thetas,log):Subst.t list * string list) (bps:(string * (string list list)) list) : Subst.t list * string list =
|
||||
match bps with
|
||||
| [] -> (thetas,log)
|
||||
| (bp::bps) ->
|
||||
let rec substLoop (new_thetas:Subst.t list) (thetas:Subst.t list) =
|
||||
match thetas with
|
||||
| [] -> new_thetas
|
||||
| (theta::thetas) ->
|
||||
let extra_thetas =
|
||||
begin match partTy with
|
||||
| Database.PROM(props) -> Lib.collect (fun pp -> tryFindPromoterSubsts theta bp pp) props
|
||||
| Database.PCR(prop) -> tryFindPCRSubsts theta bp prop
|
||||
| Database.RBS(prop) -> tryFindRBSSubsts theta bp prop
|
||||
| Database.TER -> tryFindTerSubsts theta bp (* NB: no property to put here as terminators don't have any... *)
|
||||
end
|
||||
in
|
||||
substLoop (new_thetas@extra_thetas) thetas
|
||||
in
|
||||
let new_thetas = substLoop [] thetas in
|
||||
let extra_log = ["Thetas are:\n" + (Lib.string_of_list Subst.display"\n" thetas);
|
||||
"New_thetas are:\n" + (Lib.string_of_list Subst.display"\n" new_thetas)] in
|
||||
let new_log = log@extra_log in
|
||||
expand (new_thetas,new_log) bps
|
||||
in
|
||||
let initString = "Initial subst: " + (match init with [init] -> Subst.display init | _ -> "*NO MATCH*") in
|
||||
let propsString =
|
||||
let inner (zs:string list) = "[" + (Lib.string_of_list Lib.id ";" zs) + "]" in
|
||||
"Properties: " + (Lib.string_of_list (fun (x,zss) -> x + "(" + (Lib.string_of_list inner "," zss) + ")") "; " props)
|
||||
in
|
||||
let thetas,expand_log = expand (init,[]) props in
|
||||
// Eliminate any duplicate results from the list of substitutions
|
||||
let thetas = Lib.remove_duplicates Subst.eq thetas in
|
||||
let mkCSSubst (theta:Subst.t) : (Cssubst.t * string) option =
|
||||
let rho = Subst.speciesDomain theta in
|
||||
let ground_props = List.map (Subst.applyToPartTypeStrings theta) props in
|
||||
let sigma = Lib.collect_union Ast.complexesEqual getComplexesFromStrings ground_props in
|
||||
let tau = Lib.difference Ast.complexesEqual (Database.speciesInPartType partTy) sigma in
|
||||
let cs = Cssubst.make theta rho sigma tau in
|
||||
let log = "Producing a CSSubst: " + Lib.newline +
|
||||
Cssubst.display cs + Lib.newline +
|
||||
"...where FS(Q_i) = " + Lib.string_of_list Ast.complexString ", " (Database.speciesInPartType partTy) + Lib.newline +
|
||||
"...where ground_props = " + Lib.string_of_list (fun (x,ps) -> x+"("+(Lib.string_of_list Ast.complexString ", " ps)+")") ", " ground_props in
|
||||
if Cssubst.isOK cs then Some (cs,log) else None
|
||||
in
|
||||
let new_csSubstsLogs = Lib.maybemap mkCSSubst thetas in
|
||||
let new_csSubsts, new_CsLogs = Lib.unzip new_csSubstsLogs in
|
||||
let new_log = propsString::new_CsLogs in
|
||||
((res@new_csSubsts),(log@new_log))
|
||||
in
|
||||
Stringmap.fold find ([],[]) db.parts
|
||||
|
||||
(* Compute a set of context-sensitive substitutions for a normal reaction, relative to a database. *)
|
||||
let matchNormalReactions (db:Database.t) (catalysts:string list list) (reactants:string list list)
|
||||
(products:string list list) (rate:string) : Cssubst.t list * string list =
|
||||
|
||||
(* Recursive function for searching the reactions database. *)
|
||||
let find ((res,log):Cssubst.t list * string list) (entry:Gecreaction.t Database.entry) : Cssubst.t list * string list =
|
||||
if not entry.enabled then (res,log) else
|
||||
let reac = entry.value in
|
||||
match Gecreaction.isNormal reac with
|
||||
| None -> (res,log)
|
||||
| Some(r_catalysts,r_reactants,r_products,r_rate) ->
|
||||
let log = log@["Trying reaction " + Lib.quote (Gecreaction.display reac)] in
|
||||
// All substitutions that unify the catalysts
|
||||
let thetasE = unifyComplexLists catalysts r_catalysts in
|
||||
let log = log@["thetasE = " + Lib.string_of_list Subst.display " ~~ " thetasE] in
|
||||
// Each substitution in thetasE may be expanded to multiple substitutions that also unify the reactants
|
||||
let thetasER = Lib.collect (fun theta -> let reactants = List.map (Subst.applyToComplex theta) reactants in
|
||||
let thetas' = unifyComplexLists reactants r_reactants in
|
||||
Lib.maybemap (Subst.union theta) thetas') thetasE
|
||||
in
|
||||
let log = log@["thetasER = " + Lib.string_of_list Subst.display " ~~ " thetasER] in
|
||||
// Each substitution in thetasER may be expanded to multiple substitutions that also unify the products
|
||||
let thetasERP = Lib.collect (fun theta -> let products = List.map (Subst.applyToComplex theta) products in
|
||||
let thetas' = unifyComplexLists products r_products in
|
||||
Lib.maybemap (Subst.union theta) thetas') thetasER
|
||||
in
|
||||
let log=log@["thetasERP = " + Lib.string_of_list Subst.display " ~~ " thetasERP] in
|
||||
// Each substution in thetasERP may be extended to also unify the rates
|
||||
let thetasERPr = Lib.maybemap (fun theta -> match Subst.unify rate (Subst.NUMBER r_rate) with
|
||||
| None -> None
|
||||
| Some theta' -> Subst.union theta theta') thetasERP
|
||||
in
|
||||
// Eliminate any duplicate results from the list of substitutions
|
||||
let thetasERPr = Lib.remove_duplicates Subst.eq thetasERPr in
|
||||
let log = log@["thetasERPr = " + Lib.string_of_list Subst.display " ~~ " thetasERPr] in
|
||||
let mkCSSubst (theta:Subst.t) : Cssubst.t option =
|
||||
let ground_reaction = Gecreaction.applySubst theta reac in
|
||||
let rho = Subst.speciesDomain theta in
|
||||
let sigma = Gecreaction.species ground_reaction in
|
||||
let cs = Cssubst.make theta rho sigma [] in
|
||||
if Cssubst.isOK cs then Some cs else None
|
||||
in
|
||||
let new_csSubsts = Lib.maybemap mkCSSubst thetasERPr in
|
||||
((res@new_csSubsts),log)
|
||||
in
|
||||
Lib.fold_left find ([],[]) db.reactions
|
||||
|
||||
(* Compute a set of context-sensitive substitutions for a transport reaction, relative to a database. *)
|
||||
let matchTransportReactions (db:Database.t) (reactant:string list) (product:string list) (rate:string)
|
||||
(compartment:string) (direction:Ast.direction) : Cssubst.t list * string list =
|
||||
|
||||
(* Recursive function for searching the reactions database. *)
|
||||
let find ((res,log):Cssubst.t list * string list) (entry:Gecreaction.t Database.entry) : Cssubst.t list * string list =
|
||||
if not entry.enabled then (res,log) else
|
||||
let reac = entry.value in
|
||||
match Gecreaction.isTransport reac with
|
||||
| None -> (res,log)
|
||||
| Some (r_reactant,r_product,r_rate,r_compartment,r_direction) ->
|
||||
let log = log@["Trying reaction " + Lib.quote (Gecreaction.display reac)] in
|
||||
if not(r_direction = direction) then (res,log@["...Directions don't match!"]) else
|
||||
// All substitutions that unify the reactant
|
||||
let thetasR = unifyComplexes reactant r_reactant in
|
||||
let log = log@["thetasR = " + Lib.string_of_list Subst.display " ~~ " thetasR] in
|
||||
// Each substitution in thetasR may be expanded to multiple substitutions that also unify the product
|
||||
let thetasRP = Lib.collect (fun theta -> let product = Subst.applyToComplex theta product in
|
||||
let thetas' = unifyComplexes product r_product in
|
||||
Lib.maybemap (Subst.union theta) thetas') thetasR
|
||||
in
|
||||
let log = log@["thetasRP = " + Lib.string_of_list Subst.display " ~~ " thetasRP] in
|
||||
// Each substution in thetasRP may be extended to also unify the rates
|
||||
let thetasRPr = Lib.maybemap (fun theta -> match Subst.unify rate (Subst.NUMBER r_rate) with
|
||||
| None -> None
|
||||
| Some theta' -> Subst.union theta theta') thetasRP
|
||||
in
|
||||
// Eliminate any duplicate results from the list of substitutions
|
||||
let thetasRPr = Lib.remove_duplicates Subst.eq thetasRPr in
|
||||
let log = log@["thetasRPr = " + Lib.string_of_list Subst.display" ~~ " thetasRPr] in
|
||||
let mkCSSubst (theta:Subst.t) : Cssubst.t option =
|
||||
let ground_reaction = Gecreaction.applySubst theta reac in
|
||||
let rho = Subst.speciesDomain theta in
|
||||
let sigma = Gecreaction.species ground_reaction in
|
||||
let cs = Cssubst.make theta rho sigma [] in
|
||||
if Cssubst.isOK cs then Some cs else None
|
||||
in
|
||||
let new_csSubsts = Lib.maybemap mkCSSubst thetasRPr in
|
||||
((res@new_csSubsts),log)
|
||||
in
|
||||
Lib.fold_left find ([],[]) db.reactions
|
|
@ -0,0 +1,16 @@
|
|||
module Microsoft.Research.GEC.Solver
|
||||
|
||||
open Microsoft.Research.GEC
|
||||
|
||||
//open Microsoft.Research.ModellingEngine
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
(* Compute a set of context-sensitive substitutions for a brick, relative to a database. *)
|
||||
val matchParts : Database.t -> string -> string -> (string * (string list list)) list -> Cssubst.t list * string list
|
||||
|
||||
(* Compute a set of context-sensitive substitutions for a normal reaction, relative to a database. *)
|
||||
val matchNormalReactions : Database.t -> string list list -> string list list -> string list list -> string -> Cssubst.t list * string list
|
||||
|
||||
(* Compute a set of context-sensitive substitutions for a transport reaction, relative to a database. *)
|
||||
val matchTransportReactions : Database.t -> reactant:string list -> product:string list -> string -> string ->
|
||||
Ast.direction -> Cssubst.t list * string list
|
|
@ -0,0 +1,232 @@
|
|||
[<JavaScript>]
|
||||
module Microsoft.Research.GEC.Subst
|
||||
open Microsoft.Research.GEC
|
||||
|
||||
//open Microsoft.Research.ModellingEngine
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
module Expressions = Microsoft.Research.CRNEngine.Expression
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* A "normal" substitution can either produce a species name, a part id or a real number. *)
|
||||
type target = SPECIES of string list
|
||||
| PART of string
|
||||
| NUMBER of float
|
||||
| ALGEBRAIC_EXPRESSION of Ast.aexp
|
||||
type t = target Stringmap.t
|
||||
|
||||
(* The empty substitution and singleton substitution. *)
|
||||
let empty : t = Stringmap.empty
|
||||
let singleton (x:string) (t:target) : t = empty |> Stringmap.add x t
|
||||
|
||||
(* Produce a string representation of a substitution. *)
|
||||
let displayTarget = function
|
||||
| SPECIES ys -> Ast.complexString ys
|
||||
| PART y -> y
|
||||
| NUMBER n -> Lib.display_float n
|
||||
| ALGEBRAIC_EXPRESSION(_) -> "(algebraic_expression)"
|
||||
let display (theta:t) =
|
||||
let body = Stringmap.fold (fun acc x tgt -> acc + "(" + Lib.quote x + ", " + Lib.quote (displayTarget tgt) + ")" + "; ") "" theta in
|
||||
"[" + body + "]"
|
||||
|
||||
(* Find the result of looking up a variable (NB raises an exception if not found...) *)
|
||||
let find (x:string) (theta:t) = Stringmap.find x theta
|
||||
|
||||
(* Try to find the result of lookup up a variable (returns an option type). *)
|
||||
let tryFind (x:string) (theta:t) = Stringmap.tryFind x theta
|
||||
|
||||
(* An equality function on substitution targets, which accounts for complexes. *)
|
||||
let targetEq (tgt1:target) (tgt2:target) : bool =
|
||||
match tgt1, tgt2 with
|
||||
| SPECIES xs1, SPECIES xs2 -> Ast.complexesEqual xs1 xs2
|
||||
| PART p1, PART p2 -> p1=p2
|
||||
| NUMBER f1, NUMBER f2 -> f1=f2
|
||||
| _,_ -> false
|
||||
|
||||
(* An equality function on substitutions themselves. *)
|
||||
let eq (theta1:t) (theta2:t) =
|
||||
let dom1 = Stringmap.getKeys theta1 in
|
||||
let dom2 = Stringmap.getKeys theta2 in
|
||||
if (dom1=dom2) then
|
||||
Lib.forall (fun x -> targetEq (find x theta1) (find x theta2)) dom1
|
||||
else false
|
||||
|
||||
(* Compute the union of two substitutions, if possible. *)
|
||||
let union (theta1:t) (theta2:t) : t option =
|
||||
Stringmap.fold (fun acc x t ->
|
||||
match acc with
|
||||
| None -> None
|
||||
| Some smap ->
|
||||
match Stringmap.tryFind x smap with
|
||||
| None -> Some(Stringmap.add x t smap)
|
||||
| Some t' -> if t=t' then Some smap else None)
|
||||
(Some theta1) theta2
|
||||
|
||||
(* Compute Dom_S(theta). *)
|
||||
let speciesDomain (theta:t) =
|
||||
let f snames x tgt : string list =
|
||||
match tgt with
|
||||
| SPECIES _ -> Lib.maybeappend (=) snames x
|
||||
| _ -> snames
|
||||
in
|
||||
Stringmap.fold f [] theta
|
||||
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* Does a string correspond to a meta-variable? (i.e. does it begin with a capital? *)
|
||||
let isMetaVariable (x:string) : bool =
|
||||
System.Char.IsUpper (x.[0])
|
||||
|
||||
(* Does a string correspond to a floating-point value? *)
|
||||
let getFloat (x:string) : float option =
|
||||
let ret = ref 0.0
|
||||
if System.Double.TryParse(x, ret) then Some !ret else None
|
||||
|
||||
(* Implement a rudimentary "occurs check". Assumes that x is a metavariable. *)
|
||||
let occursCheckPassed (x:string) (tgt:target) : bool =
|
||||
match tgt with
|
||||
| PART z -> not(x=z)
|
||||
| SPECIES zs -> not(Lib.contains x zs)
|
||||
| _ -> true
|
||||
|
||||
(* "Unify" a string from the program with a "substTarget" from the database. *)
|
||||
let unify (x:string) (tgt:target) : t option =
|
||||
if isMetaVariable x then
|
||||
(if occursCheckPassed x tgt then Some(singleton x tgt) else None)
|
||||
else
|
||||
match tgt with
|
||||
| PART z -> if x=z then Some empty else None
|
||||
| SPECIES zs -> (if zs=[x] then Some empty else None)
|
||||
| NUMBER f -> (match getFloat x with None -> None | Some f' -> if f=f' then Some empty else None)
|
||||
| ALGEBRAIC_EXPRESSION a -> None // check this
|
||||
|
||||
(* Turn an association list into a substitution, if possible... *)
|
||||
let multiple (prs:(string * target) list) : t option =
|
||||
let rec loop (theta:t) (prs:(string * target) list) =
|
||||
match prs with
|
||||
| [] -> Some theta
|
||||
| ((x,t)::prs) ->
|
||||
begin match unify x t with
|
||||
| None -> None
|
||||
| Some theta' ->
|
||||
begin match union theta theta' with
|
||||
| None -> None
|
||||
| Some theta -> loop theta prs
|
||||
end
|
||||
end
|
||||
in
|
||||
loop empty prs
|
||||
|
||||
(* Apply a substitution to a complex, represented as strings. *)
|
||||
let applyToComplex (theta:t) (xs:string list) : string list =
|
||||
Lib.collect (fun x -> match tryFind x theta with Some(SPECIES zs) -> zs | _ -> [x]) xs
|
||||
|
||||
(* Apply a substitution to a "part type" presented as in trans.fs, using strings... *)
|
||||
let applyToPartTypeStrings (theta:t) (pt:string * (string list list)) : string * (string list list) =
|
||||
let (brickType, brickProps) = pt in
|
||||
let applySubst x = match tryFind x theta with None -> x | Some tgt -> displayTarget tgt in
|
||||
(brickType, List.map (List.map applySubst) brickProps)
|
||||
|
||||
(* Apply a substitution to a "gecSpecies" (for generic plotting). *)
|
||||
let applyToGecSpecies (theta:t) (i:Ast.gecSimpleSpecies) : Ast.gecSimpleSpecies =
|
||||
(* Apply a substitution to a value. *)
|
||||
let applyToValue (theta:t) (v:Ast.value) : Ast.value list =
|
||||
match v with
|
||||
| Ast.IdVal x -> begin match tryFind x theta with
|
||||
| Some (SPECIES(xs)) -> List.map (fun x -> Ast.IdVal(x)) xs
|
||||
| _ -> [v]
|
||||
end
|
||||
| _ -> [v]
|
||||
in
|
||||
(* Apply a substitution to a "simple" GEC species. *)
|
||||
let applyToSimpleGecSpecies (theta:t) (i:Ast.gecSimpleSpecies) : Ast.gecSimpleSpecies =
|
||||
match i with
|
||||
| Ast.SimpleSpecies ac -> Ast.SimpleSpecies(Lib.collect (applyToValue theta) ac)
|
||||
| Ast.CompartmentSpecies(c,ac) -> Ast.CompartmentSpecies(c, Lib.collect (applyToValue theta) ac)
|
||||
in
|
||||
(applyToSimpleGecSpecies theta) i
|
||||
|
||||
(* Apply a substitution to a directive data structure (for generic plotting). *)
|
||||
let applyToDirective (theta:t) (d:Ast.directive) : Ast.directive =
|
||||
(* Apply a substitution to a "plottable". *)
|
||||
let applyToPlottable (theta:t) (p:Ast.gecSimpleSpecies Key Expression.t) = Expressions.map (Key.map (applyToGecSpecies theta)) p in
|
||||
(*
|
||||
let rec applyToPlottable (theta:t) (p:Ast.gecSpecies Plottable.t) : Ast.gecSpecies Plottable.t = match p with
|
||||
| Expressions.PopulationAExp g -> Expressions.PopulationAExp (applyToGecSpecies theta g)
|
||||
//| Plottable.PLOT_STRING s -> Plottable.PLOT_STRING s
|
||||
| Expressions.SumAExp ps -> Expressions.SumAExp (List.map (applyToPlottable theta) ps)
|
||||
in *)
|
||||
match d with
|
||||
| Ast.PLOT ps -> Ast.PLOT (List.map (applyToPlottable theta) ps)
|
||||
| _ -> d
|
||||
|
||||
(* Apply a substitution to an arithmetic expression. *)
|
||||
let rec applyToArithmeticExpression (theta:t) (a:Ast.aexp) : Ast.aexp =
|
||||
match a with
|
||||
| Ast.FloatAExp f -> Ast.FloatAExp f
|
||||
| Ast.IdAExp x -> begin
|
||||
match tryFind x theta with
|
||||
| None -> Ast.IdAExp x
|
||||
| Some (NUMBER f) -> Ast.FloatAExp f
|
||||
| Some t -> failwith ("applyToArithmeticExpression: illegal substitution because " + x + " maps to " + (displayTarget t))
|
||||
end
|
||||
| Ast.PlusAExp (a1,a2) -> Ast.PlusAExp((applyToArithmeticExpression theta a1),(applyToArithmeticExpression theta a2))
|
||||
| Ast.MinusAExp (a1,a2) -> Ast.MinusAExp((applyToArithmeticExpression theta a1),(applyToArithmeticExpression theta a2))
|
||||
| Ast.MulAExp (a1,a2) -> Ast.MulAExp((applyToArithmeticExpression theta a1),(applyToArithmeticExpression theta a2))
|
||||
| Ast.DivAExp (a1,a2) -> Ast.DivAExp((applyToArithmeticExpression theta a1),(applyToArithmeticExpression theta a2))
|
||||
| Ast.PowAExp (a1,a2) -> Ast.PowAExp((applyToArithmeticExpression theta a1),(applyToArithmeticExpression theta a2))
|
||||
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* Does a ground constraint hold between floating point values? *)
|
||||
let groundConstraintHolds ((f1,op,f2):float*Ast.op*float) : bool =
|
||||
match op with
|
||||
| Ast.Lt -> f1<f2
|
||||
| Ast.Gt -> f1>f2
|
||||
| Ast.Eq -> f1=f2
|
||||
|
||||
(* Try to evaluate an algebraic expression to a float, using a given substitution. *)
|
||||
let rec tryProduceFloat (theta:t) (a:Ast.aexp) : float option =
|
||||
match a with
|
||||
| Ast.FloatAExp f -> Some f
|
||||
| Ast.IdAExp id -> if isMetaVariable id then begin match tryFind id theta with Some(NUMBER f) -> Some f | _ -> None end
|
||||
else failwith ("Subst.satisfiesConstraint: " + id + " is not a metavariable.")
|
||||
| Ast.PlusAExp (a1,a2) -> (match (tryProduceFloat theta a1, tryProduceFloat theta a2) with
|
||||
| Some f1, Some f2 -> Some(f1 + f2)
|
||||
| _,_ -> None)
|
||||
| Ast.MinusAExp (a1,a2) -> (match (tryProduceFloat theta a1, tryProduceFloat theta a2) with
|
||||
| Some f1, Some f2 -> Some(f1 - f2)
|
||||
| _,_ -> None)
|
||||
| Ast.MulAExp (a1,a2) -> (match (tryProduceFloat theta a1, tryProduceFloat theta a2) with
|
||||
| Some f1, Some f2 -> Some(f1 * f2)
|
||||
| _,_ -> None)
|
||||
| Ast.DivAExp (a1,a2) -> (match (tryProduceFloat theta a1, tryProduceFloat theta a2) with
|
||||
| Some f1, Some f2 -> Some(f1 / f2)
|
||||
| _,_ -> None)
|
||||
| Ast.PowAExp (a1,a2) -> (match (tryProduceFloat theta a1, tryProduceFloat theta a2) with
|
||||
| Some f1, Some f2 -> Some(f1 * f2)
|
||||
| _,_ -> None)
|
||||
|
||||
(* Check whether a substitution satisfies an arithmetic constraint. *)
|
||||
let satisfiesConstraint (theta:t) ((a1,op,a2):Ast.aexp*Ast.op*Ast.aexp) : bool =
|
||||
(* Turn a string into a float, using a given substitution, if possible... *)
|
||||
match (tryProduceFloat theta a1),(tryProduceFloat theta a2) with
|
||||
| Some f1, Some f2 -> groundConstraintHolds (f1,op,f2)
|
||||
| _,_ -> true (* Constraints involving uninstantiated variables can always be satisfied. *)
|
||||
|
||||
(* Produce a "varAss" (variable assignments) from a substitution. *)
|
||||
let mkVarAss (theta:t) : (string * string) list * (string * string) list * (string * string) list =
|
||||
Stringmap.fold
|
||||
(fun (parts,species,rates) x tgt ->
|
||||
match tgt with
|
||||
| SPECIES ys ->
|
||||
(parts,(species@[x,(Ast.complexString ys)]),rates)
|
||||
| PART y ->
|
||||
((parts@[x,y]),species,rates)
|
||||
| NUMBER n ->
|
||||
(parts,species,(rates@[x,(Lib.display_float n)]))
|
||||
| ALGEBRAIC_EXPRESSION a ->
|
||||
(parts,species,(rates@[x,(Ast.lbsStringOfAExp a)]))
|
||||
)
|
||||
([],[],[])
|
||||
theta
|
|
@ -0,0 +1,71 @@
|
|||
module Microsoft.Research.GEC.Subst
|
||||
|
||||
open Microsoft.Research.GEC
|
||||
|
||||
//open Microsoft.Research.ModellingEngine
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* The target of a "normal" substitution can either produce a species name, a part id or a real number. *)
|
||||
type target = SPECIES of string list
|
||||
| PART of string
|
||||
| NUMBER of float
|
||||
| ALGEBRAIC_EXPRESSION of Ast.aexp
|
||||
type t = target Stringmap.t
|
||||
|
||||
(* The empty substitution. *)
|
||||
val empty : t
|
||||
|
||||
(* An equality function on substitution targets, which accounts for complexes. *)
|
||||
val targetEq : target -> target -> bool
|
||||
|
||||
(* An equality function on substitutions themselves. *)
|
||||
val eq : t -> t -> bool
|
||||
|
||||
(* Produce a string representation of a substitution. *)
|
||||
val displayTarget : target -> string
|
||||
val display : t -> string
|
||||
|
||||
(* Compute the union of two substitutions, if possible. *)
|
||||
val union : t -> t -> t option
|
||||
|
||||
(* Compute Dom_S(theta). *)
|
||||
val speciesDomain : t -> string list
|
||||
|
||||
(* Find the result of looking up a variable (NB raises an exception if not found...) *)
|
||||
val find : string -> t -> target
|
||||
|
||||
(* Try to find the result of lookup up a variable (returns an option type). *)
|
||||
val tryFind : string -> t -> target option
|
||||
|
||||
(* Does a string correspond to a floating-point value? *)
|
||||
val getFloat : string -> float option
|
||||
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* "Unify" a string from the program with a "target" from the database. *)
|
||||
val unify : string -> target -> t option
|
||||
|
||||
(* Turn an association list into a substitution, if possible... *)
|
||||
val multiple : (string * target) list -> t option
|
||||
|
||||
(* Apply a substitution to a complex. *)
|
||||
val applyToComplex : t -> string list -> string list
|
||||
|
||||
(* Apply a substitution to a "part type" presented as in trans.fs, using strings... *)
|
||||
val applyToPartTypeStrings : t -> string * (string list list) -> string * (string list list)
|
||||
|
||||
(* Apply a substitution to a directive data structure (for generic plotting). *)
|
||||
val applyToDirective : t -> Ast.directive -> Ast.directive
|
||||
|
||||
(* Apply a substitution to an arithmetic expression. *)
|
||||
val applyToArithmeticExpression : t -> Ast.aexp -> Ast.aexp
|
||||
|
||||
(* ************************************************************************************************************ *)
|
||||
|
||||
(* Check whether a substitution satisfies an arithmetic constraint. *)
|
||||
val satisfiesConstraint : t -> (Ast.aexp * Ast.op * Ast.aexp) -> bool
|
||||
|
||||
(* Produce a "varAss" (variable assignments) from a substitution. *)
|
||||
val mkVarAss : t -> (string * string) list * (string * string) list * (string * string) list
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,28 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
<GenerateProgramFile>false</GenerateProgramFile>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="gecspecies.test.fs" />
|
||||
<Compile Include="gecreaction.test.fs" />
|
||||
<Compile Include="database.test.fs" />
|
||||
<Compile Include="hypothesis.test.fs" />
|
||||
<Compile Include="programParser.test.fs" />
|
||||
<Compile Include="main.test.fs" />
|
||||
<Compile Include="transCrn.test.fs" />
|
||||
<Compile Include="Program.fs" />
|
||||
<None Include="paket.references" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\ClassicGECDotNet\ClassicGECDotNet.fsproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Oslo.FSharp">
|
||||
<HintPath>..\..\Lib\Oslo.FSharp\Oslo.FSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\.paket\Paket.Restore.targets" />
|
||||
</Project>
|
|
@ -0,0 +1 @@
|
|||
module Program = let [<EntryPoint>] main _ = 0
|
|
@ -0,0 +1,165 @@
|
|||
module Microsoft.Research.GEC.DatabaseTest
|
||||
|
||||
open Microsoft.Research.GEC.Database
|
||||
open FSBOL
|
||||
open FSBOL.SBOLDocument
|
||||
open FSBOL.XmlSerializer
|
||||
open Xunit
|
||||
open FsUnit.Xunit
|
||||
open System.Diagnostics
|
||||
open System.Xml
|
||||
open System.IO
|
||||
open System.Text
|
||||
|
||||
[<Fact(DisplayName="GEC - Database Parser")>]
|
||||
let databaseParserText() =
|
||||
let sampledb0 =
|
||||
"i723017,pcr,codes(xylR;0.001)\n"+
|
||||
"i723024,pcr,codes(phzM;0.001)\n"+
|
||||
"e0040,pcr,codes(gfp;0.01)\n"+
|
||||
"c0099,pcr,codes(cviR;0.01)\n"+
|
||||
"i723025,pcr,codes(phzS;0.001)\n"+
|
||||
"i723028,pcr,codes(pca;0.001)\n"+
|
||||
"c0051,pcr,codes(cI;0.01)\n"+
|
||||
"c0040,pcr,codes(tetR;0.01)\n"+
|
||||
"c0080,pcr,codes(araC;0.01)\n"+
|
||||
"c0012,pcr,codes(lacI;0.01)\n"+
|
||||
"cunknown2,pcr,codes(unknown2;0.001)\n"+
|
||||
"c0061,pcr,codes(luxI;0.01)\n"+
|
||||
"c0062,pcr,codes(luxR;0.01)\n"+
|
||||
"c0079,pcr,codes(lasR;0.01)\n"+
|
||||
"c0078,pcr,codes(lasI;0.01)\n"+
|
||||
"cunknown3,pcr,codes(ccdB;0.005)\n"+
|
||||
"cunknown4,pcr,codes(ccdA;0.1)\n"+
|
||||
"i723020,prom,pos(toluene::xylR;0.001;0.001;1.0);con(0.0001)\n"+
|
||||
"r0051,prom,neg(cI;1.0;0.5;0.00005);con(0.12)\n"+
|
||||
"r0040,prom,neg(tetR;1.0;0.5;0.00005);con(0.09)\n"+
|
||||
"runknown1,prom,neg(unknown1;1.0;0.005;0.001);con(0.04)\n"+
|
||||
"b0034,rbs,rate(0.1)\n"+
|
||||
"b0015,ter\n" +
|
||||
"j06504,pcr,codes(mCherry;0.1)"
|
||||
|
||||
let sampledb1 =
|
||||
"i723017,pcr,codes(xylR;0.001)\n"+
|
||||
"i723024,pcr,codes(phzM;0.001)\n"+
|
||||
"e0040,pcr,codes(gfp;0.01)\n"+
|
||||
"c0099,pcr,codes(cviR;0.01)\n"+
|
||||
"i723025,pcr,codes(phzS;0.001)\n"+
|
||||
"i723028,pcr,codes(pca;0.001)\n"+
|
||||
"c0051,pcr,codes(cI;0.01)\n"+
|
||||
"c0040,pcr,codes(tetR;0.01)\n"+
|
||||
"c0080,pcr,codes(araC;0.01)\n"+
|
||||
"c0012,pcr,codes(lacI;0.01)\n"+
|
||||
"cunknown2,pcr,codes(unknown2;0.001)\n"+
|
||||
"c0061,pcr,codes(luxI;0.01)\n"+
|
||||
"c0062,pcr,codes(luxR;0.01)\n"+
|
||||
"c0079,pcr,codes(lasR;0.01)\n"+
|
||||
"c0078,pcr,codes(lasI;0.01)\n"+
|
||||
"cunknown3,pcr,codes(ccdB;0.005)\n"+
|
||||
"cunknown4,pcr,codes(ccdA;0.1)\n"+
|
||||
"i723020,prom,pos(toluene::xylR;0.001;0.001;1.0);con(0.0001)\n"+
|
||||
"r0051,prom,neg(cI;1.0;0.5;0.00005);con(0.12)\n"+
|
||||
"r0040,prom,neg(tetR;1.0;0.5;0.00005);con(0.09)\n"+
|
||||
"runknown1,prom,neg(unknown1;1.0;0.005;0.001);con(0.04)\n"+
|
||||
"b0034,rbs,rate(0.1)\n"+
|
||||
"b0015,ter\n" +
|
||||
"j06504,pcr,codes(mCherry;0.1)\n"+
|
||||
"PRFP,device,components[P;R;RFP;T]\n" +
|
||||
"PTetRS100LuxR,device,components[PTet;RS100;LuxR;T]"
|
||||
|
||||
|
||||
let from_string (s:string) = Parser.from_string parse s
|
||||
let table0 = from_string sampledb0
|
||||
let table1 = from_string sampledb1
|
||||
let sbol = Database.convertTableToSBOLDocument table0
|
||||
//Debug.WriteLine(sbolXmlString sbol)
|
||||
|
||||
let fwsw = new StreamWriter("gecSBOLdb.xml",false)
|
||||
let fwxwSettings = new XmlWriterSettings()
|
||||
fwxwSettings.Indent <- true
|
||||
fwxwSettings.Encoding <- Encoding.UTF8
|
||||
let fwxw = XmlWriter.Create(fwsw,fwxwSettings)
|
||||
(XmlSerializer.sbolToXml sbol).WriteTo(fwxw)
|
||||
fwxw.Close()
|
||||
|
||||
Assert.Equal(table0.parts.Count,24)
|
||||
Assert.True(table0.parts.ContainsKey("b0015"))
|
||||
Assert.True(table0.parts.ContainsKey("b0034"))
|
||||
Assert.True(table0.parts.ContainsKey("i723020"))
|
||||
Assert.True(table0.parts.ContainsKey("r0040"))
|
||||
Assert.True(table0.parts.ContainsKey("c0012"))
|
||||
|
||||
Assert.Equal(table0.devices.Length,0)
|
||||
Assert.Equal(table1.devices.Length,2)
|
||||
|
||||
Debug.WriteLine("END OF TEST")
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - Database Parser - PCR")>]
|
||||
let ``PCRParserTest``() =
|
||||
let pcrEntry =
|
||||
"i723017,pcr,codes(xylR; 0.001)"
|
||||
|
||||
let from_string (s:string) = Parser.from_string Database.partParser s
|
||||
let dnacomp = from_string pcrEntry
|
||||
let (id,pcr) = match dnacomp with
|
||||
| Part(x,y) -> (x,y)
|
||||
| _ -> failwith "Unexpected Device found"
|
||||
|
||||
Assert.Equal(id,"i723017")
|
||||
match pcr with
|
||||
| Database.PCR(Database.CODES(codes,rate)) ->
|
||||
Assert.Equal(codes.Length,1)
|
||||
Assert.Equal(codes.Head,"xylR")
|
||||
Assert.Equal(rate,0.001)
|
||||
| _ ->
|
||||
Debug.WriteLine("Error")
|
||||
Assert.Equal(true,false)
|
||||
|
||||
Debug.WriteLine("End of Test")
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - Database Parser - Regulation promoter")>]
|
||||
let ``RegulationPromParserTest``() =
|
||||
let negativeRegulation =
|
||||
"r0051,prom,neg(cI;1.0;0.5;0.00005);con(0.12)"
|
||||
|
||||
let from_string (s:string) = Parser.from_string Database.partParser s
|
||||
let dnacomp = from_string negativeRegulation
|
||||
let (id,negProm) =
|
||||
match dnacomp with
|
||||
| Part(x,y) -> (x,y)
|
||||
| _ -> failwith "Unexpected Device found"
|
||||
|
||||
Assert.Equal(id,"r0051")
|
||||
match negProm with
|
||||
| Database.PROM(props) ->
|
||||
Assert.Equal(props.Length,2)
|
||||
match props with
|
||||
first::remaining ->
|
||||
Assert.Equal(props.Head,Database.NEG(["cI"],1.0,0.5,0.00005))
|
||||
Assert.Equal(remaining.Head,Database.CON(0.12))
|
||||
| _ -> failwith ""
|
||||
| _ ->
|
||||
Debug.WriteLine("Unexpected Part type found")
|
||||
Assert.Equal(true,false)
|
||||
|
||||
Debug.WriteLine("End of Test")
|
||||
|
||||
[<Fact(DisplayName="GEC - Database Parser - Terminator")>]
|
||||
let ``TerminatorParserTest``() =
|
||||
let ter = "b0015,ter"
|
||||
|
||||
let from_string (s:string) = Parser.from_string Database.partParser s
|
||||
let dnacomp = from_string ter
|
||||
let (id,ter) =
|
||||
match dnacomp with
|
||||
| Part(x,y) -> (x,y)
|
||||
| _ -> failwith "Unexpected Device found"
|
||||
|
||||
Assert.Equal(id,"b0015")
|
||||
Assert.Equal(ter,Database.TER)
|
||||
|
||||
Debug.WriteLine("End of Test")
|
||||
|
||||
|
|
@ -0,0 +1,130 @@
|
|||
module Microsoft.Research.GEC.GecreactionTest
|
||||
|
||||
open Microsoft.Research.GEC.Gecreaction
|
||||
|
||||
open Xunit
|
||||
open FsUnit.Xunit
|
||||
open System.Diagnostics
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - Reaction Parser - Transport")>]
|
||||
let ``TransportParserTest``() =
|
||||
let transportInReaction = "m3OC6HSL->{1.0}c[m3OC6HSL]"
|
||||
let transportOutReaction = "c[m3OC12HSL] -> {1.01}m3OC12HSL"
|
||||
let from_string (s:string) = Parser.from_string parseReaction s
|
||||
|
||||
let tir = from_string transportInReaction
|
||||
let tirProps = Gecreaction.isTransport tir
|
||||
if tirProps.IsSome then
|
||||
let (reactant,product,rate,compartment,direction) = tirProps.Value
|
||||
Assert.Equal(reactant.Head,"m3OC6HSL")
|
||||
Assert.Equal(reactant.Length,1)
|
||||
Assert.Equal(compartment,"c")
|
||||
Assert.Equal(rate,1.0)
|
||||
Assert.Equal(direction,Ast.direction.In)
|
||||
Assert.Equal(product.Length,1)
|
||||
Assert.Equal(product.Head,"m3OC6HSL")
|
||||
else
|
||||
failwith("None encountered. Error.")
|
||||
let tor = from_string transportOutReaction
|
||||
let torProps = Gecreaction.isTransport tor
|
||||
if torProps.IsSome then
|
||||
let (reactant,product,rate,compartment,direction) = torProps.Value
|
||||
Assert.Equal(reactant.Head,"m3OC12HSL")
|
||||
Assert.Equal(reactant.Length,1)
|
||||
Assert.Equal(compartment,"c")
|
||||
Assert.Equal(rate,1.01)
|
||||
Assert.Equal(direction,Ast.direction.Out)
|
||||
Assert.Equal(product.Length,1)
|
||||
Assert.Equal(product.Head,"m3OC12HSL")
|
||||
else
|
||||
failwith("None encountered. Error.")
|
||||
Assert.True(false)
|
||||
|
||||
Debug.WriteLine("END of Test")
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - Reaction Parser - Normal")>]
|
||||
let ``NormalParserTest``() =
|
||||
let norNoReactants = "luxI ~ -> {1.0}m3OC6HSL"
|
||||
let from_string (s:string) = Parser.from_string parseReaction s
|
||||
let nnr = from_string norNoReactants
|
||||
let nnrProps = Gecreaction.isNormal nnr
|
||||
if nnrProps.IsSome then
|
||||
let (catalysts,reactants,products,rate) = nnrProps.Value
|
||||
Assert.Equal(catalysts.Length,1)
|
||||
Assert.Equal(catalysts.Head.Head,"luxI")
|
||||
Assert.True(reactants.IsEmpty)
|
||||
Assert.Equal(rate,1.0)
|
||||
Assert.Equal(products.Head.Head,"m3OC6HSL")
|
||||
Assert.Equal(products.Length,1)
|
||||
else
|
||||
failwith("None encountered. Error.")
|
||||
Assert.True(true)
|
||||
|
||||
let nor1Nocat = "lasR + m3OC12HSL->{1.0}lasR::m3OC12HSL"
|
||||
let nor1nc = from_string nor1Nocat
|
||||
let nor1ncProps = Gecreaction.isNormal nor1nc
|
||||
if nor1ncProps.IsSome then
|
||||
let (catalysts,reactants,products,rate) = nor1ncProps.Value
|
||||
Assert.True(catalysts.IsEmpty)
|
||||
Assert.Equal(reactants.Length,2)
|
||||
Assert.Equal(reactants.Head.Head,"lasR")
|
||||
Assert.Equal(rate,1.0)
|
||||
Assert.Equal(products.Head.Item(0),"lasR")
|
||||
Assert.Equal(products.Head.Item(1),"m3OC12HSL")
|
||||
Assert.Equal(products.Length,1)
|
||||
else
|
||||
failwith("None encountered. Error.")
|
||||
Assert.True(true)
|
||||
|
||||
let nor2Nocat = "lasR::m3OC12HSL->{1.0}lasR+m3OC12HSL"
|
||||
let nor2nc = from_string nor2Nocat
|
||||
let nor2ncProps = Gecreaction.isNormal nor2nc
|
||||
if nor2ncProps.IsSome then
|
||||
let (catalysts,reactants,products,rate) = nor2ncProps.Value
|
||||
Assert.True(catalysts.IsEmpty)
|
||||
Assert.Equal(reactants.Length,1)
|
||||
Assert.Equal(reactants.Head.Length,2)
|
||||
Assert.Equal(reactants.Head.Item(0),"lasR")
|
||||
Assert.Equal(reactants.Head.Item(1),"m3OC12HSL")
|
||||
Assert.Equal(rate,1.0)
|
||||
Assert.Equal(products.Item(0).Item(0),"lasR")
|
||||
Assert.Equal(products.Item(1).Item(0),"m3OC12HSL")
|
||||
Assert.Equal(products.Length,2)
|
||||
else
|
||||
failwith("None encountered. Error.")
|
||||
Assert.True(true)
|
||||
|
||||
let nor1 = "a::b+b::c+dc+e::f ~ i::j->{0.9}t::v+y::u"
|
||||
let n1 = from_string nor1
|
||||
let n1Props = Gecreaction.isNormal n1
|
||||
if n1Props.IsSome then
|
||||
let (catalysts,reactants,products,rate) = n1Props.Value
|
||||
Assert.Equal(catalysts.Length,4)
|
||||
Assert.Equal(catalysts.Item(0).Item(0),"a")
|
||||
Assert.Equal(catalysts.Item(0).Item(1),"b")
|
||||
Assert.Equal(catalysts.Item(1).Item(0),"b")
|
||||
Assert.Equal(catalysts.Item(1).Item(1),"c")
|
||||
Assert.Equal(catalysts.Item(2).Item(0),"dc")
|
||||
Assert.Equal(catalysts.Item(3).Item(0),"e")
|
||||
Assert.Equal(catalysts.Item(3).Item(1),"f")
|
||||
|
||||
Assert.Equal(reactants.Length,1)
|
||||
Assert.Equal(reactants.Head.Length,2)
|
||||
Assert.Equal(reactants.Head.Item(0),"i")
|
||||
Assert.Equal(reactants.Head.Item(1),"j")
|
||||
Assert.Equal(rate,0.9)
|
||||
Assert.Equal(products.Length,2)
|
||||
Assert.Equal(products.Item(0).Item(0),"t")
|
||||
Assert.Equal(products.Item(0).Item(1),"v")
|
||||
Assert.Equal(products.Item(1).Item(0),"y")
|
||||
Assert.Equal(products.Item(1).Item(1),"u")
|
||||
else
|
||||
failwith("None encountered. Error.")
|
||||
Assert.True(true)
|
||||
|
||||
Debug.WriteLine("END of Test")
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
module Microsoft.Research.GEC.GecSpeciesTest
|
||||
|
||||
open Parser
|
||||
|
||||
open Xunit
|
||||
open System.Diagnostics
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - Species - To String")>]
|
||||
let ``speciesToStringTest``() =
|
||||
let species0 = {GecSpecies.t.empty_Species with species = ["a"]}
|
||||
let species1 = {GecSpecies.t.empty_Species with species = ["a";"b"]}
|
||||
let species2 = {GecSpecies.t.empty_Species with species = ["a";"b";"c";"d"]}
|
||||
Assert.Equal(GecSpecies.t.empty_Species.to_string(),"")
|
||||
Assert.Equal(species0.to_string(),"a")
|
||||
Assert.Equal(species1.to_string(),"a::b")
|
||||
Assert.Equal(species2.to_string(),"a::b::c::d")
|
||||
|
||||
[<Fact(DisplayName="GEC - Species - To CRN String")>]
|
||||
let ``speciesToCrnStringTest``() =
|
||||
let species0 = {GecSpecies.t.empty_Species with species = ["a"]}
|
||||
let species1 = {GecSpecies.t.empty_Species with species = ["a";"b"]}
|
||||
let species2 = {GecSpecies.t.empty_Species with species = ["a";"b";"c";"d"]}
|
||||
Assert.Equal(GecSpecies.t.empty_Species.to_string(),"")
|
||||
Assert.Equal(species0.to_crn_string(),"a")
|
||||
Assert.Equal(species1.to_crn_string(),"a_b")
|
||||
Assert.Equal(species2.to_crn_string(),"a_b_c_d")
|
||||
|
||||
[<Fact(DisplayName="GEC - Species - Parse Tests")>]
|
||||
let speciesParseTest() =
|
||||
let species0 = "Signal"
|
||||
let species1 = "Receiver::Signal"
|
||||
let species2 = "cell[gfp]"
|
||||
let species3 = "a::b::c"
|
||||
let get_species (s:string) = Parser.from_string GecSpecies.parse s
|
||||
let s0 = get_species species0
|
||||
let s1 = get_species species1
|
||||
let s2 = get_species species2
|
||||
let s3 = get_species species3
|
||||
|
||||
//Compartment tests
|
||||
Assert.Equal(s0.compartment,None)
|
||||
Assert.Equal(s1.compartment,None)
|
||||
Assert.Equal(s2.compartment,Some("cell"))
|
||||
Assert.Equal(s3.compartment,None)
|
||||
|
||||
//Length tests
|
||||
Assert.Equal(s0.species.Length,1)
|
||||
Assert.Equal(s1.species.Length,2)
|
||||
Assert.Equal(s2.species.Length,1)
|
||||
Assert.Equal(s3.species.Length,3)
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,390 @@
|
|||
module Microsoft.Research.GEC.HypothesisTest
|
||||
|
||||
open Xunit
|
||||
open FsUnit.Xunit
|
||||
open System.Diagnostics
|
||||
|
||||
open Parser
|
||||
open Microsoft.Research.GEC
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - GEC CRN Parser - Directives")>]
|
||||
let ``directivesParser``()=
|
||||
let directiveString = """directive simulator sundials
|
||||
//directive simulator deterministic
|
||||
//directive deterministic {stiff = true}
|
||||
//directive inference {name=target; burnin=400000; samples=400000; thin=50; noise_model=proportional}
|
||||
directive inference {name=target; burnin=10; samples=10; thin=1; noise_model=proportional}
|
||||
directive sweeps [
|
||||
sweepC6C12 = [
|
||||
(condition,C6,C12) = [
|
||||
(1,25000,0); (2,8333.33333333333,0); (3,2777.77777777778,0); (4,925.925925925926,0); (5,308.641975308642,0); (6,102.880658436214,0); (7,34.2935528120713,0); (8,11.4311842706904,0); (9,3.81039475689681,0); (10,1.27013158563227,0); (11,0.423377195210757,0); (12,0,0);
|
||||
(13,0,25000); (14,0,8333.33333333333); (15,0,2777.77777777778); (16,0,925.925925925926); (17,0,308.641975308642); (18,0,102.880658436214); (19,0,34.2935528120713); (20,0,11.4311842706904); (21,0,3.81039475689681); (22,0,1.27013158563227); (23,0,0.423377195210757); (24,0,0);
|
||||
];
|
||||
];
|
||||
sweepC6C12double = [
|
||||
(condition,C6,C12) = [
|
||||
(1,25000,0); (2,8333.33333333333,0); (3,2777.77777777778,0); (4,925.925925925926,0); (5,308.641975308642,0); (6,102.880658436214,0); (7,34.2935528120713,0); (8,11.4311842706904,0); (9,3.81039475689681,0); (10,1.27013158563227,0); (11,0.423377195210757,0); (12,0,0);
|
||||
(13,0,25000); (14,0,8333.33333333333); (15,0,2777.77777777778); (16,0,925.925925925926); (17,0,308.641975308642); (18,0,102.880658436214); (19,0,34.2935528120713); (20,0,11.4311842706904); (21,0,3.81039475689681); (22,0,1.27013158563227); (23,0,0.423377195210757); (24,0,0);
|
||||
(1,25000,0); (2,8333.33333333333,0); (3,2777.77777777778,0); (4,925.925925925926,0); (5,308.641975308642,0); (6,102.880658436214,0); (7,34.2935528120713,0); (8,11.4311842706904,0); (9,3.81039475689681,0); (10,1.27013158563227,0); (11,0.423377195210757,0); (12,0,0);
|
||||
(13,0,25000); (14,0,8333.33333333333); (15,0,2777.77777777778); (16,0,925.925925925926); (17,0,308.641975308642); (18,0,102.880658436214); (19,0,34.2935528120713); (20,0,11.4311842706904); (21,0,3.81039475689681); (22,0,1.27013158563227); (23,0,0.423377195210757); (24,0,0);
|
||||
];
|
||||
];
|
||||
]
|
||||
|
||||
directive simulation { final=20; points=250 }
|
||||
|
||||
directive rates [
|
||||
boundLuxR = [luxR]^2 * ((KR6*[c6])^nR + (KR12*[c12])^nR) / ((1.0 + KR6*[c6] + KR12*[c12])^nR);
|
||||
boundLasR = [lasR]^2 * ((KS6*[c6])^nS + (KS12*[c12])^nS) / ((1.0 + KS6*[c6] + KS12*[c12])^nS);
|
||||
P76 = (e76 + KGR_76*[boundLuxR] + KGS_76*[boundLasR]) / (1.0 + KGR_76*[boundLuxR] + KGS_76*[boundLasR]);
|
||||
P81 = (e81 + KGR_81*[boundLuxR] + KGS_81*[boundLasR]) / (1.0 + KGR_81*[boundLuxR] + KGS_81*[boundLasR]);
|
||||
PBad = (Ara^nA+eA*KAra^nA)/(Ara^nA+KAra^nA);
|
||||
PTet = 1/(1+[tetR]^nT);
|
||||
PLac = 1/(1+[lacI]^nL);
|
||||
plot_od = [x]+x0;
|
||||
plot_fp = [x]*[fp]+f0;
|
||||
plot_yfp = [x]*([yfp]+[f500])+yb0;
|
||||
plot_cfp = [x]*([cfp]+[f430])+cb0;
|
||||
]
|
||||
|
||||
directive parameters [
|
||||
// Background
|
||||
c0 = 0.001, { distribution=Uniform(1e-4,3e-1) };
|
||||
x0 = 0.1, { interval=Real; distribution=Uniform(0,0.2) };
|
||||
f0=5000.0,{ interval=Real; distribution=Uniform(0.0,10000.0) };
|
||||
yb0=1e3, { interval=Real; distribution=Uniform(0.0,5e3) };
|
||||
cb0=1e3, { interval=Real; distribution=Uniform(0.0,1e4) };
|
||||
|
||||
// Autofluorescence
|
||||
dfp=0.1, { distribution=Uniform(1e-3,1e0) };
|
||||
autoYFP=1e0, { distribution=Uniform(1e-3,1e3) };
|
||||
autoCFP=1e0, { distribution=Uniform(1e-3,1e3) };
|
||||
|
||||
// Standard
|
||||
dCFP=1e-2, { distribution=Uniform(1e-3,1e0) };
|
||||
dYFP=1e-2, { distribution=Uniform(1e-3,1e0) };
|
||||
|
||||
// Receivers
|
||||
KR6=1e-2, { distribution=Uniform(1e-8,1e0) };
|
||||
KS6=1e-4, { distribution=Uniform(1e-8,1e0) };
|
||||
KR12=1e-3, { distribution=Uniform(1e-8,1e0) };
|
||||
KS12=1e-2, { distribution=Uniform(1e-8,1e0) };
|
||||
nR=0.797, { interval=Real; distribution=Uniform(0.5,2.0) };
|
||||
nS=0.797, { interval=Real; distribution=Uniform(0.5,2.0) };
|
||||
aR33=1.0, { distribution=Uniform(1e0,1e2) };
|
||||
aS175=1.0, { distribution=Uniform(1e0,1e2) };
|
||||
aRS100=1.0, { distribution=Uniform(1e0,1e2) };
|
||||
aS32=1.0, { distribution=Uniform(1e0,1e2) };
|
||||
nL=0.797, { interval=Real; distribution=Uniform(0.5,2.0) };
|
||||
nT=0.797, { interval=Real; distribution=Uniform(0.5,2.0) };
|
||||
|
||||
dR=0.1, { distribution=Uniform(1e-2,1e1) };
|
||||
//dS=0.1, { distribution=Uniform(1e-2,1e2) };
|
||||
e76=1e-2, { distribution=Uniform(1e-4,1.0) };
|
||||
KGR_76=1e-2,{ distribution=Uniform(1e-4,1e0) };
|
||||
KGS_76=1e-6,{ distribution=Uniform(1e-8,1e0) };
|
||||
e81=1e-2, { distribution=Uniform(1e-4,1.0) };
|
||||
KGR_81=1e-6,{ distribution=Uniform(1e-8,1e0) };
|
||||
KGS_81=1e-2,{ distribution=Uniform(1e-4,1e0) };
|
||||
aCFP=1e3, { distribution=Uniform(1e0,1e5) };
|
||||
aYFP=1e3, { distribution=Uniform(1e0,1e5) };
|
||||
|
||||
// Relays
|
||||
kC6=1e0, { distribution=Uniform(1e0,1e6) };
|
||||
Klux=1.0, { distribution=Uniform(1e0,1e6) };
|
||||
dluxI=0.1,{ distribution=Uniform(1e-3,1e1) };
|
||||
kC12=1e0, { distribution=Uniform(1e0,1e6) };
|
||||
Klas=1.0, { distribution=Uniform(1e0,1e6) };
|
||||
dlasI=0.1,{ distribution=Uniform(1e-3,1e1) };
|
||||
|
||||
// Arabinose
|
||||
KAra=1.0, { distribution=Uniform(1e-2,1e2) };
|
||||
nA=1.0, { interval=Real; distribution=Uniform(0.5,3.0) };
|
||||
eA=0.1, { interval=Real; distribution=Uniform(0.0,0.5) };
|
||||
|
||||
// Degrader
|
||||
dA6=1e-1, { distribution=Uniform(1e-3,1e1) };
|
||||
dA12=1e-1, { distribution=Uniform(1e-3,1e1) };
|
||||
daiiA=0.1, { distribution=Uniform(1e-3,1e1) };
|
||||
|
||||
C6=0.0; C12=0.0; tau=0.0; aR=1.0; aS=1.0; ATC=0.0; IPTG=0.0;
|
||||
aYFP_PL=1000.0; aCFP_PL=1000.0; Ara=0.0; condition = 0;
|
||||
]"""
|
||||
let directives = Parser.from_string Hypothesis.parse_crnSettings directiveString
|
||||
Debug.Write(directives.to_string Functional2.to_string Functional2.to_string_plot)
|
||||
()
|
||||
|
||||
[<Fact(DisplayName="GEC - GEC CRN Parser - Modules")>]
|
||||
let ``moduleParser``()=
|
||||
let moduleString = """
|
||||
module Control(growth,capacity) = {
|
||||
//| Growth(growth,tlag)
|
||||
| fp ->[[growth]*[fp]] // Dilution
|
||||
| ->[[capacity]] fp // Transcription/translation
|
||||
| fp ->{dfp} // Degradation
|
||||
}
|
||||
module cells(growth,tlag,capacity) = {
|
||||
| init luxR 0 | init lasR 0 | init lacI 0 | init tetR 0
|
||||
| init yfp 0 | init cfp 0 | init f430 0 | init f500 0
|
||||
| init c6 C6 @ tau | init c12 C12 @ tau // Hack to prevent greedy evaluation of rates from hurting us
|
||||
| Growth(growth,tlag)
|
||||
// Autofluorescence
|
||||
| ->[[capacity]*autoYFP] f500
|
||||
| f500 ->[[growth]*[f500]]
|
||||
| ->[[capacity]*autoCFP] f430
|
||||
| f430 ->[[growth]*[f430]]
|
||||
}
|
||||
|
||||
module AiiA(P,aI,growth,capacity) = {
|
||||
| ->[[capacity]*aI*[P]] aiiA
|
||||
| aiiA ->{daiiA}
|
||||
| aiiA ->[[growth]*[aiiA]]
|
||||
//| c6 -> [[x]*dA6*[c6]*[aiiA]/(1+KA6*[c6]+KA12*[c12])]
|
||||
//| c12 -> [[x]*dA12*[c12]*[aiiA]/(1+KA6*[c6]+KA12*[c12])]
|
||||
| c6 -> [[x]*dA6*[c6]*[aiiA]]
|
||||
| c12 -> [[x]*dA12*[c12]*[aiiA]]
|
||||
}
|
||||
"""
|
||||
let modules = Parser.from_string (Hypothesis.parse_crnModules Crn_settings.defaults) moduleString
|
||||
|
||||
Debug.WriteLine(Hypothesis.modules_to_string 0.0 modules)
|
||||
|
||||
()
|
||||
|
||||
[<Fact(DisplayName="GEC - GEC CRN Parser - Directive Device Parser")>]
|
||||
let ``deviceDirectiveParser``()=
|
||||
let device0 = "device [LuxR]"
|
||||
let device1 = "device [LuxR;pTet]"
|
||||
let device2 = "device [cfp; gfp]"
|
||||
let dev0 = Parser.from_string Hypothesis.parse_hypothesisDirective device0
|
||||
let dev1 = Parser.from_string Hypothesis.parse_hypothesisDirective device1
|
||||
let dev2 = Parser.from_string Hypothesis.parse_hypothesisDirective device2
|
||||
|
||||
()
|
||||
|
||||
[<Fact(DisplayName="GEC - GEC CRN Parser - Device Definition Parser")>]
|
||||
let ``deviceDefinitionParser``()=
|
||||
let device0 = "device PRFP(growth,capacity) = { Control(growth,capacity) }"
|
||||
let device1 = "device PLacYFPCFP(growth,capacity) = { YFP(PLac,aYFP,growth,capacity) | CFP(PLac,aCFP,growth,capacity) }"
|
||||
let dev0 = Parser.from_string Hypothesis.parse_device device0
|
||||
let dev1 = Parser.from_string Hypothesis.parse_device device1
|
||||
Debug.WriteLine(Hypothesis.deviceDefinition_to_string dev0)
|
||||
Debug.WriteLine(Hypothesis.deviceDefinition_to_string dev1)
|
||||
()
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - GEC CRN Parser - System Parser")>]
|
||||
let ``systemParser``()=
|
||||
let system0 = """system growth = {
|
||||
directive simulation { final=20; points=250 }
|
||||
| Growth(growth,tlag)
|
||||
}"""
|
||||
let sys0 = Parser.from_string Hypothesis.parse_crn_system system0
|
||||
|
||||
let system1 = """system growth = {
|
||||
directive simulation { final=20; points=250 }
|
||||
directive device [pTet];
|
||||
| Growth(growth,tlag)
|
||||
}"""
|
||||
|
||||
let sys1 = Parser.from_string Hypothesis.parse_crn_system system1
|
||||
|
||||
let system2 = """system growth = {
|
||||
control with directive data [R33S175_Y81C76_mRFP1_proc141021]
|
||||
directive device [pTet];
|
||||
}"""
|
||||
let sys2 = Parser.from_string Hypothesis.parse_crn_system system2
|
||||
()
|
||||
|
||||
[<Fact(DisplayName="GEC - GEC CRN Parser - IGraph Element Parser")>]
|
||||
let ``igElementParser``()=
|
||||
let element0 = """edge Receivers_growth.Receiver0_growth ->[r=Fixed;K=Fixed;tlag=Fixed] Receivers_control.Receiver0_control"""
|
||||
let element1 = """edge Relays ->[KR6;KS6;KR12;KS12;nR;nS;aR33;aS175;dR;e76;KGR_76;KGS_76;e81;KGR_81;KGS_81;aCFP;aYFP;] Degrader"""
|
||||
let element2 = """edge Auto_control ->[dfp] Standard_control"""
|
||||
let element3 = """edge Auto_control ->[r=Fixed;dfp] Standard_control"""
|
||||
let element4 = """node Auto { systems = [Auto] }"""
|
||||
let element5 = """node Receivers_growth { systems = [Receiver0_growth; Receiver1_growth; Receiver2_growth; Receiver3_growth] }"""
|
||||
let element6 = """node Auto_Growth { systems = [growth]; inference = {burnin=1000; samples=1000; partial=true} }"""
|
||||
let element7 = """node Auto_Target { systems = [auto]; inference = {burnin=50000; samples=50000} }"""
|
||||
|
||||
let elem0 = Parser.from_string Hypothesis.parse_igraphElement element0
|
||||
let elem1 = Parser.from_string Hypothesis.parse_igraphElement element1
|
||||
let elem2 = Parser.from_string Hypothesis.parse_igraphElement element2
|
||||
let elem3 = Parser.from_string Hypothesis.parse_igraphElement element3
|
||||
let elem4 = Parser.from_string Hypothesis.parse_igraphElement element4
|
||||
let elem5 = Parser.from_string Hypothesis.parse_igraphElement element5
|
||||
let elem6 = Parser.from_string Hypothesis.parse_igraphElement element6
|
||||
let elem7 = Parser.from_string Hypothesis.parse_igraphElement element7
|
||||
|
||||
()
|
||||
|
||||
[<Fact(DisplayName="GEC - Hypothesis Test")>]
|
||||
let ``hypothesisTest``()=
|
||||
let database = """i723017,pcr,codes(xylR;0.001)
|
||||
i723024,pcr,codes(phzM;0.001)
|
||||
e0040,pcr,codes(gfp;0.01)
|
||||
c0099,pcr,codes(cviR;0.01)
|
||||
i723025,pcr,codes(phzS;0.001)
|
||||
i723028,pcr,codes(pca;0.001)
|
||||
c0051,pcr,codes(cI;0.01)
|
||||
c0040,pcr,codes(tetR;0.01)
|
||||
c0080,pcr,codes(araC;0.01)
|
||||
c0012,pcr,codes(lacI;0.01)
|
||||
cunknown2,pcr,codes(unknown2;0.001)
|
||||
c0061,pcr,codes(luxI;0.01)
|
||||
c0062,pcr,codes(luxR;0.01)
|
||||
c0079,pcr,codes(lasR;0.01)
|
||||
c0078,pcr,codes(lasI;0.01)
|
||||
cunknown3,pcr,codes(ccdB;0.005)
|
||||
cunknown4,pcr,codes(ccdA;0.1)
|
||||
i723020,prom,pos(toluene::xylR;0.001;0.001;1.0);con(0.0001)
|
||||
r0051,prom,neg(cI;1.0;0.5;0.00005);con(0.12)
|
||||
r0040,prom,neg(tetR;1.0;0.5;0.00005);con(0.09)
|
||||
runknown1,prom,neg(unknown1;1.0;0.005;0.001);con(0.04)
|
||||
b0034,rbs,rate(0.1)
|
||||
b0015,ter
|
||||
j06504,pcr,codes(mCherry;0.1)
|
||||
PRFP,device,components[P;R;RFP;T]
|
||||
PTetRS100LuxR,device,components[PTet;RS100;LuxR;T]
|
||||
DRR33S175,device,components[PRFP;PTetRS100LuxR]
|
||||
DRRS,device,components[DRR33S175|LuxR]
|
||||
EC10G,device,components[P]
|
||||
PLPL,device,components[P;R;eYFP;T;P;R;eCFP;T]"""
|
||||
|
||||
let hypothesis_content = """directive simulator sundials
|
||||
directive parameters [
|
||||
C6=0.0; C12=0.0; c0 = 0.002; r = 1.0; K = 2.0; rc = 1000.0; tlag=0.0; tau=0.0;
|
||||
// Autofluorescence
|
||||
autoYFP=1e0, { interval=Log; distribution=Uniform(1e-3,1e3); variation=Random };
|
||||
autoCFP=1e0, { interval=Log; distribution=Uniform(1e-3,1e3); variation=Random };
|
||||
// FP
|
||||
dRFP=0.1, { interval=Log; distribution=Uniform(1e-3,1e0); variation=Random };
|
||||
dCFP=1e-2, { interval=Log; distribution=Uniform(1e-3,1e0); variation=Random };
|
||||
dYFP=1e-2, { interval=Log; distribution=Uniform(1e-3,1e0); variation=Random };
|
||||
]
|
||||
directive inference { thin=100; noise_model = proportional }
|
||||
directive simulation {multicore=True}
|
||||
directive rates [
|
||||
growth = [grow]*r*(1 - [x] / K);
|
||||
capacity = rc;
|
||||
]
|
||||
|
||||
module CFP(a) = {
|
||||
->[[capacity]*a] cfp |
|
||||
cfp ->{dCFP} |
|
||||
cfp ->[[growth]*[cfp]]
|
||||
}
|
||||
module YFP(a) = {
|
||||
->[[capacity]*a] yfp |
|
||||
yfp ->{dYFP} |
|
||||
yfp ->[[growth]*[yfp]]
|
||||
}
|
||||
module cells() = {
|
||||
init x c0 |
|
||||
init grow 1 @ tlag |
|
||||
init c6 C6 @ tau |
|
||||
init c12 C12 @ tau |
|
||||
->[[growth]*[x]] x
|
||||
}
|
||||
module autofluorescence() = {
|
||||
->[[capacity]*autoYFP] f530 |
|
||||
f530 ->[[growth]*[f530]] |
|
||||
->[[capacity]*autoCFP] f480 |
|
||||
f480 ->[[growth]*[f480]]
|
||||
}
|
||||
module Control() = {
|
||||
//| Growth(growth,tlag)
|
||||
| fp ->[[growth]*[fp]] // Dilution
|
||||
| ->[[capacity]] fp // Transcription/translation
|
||||
| fp ->{dRFP} // Degradation
|
||||
}
|
||||
|
||||
device PRFP() = { Control() }
|
||||
device PLPL() = { YFP(aYFP) | CFP(aCFP) }
|
||||
|
||||
system growth = {
|
||||
directive simulation { final=36.0; points=250; plots=[[x]+x0] }
|
||||
directive parameters [
|
||||
r = 1, { interval=Real; distribution=Uniform(0.1,10); variation=Multiple };
|
||||
K = 2, { interval=Real; distribution=Uniform(0.1,5); variation=Multiple };
|
||||
tlag = 1, { interval=Real; distribution=Uniform(0,10); variation=Multiple };
|
||||
x0=0.1,{ interval=Real; distribution=Uniform(0.0,0.2); variation=Random };
|
||||
]
|
||||
directive rates [growth = [grow]*r*(1 - [x] / K)]
|
||||
cells()
|
||||
}
|
||||
system control = {
|
||||
directive simulation { final=36.0; points=250; plots=[[x]*[fp]+f0]; plotcolours=["#FF0000"] }
|
||||
directive parameters [
|
||||
r = 1, { interval=Real; distribution=Uniform(0.1,10); variation=Multiple };
|
||||
K = 2, { interval=Real; distribution=Uniform(0.1,5); variation=Multiple };
|
||||
tlag = 1, { interval=Real; distribution=Uniform(0,10); variation=Multiple };
|
||||
rc=1e2, { interval=Log; distribution=Uniform(1e0,1e5); variation=Multiple };
|
||||
f0=100.0,{ interval=Real; distribution=Uniform(0.0,10000.0); variation=Random };
|
||||
]
|
||||
directive rates [growth = [grow]*r*(1 - [x] / K);capacity = rc]
|
||||
directive device [PRFP]
|
||||
cells()
|
||||
}
|
||||
system auto = {
|
||||
directive simulation { final=36.0; points=250; plots=[[x]*[f530]+yb0; [x]*[f480]+cb0]; plotcolours=["#FFDF00"; "#ADD8E6"] }
|
||||
directive parameters [
|
||||
r = 1, { interval=Real; distribution=Uniform(0.1,10); variation=Multiple };
|
||||
K = 2, { interval=Real; distribution=Uniform(0.1,5); variation=Multiple };
|
||||
tlag = 1, { interval=Real; distribution=Uniform(0,10); variation=Multiple };
|
||||
rc=1e2, { interval=Log; distribution=Uniform(1e0,1e5); variation=Multiple };
|
||||
yb0=1e3, { interval=Real; distribution=Uniform(0.0,5e3); variation=Random };
|
||||
cb0=1e3, { interval=Real; distribution=Uniform(0.0,1e4); variation=Random };
|
||||
]
|
||||
directive rates [growth = [grow]*r*(1 - [x] / K);capacity = rc]
|
||||
| cells()
|
||||
| autofluorescence()
|
||||
}
|
||||
system prpr = {
|
||||
directive simulation { final=36.0; points=250; plots=[[x]*([yfp]+[f530])+yb0; [x]*([cfp]+[f480])+cb0]; plotcolours=["#FFDF00"; "#ADD8E6"] }
|
||||
directive parameters [
|
||||
r = 1, { interval=Real; distribution=Uniform(0.1,10); variation=Multiple };
|
||||
K = 2, { interval=Real; distribution=Uniform(0.1,5); variation=Multiple };
|
||||
tlag = 1, { interval=Real; distribution=Uniform(0,10); variation=Multiple };
|
||||
rc=1e2, { interval=Log; distribution=Uniform(1e0,1e5); variation=Multiple };
|
||||
aCFP=1e3, { interval=Log; distribution=Uniform(1e0,1e5); variation=Random };
|
||||
aYFP=1e3, { interval=Log; distribution=Uniform(1e0,1e5); variation=Random };
|
||||
yb0=1e3, { interval=Real; distribution=Uniform(0.0,5e3); variation=Random };
|
||||
cb0=1e3, { interval=Real; distribution=Uniform(0.0,1e4); variation=Random };
|
||||
]
|
||||
directive rates [growth = [grow]*r*(1 - [x] / K);capacity = rc]
|
||||
directive device [PLPL]
|
||||
| cells()
|
||||
| autofluorescence()
|
||||
}
|
||||
|
||||
//node Auto_Growth { systems = [growth] }
|
||||
//node Auto_Control { systems = [control] }
|
||||
|
||||
node Auto_Growth { systems = [growth]; inference = {burnin=1000; samples=1000; partial=true} }
|
||||
node Auto_Control { systems = [control]; inference = {burnin=1000; samples=1000; partial=true} }
|
||||
node Auto_Target { systems = [auto]; inference = {burnin=50000; samples=50000} }
|
||||
|
||||
node PRPR_Growth { systems = [growth]; inference = {burnin=1000; samples=1000; partial=true} }
|
||||
node PRPR_Control { systems = [control]; inference = {burnin=100000; samples=100000; partial=true} }
|
||||
node PRPR_Target { systems = [prpr]; inference = {burnin=100000; samples=100000} }
|
||||
|
||||
edge Auto_Growth.growth ->[r=Fixed;K=Fixed;tlag=Fixed] Auto_Control.control
|
||||
edge Auto_Control.control ->[r=Fixed;K=Fixed;tlag=Fixed;rc=Fixed] Auto_Target.auto
|
||||
|
||||
edge PRPR_Growth.growth ->[r=Fixed;K=Fixed;tlag=Fixed] PRPR_Control.control
|
||||
edge PRPR_Control.control ->[r=Fixed;K=Fixed;tlag=Fixed;rc=Fixed] PRPR_Target.prpr
|
||||
|
||||
edge Auto_Control ->[dRFP=TruncatedNormal] PRPR_Control
|
||||
edge Auto_Target ->[autoYFP=TruncatedNormal;autoCFP=TruncatedNormal] PRPR_Target
|
||||
|
||||
"""
|
||||
let lib = Parser.from_string Database.parse database
|
||||
let hypothesis = Parser.from_string Hypothesis.parse_hypothesis_content hypothesis_content
|
||||
|
||||
Debug.WriteLine(Hypothesis.hypothesis_to_crn_program hypothesis lib.devices)
|
||||
|
||||
()
|
||||
|
|
@ -0,0 +1,105 @@
|
|||
module Microsoft.Research.GEC.MainTest
|
||||
|
||||
open Microsoft.Research.GEC.Program
|
||||
|
||||
open Xunit
|
||||
open FsUnit.Xunit
|
||||
open System.Diagnostics
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - Parser Directives")>]
|
||||
let ``directivesParserTest``() =
|
||||
|
||||
let sampledir = "directive sample 100000.0"
|
||||
let sampledir2 = "directive sample 100000.0 1"
|
||||
let sampledir3 = "directive sample 100000.0 all"
|
||||
let plotPredprey = "directive plot predator[ccdB]; prey[ccdB]"
|
||||
let plotab = "directive plot A; B; C"
|
||||
let plotcellsig = "directive plot cell[gfp]; Signal"
|
||||
let plotrec = "directive plot receiver[gfp]"
|
||||
|
||||
let parseGECDirective (s:string) = Parser.from_string Program.directiveParser s
|
||||
|
||||
let sampledirfs = parseGECDirective sampledir
|
||||
let sampledir2fs = parseGECDirective sampledir2
|
||||
let sampledir3fs = parseGECDirective sampledir3
|
||||
let plotPredpreyfs = parseGECDirective plotPredprey
|
||||
let plotabfs = parseGECDirective plotab
|
||||
let plotcellsigfs = parseGECDirective plotcellsig
|
||||
let plotrecfs = parseGECDirective plotrec
|
||||
|
||||
|
||||
Debug.WriteLine("Test completed")
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - Parser Expression")>]
|
||||
let ``expressionParserTest``() =
|
||||
let exp0 = "a+ c"
|
||||
let exp1 = "a+b"
|
||||
let exp2 = "a+b+c"
|
||||
let exp3 = "a+b+c+d"
|
||||
let exp4 = "a+b-c"
|
||||
|
||||
let parseExpression (s:string) = Parser.from_string Program.expressionParser s
|
||||
|
||||
let exp0p = parseExpression exp0
|
||||
let exp1p = parseExpression exp1
|
||||
let exp2p = parseExpression exp2
|
||||
let exp3p = parseExpression exp3
|
||||
let exp4p = parseExpression exp4
|
||||
|
||||
Debug.WriteLine("Test Completed")
|
||||
|
||||
[<Fact(DisplayName="GEC - Parser Brick")>]
|
||||
let ``brickParserTest``() =
|
||||
let test (s:string) = Parser.from_string Program.parse_brick s
|
||||
let a = test "r0051:prom"
|
||||
let b = test "rbs"
|
||||
let c = test "pcr<codes(Q2b)>"
|
||||
let d = test "r0051:prom<pos(Q2b-H2)>"
|
||||
let e = test "ter"
|
||||
let f = test "prom<con(RT), neg(i, RB, RUB, RTB)>"
|
||||
let g = test "rbs<rate(R)>"
|
||||
let h = test "pcr<codes(o,RD)>"
|
||||
|
||||
Debug.WriteLine("End of Test")
|
||||
|
||||
[<Fact(DisplayName="GEC - Parser New")>]
|
||||
let ``newparsertest``()=
|
||||
let prog = "new RB. new RUB.\n" +
|
||||
"prom<con(RT), neg(i, RB, RUB, RTB)>"
|
||||
|
||||
let test (s:string) = Parser.from_string Program.parse_new_outer s
|
||||
let a = test prog
|
||||
match a with
|
||||
| Ast.New(id1,prog1) ->
|
||||
Assert.Equal(id1,"RB")
|
||||
match prog1 with
|
||||
| Ast.New(id2,prog2) ->
|
||||
Assert.Equal(id2,"RUB")
|
||||
match prog2 with
|
||||
| Ast.Brick(t,v,propLst) ->
|
||||
Debug.WriteLine(v)
|
||||
| _ -> failwith ""
|
||||
| _ -> failwith ""
|
||||
| _ -> failwith ""
|
||||
|
||||
Debug.WriteLine("end of test")
|
||||
|
||||
[<Fact(DisplayName="GEC - Parser Reaction")>]
|
||||
let ``ReactionCodeParserTest``() =
|
||||
|
||||
let rxn = "luxR + Signal -> luxR::Signal"
|
||||
let test (s:string) = Parser.from_string Program.parse_reaction s
|
||||
let res = test rxn
|
||||
Debug.WriteLine("end of test")
|
||||
|
||||
[<Fact(DisplayName="GEC - Parser Module Invocation ")>]
|
||||
let modInvTest() =
|
||||
let miprog = "gate(A,B)"
|
||||
let test (s:string) = Parser.from_string Program.parse_ast_template_inv s
|
||||
let a = test miprog
|
||||
|
||||
Debug.WriteLine("End of test")
|
||||
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
group DOTNETCORE
|
||||
|
||||
FSharp.Core
|
||||
FsUnit.xUnit
|
||||
xunit.core
|
||||
xunit.runner.console
|
||||
xunit.runner.visualstudio
|
|
@ -0,0 +1,747 @@
|
|||
module Microsoft.Research.GEC.ProgramParserTest
|
||||
|
||||
open Microsoft.Research.GEC.Program
|
||||
|
||||
open Xunit
|
||||
open FsUnit.Xunit
|
||||
open System.Diagnostics
|
||||
|
||||
open Parser
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
let basic_program = """//solution 1 Y = araC
|
||||
directive simulation {final = 100000.0; points = 1000}
|
||||
|
||||
prom<neg(Y)>; rbs; pcr<codes(Y)>; ter"""
|
||||
|
||||
let basic_crn = """directive simulation {final = 100000.0; points = 1000}
|
||||
directive crn {
|
||||
module g2module(val) = {
|
||||
| val g2
|
||||
}
|
||||
| 1 g4
|
||||
| g2module(2)
|
||||
}
|
||||
|
||||
x1:prom<neg(Y)>; rbs; pcr<codes(Y)>; ter
|
||||
"""
|
||||
|
||||
let repressilator = """directive simulation {final = 100000.0; points = 1000; plots = [A; B; C]}
|
||||
|
||||
prom<neg(C)>; rbs; pcr<codes(A)>; ter;
|
||||
prom<neg(A)>; rbs; pcr<codes(B)>; ter;
|
||||
prom<neg(B)>; rbs; pcr<codes(C)>; ter"""
|
||||
|
||||
let repressilator_similar = """directive simulation {final = 100000.0; points = 1000; plots = [A; B; C]}
|
||||
|
||||
prom<con(RtA),neg(C,RbA,RubA,RtbA)>;
|
||||
rbs<rate(RA)>; pcr<codes(A,RdA)>; ter;
|
||||
prom<con(RtB),neg(A,RbB,RubB,RtbB)>;
|
||||
rbs<rate(RB)>; pcr<codes(B,RdB)>; ter;
|
||||
prom<con(RtC),neg(B,RbC,RubC,RtbC)>;
|
||||
rbs<rate(RC)>; pcr<codes(C,RdC)>; ter
|
||||
|
||||
| 0.4 < RubB | RubB < 0.6
|
||||
| 0.4 < RubC | RubC < 0.6
|
||||
| 0.4 < RubA | RubA < 0.6 """
|
||||
|
||||
let repressilator_modules = """directive simulation {final = 100000.0; points = 1000; plots = [A; B; C]}
|
||||
|
||||
template gate(i,o) {
|
||||
prom<neg(i)>; rbs; pcr<codes(o)>; ter
|
||||
};
|
||||
gate(A,B) | gate(B,C) | gate(C,A)"""
|
||||
|
||||
let repressilator_modules_similar = """directive simulation {final = 100000.0; points = 1000; plots = [A; B; C]}
|
||||
|
||||
template gate(i,o) {
|
||||
new RB. new RUB. new RTB. new RT. new R. new RD.
|
||||
prom<con(RT), neg(i, RB, RUB, RTB)>;rbs<rate(R)>; pcr<codes(o,RD)>; ter
|
||||
| 0.4 < RUB | RUB < 0.6
|
||||
};
|
||||
gate(A,B) | gate(B,C) | gate(C,A)"""
|
||||
|
||||
let repressilator_system = """//any solution
|
||||
directive simulation {final = 100000.0; points = 1000; plots = [AF;B;C]}
|
||||
|
||||
template gate(i,o) {
|
||||
new RB. new RUB. new RTB. new RT. new R. new RD.
|
||||
prom<con(RT), neg(i, RB, RUB, RTB)>;rbs<rate(R)>; pcr<codes(o,RD)>; ter
|
||||
| 0.4 < RUB | RUB < 0.6
|
||||
};
|
||||
|
||||
system s1{
|
||||
gate(A,B)
|
||||
}
|
||||
|
||||
system s2{
|
||||
gate(B,C)
|
||||
}
|
||||
|
||||
system s3{
|
||||
gate(C,A)
|
||||
}
|
||||
"""
|
||||
|
||||
let reciever_device = """directive simulation {final = 100000.0; points = 1000; plots = [Signal]}
|
||||
|
||||
cell
|
||||
[ prom; rbs; pcr<codes(Receiver)>; ter
|
||||
| prom<pos(Receiver::Signal)>;
|
||||
rbs; pcr<codes(gfp)>; ter
|
||||
| Receiver + Signal -> Receiver::Signal
|
||||
| Receiver::Signal -> Receiver + Signal
|
||||
]
|
||||
| Signal -> cell[Signal]
|
||||
| cell[Signal] -> Signal
|
||||
| initPop Signal 100.0"""
|
||||
|
||||
let predator_prey = """directive simulation {final = 100000.0; points = 1000; plots = [predator_ccdB; prey_ccdB]}
|
||||
|
||||
predator
|
||||
[ r0051:prom; rbs; pcr<codes(Q2b)>
|
||||
; rbs; pcr<codes(Q1a)>; ter
|
||||
; prom<pos(Q2b::H2)>; rbs; pcr<codes(A)>; ter
|
||||
; r0051:prom; rbs; pcr<codes(ccdB)>; ter
|
||||
| Q1a ~-> H1 | Q2b + H2 <-> Q2b::H2
|
||||
| A ~ ccdB ->
|
||||
| H1 *->{10.0} | H2 *->{10.0}
|
||||
| ccdB ~ Q1a *->{10.0}
|
||||
] ||
|
||||
|
||||
prey
|
||||
[ prom<pos(H1::Q1b)>; rbs; pcr<codes(ccdB)>; ter
|
||||
; r0051:prom; rbs; pcr<codes(Q1b)>
|
||||
; rbs; pcr<codes(Q2a)>; ter
|
||||
| Q2a ~-> H2 | H1 + Q1b <-> H1::Q1b
|
||||
| H2 *->{10.0} | H1 *->{10.0}
|
||||
| ccdB ~ Q2a *->{10.0}
|
||||
] ||
|
||||
|
||||
predator[H1] -> H1 | H1 -> prey[H1]
|
||||
| prey[H2] -> H2 | H2 -> predator[H2]"""
|
||||
|
||||
let band_detector = """directive simulation {final = 100000.0; points = 1000; plots = [receiver_gfp]}
|
||||
|
||||
receiver
|
||||
[ runknown5:prom; rbs; pcr<codes(luxR)>; ter
|
||||
| prom<pos(luxR::Signal)>; rbs; pcr<codes(lacI)>;ter
|
||||
| prom<pos(luxR::Signal)>; rbs; pcr<codes(cI)>;ter
|
||||
| prom<neg(cI)>;rbs; pcr<codes(lacI)>;ter
|
||||
| prom<neg(lacI)>;rbs;pcr<codes(gfp)>;ter
|
||||
| luxR + Signal -> luxR::Signal
|
||||
| luxR::Signal -> luxR + Signal
|
||||
]
|
||||
| Signal -> receiver[Signal]
|
||||
| receiver[Signal] -> Signal
|
||||
| initPop Signal 100.0"""
|
||||
|
||||
|
||||
let constant_ratiometric = """directive simulator sundials
|
||||
directive plot_settings { x_label = "Time (h)"; y_label = "Fluorescence (a.u.)" }
|
||||
directive parameters [
|
||||
// Treatments
|
||||
C6=0.0; C12=0.0; Ara=0.0; tau=0.0;
|
||||
// Cell growth
|
||||
c0 = 0.002;
|
||||
// Autofluorescence
|
||||
autoYFP=1e0, { distribution=Uniform(1e-3,1e3) };
|
||||
autoCFP=1e0, { distribution=Uniform(1e-3,1e3) };
|
||||
// FP
|
||||
dRFP=0.1, { distribution=Uniform(1e-3,1e0) };
|
||||
dCFP=1e-2, { distribution=Uniform(1e-3,1e0) };
|
||||
dYFP=1e-2, { distribution=Uniform(1e-3,1e0) };
|
||||
// Double receiver
|
||||
KR6=1e-2, { distribution=Uniform(1e-8,1e0) };
|
||||
KS6=1e-4, { distribution=Uniform(1e-8,1e0) };
|
||||
KR12=1e-3, { distribution=Uniform(1e-8,1e0) };
|
||||
KS12=1e-2, { distribution=Uniform(1e-8,1e0) };
|
||||
nR=0.797, { interval=Real; distribution=Uniform(0.5,2.0) };
|
||||
nS=0.797, { interval=Real; distribution=Uniform(0.5,2.0) };
|
||||
aRS100=1.0, { distribution=Uniform(1e0,1e2) };
|
||||
aR33=1.0, { distribution=Uniform(1e0,1e2) };
|
||||
aS32=1.0, { distribution=Uniform(1e0,1e2) };
|
||||
aS175=1.0, { distribution=Uniform(1e0,1e2) };
|
||||
dR=0.1, { distribution=Uniform(1e-2,1e1) };
|
||||
//dS=0.1, { distribution=Uniform(1e-2,1e2) };
|
||||
e76=1e-2, { distribution=Uniform(1e-4,1.0) };
|
||||
KGR_76=1e-2,{ distribution=Uniform(1e-4,1e0) };
|
||||
KGS_76=1e-6,{ distribution=Uniform(1e-8,1e0) };
|
||||
e81=1e-2, { distribution=Uniform(1e-4,1.0) };
|
||||
KGR_81=1e-6,{ distribution=Uniform(1e-8,1e0) };
|
||||
KGS_81=1e-2,{ distribution=Uniform(1e-4,1e0) };
|
||||
aCFP=1e3, { distribution=Uniform(1e0,1e5) };
|
||||
aYFP=1e3, { distribution=Uniform(1e0,1e5) };
|
||||
dCFP=1e-2, { distribution=Uniform(1e-3,1e0) };
|
||||
dYFP=1e-2, { distribution=Uniform(1e-3,1e0) };
|
||||
// Relay P81-LuxI
|
||||
kC6=1e0, { distribution=Uniform(1e0,1e6) };
|
||||
Klux=1.0, { distribution=Uniform(1e0,1e6) };
|
||||
dluxI=0.1,{ distribution=Uniform(1e-3,1e1) };
|
||||
// Relay P76-LasI
|
||||
kC12=1e0, { distribution=Uniform(1e0,1e6) };
|
||||
Klas=1.0, { distribution=Uniform(1e0,1e6) };
|
||||
dlasI=0.1,{ distribution=Uniform(1e-3,1e1) };
|
||||
// PBad
|
||||
KAra=1.0, { distribution=Uniform(1e-2,1e2) };
|
||||
nA=1.0, { interval=Real; distribution=Uniform(0.5,3.0) };
|
||||
eA=0.1, { interval=Real; distribution=Uniform(0.0,0.5) };
|
||||
// AiiA
|
||||
dA6=1e-1, { distribution=Uniform(1e-3,1e1) };
|
||||
dA12=1e-1, { distribution=Uniform(1e-3,1e1) };
|
||||
daiiA=0.1, { distribution=Uniform(1e-3,1e1) };
|
||||
]
|
||||
directive inference { burnin=200; samples=200; thin=20; noise_model = proportional }
|
||||
directive simulation {multicore=True}
|
||||
directive rates [
|
||||
growth = [grow]*r*(1 - [x] / K);
|
||||
capacity = rc;
|
||||
boundLuxR = [luxR]^2 * ((KR6*[c6])^nR + (KR12*[c12])^nR) / ((1.0 + KR6*[c6] + KR12*[c12])^nR);
|
||||
boundLasR = [lasR]^2 * ((KS6*[c6])^nS + (KS12*[c12])^nS) / ((1.0 + KS6*[c6] + KS12*[c12])^nS);
|
||||
P76 = (e76 + KGR_76*[boundLuxR] + KGS_76*[boundLasR]) / (1.0 + KGR_76*[boundLuxR] + KGS_76*[boundLasR]);
|
||||
P81 = (e81 + KGR_81*[boundLuxR] + KGS_81*[boundLasR]) / (1.0 + KGR_81*[boundLuxR] + KGS_81*[boundLasR]);
|
||||
PBad = (Ara^nA+eA*KAra^nA)/(Ara^nA+KAra^nA);
|
||||
one = 1.0;
|
||||
]
|
||||
|
||||
module CFP(P,a,growth,capacity) = {
|
||||
->[[capacity]*a*[P]] cfp |
|
||||
cfp ->{dCFP} |
|
||||
cfp ->[[growth]*[cfp]]
|
||||
}
|
||||
module YFP(P,a,growth,capacity) = {
|
||||
->[[capacity]*a*[P]] yfp |
|
||||
yfp ->{dYFP} |
|
||||
yfp ->[[growth]*[yfp]]
|
||||
}
|
||||
module LuxR(aR,growth,capacity) = {
|
||||
->[[capacity]*aR] luxR |
|
||||
luxR ->{dR} |
|
||||
luxR ->[[growth]*[luxR]]
|
||||
}
|
||||
module LasR(aS,growth,capacity) = {
|
||||
->[[capacity]*aS] lasR |
|
||||
lasR ->{dR} |
|
||||
lasR ->[[growth]*[lasR]]
|
||||
}
|
||||
module LuxI(P,growth,capacity) = {
|
||||
->[[capacity]*[P]] luxI |
|
||||
luxI ->{dluxI} |
|
||||
luxI ->[[growth]*[luxI]] |
|
||||
->[kC6*[capacity]*[x]*[luxI]/(1+[luxI]/Klux)] c6
|
||||
}
|
||||
module LasI(P,growth,capacity) = {
|
||||
->[[capacity]*[P]] lasI |
|
||||
lasI ->{dlasI} |
|
||||
lasI ->[[growth]*[lasI]] |
|
||||
->[kC12*[capacity]*[x]*[lasI]/(1+[lasI]/Klas)] c12
|
||||
}
|
||||
module AiiA(P,aI,growth,capacity) = {
|
||||
->[[capacity]*aI*[P]] aiiA |
|
||||
aiiA ->{daiiA} |
|
||||
aiiA ->[[growth]*[aiiA]] |
|
||||
c6 -> [[x]*dA6*[c6]*[aiiA]] |
|
||||
c12 -> [[x]*dA12*[c12]*[aiiA]]
|
||||
}
|
||||
module cells(growth,tlag) = {
|
||||
init x c0 | init grow 1 @ tlag |
|
||||
init c6 C6 @ tau | init c12 C12 @ tau |
|
||||
->[[growth]*[x]] x
|
||||
}
|
||||
module autofluorescence(growth,capacity) = {
|
||||
->[[capacity]*autoYFP] f530 |
|
||||
f530 ->[[growth]*[f530]] |
|
||||
->[[capacity]*autoCFP] f480 |
|
||||
f480 ->[[growth]*[f480]]
|
||||
}
|
||||
module doublereceiver(aR,aS,growth,capacity) = {
|
||||
LuxR(aR,growth,capacity) |
|
||||
LasR(aS,growth,capacity) |
|
||||
YFP(P81,aYFP,growth,capacity) |
|
||||
CFP(P76,aCFP,growth,capacity)
|
||||
}
|
||||
|
||||
// Models of each GEC device
|
||||
device prpr() = { YFP(one,aYFP,growth,capacity) | CFP(one,aCFP,growth,capacity) }
|
||||
device drPcat() = { doublereceiver(1.0,1.0,growth,capacity) }
|
||||
device drRS100S32() = { doublereceiver(aRS100,aS32,growth,capacity) }
|
||||
device drR33S32() = { doublereceiver(aR33,aS32,growth,capacity) }
|
||||
device drR33S175() = { doublereceiver(aR33,aS175,growth,capacity) }
|
||||
device relayP76LasI() = { LasI(P76,growth,capacity) }
|
||||
device relayP81LuxI() = { LuxI(P81,growth,capacity) }
|
||||
device pBadYFP() = { YFP(PBad,aYFP,growth,capacity) }
|
||||
device pBadAiiA() = { AiiA(PBad,1.0,growth,capacity) }
|
||||
|
||||
// Systems for growth and control that will be reused heavily
|
||||
system growth = {
|
||||
directive simulation { final=36.0; points=250; plots=[[x]+x0]; multicore=True; sweeps=[sweep_R33S175_PBadaiia_dataset7] }
|
||||
directive plot_settings { y_label = "OD" }
|
||||
directive parameters [
|
||||
r = 1, { interval=Real; distribution=Uniform(0.1,10); variation=Multiple };
|
||||
K = 2, { interval=Real; distribution=Uniform(0.1,5); variation=Multiple };
|
||||
tlag = 1, { interval=Real; distribution=Uniform(0,10); variation=Multiple };
|
||||
x0=0.1,{ interval=Real; distribution=Uniform(0.0,0.2) };
|
||||
]
|
||||
directive rates [growth = [grow]*r*(1 - [x] / K)]
|
||||
directive sweeps [
|
||||
sweep_R33S175_PBadaiia_dataset7 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,5); (0,0,25000,0,2.5); (0,0,25000,0,1.25); (0,0,25000,0,0.625); (0,0,25000,0,0.3125); (0,0,25000,0,0); (0,0,0,25000,5); (0,0,0,25000,2.5); (0,0,0,25000,1.25); (0,0,0,25000,0.625); (0,0,0,25000,0.3125); (0,0,0,25000,0); (0,0,5000,0,5); (0,0,5000,0,2.5); (0,0,5000,0,1.25); (0,0,5000,0,0.625); (0,0,5000,0,0.3125); (0,0,5000,0,0); (0,0,0,5000,5); (0,0,0,5000,2.5); (0,0,0,5000,1.25); (0,0,0,5000,0.625); (0,0,0,5000,0.3125); (0,0,0,5000,0); (0,0,1000,0,5); (0,0,1000,0,2.5); (0,0,1000,0,1.25); (0,0,1000,0,0.625); (0,0,1000,0,0.3125); (0,0,1000,0,0); (0,0,0,1000,5); (0,0,0,1000,2.5); (0,0,0,1000,1.25); (0,0,0,1000,0.625); (0,0,0,1000,0.3125); (0,0,0,1000,0); (0,0,200,0,5); (0,0,200,0,2.5); (0,0,200,0,1.25); (0,0,200,0,0.625); (0,0,200,0,0.3125); (0,0,200,0,0); (0,0,0,200,5); (0,0,0,200,2.5); (0,0,0,200,1.25); (0,0,0,200,0.625); (0,0,0,200,0.3125); (0,0,0,200,0); (0,0,40,0,5); (0,0,40,0,2.5); (0,0,40,0,1.25); (0,0,40,0,0.625); (0,0,40,0,0.3125); (0,0,40,0,0); (0,0,0,40,5); (0,0,0,40,2.5); (0,0,0,40,1.25); (0,0,0,40,0.625); (0,0,0,40,0.3125); (0,0,0,40,0); (0,0,8,0,5); (0,0,8,0,2.5); (0,0,8,0,1.25); (0,0,8,0,0.625); (0,0,8,0,0.3125); (0,0,8,0,0); (0,0,0,8,5); (0,0,0,8,2.5); (0,0,0,8,1.25); (0,0,0,8,0.625); (0,0,0,8,0.3125); (0,0,0,8,0); (0,0,1.6,0,5); (0,0,1.6,0,2.5); (0,0,1.6,0,1.25); (0,0,1.6,0,0.625); (0,0,1.6,0,0.3125); (0,0,1.6,0,0); (0,0,0,1.6,5); (0,0,0,1.6,2.5); (0,0,0,1.6,1.25); (0,0,0,1.6,0.625); (0,0,0,1.6,0.3125); (0,0,0,1.6,0); (0,0,0,0,5); (0,0,0,0,2.5); (0,0,0,0,1.25); (0,0,0,0,0.625); (0,0,0,0,0.3125); (0,0,0,0,0); (0,0,0,0,5); (0,0,0,0,2.5); (0,0,0,0,1.25); (0,0,0,0,0.625); (0,0,0,0,0.3125); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S175_PBadaiia_OD_proc_PBadAiia_Ara_C6C12]
|
||||
directive crn { cells(growth,tlag) }
|
||||
}
|
||||
system control = {
|
||||
directive simulation { final=36.0; points=250; plots=[[x]*[fp]+f0]; plotcolours=["#FF0000"]; multicore=True; sweeps=[sweep_R33S175_PBadaiia_dataset7] }
|
||||
directive plot_settings { y_label = "RFP fluorescence (a.u.)" }
|
||||
directive parameters [
|
||||
r = 1, { interval=Real; distribution=Uniform(0.1,10); variation=Multiple };
|
||||
K = 2, { interval=Real; distribution=Uniform(0.1,5); variation=Multiple };
|
||||
tlag = 1, { interval=Real; distribution=Uniform(0,10); variation=Multiple };
|
||||
rc=1e2, { distribution=Uniform(1e0,1e5); variation=Multiple };
|
||||
f0=100.0,{ interval=Real; distribution=Uniform(0.0,10000.0) };
|
||||
]
|
||||
directive rates [growth = [grow]*r*(1 - [x] / K);capacity = rc]
|
||||
directive sweeps [
|
||||
sweep_R33S175_PBadaiia_dataset7 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,5); (0,0,25000,0,2.5); (0,0,25000,0,1.25); (0,0,25000,0,0.625); (0,0,25000,0,0.3125); (0,0,25000,0,0); (0,0,0,25000,5); (0,0,0,25000,2.5); (0,0,0,25000,1.25); (0,0,0,25000,0.625); (0,0,0,25000,0.3125); (0,0,0,25000,0); (0,0,5000,0,5); (0,0,5000,0,2.5); (0,0,5000,0,1.25); (0,0,5000,0,0.625); (0,0,5000,0,0.3125); (0,0,5000,0,0); (0,0,0,5000,5); (0,0,0,5000,2.5); (0,0,0,5000,1.25); (0,0,0,5000,0.625); (0,0,0,5000,0.3125); (0,0,0,5000,0); (0,0,1000,0,5); (0,0,1000,0,2.5); (0,0,1000,0,1.25); (0,0,1000,0,0.625); (0,0,1000,0,0.3125); (0,0,1000,0,0); (0,0,0,1000,5); (0,0,0,1000,2.5); (0,0,0,1000,1.25); (0,0,0,1000,0.625); (0,0,0,1000,0.3125); (0,0,0,1000,0); (0,0,200,0,5); (0,0,200,0,2.5); (0,0,200,0,1.25); (0,0,200,0,0.625); (0,0,200,0,0.3125); (0,0,200,0,0); (0,0,0,200,5); (0,0,0,200,2.5); (0,0,0,200,1.25); (0,0,0,200,0.625); (0,0,0,200,0.3125); (0,0,0,200,0); (0,0,40,0,5); (0,0,40,0,2.5); (0,0,40,0,1.25); (0,0,40,0,0.625); (0,0,40,0,0.3125); (0,0,40,0,0); (0,0,0,40,5); (0,0,0,40,2.5); (0,0,0,40,1.25); (0,0,0,40,0.625); (0,0,0,40,0.3125); (0,0,0,40,0); (0,0,8,0,5); (0,0,8,0,2.5); (0,0,8,0,1.25); (0,0,8,0,0.625); (0,0,8,0,0.3125); (0,0,8,0,0); (0,0,0,8,5); (0,0,0,8,2.5); (0,0,0,8,1.25); (0,0,0,8,0.625); (0,0,0,8,0.3125); (0,0,0,8,0); (0,0,1.6,0,5); (0,0,1.6,0,2.5); (0,0,1.6,0,1.25); (0,0,1.6,0,0.625); (0,0,1.6,0,0.3125); (0,0,1.6,0,0); (0,0,0,1.6,5); (0,0,0,1.6,2.5); (0,0,0,1.6,1.25); (0,0,0,1.6,0.625); (0,0,0,1.6,0.3125); (0,0,0,1.6,0); (0,0,0,0,5); (0,0,0,0,2.5); (0,0,0,0,1.25); (0,0,0,0,0.625); (0,0,0,0,0.3125); (0,0,0,0,0); (0,0,0,0,5); (0,0,0,0,2.5); (0,0,0,0,1.25); (0,0,0,0,0.625); (0,0,0,0,0.3125); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S175_PBadaiia_mRFP1_proc_PBadAiia_Ara_C6C12]
|
||||
directive crn {
|
||||
cells(growth,tlag)
|
||||
| fp ->[[growth]*[fp]] // Dilution
|
||||
| ->[[capacity]] fp // Transcription/translation
|
||||
| fp ->{dRFP} // Degradation
|
||||
}
|
||||
}
|
||||
|
||||
system target = {
|
||||
directive simulation { final=36.0; points=250; plots=[[x]*([yfp]+[f530])+yb0; [x]*([cfp]+[f480])+cb0]; plotcolours=["#FFDF00"; "#ADD8E6"] }
|
||||
directive parameters [
|
||||
r = 1, { interval=Real; distribution=Uniform(0.1,10); variation=Multiple };
|
||||
K = 2, { interval=Real; distribution=Uniform(0.1,5); variation=Multiple };
|
||||
tlag = 1, { interval=Real; distribution=Uniform(0,10); variation=Multiple };
|
||||
rc=1e2, { distribution=Uniform(1e0,1e5); variation=Multiple };
|
||||
yb0=1e3, { interval=Real; distribution=Uniform(0.0,5e3) };
|
||||
cb0=1e3, { interval=Real; distribution=Uniform(0.0,1e4) };
|
||||
]
|
||||
directive rates [growth = [grow]*r*(1 - [x] / K);capacity = rc]
|
||||
directive crn { cells(growth,tlag) | autofluorescence(growth,capacity) }
|
||||
}
|
||||
|
||||
system auto = { target with
|
||||
directive simulation { final=36.0; points=250; plots=[[x]*[f530]+yb0; [x]*[f480]+cb0]; plotcolours=["#FFDF00"; "#ADD8E6"]; multicore=True; sweeps=[sweep_EC10G_dataset0] }
|
||||
directive sweeps [
|
||||
sweep_EC10G_dataset0 = [(EtOH,chlor,C6,C12,Ara) = [(1700000000,0,0,0,0); (170000000,0,0,0,0); (17000000,0,0,0,0); (1700000,0,0,0,0); (170000,0,0,0,0); (17000,0,0,0,0); (1700,0,0,0,0); (170,0,0,0,0); (17,0,0,0,0); (1.7,0,0,0,0); (0.17,0,0,0,0); (0,0,0,0,0); (1700000000,0,0,0,0); (170000000,0,0,0,0); (17000000,0,0,0,0); (1700000,0,0,0,0); (170000,0,0,0,0); (17000,0,0,0,0); (1700,0,0,0,0); (170,0,0,0,0); (17,0,0,0,0); (1.7,0,0,0,0); (0.17,0,0,0,0); (0,0,0,0,0); (1700000000,0,0,0,0); (170000000,0,0,0,0); (17000000,0,0,0,0); (1700000,0,0,0,0); (170000,0,0,0,0); (17000,0,0,0,0); (1700,0,0,0,0); (170,0,0,0,0); (17,0,0,0,0); (1.7,0,0,0,0); (0.17,0,0,0,0); (0,0,0,0,0); (1700000000,0,0,0,0); (170000000,0,0,0,0); (17000000,0,0,0,0); (1700000,0,0,0,0); (170000,0,0,0,0); (17000,0,0,0,0); (1700,0,0,0,0); (170,0,0,0,0); (17,0,0,0,0); (1.7,0,0,0,0); (0.17,0,0,0,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [EC10G_EYFP_ECFP_proc_EC10G_EtOH]
|
||||
}
|
||||
|
||||
system prpr = { target with
|
||||
directive simulation {multicore=True; sweeps=[sweep_PLPL_dataset1]}
|
||||
directive parameters [
|
||||
r = 1, { interval=Real; distribution=Uniform(0.1,10); variation=Multiple };
|
||||
K = 2, { interval=Real; distribution=Uniform(0.1,5); variation=Multiple };
|
||||
tlag = 1, { interval=Real; distribution=Uniform(0,10); variation=Multiple };
|
||||
rc=1e2, { distribution=Uniform(1e0,1e5); variation=Multiple };
|
||||
aCFP=1e3, { distribution=Uniform(1e0,1e5); variation=Random };
|
||||
aYFP=1e3, { distribution=Uniform(1e0,1e5); variation=Random };
|
||||
yb0=1e3, { interval=Real; distribution=Uniform(0.0,5e3) };
|
||||
cb0=1e3, { interval=Real; distribution=Uniform(0.0,1e4) };
|
||||
]
|
||||
directive sweeps [
|
||||
sweep_PLPL_dataset1 = [(EtOH,chlor,C6,C12,Ara) = [(0,5,0,0,0); (0,5,0,0,0); (0,2.5,0,0,0); (0,2.5,0,0,0); (0,1.25,0,0,0); (0,1.25,0,0,0); (0,0.625,0,0,0); (0,0.625,0,0,0); (0,0.3125,0,0,0); (0,0.3125,0,0,0); (0,0,0,0,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [PLPL_EYFP_ECFP_proc_PLPL_Chlor]
|
||||
prpr:device
|
||||
}
|
||||
|
||||
// DR (Pcat-Pcat)
|
||||
system growth_PcatPcat = { growth with
|
||||
directive simulation {multicore=True; sweeps=[sweep_Pcat_Y81C76_dataset4]}
|
||||
directive sweeps [
|
||||
sweep_Pcat_Y81C76_dataset4 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0); (0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [Pcat_Y81C76_OD_proc141006]
|
||||
}
|
||||
|
||||
system control_PcatPcat = { control with
|
||||
directive simulation {multicore=True; sweeps=[sweep_Pcat_Y81C76_dataset4]}
|
||||
directive sweeps [
|
||||
sweep_Pcat_Y81C76_dataset4 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0); (0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [Pcat_Y81C76_mRFP1_proc141006]
|
||||
}
|
||||
|
||||
system dr_PcatPcat = { target with
|
||||
directive simulation {multicore=True; sweeps=[sweep_Pcat_Y81C76_dataset4]}
|
||||
directive sweeps [
|
||||
sweep_Pcat_Y81C76_dataset4 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0); (0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [Pcat_Y81C76_EYFP_ECFP_proc141006]
|
||||
drPcat:device
|
||||
}
|
||||
|
||||
// DR (RS100-S32)
|
||||
system growth_RS100S32 = { growth with
|
||||
directive simulation {multicore=True; sweeps=[sweep_RS100S32_Y81C76_dataset3]}
|
||||
directive sweeps [
|
||||
sweep_RS100S32_Y81C76_dataset3 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [RS100S32_Y81C76_OD_proc140916]
|
||||
}
|
||||
|
||||
system control_RS100S32 = { control with
|
||||
directive simulation {multicore=True; sweeps=[sweep_RS100S32_Y81C76_dataset3]}
|
||||
directive sweeps [
|
||||
sweep_RS100S32_Y81C76_dataset3 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [RS100S32_Y81C76_mRFP1_proc140916]
|
||||
}
|
||||
|
||||
system dr_RS100S32 = { target with
|
||||
directive simulation {multicore=True; sweeps=[sweep_RS100S32_Y81C76_dataset3]}
|
||||
directive sweeps [
|
||||
sweep_RS100S32_Y81C76_dataset3 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [RS100S32_Y81C76_EYFP_ECFP_proc140916]
|
||||
drRS100S32:device
|
||||
}
|
||||
|
||||
// DR (R33-S32)
|
||||
system growth_R33S32 = { growth with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S32_Y81C76_dataset3]}
|
||||
directive sweeps [
|
||||
sweep_R33S32_Y81C76_dataset3 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S32_Y81C76_OD_proc140916]
|
||||
}
|
||||
|
||||
system control_R33S32 = { control with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S32_Y81C76_dataset3]}
|
||||
directive sweeps [
|
||||
sweep_R33S32_Y81C76_dataset3 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S32_Y81C76_mRFP1_proc140916]
|
||||
}
|
||||
|
||||
system dr_R33S32 = { target with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S32_Y81C76_dataset3]}
|
||||
directive sweeps [
|
||||
sweep_R33S32_Y81C76_dataset3 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S32_Y81C76_EYFP_ECFP_proc140916]
|
||||
drR33S32:device
|
||||
}
|
||||
|
||||
// DR (R33-S175)
|
||||
system growth_R33S175 = { growth with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S175_Y81C76_dataset2]}
|
||||
directive sweeps [
|
||||
sweep_R33S175_Y81C76_dataset2 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S175_Y81C76_OD_proc141021]
|
||||
}
|
||||
|
||||
system control_R33S175 = { control with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S175_Y81C76_dataset2]}
|
||||
directive sweeps [
|
||||
sweep_R33S175_Y81C76_dataset2 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S175_Y81C76_mRFP1_proc141021]
|
||||
}
|
||||
system dr_R33S175 = { target with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S175_Y81C76_dataset2]}
|
||||
directive sweeps [
|
||||
sweep_R33S175_Y81C76_dataset2 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.33333333333,0,0); (0,0,2777.77777777778,0,0); (0,0,925.925925925926,0,0); (0,0,308.641975308642,0,0); (0,0,102.880658436214,0,0); (0,0,34.2935528120713,0,0); (0,0,11.4311842706904,0,0); (0,0,3.81039475689681,0,0); (0,0,1.27013158563227,0,0); (0,0,0.423377195210757,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.33333333333,0); (0,0,0,2777.77777777778,0); (0,0,0,925.925925925926,0); (0,0,0,308.641975308642,0); (0,0,0,102.880658436214,0); (0,0,0,34.2935528120713,0); (0,0,0,11.4311842706904,0); (0,0,0,3.81039475689681,0); (0,0,0,1.27013158563227,0); (0,0,0,0.423377195210757,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S175_Y81C76_EYFP_ECFP_proc141021]
|
||||
drR33S175:device
|
||||
}
|
||||
|
||||
// Timed additions circuit (for prediction)
|
||||
system doublereceiverTimed = { dr_R33S175 with directive parameters [ sigma = 1.0 ] }
|
||||
|
||||
// Relays
|
||||
system growth_P76LasI = { growth with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S175DR_P76LasI_dataset5]}
|
||||
directive sweeps [
|
||||
sweep_R33S175DR_P76LasI_dataset5 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.333333,0,0); (0,0,2777.777778,0,0); (0,0,925.925926,0,0); (0,0,308.641975,0,0); (0,0,102.880658,0,0); (0,0,34.293553,0,0); (0,0,11.431184,0,0); (0,0,3.810395,0,0); (0,0,1.270132,0,0); (0,0,0.423377,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.333333,0); (0,0,0,2777.777778,0); (0,0,0,925.925926,0); (0,0,0,308.641975,0); (0,0,0,102.880658,0); (0,0,0,34.293553,0); (0,0,0,11.431184,0); (0,0,0,3.810395,0); (0,0,0,1.270132,0); (0,0,0,0.423377,0); (0,0,0,0,0); (0,0,25000,0,0); (0,0,8333.333333,0,0); (0,0,2777.777778,0,0); (0,0,925.925926,0,0); (0,0,308.641975,0,0); (0,0,102.880658,0,0); (0,0,34.293553,0,0); (0,0,11.431184,0,0); (0,0,3.810395,0,0); (0,0,1.270132,0,0); (0,0,0.423377,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.333333,0); (0,0,0,2777.777778,0); (0,0,0,925.925926,0); (0,0,0,308.641975,0); (0,0,0,102.880658,0); (0,0,0,34.293553,0); (0,0,0,11.431184,0); (0,0,0,3.810395,0); (0,0,0,1.270132,0); (0,0,0,0.423377,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S175DR_P76LasI_OD_proc_Relays_RemovedOutlier]
|
||||
}
|
||||
|
||||
system control_P76LasI = { control with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S175DR_P76LasI_dataset5]}
|
||||
directive sweeps [
|
||||
sweep_R33S175DR_P76LasI_dataset5 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.333333,0,0); (0,0,2777.777778,0,0); (0,0,925.925926,0,0); (0,0,308.641975,0,0); (0,0,102.880658,0,0); (0,0,34.293553,0,0); (0,0,11.431184,0,0); (0,0,3.810395,0,0); (0,0,1.270132,0,0); (0,0,0.423377,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.333333,0); (0,0,0,2777.777778,0); (0,0,0,925.925926,0); (0,0,0,308.641975,0); (0,0,0,102.880658,0); (0,0,0,34.293553,0); (0,0,0,11.431184,0); (0,0,0,3.810395,0); (0,0,0,1.270132,0); (0,0,0,0.423377,0); (0,0,0,0,0); (0,0,25000,0,0); (0,0,8333.333333,0,0); (0,0,2777.777778,0,0); (0,0,925.925926,0,0); (0,0,308.641975,0,0); (0,0,102.880658,0,0); (0,0,34.293553,0,0); (0,0,11.431184,0,0); (0,0,3.810395,0,0); (0,0,1.270132,0,0); (0,0,0.423377,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.333333,0); (0,0,0,2777.777778,0); (0,0,0,925.925926,0); (0,0,0,308.641975,0); (0,0,0,102.880658,0); (0,0,0,34.293553,0); (0,0,0,11.431184,0); (0,0,0,3.810395,0); (0,0,0,1.270132,0); (0,0,0,0.423377,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S175DR_P76LasI_mRFP1_proc_Relays_RemovedOutlier]
|
||||
}
|
||||
system relay_P76LasI = { dr_R33S175 with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S175DR_P76LasI_dataset5]}
|
||||
directive sweeps [
|
||||
sweep_R33S175DR_P76LasI_dataset5 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.333333,0,0); (0,0,2777.777778,0,0); (0,0,925.925926,0,0); (0,0,308.641975,0,0); (0,0,102.880658,0,0); (0,0,34.293553,0,0); (0,0,11.431184,0,0); (0,0,3.810395,0,0); (0,0,1.270132,0,0); (0,0,0.423377,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.333333,0); (0,0,0,2777.777778,0); (0,0,0,925.925926,0); (0,0,0,308.641975,0); (0,0,0,102.880658,0); (0,0,0,34.293553,0); (0,0,0,11.431184,0); (0,0,0,3.810395,0); (0,0,0,1.270132,0); (0,0,0,0.423377,0); (0,0,0,0,0); (0,0,25000,0,0); (0,0,8333.333333,0,0); (0,0,2777.777778,0,0); (0,0,925.925926,0,0); (0,0,308.641975,0,0); (0,0,102.880658,0,0); (0,0,34.293553,0,0); (0,0,11.431184,0,0); (0,0,3.810395,0,0); (0,0,1.270132,0,0); (0,0,0.423377,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.333333,0); (0,0,0,2777.777778,0); (0,0,0,925.925926,0); (0,0,0,308.641975,0); (0,0,0,102.880658,0); (0,0,0,34.293553,0); (0,0,0,11.431184,0); (0,0,0,3.810395,0); (0,0,0,1.270132,0); (0,0,0,0.423377,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S175DR_P76LasI_EYFP_ECFP_proc_Relays_RemovedOutlier]
|
||||
relayP76LasI:device
|
||||
}
|
||||
|
||||
system growth_P81LuxI = { growth with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S175DR_P81LuxI_dataset5]}
|
||||
directive sweeps [
|
||||
sweep_R33S175DR_P81LuxI_dataset5 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.333333,0,0); (0,0,2777.777778,0,0); (0,0,925.925926,0,0); (0,0,308.641975,0,0); (0,0,102.880658,0,0); (0,0,34.293553,0,0); (0,0,11.431184,0,0); (0,0,3.810395,0,0); (0,0,1.270132,0,0); (0,0,0.423377,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.333333,0); (0,0,0,2777.777778,0); (0,0,0,925.925926,0); (0,0,0,308.641975,0); (0,0,0,102.880658,0); (0,0,0,34.293553,0); (0,0,0,11.431184,0); (0,0,0,3.810395,0); (0,0,0,1.270132,0); (0,0,0,0.423377,0); (0,0,0,0,0); (0,0,25000,0,0); (0,0,8333.333333,0,0); (0,0,2777.777778,0,0); (0,0,925.925926,0,0); (0,0,308.641975,0,0); (0,0,102.880658,0,0); (0,0,34.293553,0,0); (0,0,11.431184,0,0); (0,0,3.810395,0,0); (0,0,1.270132,0,0); (0,0,0.423377,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.333333,0); (0,0,0,2777.777778,0); (0,0,0,925.925926,0); (0,0,0,308.641975,0); (0,0,0,102.880658,0); (0,0,0,34.293553,0); (0,0,0,11.431184,0); (0,0,0,3.810395,0); (0,0,0,1.270132,0); (0,0,0,0.423377,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S175DR_P81LuxI_OD_proc_Relays_RemovedOutlier]
|
||||
}
|
||||
|
||||
system control_P81LuxI = { control with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S175DR_P81LuxI_dataset5]}
|
||||
directive sweeps [
|
||||
sweep_R33S175DR_P81LuxI_dataset5 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.333333,0,0); (0,0,2777.777778,0,0); (0,0,925.925926,0,0); (0,0,308.641975,0,0); (0,0,102.880658,0,0); (0,0,34.293553,0,0); (0,0,11.431184,0,0); (0,0,3.810395,0,0); (0,0,1.270132,0,0); (0,0,0.423377,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.333333,0); (0,0,0,2777.777778,0); (0,0,0,925.925926,0); (0,0,0,308.641975,0); (0,0,0,102.880658,0); (0,0,0,34.293553,0); (0,0,0,11.431184,0); (0,0,0,3.810395,0); (0,0,0,1.270132,0); (0,0,0,0.423377,0); (0,0,0,0,0); (0,0,25000,0,0); (0,0,8333.333333,0,0); (0,0,2777.777778,0,0); (0,0,925.925926,0,0); (0,0,308.641975,0,0); (0,0,102.880658,0,0); (0,0,34.293553,0,0); (0,0,11.431184,0,0); (0,0,3.810395,0,0); (0,0,1.270132,0,0); (0,0,0.423377,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.333333,0); (0,0,0,2777.777778,0); (0,0,0,925.925926,0); (0,0,0,308.641975,0); (0,0,0,102.880658,0); (0,0,0,34.293553,0); (0,0,0,11.431184,0); (0,0,0,3.810395,0); (0,0,0,1.270132,0); (0,0,0,0.423377,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S175DR_P81LuxI_mRFP1_proc_Relays_RemovedOutlier]
|
||||
}
|
||||
system relay_P81LuxI = { dr_R33S175 with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S175DR_P81LuxI_dataset5]}
|
||||
directive sweeps [
|
||||
sweep_R33S175DR_P81LuxI_dataset5 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,0); (0,0,8333.333333,0,0); (0,0,2777.777778,0,0); (0,0,925.925926,0,0); (0,0,308.641975,0,0); (0,0,102.880658,0,0); (0,0,34.293553,0,0); (0,0,11.431184,0,0); (0,0,3.810395,0,0); (0,0,1.270132,0,0); (0,0,0.423377,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.333333,0); (0,0,0,2777.777778,0); (0,0,0,925.925926,0); (0,0,0,308.641975,0); (0,0,0,102.880658,0); (0,0,0,34.293553,0); (0,0,0,11.431184,0); (0,0,0,3.810395,0); (0,0,0,1.270132,0); (0,0,0,0.423377,0); (0,0,0,0,0); (0,0,25000,0,0); (0,0,8333.333333,0,0); (0,0,2777.777778,0,0); (0,0,925.925926,0,0); (0,0,308.641975,0,0); (0,0,102.880658,0,0); (0,0,34.293553,0,0); (0,0,11.431184,0,0); (0,0,3.810395,0,0); (0,0,1.270132,0,0); (0,0,0.423377,0,0); (0,0,0,0,0); (0,0,0,25000,0); (0,0,0,8333.333333,0); (0,0,0,2777.777778,0); (0,0,0,925.925926,0); (0,0,0,308.641975,0); (0,0,0,102.880658,0); (0,0,0,34.293553,0); (0,0,0,11.431184,0); (0,0,0,3.810395,0); (0,0,0,1.270132,0); (0,0,0,0.423377,0); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S175DR_P81LuxI_EYFP_ECFP_proc_Relays_RemovedOutlier]
|
||||
relayP81LuxI:device
|
||||
}
|
||||
|
||||
// PBad
|
||||
system pbad = { target with
|
||||
directive simulation { final=36.0; points=250; plots=[[x]*([yfp]+[f530])+yb0]; plotcolours=["#FFDF00"]; multicore=True; sweeps=[sweep_PBad_eYFP_dataset6] }
|
||||
directive parameters [
|
||||
r = 1, { interval=Real; distribution=Uniform(0.1,10); variation=Multiple };
|
||||
K = 2, { interval=Real; distribution=Uniform(0.1,5); variation=Multiple };
|
||||
tlag = 1, { interval=Real; distribution=Uniform(0,10); variation=Multiple };
|
||||
rc=1e2, { distribution=Uniform(1e0,1e5); variation=Multiple };
|
||||
aYFP=1.0, { distribution=Uniform(1e0,1e5) };
|
||||
yb0=1e3, { interval=Real; distribution=Uniform(0.0,5e3) };
|
||||
]
|
||||
directive sweeps [
|
||||
sweep_PBad_eYFP_dataset6 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,0,0,25); (0,0,0,0,0.78); (0,0,0,0,12.5); (0,0,0,0,0.39); (0,0,0,0,6.25); (0,0,0,0,0.195); (0,0,0,0,3.125); (0,0,0,0,0.0975); (0,0,0,0,1.5625); (0,0,0,0,0.04875); (0,0,0,0,0.78125); (0,0,0,0,0.024375)]];
|
||||
]
|
||||
directive data [PBad_eYFP_EYFP_proc_PBadYFP]
|
||||
pBadYFP:device
|
||||
}
|
||||
|
||||
// AiiA
|
||||
system aiia = { dr_R33S175 with
|
||||
directive simulation {multicore=True; sweeps=[sweep_R33S175_PBadaiia_dataset7]}
|
||||
directive deterministic {reltolerance=1e-12; abstolerance=1e-10}
|
||||
directive sweeps [
|
||||
sweep_R33S175_PBadaiia_dataset7 = [(EtOH,chlor,C6,C12,Ara) = [(0,0,25000,0,5); (0,0,25000,0,2.5); (0,0,25000,0,1.25); (0,0,25000,0,0.625); (0,0,25000,0,0.3125); (0,0,25000,0,0); (0,0,0,25000,5); (0,0,0,25000,2.5); (0,0,0,25000,1.25); (0,0,0,25000,0.625); (0,0,0,25000,0.3125); (0,0,0,25000,0); (0,0,5000,0,5); (0,0,5000,0,2.5); (0,0,5000,0,1.25); (0,0,5000,0,0.625); (0,0,5000,0,0.3125); (0,0,5000,0,0); (0,0,0,5000,5); (0,0,0,5000,2.5); (0,0,0,5000,1.25); (0,0,0,5000,0.625); (0,0,0,5000,0.3125); (0,0,0,5000,0); (0,0,1000,0,5); (0,0,1000,0,2.5); (0,0,1000,0,1.25); (0,0,1000,0,0.625); (0,0,1000,0,0.3125); (0,0,1000,0,0); (0,0,0,1000,5); (0,0,0,1000,2.5); (0,0,0,1000,1.25); (0,0,0,1000,0.625); (0,0,0,1000,0.3125); (0,0,0,1000,0); (0,0,200,0,5); (0,0,200,0,2.5); (0,0,200,0,1.25); (0,0,200,0,0.625); (0,0,200,0,0.3125); (0,0,200,0,0); (0,0,0,200,5); (0,0,0,200,2.5); (0,0,0,200,1.25); (0,0,0,200,0.625); (0,0,0,200,0.3125); (0,0,0,200,0); (0,0,40,0,5); (0,0,40,0,2.5); (0,0,40,0,1.25); (0,0,40,0,0.625); (0,0,40,0,0.3125); (0,0,40,0,0); (0,0,0,40,5); (0,0,0,40,2.5); (0,0,0,40,1.25); (0,0,0,40,0.625); (0,0,0,40,0.3125); (0,0,0,40,0); (0,0,8,0,5); (0,0,8,0,2.5); (0,0,8,0,1.25); (0,0,8,0,0.625); (0,0,8,0,0.3125); (0,0,8,0,0); (0,0,0,8,5); (0,0,0,8,2.5); (0,0,0,8,1.25); (0,0,0,8,0.625); (0,0,0,8,0.3125); (0,0,0,8,0); (0,0,1.6,0,5); (0,0,1.6,0,2.5); (0,0,1.6,0,1.25); (0,0,1.6,0,0.625); (0,0,1.6,0,0.3125); (0,0,1.6,0,0); (0,0,0,1.6,5); (0,0,0,1.6,2.5); (0,0,0,1.6,1.25); (0,0,0,1.6,0.625); (0,0,0,1.6,0.3125); (0,0,0,1.6,0); (0,0,0,0,5); (0,0,0,0,2.5); (0,0,0,0,1.25); (0,0,0,0,0.625); (0,0,0,0,0.3125); (0,0,0,0,0); (0,0,0,0,5); (0,0,0,0,2.5); (0,0,0,0,1.25); (0,0,0,0,0.625); (0,0,0,0,0.3125); (0,0,0,0,0)]];
|
||||
]
|
||||
directive data [R33S175_PBadaiia_EYFP_ECFP_proc_PBadAiia_Ara_C6C12]
|
||||
| pBadAiiA:device
|
||||
}
|
||||
|
||||
// Auto
|
||||
node Auto_Growth { systems = [growth]; inference = {partial=true} }
|
||||
node Auto_Control { systems = [control]; inference = {partial=true} }
|
||||
node Auto_Target { systems = [auto] }
|
||||
edge Auto_Growth.growth ->[r=Fixed;K=Fixed;tlag=Fixed] Auto_Control.control
|
||||
edge Auto_Control.control ->[r=Fixed;K=Fixed;tlag=Fixed;rc=Fixed] Auto_Target.auto
|
||||
|
||||
// PRPR
|
||||
node PRPR_Growth { systems = [growth]; inference = {partial=true} }
|
||||
node PRPR_Control { systems = [control]; inference = {partial=true} }
|
||||
node PRPR_Target { systems = [prpr] }
|
||||
edge PRPR_Growth.growth ->[r=Fixed;K=Fixed;tlag=Fixed] PRPR_Control.control
|
||||
edge PRPR_Control.control ->[r=Fixed;K=Fixed;tlag=Fixed;rc=Fixed] PRPR_Target.prpr
|
||||
edge Auto_Control ->[dRFP] PRPR_Control
|
||||
edge Auto_Target ->[autoYFP;autoCFP] PRPR_Target
|
||||
|
||||
// DR
|
||||
node DR_Growth { systems = [growth_PcatPcat; growth_RS100S32; growth_R33S32; growth_R33S175]; inference = {partial=true} }
|
||||
node DR_Control { systems = [control_PcatPcat; control_RS100S32; control_R33S32; control_R33S175]; inference = {partial=true} }
|
||||
node DR_Target { systems = [dr_PcatPcat; dr_RS100S32; dr_R33S32; dr_R33S175] }
|
||||
edge DR_Growth.growth_PcatPcat ->[r=Fixed;K=Fixed;tlag=Fixed] DR_Control.control_PcatPcat
|
||||
edge DR_Growth.growth_RS100S32 ->[r=Fixed;K=Fixed;tlag=Fixed] DR_Control.control_RS100S32
|
||||
edge DR_Growth.growth_R33S32 ->[r=Fixed;K=Fixed;tlag=Fixed] DR_Control.control_R33S32
|
||||
edge DR_Growth.growth_R33S175 ->[r=Fixed;K=Fixed;tlag=Fixed] DR_Control.control_R33S175
|
||||
edge DR_Control.control_PcatPcat ->[r=Fixed;K=Fixed;tlag=Fixed;rc=Fixed] DR_Target.dr_PcatPcat
|
||||
edge DR_Control.control_RS100S32 ->[r=Fixed;K=Fixed;tlag=Fixed;rc=Fixed] DR_Target.dr_RS100S32
|
||||
edge DR_Control.control_R33S32 ->[r=Fixed;K=Fixed;tlag=Fixed;rc=Fixed] DR_Target.dr_R33S32
|
||||
edge DR_Control.control_R33S175 ->[r=Fixed;K=Fixed;tlag=Fixed;rc=Fixed] DR_Target.dr_R33S175
|
||||
edge PRPR_Control ->[dRFP] DR_Control
|
||||
edge PRPR_Target ->[autoYFP; autoCFP; dYFP; dCFP] DR_Target
|
||||
|
||||
// Relays
|
||||
node Relays_Growth { systems = [growth_P76LasI; growth_P81LuxI]; inference = {partial=true} }
|
||||
node Relays_Control { systems = [control_P76LasI; control_P81LuxI]; inference = {partial=true} }
|
||||
node Relays_Target { systems = [relay_P76LasI; relay_P81LuxI] }
|
||||
edge Relays_Growth.growth_P76LasI ->[r=Fixed;K=Fixed;tlag=Fixed] Relays_Control.control_P76LasI
|
||||
edge Relays_Growth.growth_P81LuxI ->[r=Fixed;K=Fixed;tlag=Fixed] Relays_Control.control_P81LuxI
|
||||
edge Relays_Control.control_P76LasI ->[r=Fixed;K=Fixed;tlag=Fixed;rc=Fixed] Relays_Target.relay_P76LasI
|
||||
edge Relays_Control.control_P81LuxI ->[r=Fixed;K=Fixed;tlag=Fixed;rc=Fixed] Relays_Target.relay_P81LuxI
|
||||
edge DR_Control ->[dRFP] Relays_Control
|
||||
edge DR_Target ->[
|
||||
autoYFP;autoCFP;dYFP;dCFP;
|
||||
aR33;aS175;aYFP;aCFP;e76;e81;KGR_76;KGS_76;KGR_81;KGS_81;KR6;KS6;KR12;KS12;nR;nS;dR;
|
||||
] Relays_Target
|
||||
|
||||
// PBad
|
||||
node PBad_Growth { systems = [growth]; inference = {partial=true} }
|
||||
node PBad_Control { systems = [control]; inference = {partial=true} }
|
||||
node PBad_Target { systems = [pbad] }
|
||||
edge PBad_Growth.growth ->[r=Fixed;K=Fixed;tlag=Fixed] PBad_Control.control
|
||||
edge PBad_Control.control ->[r=Fixed;K=Fixed;tlag=Fixed;rc=Fixed] PBad_Target.pbad
|
||||
edge PRPR_Control ->[dRFP] PBad_Control
|
||||
edge PRPR_Target ->[autoYFP;dYFP] PBad_Target
|
||||
|
||||
// AiiA
|
||||
node AiiA_Growth { systems = [growth]; inference = {partial=true} }
|
||||
node AiiA_Control { systems = [control]; inference = {partial=true} }
|
||||
node AiiA_Target { systems = [aiia] }
|
||||
edge AiiA_Growth.growth ->[r=Fixed;K=Fixed;tlag=Fixed] AiiA_Control.control
|
||||
edge AiiA_Control.control ->[r=Fixed;K=Fixed;tlag=Fixed;rc=Fixed] AiiA_Target.aiia
|
||||
edge DR_Control ->[dRFP] AiiA_Control
|
||||
edge DR_Target ->[
|
||||
autoYFP;autoCFP;dYFP;dCFP;
|
||||
aR33;aS175;aYFP;aCFP;e76;e81;KGR_76;KGS_76;KGR_81;KGS_81;KR6;KS6;KR12;KS12;nR;nS;dR;
|
||||
] AiiA_Target
|
||||
edge PBad_Target ->[KAra; nA; eA] AiiA_Target"""
|
||||
|
||||
[<Fact(DisplayName="GEC - Program Parser - Basic")>]
|
||||
let ``progBasicTest``() =
|
||||
|
||||
let prog = basic_program
|
||||
Debug.WriteLine(prog)
|
||||
let testprog (s:string) = Parser.from_string Program.parse s
|
||||
match testprog prog with
|
||||
| ClassicGec gecprog ->
|
||||
let crn_settings = Crn_settings.defaults.from_default_directive_list gecprog.settings.directives
|
||||
Assert.Equal(crn_settings.simulation.final,100000.0)
|
||||
Assert.Equal(crn_settings.simulation.points,1000)
|
||||
match gecprog.prog with
|
||||
| Ast.Seq(p1,brick) ->
|
||||
match brick with
|
||||
| Ast.Brick(Ast.WildCardVal,str,props) -> Assert.Equal(str,"ter")
|
||||
| _ -> failwith "Unexpected Type found"
|
||||
| _ ->
|
||||
Debug.WriteLine("Error. Seq expected")
|
||||
Assert.Equal(true,false)
|
||||
Debug.WriteLine("End of Test")
|
||||
| _ -> failwith "Unexpected Logic GEC program."
|
||||
|
||||
[<Fact(DisplayName="GEC - Program Parser - Repressilator")>]
|
||||
let ``progRepressilatorTest``() =
|
||||
let progRepressilator = repressilator
|
||||
|
||||
Debug.WriteLine(progRepressilator)
|
||||
|
||||
let testprog (s:string) = Parser.from_string Program.parse s
|
||||
let gecprog = testprog progRepressilator
|
||||
|
||||
Debug.WriteLine("End of Test")
|
||||
|
||||
[<Fact(DisplayName="GEC - Program Parser - RepressilatorSimilar")>]
|
||||
let ``progRepressilatorSimilarTest``()=
|
||||
let progRepressilatorSimilar = repressilator_similar
|
||||
|
||||
|
||||
Debug.WriteLine(progRepressilatorSimilar)
|
||||
|
||||
let testprog (s:string) = Parser.from_string Program.parse s
|
||||
let gecprog = testprog progRepressilatorSimilar
|
||||
|
||||
Debug.WriteLine("End of Test")
|
||||
|
||||
[<Fact(DisplayName="GEC - Program Parser - Repressilator Modules")>]
|
||||
let ``progRepressilatorModulesTest``()=
|
||||
|
||||
let progRepressilatorModules = repressilator_modules
|
||||
Debug.WriteLine(progRepressilatorModules)
|
||||
let testprog (s:string) = Parser.from_string Program.parse s
|
||||
let gecprog = testprog progRepressilatorModules
|
||||
Debug.WriteLine("End of Test")
|
||||
|
||||
[<Fact(DisplayName="GEC - Program Parser - Repressilator Modules Similar")>]
|
||||
let ``progRepressilatorModuleSimilarTest``()=
|
||||
|
||||
let progRepressilatorModuleSimilar = repressilator_modules_similar
|
||||
Debug.WriteLine(progRepressilatorModuleSimilar)
|
||||
let testprog (s:string) = Parser.from_string Program.parse s
|
||||
let gecprog = testprog progRepressilatorModuleSimilar
|
||||
Debug.WriteLine("End of Test")
|
||||
|
||||
[<Fact(DisplayName="GEC - Program Parser - Receiver Device")>]
|
||||
let ``progReceiverDeviceTest``()=
|
||||
|
||||
let progReceiverDevice = reciever_device
|
||||
Debug.WriteLine(progReceiverDevice)
|
||||
|
||||
let testprog (s:string) = Parser.from_string Program.parse s
|
||||
let gecprog = testprog progReceiverDevice
|
||||
|
||||
Debug.WriteLine("End of Test")
|
||||
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - Program Parser - Predator Prey")>]
|
||||
let ``progPredatorPreyTest``()=
|
||||
|
||||
let progPredatorPrey = predator_prey
|
||||
|
||||
Debug.WriteLine(progPredatorPrey)
|
||||
|
||||
let testprog (s:string) = Parser.from_string Program.parse s
|
||||
let gecprog = testprog progPredatorPrey
|
||||
|
||||
Debug.WriteLine("End of Test")
|
||||
|
||||
[<Fact(DisplayName="GEC - Program Parser - CRN Directive with Program")>]
|
||||
let crnDirectiveProgTest() =
|
||||
let progWithCrn = basic_crn
|
||||
let testprog (s:string) = Parser.from_string Program.parse s
|
||||
match testprog progWithCrn with
|
||||
| ClassicGec gecprog ->
|
||||
let crn_settings = Crn_settings.defaults.from_default_directive_list gecprog.settings.directives
|
||||
Assert.Equal(crn_settings.simulation.final,100000.0)
|
||||
Assert.False(gecprog.settings.overrideCrn)
|
||||
let (moduledefs,instructions) = gecprog.settings.crn
|
||||
Assert.Equal(moduledefs.Length,1)
|
||||
Assert.Equal(instructions.Length,2)
|
||||
| _ -> failwith "Unexpected Logic GEC program."
|
||||
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - Program Parser - Sandbox")>]
|
||||
let ``progSandboxTest``()=
|
||||
|
||||
let get_obj s = Parser.from_string Program.pInnerParallelContent s
|
||||
|
||||
let str0 = "4 * x > 5"
|
||||
let str1 = "b5:rbs;b1:ter"
|
||||
let str2 = "a > 6"
|
||||
let str3 = "m(a::g,6+C)"
|
||||
let obj = get_obj str0
|
||||
let obj = get_obj str1
|
||||
let obj = get_obj str2
|
||||
let obj = get_obj str3
|
||||
|
||||
let str = "cell[signal] -> signal"
|
||||
let reac = get_obj str
|
||||
|
||||
let str4 = "a + b + c > t + 6 - g"
|
||||
let reac4 = get_obj str4
|
||||
let str5 = ""
|
||||
let reac5 = get_obj str5
|
||||
|
||||
let nilprog = Parser.from_string Program.parse_new_outer ""
|
||||
|
||||
|
||||
()
|
||||
|
||||
[<Fact(DisplayName="GEC - Program Parser - Band Detector")>]
|
||||
let ``progBandDetectorTest``()=
|
||||
|
||||
let progBandDetector = band_detector
|
||||
|
||||
Debug.WriteLine(progBandDetector)
|
||||
let testprog (s:string) = Parser.from_string Program.parse s
|
||||
let gecprog = testprog progBandDetector
|
||||
Debug.WriteLine("End of Test")
|
||||
|
|
@ -0,0 +1,200 @@
|
|||
module Microsoft.Research.GEC.TransCrnTest
|
||||
|
||||
open Microsoft.Research.GEC.GECEngine
|
||||
open Microsoft.Research.GEC.JSAPI
|
||||
open Microsoft.Research.GEC.TransCrn
|
||||
open Microsoft.Research.CRNEngine
|
||||
open Xunit
|
||||
open FsUnit.Xunit
|
||||
open System.Xml
|
||||
open System.Diagnostics
|
||||
open Parser
|
||||
open FSBOL
|
||||
|
||||
|
||||
|
||||
let databaseText = """i723017,pcr,codes(xylR;0.001)
|
||||
i723024,pcr,codes(phzM;0.001)
|
||||
e0040,pcr,codes(gfp;0.01)
|
||||
c0099,pcr,codes(cviR;0.01)
|
||||
i723025,pcr,codes(phzS;0.001)
|
||||
i723028,pcr,codes(pca;0.001)
|
||||
c0051,pcr,codes(cI;0.01)
|
||||
c0040,pcr,codes(tetR;0.01)
|
||||
c0080,pcr,codes(araC;0.01)
|
||||
c0012,pcr,codes(lacI;0.01)
|
||||
cunknown2,pcr,codes(unknown2;0.001)
|
||||
c0061,pcr,codes(luxI;0.01)
|
||||
c0062,pcr,codes(luxR;0.01)
|
||||
c0079,pcr,codes(lasR;0.01)
|
||||
c0078,pcr,codes(lasI;0.01)
|
||||
cunknown3,pcr,codes(ccdB;0.005)
|
||||
cunknown4,pcr,codes(ccdA;0.1)
|
||||
i723020,prom,pos(toluene::xylR;0.001;0.001;1.0);con(0.0001)
|
||||
r0051,prom,neg(cI;1.0;0.5;0.00005);con(0.12)
|
||||
r0040,prom,neg(tetR;1.0;0.5;0.00005);con(0.09)
|
||||
runknown1,prom,neg(unknown1;1.0;0.005;0.001);con(0.04)
|
||||
r0080,prom,neg(araC;1.0;0.000001;0.0001);pos(araC::arabinose;0.001;0.001;1.0);con(0.1)
|
||||
r0011,prom,neg(lacI;1.0;0.5;0.00005);con(0.1)
|
||||
r0062,prom,pos(lasR::m3OC12HSL;1.0;0.8;0.1);pos(luxR::m3OC6HSL;1.0;0.8;0.1);con(0.01)
|
||||
r0090,prom,pos(lasR::m3OC12HSL;1.0;0.8;0.1);con(0.01)
|
||||
r0099,prom,pos(cviR::m3OC6HSL;1.0;0.8;0.1);con(0.01)
|
||||
b0034,rbs,rate(0.1)
|
||||
b0015,ter
|
||||
cunknown5,pcr,codes(ccdA2;10.0)
|
||||
runknown5,prom,con(10.0)
|
||||
j06504,pcr,codes(mCherry;0.1)
|
||||
prpr,device,components[pr;rbs34;eyfp;ter1;pr;rbs34;ecfp;ter1]
|
||||
drPcat,device,components[pCat;rbs34;luxR;rbs34;lasR;ter1;pLas81;rbs34;eyfp;ter1;plux76;rbs34;ecfp;ter1]
|
||||
drRS100S32,device,components[pTet;rbss100;luxR;ter1;pLac;rbs32;lasR;ter1;pLas81;rbs34;eyfp;ter1;plux76;rbs34;ecfp;ter1]
|
||||
drR33S32,device,components[pTet;rbs33;luxR;ter1;pLac;rbs32;lasR;ter1;pLas81;rbs34;eyfp;ter1;plux76;rbs34;ecfp;ter1]
|
||||
drR33S175,device,components[pTet;rbs33;luxR;ter1;pLac;rbsS175;lasR;ter1;pLas81;rbs34;eyfp;ter1;plux76;rbs34;ecfp;ter1]
|
||||
relayP76LasI,device,components[pLux76;rbs900;lasI;l3s2p21]
|
||||
relayP81LuxI,device,components[pLas81;rbs32;luxI;l3s2p21]
|
||||
pBadYFP,device,components[pBad;rbs34;eyfp;l3s2p21]
|
||||
lactonase,device,components[pBad;rbs34;aiia;l3s2p21]"""
|
||||
|
||||
let reactions = """toluene + xylR ->{1.0} toluene::xylR
|
||||
phzM ~ pca ->{1.0} metPCA
|
||||
phzS ~ metPCA ->{1.0} pyo
|
||||
luxR + m3OC6HSL ->{0.5} luxR::m3OC6HSL
|
||||
lasR + m3OC12HSL ->{0.5} lasR::m3OC12HSL
|
||||
cviR + m3OC6HSL ->{0.5} cviR::m3OC6HSL
|
||||
cviR + m3OC12HSL ->{0.5} cviR::m3OC12HSL
|
||||
luxI ~ ->{1.0} m3OC6HSL
|
||||
lasI ~ ->{1.0} m3OC12HSL
|
||||
ccdA ~ ccdB ->{1.0}
|
||||
c[m3OC6HSL] ->{0.5} m3OC6HSL
|
||||
m3OC6HSL ->{0.5} c[m3OC6HSL]
|
||||
c[m3OC12HSL] ->{0.5} m3OC12HSL
|
||||
m3OC12HSL ->{0.5} c[m3OC12HSL]
|
||||
luxR::m3OC6HSL ->{1.0} luxR + m3OC6HSL
|
||||
cviR::m3OC6HSL ->{1.0} cviR + m3OC6HSL
|
||||
cviR::m3OC12HSL ->{1.0} cviR + m3OC12HSL
|
||||
lasR::m3OC12HSL ->{1.0} lasR + m3OC12HSL
|
||||
ccdA2 ~ ccdB ->{0.00001}
|
||||
lacI + iptg ->{1.0} lacI::iptg
|
||||
tetR + aTc ->{1.0} tetR::aTc"""
|
||||
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - Constant Ratiometric Test")>]
|
||||
let constantRatiometricTest() =
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture <- System.Globalization.CultureInfo.InvariantCulture
|
||||
let (cancel_flag: bool ref) = ref false
|
||||
|
||||
let devices = """device prpr() = { cells() | autofluorescence() | YFP(aYFP) | CFP(aCFP) }
|
||||
device drPcat() = { cells() | autofluorescence() | LuxR(1.0) | LasR(1.0) | YFP(P81,aYFP) | CFP(P76,aCFP) }
|
||||
device drRS100S32() = { cells() | autofluorescence() | LuxR(aRS100) | LasR(aS32) | YFP(P81,aYFP) | CFP(P76,aCFP) }
|
||||
device drR33S32() = { cells() | autofluorescence() | LuxR(aR33) | LasR(aS32) | YFP(P81,aYFP) | CFP(P76,aCFP) }
|
||||
device drR33S175() = { cells() | autofluorescence() | LuxR(aR33) | LasR(aS175) | YFP(P81,aYFP) | CFP(P76,aCFP) }
|
||||
device relayP76LasI() = { cells() | autofluorescence() | LuxR(aR33) | LasR(aS175) | LasI(P76) | YFP(P81,aYFP) | CFP(P76,aCFP) }
|
||||
device relayP81LuxI() = { cells() | autofluorescence() | LuxR(aR33) | LasR(aS175) | LuxI(P81) | YFP(P81,aYFP) | CFP(P76,aCFP) }
|
||||
device pBadYFP() = { cells() | autofluorescence() | YFP(PBad,aYFP) }
|
||||
device lactonase() = { cells() | autofluorescence() | LuxR(aR33) | LasR(aS175) | AiiA(PBad,1.0) | YFP(P81,aYFP) | CFP(P76,aCFP)}
|
||||
"""
|
||||
|
||||
let d = Parser.from_string (Parser.many Program.parse_device) devices
|
||||
let prog = Parser.from_string Program.parse ProgramParserTest.constant_ratiometric
|
||||
|
||||
let basicsolution = GECEngine.solveGEC cancel_flag ProgramParserTest.constant_ratiometric databaseText reactions
|
||||
(*match basicsolution.solution.solution with
|
||||
|Some(_,sol,_,_,_) -> Assert.Equal(4,sol.numSolutions)
|
||||
| _ -> failwith "Error in solving basic program"*)
|
||||
|
||||
()
|
||||
|
||||
[<Fact(DisplayName="GEC - Solution Count Test")>]
|
||||
let gecSolutionCount() =
|
||||
|
||||
let db_from_string (s:string) = Parser.from_string Database.parse s
|
||||
let partstable = db_from_string databaseText
|
||||
|
||||
let reactionListParser = Parser.sepBy Gecreaction.parseReaction Parser.newline
|
||||
let reactiondb_from_string (s:string) = Parser.from_string reactionListParser s
|
||||
|
||||
let createReactionEntry reaction =
|
||||
let (reactionEntry:Gecreaction.t Database.entry) ={value=reaction;enabled=true;comments=""}
|
||||
reactionEntry
|
||||
|
||||
let reactiondb = reactiondb_from_string reactions |> List.map (fun(x) -> createReactionEntry(x))
|
||||
|
||||
let table = {partstable with reactions = reactiondb}
|
||||
|
||||
let (cancel_flag: bool ref) = ref false
|
||||
|
||||
//basic
|
||||
//repressilator
|
||||
//repressilatorSimilar
|
||||
//repressilatorModules
|
||||
//repressilatorModulesSimilar
|
||||
//receiverDevice
|
||||
//predatorPrey
|
||||
//bandDetector
|
||||
|
||||
let basicsolution = GECEngine.solveGEC cancel_flag ProgramParserTest.basic_program databaseText reactions
|
||||
match basicsolution.solution.solution with
|
||||
|Some(_,sol,_,_,_) -> Assert.Equal(4,sol.numSolutions)
|
||||
| _ -> failwith "Error in solving basic program"
|
||||
|
||||
|
||||
let repressilatorsolution = GECEngine.solveGEC cancel_flag ProgramParserTest.repressilator databaseText reactions
|
||||
match repressilatorsolution.solution.solution with
|
||||
| Some(_,sol,_,_,_) -> Assert.Equal(24,sol.numSolutions)
|
||||
| _ -> failwith "Error in solving repressilator program"
|
||||
|
||||
let repressilatorSimilarsolution = GECEngine.solveGEC cancel_flag ProgramParserTest.repressilator_similar databaseText reactions
|
||||
match repressilatorSimilarsolution.solution.solution with
|
||||
| Some(_,sol,_,_,_) -> Assert.Equal(6,sol.numSolutions)
|
||||
| _ -> failwith "Error in solving repressilator Similar program"
|
||||
|
||||
let repressilatorModulessolution = GECEngine.solveGEC cancel_flag ProgramParserTest.repressilator_modules databaseText reactions
|
||||
match repressilatorModulessolution.solution.solution with
|
||||
| Some(_,sol,_,_,_) -> Assert.Equal(24,sol.numSolutions)
|
||||
| _ -> failwith "Error in solving repressilator Modules program"
|
||||
|
||||
let repressilatorModulesSimilarsolution = GECEngine.solveGEC cancel_flag ProgramParserTest.repressilator_similar databaseText reactions
|
||||
match repressilatorModulesSimilarsolution.solution.solution with
|
||||
| Some(_,sol,_,_,_) -> Assert.Equal(6,sol.numSolutions)
|
||||
| _ -> failwith "Error in solving repressilator Modules similar program"
|
||||
|
||||
let receiverDevicesolution = GECEngine.solveGEC cancel_flag ProgramParserTest.reciever_device databaseText reactions
|
||||
match receiverDevicesolution.solution.solution with
|
||||
| Some(_,sol,_,_,_) -> Assert.Equal(34,sol.numSolutions)
|
||||
| _ -> failwith "Error in solving receiver Device program"
|
||||
|
||||
let predatorPreysolution = GECEngine.solveGEC cancel_flag ProgramParserTest.predator_prey databaseText reactions
|
||||
match predatorPreysolution.solution.solution with
|
||||
| Some(_,sol,_,_,_) -> Assert.Equal(16,sol.numSolutions)
|
||||
| _ -> failwith "Error in solving predator-Prey program"
|
||||
|
||||
let bandDetectorsolution = GECEngine.solveGEC cancel_flag ProgramParserTest.band_detector databaseText reactions
|
||||
match bandDetectorsolution.solution.solution with
|
||||
| Some(_,sol,_,_,_) -> Assert.Equal(1,sol.numSolutions)
|
||||
| _ -> failwith "Error in solving band Detector program"
|
||||
|
||||
Debug.WriteLine("End of test")
|
||||
|
||||
|
||||
|
||||
[<Fact(DisplayName="GEC - Abstract CRN Template Test JSAPI")>]
|
||||
let ``CrnTemplateTest_JSAPI_AbstractCRN``() =
|
||||
let prog = ProgramParserTest.basic_program
|
||||
match Microsoft.Research.GEC.JSAPI.compile prog databaseText reactions with
|
||||
| (ClassicGEC solve_result) as sr ->
|
||||
let crngec = solve_result.model.nodes |> Map.toSeq |> Seq.head |> snd
|
||||
(*let crngec =
|
||||
match solve_result.model with
|
||||
| CRNgui(x) -> x*)
|
||||
|
||||
let validateReaction (r:Reaction<string,string,string>) =
|
||||
let validateSpecies sp = List.exists (fun (i:Initial<string,string>) -> i.species = sp) crngec.top.initials |> Assert.True
|
||||
List.iter validateSpecies (Mset.elements r.reactants)
|
||||
List.iter validateSpecies (Mset.elements r.products)
|
||||
List.iter validateSpecies (Mset.elements r.catalysts)
|
||||
List.iter validateReaction crngec.top.reactions
|
||||
let crn = crngec.top.to_crn()
|
||||
let solution_result = Microsoft.Research.GEC.JSAPI.get_solution sr 1
|
||||
let crn = crngec.top.to_crn()
|
||||
Debug.WriteLine("End of test")
|
||||
| LogicGEC _ -> failwith "Unexpected Logic GEC program."
|
|
@ -0,0 +1,227 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29709.97
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSAGL_JS", "..\HTML5SharedGUI\MSAGL_JS\MSAGL_JS.csproj", "{2F3B8603-CFF1-4946-B242-6F848801B49A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeEditor", "..\HTML5SharedGUI\CodeEditor\CodeEditor.csproj", "{B234C1D7-96F4-40A2-A323-3B18646BF95C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CRNComponent", "..\HTML5SharedGUI\CRNComponent\CRNComponent.csproj", "{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InferenceViewer", "..\HTML5SharedGUI\InferenceViewer\InferenceViewer.csproj", "{179FDF3E-67B8-4E2F-9089-650BB1319AF2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimulationViewer", "..\HTML5SharedGUI\SimulationViewer\SimulationViewer.csproj", "{0ECCE305-85C0-403F-A980-EEB9379BD5A4}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CRNEngineJS", "..\CRNEngine\CRNEngineJS\CRNEngineJS.fsproj", "{836AF075-6448-4CD9-8020-434B963FF5E2}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Filzbach.FSharp.JS", "..\Filzbach.FSharp.JS\Filzbach.FSharp.JS.fsproj", "{4DF94589-6870-4A4C-BFAE-5825EF4634E7}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ParserCombinatorsJS", "..\ParserCombinators\ParserCombinatorsJS\ParserCombinatorsJS.fsproj", "{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CRNEngineTSWrapper", "..\CRNEngine\CRNEngineTSWrapper\CRNEngineTSWrapper.csproj", "{FB1F1936-AC22-41B4-AF2F-E20A486E3416}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2} = {836AF075-6448-4CD9-8020-434B963FF5E2}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ReactionDiffusionJS", "..\PDESolvers\ReactionDiffusionJS\ReactionDiffusionJS.fsproj", "{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ClassicGECJS", "ClassicGECJS\ClassicGECJS.fsproj", "{512586EF-5357-49E1-A5A0-71B4389589A2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassicGECTSWrapper", "ClassicGECTSWrapper\ClassicGECTSWrapper.csproj", "{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416} = {FB1F1936-AC22-41B4-AF2F-E20A486E3416}
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2} = {836AF075-6448-4CD9-8020-434B963FF5E2}
|
||||
{512586EF-5357-49E1-A5A0-71B4389589A2} = {512586EF-5357-49E1-A5A0-71B4389589A2}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassicGECHTML5", "ClassicGECHTML5\ClassicGECHTML5.csproj", "{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1} = {A7A666E0-2ADE-4496-A84A-267BBE68B5A1}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassicGECTSWrapper_Samples", "ClassicGECTSWrapper_Samples\ClassicGECTSWrapper_Samples.csproj", "{2574F603-4B6C-4A30-BFDD-E3BC09EEDFDF}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HTML5CRN_Lib", "..\HTML5SharedGUI\HTML5CRN_Lib\HTML5CRN_Lib.csproj", "{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSBOLWrapperJS", "..\FSBOLWrapper\FSBOLWrapperJS\FSBOLWrapperJS.fsproj", "{4A5FC975-B3C1-4C89-967A-A146DED20962}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ClassicGECBrowserIntegrationTests", "ClassicGECBrowserIntegrationTests\ClassicGECBrowserIntegrationTests.fsproj", "{8B8E819B-1BA1-4559-BE26-FF0215614921}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenericComponents", "..\HTML5SharedGUI\GenericComponents\GenericComponents.csproj", "{4CD88A62-7023-4216-B37F-02FD6AF0595F}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CRNIntegrationTestLib", "..\CRNEngine\CRNIntegrationTestLib\CRNIntegrationTestLib.fsproj", "{37984538-A573-4A89-9EA7-AEAF95D2806A}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "RulesDSDJS", "..\RulesDSD\RulesDSDJS\RulesDSDJS.fsproj", "{1203D047-DFC7-4F75-B232-F5F1479DF687}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Release|x64.Build.0 = Release|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Release|x64.Build.0 = Release|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Release|x64.Build.0 = Release|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Release|x64.Build.0 = Release|Any CPU
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2}.Release|x64.Build.0 = Release|Any CPU
|
||||
{4DF94589-6870-4A4C-BFAE-5825EF4634E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4DF94589-6870-4A4C-BFAE-5825EF4634E7}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4DF94589-6870-4A4C-BFAE-5825EF4634E7}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{4DF94589-6870-4A4C-BFAE-5825EF4634E7}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{4DF94589-6870-4A4C-BFAE-5825EF4634E7}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4DF94589-6870-4A4C-BFAE-5825EF4634E7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4DF94589-6870-4A4C-BFAE-5825EF4634E7}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4DF94589-6870-4A4C-BFAE-5825EF4634E7}.Release|x64.Build.0 = Release|Any CPU
|
||||
{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}.Release|x64.Build.0 = Release|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Release|x64.Build.0 = Release|Any CPU
|
||||
{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}.Release|x64.Build.0 = Release|Any CPU
|
||||
{512586EF-5357-49E1-A5A0-71B4389589A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{512586EF-5357-49E1-A5A0-71B4389589A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{512586EF-5357-49E1-A5A0-71B4389589A2}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{512586EF-5357-49E1-A5A0-71B4389589A2}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{512586EF-5357-49E1-A5A0-71B4389589A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{512586EF-5357-49E1-A5A0-71B4389589A2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{512586EF-5357-49E1-A5A0-71B4389589A2}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{512586EF-5357-49E1-A5A0-71B4389589A2}.Release|x64.Build.0 = Release|Any CPU
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}.Release|x64.Build.0 = Release|Any CPU
|
||||
{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}.Release|x64.Build.0 = Release|Any CPU
|
||||
{2574F603-4B6C-4A30-BFDD-E3BC09EEDFDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{2574F603-4B6C-4A30-BFDD-E3BC09EEDFDF}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{2574F603-4B6C-4A30-BFDD-E3BC09EEDFDF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2574F603-4B6C-4A30-BFDD-E3BC09EEDFDF}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{4A5FC975-B3C1-4C89-967A-A146DED20962}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4A5FC975-B3C1-4C89-967A-A146DED20962}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4A5FC975-B3C1-4C89-967A-A146DED20962}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{4A5FC975-B3C1-4C89-967A-A146DED20962}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{4A5FC975-B3C1-4C89-967A-A146DED20962}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4A5FC975-B3C1-4C89-967A-A146DED20962}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4A5FC975-B3C1-4C89-967A-A146DED20962}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4A5FC975-B3C1-4C89-967A-A146DED20962}.Release|x64.Build.0 = Release|Any CPU
|
||||
{8B8E819B-1BA1-4559-BE26-FF0215614921}.Debug|Any CPU.ActiveCfg = Debug|x64
|
||||
{8B8E819B-1BA1-4559-BE26-FF0215614921}.Debug|Any CPU.Build.0 = Debug|x64
|
||||
{8B8E819B-1BA1-4559-BE26-FF0215614921}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{8B8E819B-1BA1-4559-BE26-FF0215614921}.Debug|x64.Build.0 = Debug|x64
|
||||
{8B8E819B-1BA1-4559-BE26-FF0215614921}.Release|Any CPU.ActiveCfg = Release|x64
|
||||
{8B8E819B-1BA1-4559-BE26-FF0215614921}.Release|x64.ActiveCfg = Release|x64
|
||||
{8B8E819B-1BA1-4559-BE26-FF0215614921}.Release|x64.Build.0 = Release|x64
|
||||
{4CD88A62-7023-4216-B37F-02FD6AF0595F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4CD88A62-7023-4216-B37F-02FD6AF0595F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4CD88A62-7023-4216-B37F-02FD6AF0595F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{4CD88A62-7023-4216-B37F-02FD6AF0595F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{4CD88A62-7023-4216-B37F-02FD6AF0595F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4CD88A62-7023-4216-B37F-02FD6AF0595F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4CD88A62-7023-4216-B37F-02FD6AF0595F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4CD88A62-7023-4216-B37F-02FD6AF0595F}.Release|x64.Build.0 = Release|Any CPU
|
||||
{37984538-A573-4A89-9EA7-AEAF95D2806A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{37984538-A573-4A89-9EA7-AEAF95D2806A}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{37984538-A573-4A89-9EA7-AEAF95D2806A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{37984538-A573-4A89-9EA7-AEAF95D2806A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{37984538-A573-4A89-9EA7-AEAF95D2806A}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{37984538-A573-4A89-9EA7-AEAF95D2806A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{37984538-A573-4A89-9EA7-AEAF95D2806A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{37984538-A573-4A89-9EA7-AEAF95D2806A}.Release|x64.Build.0 = Release|Any CPU
|
||||
{1203D047-DFC7-4F75-B232-F5F1479DF687}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1203D047-DFC7-4F75-B232-F5F1479DF687}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1203D047-DFC7-4F75-B232-F5F1479DF687}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{1203D047-DFC7-4F75-B232-F5F1479DF687}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{1203D047-DFC7-4F75-B232-F5F1479DF687}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1203D047-DFC7-4F75-B232-F5F1479DF687}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{1203D047-DFC7-4F75-B232-F5F1479DF687}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{1203D047-DFC7-4F75-B232-F5F1479DF687}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {B7CBE076-B324-473D-9A42-7AE164D8F1E0}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,23 @@
|
|||
Scripts/**/*.js
|
||||
!Scripts/VISBOL/visbol/**/*.js
|
||||
!Scripts/VISBOL/pathseg.js
|
||||
!Scripts/VISBOL/visbolbundle.js
|
||||
Scripts/**/*.js.map
|
||||
Scripts/**/*.d.ts
|
||||
!Scripts/typings/**/*.d.ts
|
||||
Tests/**/*.js
|
||||
Tests/**/*.js.map
|
||||
Tests/**/*.d.ts
|
||||
|
||||
#residual files from before webpack
|
||||
Scripts/ClassicGEC
|
||||
Scripts/CodeEditor
|
||||
Scripts/CRN
|
||||
Scripts/CrnApp
|
||||
Scripts/CRNEngine
|
||||
Scripts/IDD
|
||||
Scripts/InferenceViewer
|
||||
Scripts/KnockoutGrid
|
||||
Scripts/MSAGL
|
||||
Scripts/SimulationViewer
|
||||
vs
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"AppBootstrap.js","sourceRoot":"","sources":["AppBootstrap.ts"],"names":[],"mappings":";AAAA,OAAO,CAAC,CAAC,UAAU,CAAC,EAAE;IAClB,OAAO,CAAC,CAAC,+BAA+B,CAAC,EAAE;QACvC,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,EAAE;QAC5B,CAAC,CAAA;IACL,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
<!-- Prevents CS5001 -->
|
||||
<OutputType>Library</OutputType>
|
||||
<YarnBuildCommand>--mutex file install</YarnBuildCommand>
|
||||
<NodeJsExecutablePath>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\packages\javascriptbuild\Node.js.redist\tools\win-x64\node.exe'))</NodeJsExecutablePath>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\HTML5SharedGUI\CodeEditor\CodeEditor.csproj"/>
|
||||
<ProjectReference Include="..\..\HTML5SharedGUI\CRNComponent\CRNComponent.csproj"/>
|
||||
<ProjectReference Include="..\..\HTML5SharedGUI\HTML5CRN_Lib\HTML5CRN_Lib.csproj"/>
|
||||
<ProjectReference Include="..\..\HTML5SharedGUI\InferenceViewer\InferenceViewer.csproj"/>
|
||||
<ProjectReference Include="..\..\HTML5SharedGUI\MSAGL_JS\MSAGL_JS.csproj"/>
|
||||
<ProjectReference Include="..\..\HTML5SharedGUI\SimulationViewer\SimulationViewer.csproj"/>
|
||||
<ProjectReference Include="..\ClassicGECTSWrapper\ClassicGECTSWrapper.csproj"/>
|
||||
</ItemGroup>
|
||||
<Target Name="Webpack" AfterTargets="PostBuildEvent">
|
||||
<!-- This runs Webpack. -->
|
||||
<PropertyGroup>
|
||||
<NodeJsExecutablePath>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\packages\javascriptbuild\Node.js.redist\tools\win-x64\node.exe'))</NodeJsExecutablePath>
|
||||
</PropertyGroup>
|
||||
<Exec Command="$(NodeJsExecutablePath) ..\..\node_modules\webpack\bin\webpack.js --env.mode=production" Condition="'$(Configuration)' == 'Release'" />
|
||||
<Exec Command="$(NodeJsExecutablePath) ..\..\node_modules\webpack\bin\webpack.js --env.mode=development" Condition="'$(Configuration)' == 'Debug'" />
|
||||
</Target>
|
||||
<PropertyGroup>
|
||||
<!-- This means "you must run the CollectWebpackOutput target before the collecting files step can be considered done". -->
|
||||
<CopyAllFilesToSingleFolderForPackageDependsOn>
|
||||
$(CopyAllFilesToSingleFolderForPackageDependsOn);
|
||||
CollectWebpackOutput;
|
||||
</CopyAllFilesToSingleFolderForPackageDependsOn>
|
||||
<CopyAllFilesToSingleFolderForMsdeployDependsOn>
|
||||
$(CopyAllFilesToSingleFolderForMsdeployDependsOn);
|
||||
CollectWebpackOutput;
|
||||
</CopyAllFilesToSingleFolderForMsdeployDependsOn>
|
||||
</PropertyGroup>
|
||||
<Target Name="CollectWebpackOutput">
|
||||
<!-- This means "add everything in the dist folder to the list of files for packaging". -->
|
||||
<ItemGroup>
|
||||
<_CustomFiles Include="dist\**\*" />
|
||||
<FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
|
||||
<DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension)</DestinationRelativePath>
|
||||
</FilesForPackagingFromProject>
|
||||
</ItemGroup>
|
||||
<Message Text="CollectWebpackOutput list: %(_CustomFiles.Identity)" />
|
||||
</Target>
|
||||
<Import Project="..\..\.paket\Paket.Restore.targets" />
|
||||
</Project>
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"Config.js","sourceRoot":"","sources":["Config.ts"],"names":[],"mappings":";AAAA,OAAO,CAAC,MAAM,CAAC;IACX,KAAK,EAAE;QACH,QAAQ,EAAE,kBAAkB;QAC5B,kBAAkB,EAAE,0BAA0B;QAC9C,GAAG,EAAE,0BAA0B;QAC/B,QAAQ,EAAE,gBAAgB;QAC1B,IAAI,EAAE,gBAAgB;QACtB,QAAQ,EAAE,cAAc;QACxB,aAAa,EAAE,mBAAmB;QAClC,SAAS,EAAE,aAAa;QACxB,WAAW,EAAE,mBAAmB;QAChC,UAAU,EAAE,mBAAmB;QAC/B,KAAK,EAAE,aAAa;QACpB,mBAAmB,EAAE,2BAA2B;QAChD,UAAU,EAAE,mBAAmB;QAC/B,YAAY,EAAE,iCAAiC;QAC/C,iBAAiB;QACjB,IAAI,EAAE,cAAc;QACpB,0BAA0B;QAC1B,WAAW,EAAE,mBAAmB;QAChC,WAAW,EAAE,mBAAmB;QAChC,UAAU,EAAE,6BAA6B;QACzC,KAAK,EAAE,eAAe;QAEtB,OAAO,EAAE,wBAAwB;QACjC,MAAM,EAAE,6BAA6B;KACxC;IACD,IAAI,EAAE;QACF,QAAQ,EAAE,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE;QAC/B,QAAQ,EAAE;YACN,OAAO,EAAE,GAAG;SACf;QACD,UAAU,EAAE,EAAE,IAAI,EAAE,CAAC,QAAQ,CAAC,EAAE;QAChC,kBAAkB,EAAE,EAAE,IAAI,EAAE,CAAC,UAAU,CAAC,EAAE;KAC7C;IACD,WAAW,EAAE,EAAE;CAClB,CAAC,CAAC"}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -0,0 +1,20 @@
|
|||
import Editor from '../GECCodeEditor';
|
||||
import * as ModificationIndicator from '../../../../HTML5SharedGUI/GenericComponents/Scripts/ModificationIndicators';
|
||||
import * as Features from '../Features';
|
||||
import * as KOCodeEditor from '../../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/KnockoutBasedCodeEditor';
|
||||
import * as GenericParseOperation from '../../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/GenericCodeParsing';
|
||||
import { INamedMonarchLanguage } from '../../../../HTML5SharedGUI/CodeEditor/Scripts/CodeEditor';
|
||||
import * as ko from 'knockout';
|
||||
|
||||
export class CodeEditor extends KOCodeEditor.KOCodeEditor<{}> implements GenericParseOperation.ICodeSource<{}>, GenericParseOperation.IErrorDisplay, Features.IUIAutoBindable {
|
||||
constructor(private language: INamedMonarchLanguage, private examples: Array<ExamplesGroup>, modifIndicator: ModificationIndicator.IModificationIndicator, options: {}) {
|
||||
super(modifIndicator, options);
|
||||
}
|
||||
|
||||
//Features.IUIAutoBindable implementation
|
||||
public AutoBind() {
|
||||
//CodeEditor create
|
||||
var codeEditor = new Editor(this.language, this.examples);
|
||||
ko.applyBindings(this.vm, document.getElementById('gecCode'));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
import Editor from '../PartsCodeEditor';
|
||||
import * as ModificationIndicator from '../../../../HTML5SharedGUI/GenericComponents/Scripts/ModificationIndicators';
|
||||
import * as Features from '../Features';
|
||||
import * as KOCodeEditor from '../../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/KnockoutBasedCodeEditor';
|
||||
import * as GenericParseOperation from '../../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/GenericCodeParsing';
|
||||
import { INamedMonarchLanguage } from '../../../../HTML5SharedGUI/CodeEditor/Scripts/CodeEditor';
|
||||
import * as ko from 'knockout';
|
||||
|
||||
export class CodeEditor extends KOCodeEditor.KOCodeEditor<{}> implements GenericParseOperation.ICodeSource<{}>, GenericParseOperation.IErrorDisplay, Features.IUIAutoBindable {
|
||||
constructor(private language: INamedMonarchLanguage, private examples: Array<ExamplesGroup>, modifIndicator: ModificationIndicator.IModificationIndicator, options: {}) {
|
||||
super(modifIndicator, options);
|
||||
}
|
||||
|
||||
//Features.IUIAutoBindable implementation
|
||||
public AutoBind() {
|
||||
//CodeEditor create
|
||||
var codeEditor = new Editor(this.language, this.examples);
|
||||
ko.applyBindings(this.vm, document.getElementById('gecParts'));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
import Editor from '../ReactionsCodeEditor';
|
||||
import * as ModificationIndicator from '../../../../HTML5SharedGUI/GenericComponents/Scripts/ModificationIndicators';
|
||||
import * as Features from '../Features';
|
||||
import * as KOCodeEditor from '../../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/KnockoutBasedCodeEditor';
|
||||
import * as GenericParseOperation from '../../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/GenericCodeParsing';
|
||||
import { INamedMonarchLanguage } from '../../../../HTML5SharedGUI/CodeEditor/Scripts/CodeEditor';
|
||||
import * as ko from 'knockout';
|
||||
|
||||
export class CodeEditor extends KOCodeEditor.KOCodeEditor<{}> implements GenericParseOperation.ICodeSource<{}>, GenericParseOperation.IErrorDisplay, Features.IUIAutoBindable {
|
||||
constructor(private language: INamedMonarchLanguage, private examples: Array<ExamplesGroup>, modifIndicator: ModificationIndicator.IModificationIndicator, options: {}) {
|
||||
super(modifIndicator, options);
|
||||
}
|
||||
|
||||
//Features.IUIAutoBindable implementation
|
||||
public AutoBind() {
|
||||
//CodeEditor create
|
||||
var codeEditor = new Editor(this.language, this.examples);
|
||||
ko.applyBindings(this.vm, document.getElementById('gecReactions'));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,673 @@
|
|||
/*import { ServiceWorker } from './Scripts/ServiceWorker';
|
||||
let serviceWorker = new ServiceWorker();*/
|
||||
|
||||
import "jqueryui";
|
||||
import * as $ from 'jquery';
|
||||
import "../Styles/App.css";
|
||||
import "../../../node_modules/jquery-ui/themes/base/all.css"
|
||||
import "../../../node_modules/katex/dist/katex.min.css"
|
||||
import "../../../HTML5SharedGUI/KnockoutGrid/table.css"
|
||||
// We override IDD styles with General.css, so we require IDD styles to be loaded prior to General.css.
|
||||
import "../../../node_modules/interactive-data-display/dist/idd.css"
|
||||
import "../../../HTML5SharedGUI/CodeEditor/Styles/codepad.css"
|
||||
import "../../../HTML5SharedGUI/SimulationViewer/Styles/simulation.css"
|
||||
import "../../../HTML5SharedGUI/InferenceViewer/Styles/inference.css"
|
||||
import "../../../HTML5SharedGUI/CRNComponent/Styles/crn.css"
|
||||
import "idd";
|
||||
declare var InteractiveDataDisplay: any;
|
||||
import * as visbol from '../../../node_modules/visbol/index.js';
|
||||
import * as visbolfont from '../../../node_modules/visbol/font/sbolv/main.js';
|
||||
import * as Utils from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Utils';
|
||||
import "pathseg";
|
||||
import { jsbolToObject } from "../../ClassicGECTSWrapper/Scripts/JSBOL";
|
||||
|
||||
// import convertJsonToXml from './json2xml';
|
||||
import GECLanguage from './GECLang';
|
||||
import PartsLanguage from './PartsLang';
|
||||
import ReactionsLanguage from './ReactionsLang';
|
||||
import Options from '../../../HTML5SharedGUI/GenericComponents/Scripts/Options';
|
||||
import "../../../HTML5SharedGUI/GenericComponents/Scripts/Dropdown";
|
||||
import * as CodeEditor from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/KnockoutBasedCRNCodeEditor';
|
||||
import { CodeEditor as GECCodeEditor } from './Adapters/GECCodeSource';
|
||||
import { CodeEditor as PartsDBCodeEditor } from './Adapters/PartsDBCodeSource';
|
||||
import { CodeEditor as ReactionsDBCodeEditor } from './Adapters/ReactionsDBCodeSource';
|
||||
import * as CodeStorage from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/CodeEditorStorageDecorator';
|
||||
import * as CodeParser from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/ModellingEngineCRNParser';
|
||||
import * as CrnEditor from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/KnockoutBasedCRNViewer';
|
||||
import * as CrnExport from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/KnockoutBasedCRNExport';
|
||||
import * as SimRunner from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/ModellingEngineSimulationRunner';
|
||||
import * as SimRunnerSpat1D from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/ModellingEngineSpatial1DSimulationRunner';
|
||||
import * as SimRunnerSpat2D from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/ModellingEngineSpatial2DSimulationRunner';
|
||||
import * as InferenceRunner from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/ModellingEngineInferenceRunner';
|
||||
import { Adapter as SSARunner } from "../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/ModellingEngineSSA";
|
||||
import { Viewer as SSASummaryViewer } from "../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/KnockoutBasedSSASummaryViewer";
|
||||
import * as SimViewer from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/SimViewerAdapter';
|
||||
import { StoredSettings as SpatialViewerSettings } from "../../../HTML5SharedGUI/SimulationViewer/Scripts/SpatialViewerSettings";
|
||||
import SpatialViewer1D from "../../../HTML5SharedGUI/SimulationViewer/Scripts/Spatial1DViewer";
|
||||
import SpatialViewer2D from "../../../HTML5SharedGUI/SimulationViewer/Scripts/Spatial2DViewer";
|
||||
import * as HintScreen from '../../../HTML5SharedGUI/GenericComponents/Scripts/HintScreen';
|
||||
import * as ModificationIndicator from '../../../HTML5SharedGUI/GenericComponents/Scripts/ModificationIndicators';
|
||||
import * as SVF from '../../../HTML5SharedGUI/SimulationViewer/Scripts/SimulationViewerFramework';
|
||||
import CRNEngine from '../../../CRNEngine/CRNEngineTSWrapper/Scripts/CRNEngine';
|
||||
import ClassicGEC from '../../ClassicGECTSWrapper/Scripts/ClassicGEC';
|
||||
import * as InferenceParametersViewer from '../../../HTML5SharedGUI/InferenceViewer/Scripts/InferredParametersViewer';
|
||||
import * as InferenceModelDynamicsViewer from '../../../HTML5SharedGUI/InferenceViewer/Scripts/ModelDataDynamics';
|
||||
import * as InferencePosteriorViewer from '../../../HTML5SharedGUI/InferenceViewer/Scripts/PosteriorViewer';
|
||||
import * as InferenceSummary from '../../../HTML5SharedGUI/InferenceViewer/Scripts/InferenceSummary';
|
||||
import * as InferenceCompositeViewer from '../../../HTML5SharedGUI/InferenceViewer/Scripts/CompositeViewer';
|
||||
import { Viewer as SSATextViewer } from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Components/SSATextViewer';
|
||||
import { Viewer as SSACompoundViewer } from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Components/SSACompoundViewer';
|
||||
import * as SumToVum from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/SumToVum';
|
||||
import { Viewer as PMViewer } from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/ProbabilityMapsAdapter';
|
||||
import SSAGraphViewer from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/SSAGraphAdapter';
|
||||
import CRNCompoundViewer from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Components/CRNCompoundViewer';
|
||||
import CRNGraphViewer from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/CRNGraphAdapter';
|
||||
import * as LongOperations from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/LongOperations';
|
||||
import * as LongOperationsKO from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/LongOperationsKO';
|
||||
import * as ParseOperation from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/ParseCodeFillCRN';
|
||||
import * as ExportOperation from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/ModellingEngineExporter';
|
||||
import * as GecParseOperation from './Operations/GecParseOperation';
|
||||
import * as GetSolutionOperation from './Operations/GetSolutionOperation';
|
||||
import * as SimulateOperation from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/SimulateParsedCRN';
|
||||
import * as Spatial1DSimulation from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/Spatial1DSimulation';
|
||||
import * as Spatial2DSimulation from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/Spatial2DSimulation';
|
||||
import { SimulationType, Operation as DispatchedSimulateOperation } from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/AutoChoiceSimulation';
|
||||
import * as InferOperation from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/Inference';
|
||||
import * as TabSelectOperation from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/TabSelect';
|
||||
import { Operation as SSAOperation } from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/StateSpaceAnalysis';
|
||||
import { Operation as SynthesisOperation } from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/Synthesis';
|
||||
import CRNSelector from '../../../HTML5SharedGUI/CRNComponent/Scripts/CRNSelector';
|
||||
import InferenceGraphAdapter from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/InferenceGraphAdapter';
|
||||
import SynthesisAdapter from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/ModellingEngineSynthesis';
|
||||
import { SynthesisViewer } from '../../../HTML5SharedGUI/SimulationViewer/Scripts/SynthesisViewer';
|
||||
|
||||
import { KnockoutBasedDataSetsList as DataSetList } from '../../../HTML5SharedGUI/CRNComponent/Scripts/crnDataSets';
|
||||
import { KnockoutGridDataSetViewer as DataSetViewer } from '../../../HTML5SharedGUI/CRNComponent/Scripts/crnDataSets';
|
||||
import { ObservationsSource } from '../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Adapters/MultipleDataSetObsSource';
|
||||
import { MemoryDataSetStorage, LocalStorageDataSetStorage, IndexedDBDataSetStorage } from '../../../HTML5SharedGUI/CRNComponent/Scripts/DataSetStorage';
|
||||
|
||||
import * as GECInterfaces from '../../ClassicGECTSWrapper/Scripts/Interfaces';
|
||||
import IDDTabs from "../../../HTML5SharedGUI/GenericComponents/Scripts/IDDTabs";
|
||||
|
||||
var examplesPath = "./Examples/GECModels/";
|
||||
var examples: ExamplesGroup[] = [
|
||||
{
|
||||
// NOTE: the URLs here are supposed to be resolved relativly to the HTML page that runs the script. Usually it is ($app_root)/index.html.
|
||||
// As the path to the code is $app_root/CodeExamples/* the relatice url here is CodeExamples/*
|
||||
Name: "Examples",
|
||||
Correspondence: {
|
||||
"Basic": examplesPath + "basic.txt",
|
||||
"Repressilator Similar": examplesPath + "repressilator_similar.txt",
|
||||
"Repressilator Modules": examplesPath + "repressilator_modules.txt",
|
||||
"Repressilator Modules Similar": examplesPath + "repressilator_modules_similar.txt",
|
||||
"Receiver Device": examplesPath + "receiver_device.txt",
|
||||
"Predator-Prey": examplesPath + "predator_prey.txt",
|
||||
"Band Detector": examplesPath + "band_detector.txt"
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
//Phase 1. Creating the functional components
|
||||
let dataSetStorage = (() => {
|
||||
var ret: IndexedDBDataSetStorage | MemoryDataSetStorage = null;
|
||||
if (window.indexedDB !== undefined)
|
||||
ret = new IndexedDBDataSetStorage("CRNdb");
|
||||
else
|
||||
ret = new MemoryDataSetStorage(); //e.g. Edge InPrivate
|
||||
return ret;
|
||||
})();
|
||||
var dataSetList = new DataSetList(dataSetStorage);
|
||||
var longOperationsManager = new LongOperationsKO.LongOperationsKO();
|
||||
var gecCodeModificationIndicator = new ModificationIndicator.TabSuffixIndicator($(".j-gec-tab-header"));
|
||||
var codeModificationIndicator = new ModificationIndicator.TabSuffixIndicator($(".j-code-tab-header"));
|
||||
var crnModificationIndicator = new ModificationIndicator.TabSuffixIndicator($(".j-crn-tab-header"));
|
||||
var classicGEC = new ClassicGEC(Options.Server());
|
||||
var gecCodeSource = new GECCodeEditor(<any>GECLanguage, examples, gecCodeModificationIndicator, {});
|
||||
var partsDBCodeSource = new PartsDBCodeEditor(<any>PartsLanguage, [], gecCodeModificationIndicator, {});
|
||||
var reactionsDBCodeSource = new ReactionsDBCodeEditor(<any>ReactionsLanguage, [], gecCodeModificationIndicator, {});
|
||||
var codeSource = new CodeEditor.KOCRNCodeEditor(codeModificationIndicator);
|
||||
var codeStorage = new CodeStorage.CodeEditorStorageDecorator(codeSource, "CRN");
|
||||
var gecCodeStorage = new CodeStorage.CodeEditorStorageDecorator(<any>gecCodeSource, "GEC");
|
||||
var partsCodeStorage = new CodeStorage.CodeEditorStorageDecorator(<any>partsDBCodeSource, "GECParts");
|
||||
var reactionsCodeStorage = new CodeStorage.CodeEditorStorageDecorator(<any>reactionsDBCodeSource, "GECReactions");
|
||||
var crnExport = new CrnExport.CRNExport(classicGEC);
|
||||
var options = new Options(classicGEC);
|
||||
var codeParser = new CodeParser.Parser(classicGEC);
|
||||
var crnEditor = new CrnEditor.CRNEditor<void>(dataSetList, crnModificationIndicator);
|
||||
var currentlySelectedDataSetSource = new ObservationsSource(dataSetStorage);
|
||||
var infRunner = new InferenceRunner.Adapter(classicGEC, currentlySelectedDataSetSource);
|
||||
var ssaRunner = new SSARunner(classicGEC);
|
||||
var ssaSummaryViewer = new SSASummaryViewer();
|
||||
var crnVM = crnEditor.GetVM();
|
||||
var inferenceGraphViewer = new InferenceGraphAdapter<void>(crnVM);
|
||||
var ssaGraphViewer = new SSAGraphViewer(crnVM);
|
||||
var crnGraphViewer = new CRNGraphViewer<void>(crnVM);
|
||||
var simViewer = new SimViewer.Viewer();
|
||||
var spatialViewerSettings = new SpatialViewerSettings("black,green");
|
||||
var spatialViewer1D = new SpatialViewer1D(spatialViewerSettings);
|
||||
var spatialViewer2D = new SpatialViewer2D(spatialViewerSettings);
|
||||
var dataSetViewer = new DataSetViewer();
|
||||
var probabilityMapsViewer = new PMViewer(classicGEC, spatialViewerSettings);
|
||||
var simRunner = new SimRunner.SimulationRunner(classicGEC, currentlySelectedDataSetSource);
|
||||
var spat1DSimRunner = new SimRunnerSpat1D.SimulationRunner(classicGEC);
|
||||
var spat2DSimRunner = new SimRunnerSpat2D.SimulationRunner(classicGEC);
|
||||
var crnSelector = new CRNSelector(crnVM);
|
||||
var synthesisAdapter = new SynthesisAdapter(classicGEC);
|
||||
|
||||
//var crnSettings = new CRNSettingsVM();
|
||||
//inference viewers:
|
||||
var infParamViewer = new InferenceParametersViewer.InferredParametersViewer(crnSelector);
|
||||
var infDynamicsViewer = new InferenceModelDynamicsViewer.ModelDataDynamics(crnSelector);
|
||||
var infPosteriorViewer = new InferencePosteriorViewer.PosteriorViewer(crnSelector);
|
||||
var infSummary = new InferenceSummary.InferenceSummary(crnSelector);
|
||||
var infViewer = new InferenceCompositeViewer.Viewer([infParamViewer, infDynamicsViewer, infSummary, infPosteriorViewer]);
|
||||
var synthesisViewer = new SynthesisViewer(classicGEC);
|
||||
|
||||
//SSA viewers
|
||||
var ssaTextViewer = new SSATextViewer();
|
||||
var ctmcCompoundViewer = new SSACompoundViewer(ssaGraphViewer, ssaTextViewer, ssaSummaryViewer);
|
||||
var crnCompoundViewer = new CRNCompoundViewer(crnEditor);
|
||||
|
||||
var unitsExtractor = function (): SVF.IVisualizationUpdateMessage {
|
||||
return {
|
||||
MessageType: SVF.VisualizationUpdateMessageType.UnitsInformation,
|
||||
EncapsulatedUpdate: Utils.ExponentToConcentrationString(crnEditor.GetConcentrationUnits())
|
||||
}
|
||||
};
|
||||
var plotSettingsExtractor = function (): SVF.IVisualizationUpdateMessage {
|
||||
return {
|
||||
MessageType: SVF.VisualizationUpdateMessageType.PlotSettingsInfo,
|
||||
EncapsulatedUpdate: crnEditor.GetPlotSettings()
|
||||
}
|
||||
};
|
||||
|
||||
var plotSettingsExtractorForInference = function (): InferOperation.IPlotSettingsValues {
|
||||
return crnEditor.GetPlotSettings();
|
||||
};
|
||||
|
||||
var currentCRNSimulationType = function () {
|
||||
var ig = crnEditor.getModel();
|
||||
var model = null;
|
||||
for (var n in ig.nodes) {
|
||||
model = ig.nodes[n];
|
||||
break;
|
||||
}
|
||||
if (model.top.settings.simulator != "PDE")
|
||||
return SimulationType.nonspatial;
|
||||
if (model.top.settings.spatial.dimensions == 1)
|
||||
return SimulationType.spatial1D;
|
||||
if (model.top.settings.spatial.dimensions == 2)
|
||||
return SimulationType.spatial2D;
|
||||
throw "unsupported operation type";
|
||||
}
|
||||
|
||||
var solutionSelector: HTMLSelectElement = <HTMLSelectElement>$("#solution-selector")[0];
|
||||
function setSolutionsCount(count: number) {
|
||||
while (solutionSelector.hasChildNodes())
|
||||
solutionSelector.removeChild(solutionSelector.firstChild);
|
||||
for (var i = 1; i <= count; i++) {
|
||||
var opt = document.createElement("option");
|
||||
opt.text = i.toString();
|
||||
opt.value = i.toString();
|
||||
solutionSelector.appendChild(opt);
|
||||
}
|
||||
}
|
||||
var getSolutionIdx = () => {
|
||||
var idx = solutionSelector.selectedIndex;
|
||||
if (idx < 0)
|
||||
return -1;
|
||||
return parseInt(solutionSelector.options[idx].value);
|
||||
}
|
||||
|
||||
//================================================
|
||||
//Start JSBOL -> SBOLJS Conversion
|
||||
|
||||
var visbolDesign: any;
|
||||
|
||||
function showSBOL(jsbol: GECInterfaces.jSBOLDocument) {
|
||||
|
||||
|
||||
try {
|
||||
//console.log(JSON.stringify(jsbol));
|
||||
|
||||
var sbolobj = jsbolToObject(jsbol);
|
||||
|
||||
var visbolDiv = $("#visbolContainer")[0];
|
||||
while (visbolDiv.children.length > 0)
|
||||
visbolDiv.removeChild(visbolDiv.firstChild);
|
||||
|
||||
//var index = $("#resultsTabs").find("#visbolTab").index() - 1;
|
||||
//$("#resultsTabs").tabs("option", "active", index);
|
||||
|
||||
//var xmlsbol = convertJsonToXml(jsbol);
|
||||
|
||||
//console.log("Start printing XML version");
|
||||
//console.dirxml(xmlsbol);
|
||||
//console.log("Finished printing XML version of SBOL")
|
||||
|
||||
var component: any = {
|
||||
segments: []
|
||||
}
|
||||
|
||||
//console.log(JSON.stringify(jsbol));
|
||||
|
||||
//console.log("About to print the display list for each component definition...");
|
||||
//sbolobj.componentDefinitions.forEach( (componentDefinition:any) => console.log(visbol.getDisplayList(componentDefinition)));
|
||||
//console.log("All display lists printed.");
|
||||
|
||||
|
||||
|
||||
sbolobj.componentDefinitions.forEach((componentDefinition: any) => {
|
||||
if (componentDefinition.name == 'device') {
|
||||
|
||||
var fullseq = visbol.getDisplayList.getDisplayList(componentDefinition).components[0].segments[0].sequence
|
||||
var firsthalf = fullseq.slice(0, fullseq.length / 2)
|
||||
var halfseg = visbol.getDisplayList.getDisplayList(componentDefinition).components[0].segments[0]
|
||||
halfseg.sequence = firsthalf
|
||||
component.segments = component.segments.concat(halfseg)
|
||||
//component.segments = component.segments.concat(visbol.getDisplayList.getDisplayList(componentDefinition).components[0].segments[0])
|
||||
}
|
||||
|
||||
});
|
||||
//xmlsbol.componentDefinitions.forEach(componentDefinition => component.segments = component.segments.concat(visbol.getDisplayList(componentDefinition).components[0].segments[0]));
|
||||
|
||||
var displayList: any = { version: 1, components: [component] };
|
||||
var font: any = visbolfont;
|
||||
visbolDesign = new visbol.Design({ element: visbolDiv, font: font });
|
||||
visbolDesign.setDisplayList(displayList);
|
||||
visbolDesign.redraw();
|
||||
|
||||
/*var xml = json2xml(jsbol);
|
||||
console.log(visbol != null);
|
||||
var xmlstring = JSON.stringify(xml);
|
||||
visbolDiv.text(xmlstring);*/
|
||||
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
//Phase 2. Assembling higher level functionality from the components above
|
||||
|
||||
var parseCrnOperation = new ParseOperation.Operation<void, void>(codeStorage, codeParser, crnCompoundViewer, codeSource);
|
||||
var parseGecOperation = new GecParseOperation.Operation<void>(classicGEC, gecCodeStorage, partsCodeStorage, reactionsCodeStorage, setSolutionsCount, showSBOL, crnExport, gecCodeSource, partsDBCodeSource, reactionsDBCodeSource);
|
||||
var selectSolutionOperation = new GetSolutionOperation.Operation(getSolutionIdx, classicGEC, codeSource, crnCompoundViewer, showSBOL, crnExport);
|
||||
var exportOperation = new ExportOperation.Exporter(classicGEC, crnEditor, crnSelector, crnExport);
|
||||
var simulateOperation = new SimulateOperation.Operation<SimRunner.ISimulationMessage, SVF.IVisualizationUpdateMessage, void>(crnEditor, crnSelector, simRunner, simViewer, ctmcCompoundViewer, probabilityMapsViewer, crnCompoundViewer, crnExport, unitsExtractor, plotSettingsExtractor, SumToVum.getModelfromSim, SumToVum.getExportsFromSim, SumToVum.getStateSpaceFromSim, SumToVum.Convert);
|
||||
var simulateSpatial1DOperation = new Spatial1DSimulation.Operation(crnEditor, crnSelector, spat1DSimRunner, spatialViewer1D);
|
||||
var simulateSpatial2DOperation = new Spatial2DSimulation.Operation(crnEditor, crnSelector, spat2DSimRunner, spatialViewer2D);
|
||||
var synthesisOperation = new SynthesisOperation(crnEditor, synthesisAdapter, synthesisViewer);
|
||||
|
||||
var autoChoiceSimulationOperation = new DispatchedSimulateOperation(
|
||||
currentCRNSimulationType,
|
||||
simulateSpatial1DOperation, $('#spatial1dViewer'),
|
||||
simulateSpatial2DOperation, $('#spatial2dViewer'),
|
||||
simulateOperation, $('#simulationViewer'));
|
||||
|
||||
var inferOperation = new InferOperation.Operation(crnEditor, currentlySelectedDataSetSource, infRunner, infViewer, crnExport, plotSettingsExtractorForInference);
|
||||
|
||||
var ssaOperation = new SSAOperation(crnEditor, ssaRunner, ctmcCompoundViewer, false);
|
||||
|
||||
var selectGECCodeTab = new TabSelectOperation.Operation($("#gecTabs"), "#gecCode");
|
||||
var selectCRNDirectivesTab = new TabSelectOperation.Operation($('#inputTabs'), "#crnDirectives");
|
||||
var selectInferTab = new TabSelectOperation.Operation($('#resultsTabs'), "#inferenceViewer");
|
||||
var selectModelDynamicsTab = new TabSelectOperation.Operation($('#inferenceViewer'), "#inferenceDynamics");
|
||||
var selectSimulationTab = new TabSelectOperation.Operation($('#resultsTabs'), "#simulationViewerTab");
|
||||
var selectSSATab = new TabSelectOperation.Operation($('#resultsTabs'), "#StatesViewerTab");
|
||||
var selectSSATextTab = new TabSelectOperation.Operation($('#StatesViewerTab'), "#ssaTextTab");
|
||||
var selectSBOLTab = new TabSelectOperation.Operation($('#resultsTabs'), '#visbolTab');
|
||||
var selectSynthesisTab = new TabSelectOperation.Operation($('#resultsTabs'), "#synthesisTab");
|
||||
|
||||
//var simHintScreen = new HintScreen.HintScreen(autoChoiceSimulationOperation);
|
||||
//var graphHintScreen = new HintScreen.HintScreen(new HintScreen.CombinedHintRemoveNotifier([parseCrnOperation]));
|
||||
|
||||
|
||||
//Phase 3. Setting up the layout
|
||||
// Turn the main areas into tabs.
|
||||
|
||||
IDDTabs(null, (newPanel => {
|
||||
// Force redraw of visbol when the relevant tab is focused (workaround for issue where visbol doesn't draw on hidden tabs).
|
||||
if (newPanel[0].id == 'visbolTab')
|
||||
visbolDesign.redraw();
|
||||
}));
|
||||
|
||||
//bind functional components
|
||||
codeSource.AutoBind();
|
||||
gecCodeSource.AutoBind();
|
||||
partsDBCodeSource.AutoBind();
|
||||
reactionsDBCodeSource.AutoBind();
|
||||
crnEditor.Bind(document.getElementById('crnTabs'));
|
||||
inferenceGraphViewer.Bind(document.getElementById('inferenceGraph'));
|
||||
var exportAreas = $(".c-export").get();
|
||||
for (var c in exportAreas)
|
||||
crnExport.Bind(exportAreas[c]);
|
||||
crnExport.BindToTabs(document.getElementById("crnExport"));
|
||||
dataSetList.Bind($("#datasets-viewer").get()[0]);
|
||||
dataSetViewer.Bind($("#dataset-viewer").get()[0]);
|
||||
//simHintScreen.Bind(document.getElementById('simulationHintScreen'));
|
||||
//graphHintScreen.Bind(document.getElementById('graphHintScreen'));
|
||||
simViewer.Bind(document.getElementById('simulationViewer'));
|
||||
spatialViewer1D.bind(document.getElementById('spatial1dViewer'));
|
||||
spatialViewer2D.bind(document.getElementById('spatial2dViewer'));
|
||||
ssaSummaryViewer.Bind(document.getElementById('ssaSummary'));
|
||||
infDynamicsViewer.Bind(document.getElementById('inferenceDynamics'));
|
||||
infParamViewer.Bind(document.getElementById('inferenceParameters'));
|
||||
infPosteriorViewer.Bind(document.getElementById('inferencePosterior'));
|
||||
infSummary.Bind(document.getElementById('inferenceSummary'));
|
||||
ssaTextViewer.Bind(document.getElementById('ssaTextTab'));
|
||||
probabilityMapsViewer.Bind(document.getElementById('probabilitiesTab'));
|
||||
ssaGraphViewer.Bind(document.getElementById('ssaGraph'));
|
||||
crnGraphViewer.Bind(document.getElementById('crnGraph'));
|
||||
longOperationsManager.Bind(document.getElementById('toolbar'));
|
||||
crnSelector.Bind(document.getElementById('CRNSelector'));
|
||||
ko.applyBindings(crnVM, document.getElementById('crnInferenceGraphTab'));
|
||||
options.bind(document.getElementById('options'));
|
||||
synthesisViewer.Bind(document.getElementById('synthesisTab'));
|
||||
|
||||
dataSetList.getSelectedObservable().subscribe((val) => {
|
||||
val ? dataSetViewer.Show(val) : dataSetViewer.Show(null);
|
||||
});
|
||||
|
||||
var files = ["TestInference.txt", "Join_Simulated.txt", "AM_obs.csv", "AM_obs_noised.csv",
|
||||
"Rep_Simulated.csv"];
|
||||
dataSetList.Initialize("Examples/Observations/", files);
|
||||
|
||||
partsDBCodeSource.ShowCode(classicGEC.Parts);
|
||||
reactionsDBCodeSource.ShowCode(classicGEC.Reactions);
|
||||
$("#gecTabs").tabs("option", "active", 2);
|
||||
|
||||
function getActiveTabID(tabName: string) {
|
||||
return $("#" + tabName + " .ui-tabs-panel:visible").attr("id");
|
||||
}
|
||||
function getActiveInputTabID() {
|
||||
return getActiveTabID("inputTabs");
|
||||
}
|
||||
function getActiveCrnTabID() {
|
||||
return getActiveTabID("crnTabs");
|
||||
}
|
||||
function getActiveGECTabID() {
|
||||
return getActiveTabID("gecTabs");
|
||||
}
|
||||
|
||||
$("#separator").draggable({
|
||||
axis: "x",
|
||||
containment: "parent",
|
||||
scroll: false,
|
||||
drag: (event, ui) => {
|
||||
var pos = ui.position.left;
|
||||
var percLeft = 100 * pos / ui.helper.parent().width();
|
||||
var percRight = 100 - percLeft;
|
||||
$("#input-area").css({ width: "calc(" + percLeft + "% - 5px)" });
|
||||
$("#output-area").css({ width: "calc(" + percRight + "% - 15px)" });
|
||||
InteractiveDataDisplay.updateLayouts($("#output-area"));
|
||||
},
|
||||
stop: (event, ui) => {
|
||||
let left = 100 * ui.position.left / ui.helper.parent().width();
|
||||
$("#separator").css({ left: left + "%" });
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$("#dataset-separator").draggable({
|
||||
axis: "y",
|
||||
containment: "#crnData",
|
||||
cursorAt: { top: 4 },
|
||||
scroll: false,
|
||||
drag: function (event, ui) {
|
||||
var pos = ui.position.top;
|
||||
var percTop = 100 * pos / ui.helper.parent().height();
|
||||
var percBottom = 100 - percTop;
|
||||
$("#datasets-viewer").css({ height: "calc(" + percTop + "% - 4px)" });
|
||||
$("#dataset-viewer").css({ height: "calc(" + percBottom + "% - 4px)" });
|
||||
}
|
||||
});
|
||||
$("#dataset-separator").css({ position: "static" }); // jqueryui draggable sets position to relative automatically
|
||||
|
||||
//Phase 4. Setting up button handlers
|
||||
|
||||
var isSelectingSolution = false;
|
||||
longOperationsManager.CanStartNewAction.subscribe(val => {
|
||||
if (isSelectingSolution && val) {
|
||||
setTimeout(() => solutionSelector.focus());
|
||||
isSelectingSolution = false;
|
||||
}
|
||||
});
|
||||
solutionSelector.onchange = () => {
|
||||
var operations = [selectSolutionOperation, exportOperation];
|
||||
isSelectingSolution = true;
|
||||
longOperationsManager.EnqueueOperations(operations);
|
||||
}
|
||||
|
||||
document.getElementById('parseButton').onclick = function (e) {
|
||||
var tabID = getActiveInputTabID();
|
||||
var operations: Array<LongOperations.IOperation> = []
|
||||
switch (tabID) {
|
||||
case "gecTabs":
|
||||
tabID = getActiveGECTabID();
|
||||
switch (tabID) {
|
||||
case "gecParts":
|
||||
case "gecReactions":
|
||||
case "gecCode":
|
||||
operations = [parseGecOperation, selectGECCodeTab, selectSBOLTab, selectSolutionOperation, exportOperation];
|
||||
break;
|
||||
default:
|
||||
throw "not implemented yet";
|
||||
}
|
||||
break;
|
||||
case "crnTabs":
|
||||
tabID = getActiveCrnTabID();
|
||||
switch (tabID) {
|
||||
case "crnData":
|
||||
case "crnCode"://code
|
||||
operations = [parseCrnOperation, exportOperation, selectCRNDirectivesTab];
|
||||
break;
|
||||
case "crnDirectives"://directives
|
||||
case "crnParameters"://parameters
|
||||
case "crnSpecies"://species
|
||||
case "crnReactions"://reactions
|
||||
case "crnInferenceGraph": // inference graph
|
||||
operations = [parseCrnOperation];
|
||||
break;
|
||||
default:
|
||||
throw "not implemented yet";
|
||||
}
|
||||
break;
|
||||
}
|
||||
longOperationsManager.EnqueueOperations(operations);
|
||||
}
|
||||
|
||||
document.getElementById('exportButton').onclick = function (e) {
|
||||
var tabID = getActiveInputTabID();
|
||||
var operations: Array<LongOperations.IOperation> = [];
|
||||
switch (tabID) {
|
||||
case "gecTabs":
|
||||
switch (getActiveGECTabID()) {
|
||||
case "gecParts":
|
||||
case "gecReactions":
|
||||
case "gecCode":
|
||||
operations = [parseGecOperation, selectGECCodeTab, selectSolutionOperation, exportOperation];
|
||||
break;
|
||||
default:
|
||||
throw "not implemented yet";
|
||||
}
|
||||
break;
|
||||
case "crnTabs":
|
||||
switch (getActiveCrnTabID()) {
|
||||
case "crnData":
|
||||
case "crnCode"://crn code
|
||||
operations = [parseCrnOperation, exportOperation];
|
||||
break;
|
||||
case "crnDirectives"://directives
|
||||
case "crnParameters"://parameters
|
||||
case "crnSpecies"://species
|
||||
case "crnReactions"://reactions
|
||||
case "crnInferenceGraph": // inference graph
|
||||
operations = [exportOperation];
|
||||
break;
|
||||
default:
|
||||
throw "not implemented yet";
|
||||
}
|
||||
}
|
||||
longOperationsManager.EnqueueOperations(operations);
|
||||
}
|
||||
|
||||
document.getElementById('simulateButton').onclick = function (e) {
|
||||
var tabID = getActiveInputTabID();
|
||||
var operations: Array<LongOperations.IOperation> = []
|
||||
switch (tabID) {
|
||||
case "gecTabs":
|
||||
tabID = getActiveGECTabID();
|
||||
switch (tabID) {
|
||||
case "gecParts":
|
||||
case "gecReactions":
|
||||
case "gecCode":
|
||||
operations = [parseGecOperation, selectGECCodeTab, selectSolutionOperation, parseCrnOperation, selectSimulationTab, autoChoiceSimulationOperation];
|
||||
break;
|
||||
default:
|
||||
throw "not implemented yet";
|
||||
}
|
||||
break;
|
||||
case "crnTabs":
|
||||
tabID = getActiveCrnTabID();
|
||||
switch (tabID) {
|
||||
case "crnData":
|
||||
case "crnCode"://code
|
||||
operations = [parseCrnOperation, exportOperation, selectSimulationTab, autoChoiceSimulationOperation];
|
||||
break;
|
||||
case "crnDirectives"://directives
|
||||
case "crnParameters"://parameters
|
||||
case "crnSpecies"://species
|
||||
case "crnReactions"://reactions
|
||||
case "crnInferenceGraph": // inference graph
|
||||
operations = [exportOperation, selectSimulationTab, autoChoiceSimulationOperation];
|
||||
break;
|
||||
default:
|
||||
throw "not implemented yet";
|
||||
}
|
||||
break;
|
||||
}
|
||||
longOperationsManager.EnqueueOperations(operations);
|
||||
}
|
||||
|
||||
document.getElementById('synthesisButton').onclick = function (e) {
|
||||
if (!longOperationsManager.CanStartNewAction())
|
||||
return;
|
||||
var tabIndex = getActiveInputTabID();
|
||||
var operations: Array<LongOperations.IOperation> = []
|
||||
switch (tabIndex) {
|
||||
case "sgTab":
|
||||
switch (getActiveGECTabID()) {
|
||||
case "gecParts":
|
||||
case "gecReactions":
|
||||
case "gecCode":
|
||||
operations = [parseGecOperation, selectGECCodeTab, selectSolutionOperation, parseCrnOperation, selectSynthesisTab, synthesisOperation];
|
||||
break;
|
||||
default:
|
||||
throw "not implemented yet";
|
||||
}
|
||||
break;
|
||||
case "crnTabs":
|
||||
switch (getActiveCrnTabID()) {
|
||||
case "crnData":
|
||||
case "crnCode"://code
|
||||
operations = [parseCrnOperation, exportOperation, selectSynthesisTab, synthesisOperation];
|
||||
break;
|
||||
case "crnDirectives"://directives
|
||||
case "crnParameters"://parameters
|
||||
case "crnSpecies"://species
|
||||
case "crnReactions"://reactions
|
||||
case "crnInferenceGraph"://inference graph
|
||||
operations = [selectSynthesisTab, synthesisOperation];
|
||||
break;
|
||||
default:
|
||||
throw "not implemented yet";
|
||||
}
|
||||
}
|
||||
longOperationsManager.EnqueueOperations(operations);
|
||||
}
|
||||
|
||||
document.getElementById('statesButton').onclick = function (e) {
|
||||
var tabID = getActiveInputTabID();
|
||||
var operations: Array<LongOperations.IOperation> = []
|
||||
switch (tabID) {
|
||||
case "gecTabs":
|
||||
tabID = getActiveGECTabID();
|
||||
switch (tabID) {
|
||||
case "gecParts":
|
||||
case "gecReactions":
|
||||
case "gecCode":
|
||||
operations = [parseGecOperation, selectGECCodeTab, selectSolutionOperation, parseCrnOperation, selectSSATab, selectSSATextTab, ssaOperation];
|
||||
break;
|
||||
default:
|
||||
throw "not implemented yet";
|
||||
}
|
||||
break;
|
||||
case "crnTabs":
|
||||
tabID = getActiveCrnTabID();
|
||||
switch (tabID) {
|
||||
case "crnData":
|
||||
case "crnCode"://code
|
||||
operations = [parseCrnOperation, exportOperation, selectSSATab, selectSSATextTab, ssaOperation];
|
||||
break;
|
||||
case "crnDirectives"://directives
|
||||
case "crnParameters"://parameters
|
||||
case "crnSpecies"://species
|
||||
case "crnReactions"://reactions
|
||||
case "crnInferenceGraph": // inference graph
|
||||
operations = [exportOperation, selectSSATab, selectSSATextTab, ssaOperation];
|
||||
break;
|
||||
default:
|
||||
throw "not implemented yet";
|
||||
}
|
||||
break;
|
||||
}
|
||||
longOperationsManager.EnqueueOperations(operations);
|
||||
}
|
||||
|
||||
document.getElementById('inferButton').onclick = function (e) {
|
||||
var tabID = getActiveInputTabID();
|
||||
var operations: Array<LongOperations.IOperation> = []
|
||||
switch (tabID) {
|
||||
case "gecTabs":
|
||||
tabID = getActiveGECTabID();
|
||||
switch (tabID) {
|
||||
case "gecParts":
|
||||
case "gecReactions":
|
||||
case "gecCode":
|
||||
operations = [parseGecOperation, selectGECCodeTab, selectSolutionOperation, parseCrnOperation, selectInferTab, selectModelDynamicsTab, inferOperation];
|
||||
break;
|
||||
default:
|
||||
throw "not implemented yet";
|
||||
}
|
||||
break;
|
||||
case "crnTabs":
|
||||
tabID = getActiveCrnTabID();
|
||||
switch (tabID) {
|
||||
case "crnData":
|
||||
case "crnCode"://code
|
||||
operations = [parseCrnOperation, exportOperation, selectInferTab, selectModelDynamicsTab, inferOperation];
|
||||
break;
|
||||
case "crnDirectives"://directives
|
||||
case "crnParameters"://parameters
|
||||
case "crnSpecies"://species
|
||||
case "crnReactions"://reactions
|
||||
case "crnInferenceGraph": // inference graph
|
||||
operations = [exportOperation, selectInferTab, selectModelDynamicsTab, inferOperation];
|
||||
break;
|
||||
default:
|
||||
throw "not implemented yet";
|
||||
}
|
||||
break;
|
||||
}
|
||||
longOperationsManager.EnqueueOperations(operations);
|
||||
}
|
||||
|
||||
document.getElementById('stopButton').onclick = function (e) {
|
||||
longOperationsManager.Stop();
|
||||
}
|
||||
|
||||
//serviceWorker.Bind(document.getElementById('worker'));
|
||||
|
||||
Utils.RemoveLoadingOverlay();
|
||||
|
||||
console.log("ClassicGEC loaded");
|
|
@ -0,0 +1,9 @@
|
|||
//bind to specific DOM element and occupy it
|
||||
export interface IUIBindable {
|
||||
Bind(elem: HTMLElement): void;
|
||||
}
|
||||
|
||||
//bind to the DOM, but automatically finds out a place to bind (e.g. by predefined element id)
|
||||
export interface IUIAutoBindable {
|
||||
AutoBind(): void;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import CodePad from "../../../HTML5SharedGUI/CodeEditor/Scripts/CodePad";
|
||||
import { INamedMonarchLanguage } from '../../../HTML5SharedGUI/CodeEditor/Scripts/CodeEditor';
|
||||
|
||||
class GECCodeEditor extends CodePad {
|
||||
constructor(language: INamedMonarchLanguage, examples: Array<ExamplesGroup>) {
|
||||
super(language, "gec-editor-widget", examples);
|
||||
}
|
||||
}
|
||||
|
||||
export default GECCodeEditor;
|
|
@ -0,0 +1,176 @@
|
|||
var GECLanguage = {
|
||||
displayName: 'GEC', // start by writing your language name here
|
||||
name: 'GEC',
|
||||
mimeTypes: ['text/x-crn'],
|
||||
fileExtensions: ['crn'],
|
||||
|
||||
// used in the editor to insert comments (ctrl+/ or shift+alt+A)
|
||||
lineComment: '// ',
|
||||
blockCommentStart: '(*',
|
||||
blockCommentEnd: '*)',
|
||||
|
||||
// Set defaultToken to invalid to see what you do not tokenize yet
|
||||
//defaultToken: 'invalid',
|
||||
|
||||
keywords: [
|
||||
"CNil",
|
||||
"END",
|
||||
"Nil",
|
||||
"SNil",
|
||||
"agent",
|
||||
"and",
|
||||
"as",
|
||||
"binding",
|
||||
"bool",
|
||||
"comp",
|
||||
"conc",
|
||||
"copy",
|
||||
"directive",
|
||||
"ff",
|
||||
"float",
|
||||
"force",
|
||||
"gen",
|
||||
"if",
|
||||
"init",
|
||||
"inside",
|
||||
"int",
|
||||
"kappa",
|
||||
"module",
|
||||
"moments",
|
||||
"mutation",
|
||||
"new",
|
||||
"not",
|
||||
"or",
|
||||
"phos",
|
||||
"plot",
|
||||
"plot_settings",
|
||||
"rate",
|
||||
"rates",
|
||||
"sample",
|
||||
"scale",
|
||||
"script",
|
||||
"specout",
|
||||
"spec",
|
||||
"string",
|
||||
"sum",
|
||||
"tolerance",
|
||||
"abstolerance",
|
||||
"reltolerance",
|
||||
"parameter",
|
||||
"spatialplot",
|
||||
"spatialic",
|
||||
"diffusion",
|
||||
"dt",
|
||||
"xmax",
|
||||
"nx",
|
||||
"task",
|
||||
"theta",
|
||||
"tt",
|
||||
"vol",
|
||||
"compilation",
|
||||
"simulation",
|
||||
"event",
|
||||
"parameters",
|
||||
"fit",
|
||||
"sweep",
|
||||
"fit_run",
|
||||
"plotwindow",
|
||||
"predicate",
|
||||
"query",
|
||||
"seed",
|
||||
"synthesis"
|
||||
],
|
||||
|
||||
/*builtins: [
|
||||
'rank', 'rankdir', 'ranksep', 'size', 'ratio',
|
||||
'label', 'headlabel', 'taillabel',
|
||||
'arrowhead', 'samehead', 'samearrowhead',
|
||||
'arrowtail', 'sametail', 'samearrowtail', 'arrowsize',
|
||||
'labeldistance', 'labelangle', 'labelfontsize',
|
||||
'dir', 'width', 'height', 'angle',
|
||||
'fontsize', 'fontcolor', 'same', 'weight', 'color',
|
||||
'bgcolor', 'style', 'shape', 'fillcolor', 'nodesep', 'id',
|
||||
],*/
|
||||
|
||||
attributes: [
|
||||
'doublecircle', 'circle', 'diamond', 'box', 'point', 'ellipse', 'record',
|
||||
'inv', 'invdot', 'dot', 'dashed', 'dotted', 'filled', 'back', 'forward',
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
||||
|
||||
|
||||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_\x80-\xFF][\w\x80-\xFF]*/, {
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
//'@builtins': 'predefined',
|
||||
'@attributes': 'constructor',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
||||
// html identifiers
|
||||
//[/<(?!@symbols)/, { token: 'string.html.quote', bracket: '@open', next: 'html' }],
|
||||
|
||||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'operator'
|
||||
}
|
||||
}],
|
||||
|
||||
// delimiter
|
||||
[/[;|]/, 'delimiter'],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||
[/0[xX][0-9a-fA-F]+/, 'number.hex'],
|
||||
[/\d+/, 'number'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/[^\/*]+/, 'comment'],
|
||||
[/\/\*/, 'comment', '@push'], // nested comment
|
||||
["\\*/", 'comment', '@pop'],
|
||||
[/[\/*]/, 'comment']
|
||||
],
|
||||
|
||||
/*html: [
|
||||
[/[^<>&]+/, 'string.html'],
|
||||
[/&\w+;/, 'string.html.escape'],
|
||||
[/&/, 'string.html'],
|
||||
[/</, { token: 'string.html.quote', bracket: '@open', next: '@push' }], //nested bracket
|
||||
[/>/, { token: 'string.html.quote', bracket: '@close', next: '@pop' }],
|
||||
],*/
|
||||
|
||||
string: [
|
||||
[/[^\\"&]+/, 'string'],
|
||||
[/\\"/, 'string.escape'],
|
||||
[/&\w+;/, 'string.escape'],
|
||||
[/[\\&]/, 'string'],
|
||||
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
[/#.$/, 'comment'],
|
||||
],
|
||||
},
|
||||
};
|
||||
export default GECLanguage;
|
|
@ -0,0 +1,76 @@
|
|||
import * as $ from 'jquery';
|
||||
import GEC from '../../../ClassicGECTSWrapper/Scripts/ClassicGEC';
|
||||
import * as Interfaces from '../../../ClassicGECTSWrapper/Scripts/Interfaces';
|
||||
import * as CRN from '../../../../CRNEngine/CRNEngineTSWrapper/Scripts/Interfaces';
|
||||
import * as Operations from "../../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/LongOperations";
|
||||
import * as GenericParsing from "../../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/GenericCodeParsing";
|
||||
|
||||
export interface IExportsViewer {
|
||||
ShowExport(update: CRN.ExportDef): void;
|
||||
}
|
||||
|
||||
export class Operation<TOptions> implements Operations.IOperation {
|
||||
constructor(
|
||||
private gec: GEC,
|
||||
private codeSource: GenericParsing.ICodeSource<void>,
|
||||
private partsSource: GenericParsing.ICodeSource<void>,
|
||||
private reactionsSource: GenericParsing.ICodeSource<void>,
|
||||
private showSolutionsCount: (count: number) => void,
|
||||
private showSBOL: (jsbol: Interfaces.jSBOLDocument) => void,
|
||||
private exports: IExportsViewer,
|
||||
private codeErrorDisplay: GenericParsing.IErrorDisplay,
|
||||
private partsErrorDisplay: GenericParsing.IErrorDisplay,
|
||||
private reactionsErrorDisplay: GenericParsing.IErrorDisplay) {
|
||||
}
|
||||
|
||||
public Initiate(): JQueryPromise<any> {
|
||||
this.gec.Parts = this.partsSource.GetCode();
|
||||
this.gec.Reactions = this.reactionsSource.GetCode();
|
||||
var code = this.codeSource.GetCode();
|
||||
var observables = this.gec.UserCompile(code);
|
||||
var deferred = jQuery.Deferred<any>();
|
||||
observables.solution_count.subscribe(next => {
|
||||
this.showSolutionsCount(next);
|
||||
this.exitMessage = "completed with " + (next == 0 ? "no" : next.toString()) + " solution" + (next == 1 ? "" : "s");
|
||||
this.codeErrorDisplay.ClearErrors();
|
||||
this.partsErrorDisplay.ClearErrors();
|
||||
this.reactionsErrorDisplay.ClearErrors();
|
||||
deferred.resolve(next);
|
||||
}, error => {
|
||||
this.showSolutionsCount(0);
|
||||
var errorString: string = error.message == null ? JSON.stringify(error) : error.message;
|
||||
this.exitMessage = "failed with " + errorString;
|
||||
var errorObj: GenericParsing.IError = { text: errorString };
|
||||
if (error.positions != null && error.positions.length > 0) {
|
||||
var row = error.positions[0].row;
|
||||
var column = error.positions[0].column + 1;
|
||||
errorObj.text += " at row " + row + ", column " + column;
|
||||
var len = error.positions[0].text.length;
|
||||
errorObj.location = { rowStart: row, rowEnd: row, colStart: column, colEnd: column };
|
||||
}
|
||||
if (errorString.substr(0, 5) == "parts")
|
||||
this.partsErrorDisplay.ShowErrors([errorObj]);
|
||||
else if (errorString.substr(0, 9) == "reactions")
|
||||
this.reactionsErrorDisplay.ShowErrors([errorObj]);
|
||||
else
|
||||
this.codeErrorDisplay.ShowErrors([errorObj]);
|
||||
deferred.reject(error);
|
||||
}, () => { });
|
||||
observables.jsbol.subscribeOnNext(jsbol => this.showSBOL(jsbol));
|
||||
observables.exports.subscribe(exp => this.exports.ShowExport(exp), err => { }, () => { });
|
||||
return deferred;
|
||||
}
|
||||
|
||||
public Abort(): void {
|
||||
this.gec.Abort();
|
||||
}
|
||||
|
||||
public GetName(): string {
|
||||
return "GEC parsing";
|
||||
}
|
||||
|
||||
private exitMessage: string;
|
||||
public GetExitMessage(): string {
|
||||
return this.exitMessage;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
import * as $ from 'jquery';
|
||||
import GEC from '../../../ClassicGECTSWrapper/Scripts/ClassicGEC';
|
||||
import * as Interfaces from '../../../ClassicGECTSWrapper/Scripts/Interfaces';
|
||||
import * as CRN from '../../../../CRNEngine/CRNEngineTSWrapper/Scripts/Interfaces';
|
||||
import * as Operations from "../../../../HTML5SharedGUI/HTML5CRN_Lib/Scripts/Operations/LongOperations";
|
||||
import * as HintScreen from "../../../../HTML5SharedGUI/GenericComponents/Scripts/HintScreen";
|
||||
|
||||
//Dependencies to be injected
|
||||
|
||||
export interface ICodeViewer {
|
||||
ShowCode(code: string): void;
|
||||
}
|
||||
|
||||
/** Displays the CRN entities with GUI */
|
||||
export interface ICRNViewer {
|
||||
UpdateValuesWith(update: CRN.IG, customSettings: void, fromJIT: boolean): void;
|
||||
}
|
||||
|
||||
export interface IExportsViewer {
|
||||
ShowExport(update: CRN.ExportDef): void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the code from the CodeEditor, passes it to the parser, receives CRN entities, updates CRN viewer with them, updates data files selecting control with parsed "data directive" files.
|
||||
* If any parsing error occurs, displays it with errorDisplay
|
||||
*/
|
||||
export class Operation implements Operations.IOperation, HintScreen.IHintRemoveNotifier {
|
||||
constructor(
|
||||
private getIdx: () => number,
|
||||
private gec: GEC,
|
||||
private crnCodeViewer: ICodeViewer,
|
||||
private crnViewer: ICRNViewer,
|
||||
private showSBOL: (jsbol: Interfaces.jSBOLDocument) => void,
|
||||
private exports: IExportsViewer) {
|
||||
}
|
||||
|
||||
public Initiate(): JQueryPromise<any> {
|
||||
var deferred = $.Deferred();
|
||||
var idx = this.getIdx();
|
||||
if (idx == -1) {
|
||||
this.m_ExitMessage = "no solutions found";
|
||||
deferred.reject();
|
||||
}
|
||||
else {
|
||||
var observables = this.gec.UserGetSolution(idx);
|
||||
var error = (err: any) => {
|
||||
this.m_ExitMessage = JSON.stringify(err);
|
||||
deferred.reject();
|
||||
}
|
||||
observables.solution.subscribe(solution => {
|
||||
this.m_ExitMessage = "Solution " + idx + " selected";
|
||||
this.InterpretSuccessfulResults(solution);
|
||||
deferred.resolve();
|
||||
}, error, () => { });
|
||||
observables.jsbol.subscribe(jsbol => this.showSBOL(jsbol), err => { }, () => { });
|
||||
observables.exports.subscribe(exp => this.exports.ShowExport(exp), err => { }, () => { });
|
||||
}
|
||||
return deferred;
|
||||
}
|
||||
|
||||
public Abort() {
|
||||
this.gec.Abort();
|
||||
this.m_ExitMessage = "Aborted";
|
||||
}
|
||||
|
||||
//defining abstract functions
|
||||
public GetName() {
|
||||
return "Retrieving GEC solution";
|
||||
}
|
||||
|
||||
private m_ExitMessage: string;
|
||||
|
||||
public GetExitMessage() {
|
||||
return this.m_ExitMessage;
|
||||
}
|
||||
|
||||
protected InterpretSuccessfulResults(solution: Interfaces.GECSolution) {
|
||||
this.crnViewer.UpdateValuesWith(solution.model, null, false);
|
||||
this.crnCodeViewer.ShowCode(solution.code);
|
||||
this.notificationCallbacks.forEach(c => { c() }); // notifing that hints now can be removed
|
||||
}
|
||||
|
||||
//HintScreen.IHintRemoveNotifier implementation
|
||||
private notificationCallbacks: Array<() => void> = [];
|
||||
|
||||
public SubscribeRemoveHint(callback: () => void) {
|
||||
this.notificationCallbacks.push(callback);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
import CodePad from "../../../HTML5SharedGUI/CodeEditor/Scripts/CodePad";
|
||||
import { INamedMonarchLanguage } from '../../../HTML5SharedGUI/CodeEditor/Scripts/CodeEditor';
|
||||
|
||||
class GECCodeEditor extends CodePad {
|
||||
constructor(language: INamedMonarchLanguage, examples: Array<ExamplesGroup>) {
|
||||
super(language, "parts-editor-widget", examples);
|
||||
}
|
||||
}
|
||||
|
||||
export default GECCodeEditor;
|
|
@ -0,0 +1,171 @@
|
|||
var PartsLanguage = {
|
||||
displayName: 'GECParts', // start by writing your language name here
|
||||
name: 'GECParts',
|
||||
mimeTypes: ['text/x-crn'],
|
||||
fileExtensions: ['crn'],
|
||||
|
||||
// used in the editor to insert comments (ctrl+/ or shift+alt+A)
|
||||
lineComment: '// ',
|
||||
blockCommentStart: '(*',
|
||||
blockCommentEnd: '*)',
|
||||
|
||||
// Set defaultToken to invalid to see what you do not tokenize yet
|
||||
//defaultToken: 'invalid',
|
||||
|
||||
keywords: [
|
||||
"CNil",
|
||||
"END",
|
||||
"Nil",
|
||||
"SNil",
|
||||
"agent",
|
||||
"and",
|
||||
"as",
|
||||
"binding",
|
||||
"bool",
|
||||
"comp",
|
||||
"conc",
|
||||
"copy",
|
||||
"directive",
|
||||
"ff",
|
||||
"float",
|
||||
"force",
|
||||
"gen",
|
||||
"if",
|
||||
"init",
|
||||
"inside",
|
||||
"int",
|
||||
"kappa",
|
||||
"module",
|
||||
"mutation",
|
||||
"new",
|
||||
"not",
|
||||
"or",
|
||||
"phos",
|
||||
"plot",
|
||||
"rate",
|
||||
"sample",
|
||||
"scale",
|
||||
"script",
|
||||
"specout",
|
||||
"spec",
|
||||
"string",
|
||||
"sum",
|
||||
"tolerance",
|
||||
"abstolerance",
|
||||
"reltolerance",
|
||||
"parameter",
|
||||
"spatialplot",
|
||||
"spatialic",
|
||||
"diffusion",
|
||||
"dt",
|
||||
"xmax",
|
||||
"nx",
|
||||
"theta",
|
||||
"tt",
|
||||
"vol",
|
||||
"compilation",
|
||||
"simulation",
|
||||
"event",
|
||||
"parameters",
|
||||
"fit",
|
||||
"sweep",
|
||||
"fit_run",
|
||||
"plotwindow",
|
||||
"predicate",
|
||||
"query",
|
||||
"seed"
|
||||
],
|
||||
|
||||
/*builtins: [
|
||||
'rank', 'rankdir', 'ranksep', 'size', 'ratio',
|
||||
'label', 'headlabel', 'taillabel',
|
||||
'arrowhead', 'samehead', 'samearrowhead',
|
||||
'arrowtail', 'sametail', 'samearrowtail', 'arrowsize',
|
||||
'labeldistance', 'labelangle', 'labelfontsize',
|
||||
'dir', 'width', 'height', 'angle',
|
||||
'fontsize', 'fontcolor', 'same', 'weight', 'color',
|
||||
'bgcolor', 'style', 'shape', 'fillcolor', 'nodesep', 'id',
|
||||
],*/
|
||||
|
||||
attributes: [
|
||||
'doublecircle', 'circle', 'diamond', 'box', 'point', 'ellipse', 'record',
|
||||
'inv', 'invdot', 'dot', 'dashed', 'dotted', 'filled', 'back', 'forward',
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
||||
|
||||
|
||||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_\x80-\xFF][\w\x80-\xFF]*/, {
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
//'@builtins': 'predefined',
|
||||
'@attributes': 'constructor',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
||||
// html identifiers
|
||||
//[/<(?!@symbols)/, { token: 'string.html.quote', bracket: '@open', next: 'html' }],
|
||||
|
||||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'operator'
|
||||
}
|
||||
}],
|
||||
|
||||
// delimiter
|
||||
[/[;|]/, 'delimiter'],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||
[/0[xX][0-9a-fA-F]+/, 'number.hex'],
|
||||
[/\d+/, 'number'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/[^\/*]+/, 'comment'],
|
||||
[/\/\*/, 'comment', '@push'], // nested comment
|
||||
["\\*/", 'comment', '@pop'],
|
||||
[/[\/*]/, 'comment']
|
||||
],
|
||||
|
||||
/*html: [
|
||||
[/[^<>&]+/, 'string.html'],
|
||||
[/&\w+;/, 'string.html.escape'],
|
||||
[/&/, 'string.html'],
|
||||
[/</, { token: 'string.html.quote', bracket: '@open', next: '@push' }], //nested bracket
|
||||
[/>/, { token: 'string.html.quote', bracket: '@close', next: '@pop' }],
|
||||
],*/
|
||||
|
||||
string: [
|
||||
[/[^\\"&]+/, 'string'],
|
||||
[/\\"/, 'string.escape'],
|
||||
[/&\w+;/, 'string.escape'],
|
||||
[/[\\&]/, 'string'],
|
||||
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
[/#.$/, 'comment'],
|
||||
],
|
||||
},
|
||||
};
|
||||
export default PartsLanguage;
|
|
@ -0,0 +1,10 @@
|
|||
import CodePad from "../../../HTML5SharedGUI/CodeEditor/Scripts/CodePad";
|
||||
import { INamedMonarchLanguage } from '../../../HTML5SharedGUI/CodeEditor/Scripts/CodeEditor';
|
||||
|
||||
class GECCodeEditor extends CodePad {
|
||||
constructor(language: INamedMonarchLanguage, examples: Array<ExamplesGroup>) {
|
||||
super(language, "reactions-editor-widget", examples);
|
||||
}
|
||||
}
|
||||
|
||||
export default GECCodeEditor;
|
|
@ -0,0 +1,172 @@
|
|||
var ReactionsLanguage = {
|
||||
displayName: 'GECReactions', // start by writing your language name here
|
||||
name: 'GECReactions',
|
||||
mimeTypes: ['text/x-crn'],
|
||||
fileExtensions: ['crn'],
|
||||
|
||||
// used in the editor to insert comments (ctrl+/ or shift+alt+A)
|
||||
lineComment: '// ',
|
||||
blockCommentStart: '(*',
|
||||
blockCommentEnd: '*)',
|
||||
|
||||
// Set defaultToken to invalid to see what you do not tokenize yet
|
||||
//defaultToken: 'invalid',
|
||||
|
||||
keywords: [
|
||||
"CNil",
|
||||
"END",
|
||||
"Nil",
|
||||
"SNil",
|
||||
"agent",
|
||||
"and",
|
||||
"as",
|
||||
"binding",
|
||||
"bool",
|
||||
"comp",
|
||||
"conc",
|
||||
"copy",
|
||||
"directive",
|
||||
"ff",
|
||||
"float",
|
||||
"force",
|
||||
"gen",
|
||||
"if",
|
||||
"init",
|
||||
"inside",
|
||||
"int",
|
||||
"kappa",
|
||||
"module",
|
||||
"mutation",
|
||||
"new",
|
||||
"not",
|
||||
"or",
|
||||
"phos",
|
||||
"plot",
|
||||
"rate",
|
||||
"rates",
|
||||
"sample",
|
||||
"scale",
|
||||
"script",
|
||||
"specout",
|
||||
"spec",
|
||||
"string",
|
||||
"sum",
|
||||
"tolerance",
|
||||
"abstolerance",
|
||||
"reltolerance",
|
||||
"parameter",
|
||||
"spatialplot",
|
||||
"spatialic",
|
||||
"diffusion",
|
||||
"dt",
|
||||
"xmax",
|
||||
"nx",
|
||||
"theta",
|
||||
"tt",
|
||||
"vol",
|
||||
"compilation",
|
||||
"simulation",
|
||||
"event",
|
||||
"parameters",
|
||||
"fit",
|
||||
"sweep",
|
||||
"fit_run",
|
||||
"plotwindow",
|
||||
"predicate",
|
||||
"query",
|
||||
"seed"
|
||||
],
|
||||
|
||||
/*builtins: [
|
||||
'rank', 'rankdir', 'ranksep', 'size', 'ratio',
|
||||
'label', 'headlabel', 'taillabel',
|
||||
'arrowhead', 'samehead', 'samearrowhead',
|
||||
'arrowtail', 'sametail', 'samearrowtail', 'arrowsize',
|
||||
'labeldistance', 'labelangle', 'labelfontsize',
|
||||
'dir', 'width', 'height', 'angle',
|
||||
'fontsize', 'fontcolor', 'same', 'weight', 'color',
|
||||
'bgcolor', 'style', 'shape', 'fillcolor', 'nodesep', 'id',
|
||||
],*/
|
||||
|
||||
attributes: [
|
||||
'doublecircle', 'circle', 'diamond', 'box', 'point', 'ellipse', 'record',
|
||||
'inv', 'invdot', 'dot', 'dashed', 'dotted', 'filled', 'back', 'forward',
|
||||
],
|
||||
|
||||
// we include these common regular expressions
|
||||
symbols: /[=><!~?:&|+\-*\/\^%]+/,
|
||||
|
||||
|
||||
// The main tokenizer for our languages
|
||||
tokenizer: {
|
||||
root: [
|
||||
// identifiers and keywords
|
||||
[/[a-zA-Z_\x80-\xFF][\w\x80-\xFF]*/, {
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
//'@builtins': 'predefined',
|
||||
'@attributes': 'constructor',
|
||||
'@default': 'identifier'
|
||||
}
|
||||
}],
|
||||
|
||||
// whitespace
|
||||
{ include: '@whitespace' },
|
||||
|
||||
// html identifiers
|
||||
//[/<(?!@symbols)/, { token: 'string.html.quote', bracket: '@open', next: 'html' }],
|
||||
|
||||
// delimiters and operators
|
||||
[/[{}()\[\]]/, '@brackets'],
|
||||
[/@symbols/, {
|
||||
cases: {
|
||||
'@keywords': 'keyword',
|
||||
'@default': 'operator'
|
||||
}
|
||||
}],
|
||||
|
||||
// delimiter
|
||||
[/[;|]/, 'delimiter'],
|
||||
|
||||
// numbers
|
||||
[/\d*\.\d+([eE][\-+]?\d+)?/, 'number.float'],
|
||||
[/0[xX][0-9a-fA-F]+/, 'number.hex'],
|
||||
[/\d+/, 'number'],
|
||||
|
||||
// strings
|
||||
[/"([^"\\]|\\.)*$/, 'string.invalid'], // non-teminated string
|
||||
[/"/, { token: 'string.quote', bracket: '@open', next: '@string' }],
|
||||
],
|
||||
|
||||
comment: [
|
||||
[/[^\/*]+/, 'comment'],
|
||||
[/\/\*/, 'comment', '@push'], // nested comment
|
||||
["\\*/", 'comment', '@pop'],
|
||||
[/[\/*]/, 'comment']
|
||||
],
|
||||
|
||||
/*html: [
|
||||
[/[^<>&]+/, 'string.html'],
|
||||
[/&\w+;/, 'string.html.escape'],
|
||||
[/&/, 'string.html'],
|
||||
[/</, { token: 'string.html.quote', bracket: '@open', next: '@push' }], //nested bracket
|
||||
[/>/, { token: 'string.html.quote', bracket: '@close', next: '@pop' }],
|
||||
],*/
|
||||
|
||||
string: [
|
||||
[/[^\\"&]+/, 'string'],
|
||||
[/\\"/, 'string.escape'],
|
||||
[/&\w+;/, 'string.escape'],
|
||||
[/[\\&]/, 'string'],
|
||||
[/"/, { token: 'string.quote', bracket: '@close', next: '@pop' }]
|
||||
],
|
||||
|
||||
whitespace: [
|
||||
[/[ \t\r\n]+/, 'white'],
|
||||
[/\/\*/, 'comment', '@comment'],
|
||||
[/\/\/.*$/, 'comment'],
|
||||
[/#.$/, 'comment'],
|
||||
],
|
||||
},
|
||||
};
|
||||
export default ReactionsLanguage;
|
|
@ -0,0 +1,8 @@
|
|||
#solution-selector-container {
|
||||
margin-left: 20px;
|
||||
margin-right: 20px;
|
||||
display: inline;
|
||||
}
|
||||
#solution-selector {
|
||||
min-width: 50px;
|
||||
}
|
|
@ -0,0 +1,259 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Classic GEC Tool</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="shared.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="app-cover"><!-- captures user's mouse events. hides app from the user during the load in IE --></div>
|
||||
<div id="loading-screen">
|
||||
<div id="loading-screen__inner">
|
||||
<h1>Loading...</h1>
|
||||
</div>
|
||||
</div>
|
||||
<div id="app">
|
||||
<div id="header">
|
||||
<div id="toolbar">
|
||||
<button id="parseButton" class="c-action-button" data-bind="enable:CanStartNewAction" title="Parses the current model code">Parse</button>
|
||||
<button id="exportButton" class="c-action-button" data-bind="enable:CanStartNewAction" title="Generates exports for the current model">Export</button>
|
||||
<button id="simulateButton" class="c-action-button" data-bind="enable:CanStartNewAction" title="Runs a simulation of the current model">Simulate</button>
|
||||
<button id="inferButton" class="c-action-button" data-bind="enable:CanStartNewAction" title="Runs inference on the current model">Infer</button>
|
||||
<button id="statesButton" class="c-action-button" data-bind="enable:CanStartNewAction" title="Generates the state space of the current model">CTMC</button>
|
||||
<button id="synthesisButton" class="c-action-button" data-bind="enable:CanStartNewAction" title="Runs Z3 analysis on the current model">Synthesis</button>
|
||||
<button id="stopButton" class="c-action-button" data-bind="enable:CanStopOngoingAction" title="Stops the current operation">Stop</button>
|
||||
<div id="solution-selector-container">
|
||||
<label for="solution-selector">Solutions:</label>
|
||||
<select id="solution-selector" data-bind="enable:CanStartNewAction"></select>
|
||||
</div>
|
||||
<crnselector id="CRNSelector"></crnselector>
|
||||
<label id="execution-status" data-bind="text: ExecutionStatus"></label>
|
||||
</div>
|
||||
|
||||
<div id="options" style="display: none" data-bind="visible: IsCloudCapable">
|
||||
<dropdown>
|
||||
<dropdownheader>Options</dropdownheader>
|
||||
<dropdowncontent>
|
||||
<div class="c-dropdown__item">
|
||||
<input type="checkbox" id="cloud" data-bind="checked: Cloud" />
|
||||
<label for="cloud"><strong>Cloud</strong> <span data-bind="text: '('+Account()+')'"></span></label>
|
||||
</div>
|
||||
<div class="c-dropdown__item">
|
||||
<label for="pools">Pool:</label>
|
||||
<!-- ko foreach: Pools -->
|
||||
<input name="Pool" type="radio" data-bind="value: $data, checked: $root.Pool" />
|
||||
<label data-bind="text: $data"></label>
|
||||
<!-- /ko -->
|
||||
</div>
|
||||
<div class="c-dropdown__item">
|
||||
<button data-bind="click: openJobsManager">Jobs</button>
|
||||
</div>
|
||||
</dropdowncontent>
|
||||
</dropdown>
|
||||
</div>
|
||||
|
||||
<div id="docs">
|
||||
<span id="worker">
|
||||
<!-- ko if: offlineStatus-->
|
||||
<span id="offline-text" data-bind="text: 'Offline ready |', attr: {title: hint}"></span>
|
||||
<!-- /ko -->
|
||||
</span>
|
||||
<a href="Docs\license.html" target="doc" class="c-doc__button">License</a>|
|
||||
<!--<a href="Docs\manual.html" target="doc" class="c-doc__button">Manual</a>|
|
||||
<a href="Docs\tutorial.html" target="doc" class="c-doc__button">Tutorial</a>|-->
|
||||
<a href="https://go.microsoft.com/fwlink/?LinkId=521839" class="c-doc__button" target="_blank">Privacy & Cookies</a>|
|
||||
© 2018-2020 Microsoft. All Rights reserved.
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id="input-area">
|
||||
<div id="inputTabs" class="j-has-tabs">
|
||||
<ul>
|
||||
<li><a href="#gecTabs">GEC</a></li>
|
||||
<li><a href="#crnTabs">CRN</a></li>
|
||||
</ul>
|
||||
<div id="gecTabs" class="j-has-tabs">
|
||||
<ul>
|
||||
<li><a href="#gecParts" class="j-gec-tab-header">Parts</a></li>
|
||||
<li><a href="#gecReactions" class="j-gec-tab-header">Reactions</a></li>
|
||||
<li><a href="#gecCode" class="j-gec-tab-header">Code</a></li>
|
||||
</ul>
|
||||
<div id="gecParts">
|
||||
<parts-editor-widget id="parts-editor" params="editorText: editorText, errors: errors, editorLoadEvents: editorLoadEvents"></parts-editor-widget>
|
||||
</div>
|
||||
<div id="gecReactions">
|
||||
<reactions-editor-widget id="reactions-editor" params="editorText: editorText, errors: errors, editorLoadEvents: editorLoadEvents"></reactions-editor-widget>
|
||||
</div>
|
||||
<div id="gecCode">
|
||||
<gec-editor-widget id="gec-editor" params="editorText: editorText, errors: errors, editorLoadEvents: editorLoadEvents"></gec-editor-widget>
|
||||
</div>
|
||||
</div>
|
||||
<div id="crnTabs" class="j-has-tabs">
|
||||
<ul>
|
||||
<li><a href="#crnData">Data</a></li>
|
||||
<li><a href="#crnCode" class="j-code-tab-header">Code</a></li>
|
||||
<li><a href="#crnDirectives" class="j-crn-tab-header">Directives</a></li>
|
||||
<li><a href="#crnParameters" class="j-crn-tab-header">Parameters</a></li>
|
||||
<li><a href="#crnSpecies" class="j-crn-tab-header">Species</a></li>
|
||||
<li><a href="#crnReactions" class="j-crn-tab-header">Reactions</a></li>
|
||||
<li id="crnInferenceGraphTab" data-bind="visible: Nodes().length > 1"><a href="#crnInferenceGraph" class="j-crn-tab-header">Inference Graph</a></li>
|
||||
</ul>
|
||||
<div id="crnData">
|
||||
<div id="datasets-viewer">
|
||||
<datasets-viewer></datasets-viewer>
|
||||
</div>
|
||||
<div id="dataset-separator"></div>
|
||||
<div id="dataset-viewer">
|
||||
<dataset-viewer></dataset-viewer>
|
||||
</div>
|
||||
</div>
|
||||
<div id="crnCode">
|
||||
<crn-editor-widget id="crn-editor" params="editorText: editorText, errors: errors, editorLoadEvents: editorLoadEvents"></crn-editor-widget>
|
||||
</div>
|
||||
<div id="crnDirectives">
|
||||
<crnsettings></crnsettings>
|
||||
</div>
|
||||
<div id="crnParameters">
|
||||
<parameters-viewer></parameters-viewer>
|
||||
</div>
|
||||
<div id="crnSpecies">
|
||||
<species-viewer></species-viewer>
|
||||
</div>
|
||||
<div id="crnReactions">
|
||||
<reactions-viewer></reactions-viewer>
|
||||
</div>
|
||||
<div id="crnInferenceGraph">
|
||||
<inferencegraph id="inferenceGraph"></inferencegraph>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="separator"></div>
|
||||
<div id="output-area">
|
||||
<div id="resultsTabs" class="j-has-tabs">
|
||||
<ul>
|
||||
<li><a href="#crnExport">Export</a></li>
|
||||
<li><a href="#simulationViewerTab">Simulation</a></li>
|
||||
<li><a href="#inferenceViewer">Inference</a></li>
|
||||
<li><a href="#StatesViewerTab">CTMC</a></li>
|
||||
<li><a href="#synthesisTab">Synthesis</a></li>
|
||||
</ul>
|
||||
<div id="crnExport" class="s-full-height j-has-tabs">
|
||||
<ul>
|
||||
<li><a href="#crnGraphTab">Network</a></li>
|
||||
<li><a href="#visbolTab">VisBOL</a></li>
|
||||
<li><a href="#export-code">Code</a></li>
|
||||
<li><a href="#export-initials">Initials</a></li>
|
||||
<li><a href="#export-finals">Finals</a></li>
|
||||
<li><a href="#export-reactions">Reactions</a></li>
|
||||
</ul>
|
||||
<div id="crnGraphTab">
|
||||
<crnreactiongraph id="crnGraph"></crnreactiongraph>
|
||||
</div>
|
||||
<div id="visbolTab">
|
||||
<div id="visbolContainer"></div>
|
||||
</div>
|
||||
<div id="export-code" class="c-export" data-bind="with: byID('code')">
|
||||
<crn-export></crn-export>
|
||||
</div>
|
||||
<div id="export-initials" class="c-export" data-bind="with: byID('initials')">
|
||||
<crn-export></crn-export>
|
||||
</div>
|
||||
<div id="export-finals" class="c-export" data-bind="with: byID('finals')">
|
||||
<crn-export></crn-export>
|
||||
</div>
|
||||
<div id="export-reactions" class="c-export" data-bind="with: byID('reactions')">
|
||||
<crn-export></crn-export>
|
||||
</div>
|
||||
</div>
|
||||
<div id="simulationViewerTab" style="padding: 0" class="s-full-height">
|
||||
<div id="simulationViewer" class="s-full-height"></div>
|
||||
<div id="spatial1dViewer" class="s-full-height" style="display: none"></div>
|
||||
<div id="spatial2dViewer" class="s-full-height" style="display: none"></div>
|
||||
</div>
|
||||
<div id="inferenceViewer" class="s-full-height j-has-tabs">
|
||||
<ul>
|
||||
<li><a href="#inferenceParameters">Parameters</a></li>
|
||||
<li><a href="#inferenceDynamics">Model-Data dynamics</a></li>
|
||||
<li><a href="#inferencePosterior">Posterior</a></li>
|
||||
<li><a href="#inferenceSummary">Summary</a></li>
|
||||
</ul>
|
||||
<div id="inferenceParameters">
|
||||
<inferred-parameters-viewer></inferred-parameters-viewer>
|
||||
</div>
|
||||
<div id="inferenceDynamics">
|
||||
<model-data-dynamics></model-data-dynamics>
|
||||
</div>
|
||||
<div id="inferencePosterior" class="j-has-tabs">
|
||||
<ul>
|
||||
<li><a href="#posteriorTable">Table</a></li>
|
||||
<li><a href="#posteriorScatterPlot">Scatter Plot</a></li>
|
||||
<li><a href="#posteriorDensity">Density</a></li>
|
||||
</ul>
|
||||
<div id="posteriorTable">
|
||||
<posterior-table-viewer></posterior-table-viewer>
|
||||
</div>
|
||||
<div id="posteriorScatterPlot">
|
||||
<posterior-scatter-plot></posterior-scatter-plot>
|
||||
</div>
|
||||
<div id="posteriorDensity">
|
||||
<density-plot></density-plot>
|
||||
</div>
|
||||
</div>
|
||||
<div id="inferenceSummary">
|
||||
<inference-summary-viewer></inference-summary-viewer>
|
||||
</div>
|
||||
</div>
|
||||
<div id="StatesViewerTab" class="s-full-height j-has-tabs">
|
||||
<ul>
|
||||
<li><a href="#ssaGraphTab">Graph</a></li>
|
||||
<li><a href="#ssaTextTab">Text</a></li>
|
||||
<li><a href="#ssaSummaryTab">Summary</a></li>
|
||||
<li><a href="#probabilitiesTab">Probabilities</a></li>
|
||||
</ul>
|
||||
<div id="ssaGraphTab">
|
||||
<statespacegraph id="ssaGraph"></statespacegraph>
|
||||
</div>
|
||||
<div id="ssaTextTab">
|
||||
<p>GEC Tool</p>
|
||||
</div>
|
||||
<div id="ssaSummaryTab">
|
||||
<ssa-summary-viewer id="ssaSummary" params="initialState:initialState, terminalStates:terminalStates"></ssa-summary-viewer>
|
||||
</div>
|
||||
<div id="probabilitiesTab">
|
||||
<probability-map></probability-map>
|
||||
</div>
|
||||
</div>
|
||||
<div id="synthesisTab" class="s-full-height j-has-tabs">
|
||||
<ul>
|
||||
<li><a href="#SynthesisViewer-values-tab">Values</a></li>
|
||||
<li><a href="#SynthesisViewer-equations-tab">Equations</a></li>
|
||||
<li><a href="#SynthesisViewer-jacobian-tab">Jacobian</a></li>
|
||||
<li><a href="#SynthesisViewer-dispersion-tab">Turing</a></li>
|
||||
<li><a href="#SynthesisViewer-bistability-tab">Bistability</a></li>
|
||||
<li><a href="#SynthesisViewer-code-tab">Updated CRN Code</a></li>
|
||||
</ul>
|
||||
<div id="SynthesisViewer-values-tab">
|
||||
<synthesis-values></synthesis-values>
|
||||
</div>
|
||||
<div id="SynthesisViewer-equations-tab" class="s-full-height">
|
||||
<synthesis-equations></synthesis-equations>
|
||||
</div>
|
||||
<div id="SynthesisViewer-jacobian-tab" class="s-full-height">
|
||||
<synthesis-jacobian></synthesis-jacobian>
|
||||
</div>
|
||||
<div id="SynthesisViewer-dispersion-tab" class="s-full-height">
|
||||
<synthesis-dispersion></synthesis-dispersion>
|
||||
</div>
|
||||
<div id="SynthesisViewer-bistability-tab" class="s-full-height">
|
||||
<bistability-viewer></bistability-viewer>
|
||||
</div>
|
||||
<div id="SynthesisViewer-code-tab" class="s-full-height">
|
||||
<synthesis-code></synthesis-code>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,37 @@
|
|||
#r "paket: groupref Build //"
|
||||
#load "./.fake/build.fsx/intellisense.fsx"
|
||||
|
||||
#if !FAKE
|
||||
#r "netstandard"
|
||||
#endif
|
||||
|
||||
open Fake.Core
|
||||
open Fake.Core.TargetOperators
|
||||
|
||||
#load "../../Builds/Builds/BuildHelper.fs"
|
||||
open BuildHelper
|
||||
|
||||
let localPort = "18852"
|
||||
let projectFile = "ClassicGECHTML5.csproj"
|
||||
let projectFolder = "."
|
||||
|
||||
Target.create "Run" (fun _ ->
|
||||
runDotNet ("serve -d dist -p "+localPort+" -o") projectFolder
|
||||
)
|
||||
|
||||
Target.create "Clean" (fun _ ->
|
||||
runDotNet "clean" projectFolder
|
||||
)
|
||||
|
||||
Target.create "Build" (fun _ ->
|
||||
runDotNet "build" projectFolder
|
||||
)
|
||||
|
||||
Target.create "Yarn" yarnInstall
|
||||
|
||||
"Clean"
|
||||
==> "Yarn"
|
||||
==> "Build"
|
||||
==> "Run"
|
||||
|
||||
Target.runOrDefault "Build"
|
|
@ -0,0 +1,18 @@
|
|||
declare module "*.html"
|
||||
declare module "idd" {
|
||||
var InteractiveDataDisplay: any;
|
||||
export = InteractiveDataDisplay;
|
||||
}
|
||||
declare module "tinycolor" {
|
||||
var tinycolor: any;
|
||||
export = tinycolor;
|
||||
}
|
||||
declare module "worker-loader*" {
|
||||
class WebpackWorker extends Worker {
|
||||
constructor();
|
||||
}
|
||||
export default WebpackWorker;
|
||||
}
|
||||
declare module "*index.js"
|
||||
declare module "*main.js"
|
||||
declare module "sboljs"
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 198 B |
|
@ -0,0 +1,5 @@
|
|||
group JavaScriptBuild
|
||||
|
||||
Yarn.MSBuild
|
||||
Node.js.redist
|
||||
Microsoft.TypeScript.MSBuild
|
|
@ -0,0 +1 @@
|
|||
dotnet fake build --target run
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"extends": "../../tsconfig.common",
|
||||
"include": [
|
||||
"*.ts",
|
||||
"Scripts/*.ts",
|
||||
"Scripts/Adapters/*.ts",
|
||||
"Scripts/Operations/*.ts",
|
||||
]
|
||||
}
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- Per ulteriori informazioni sull'utilizzo della trasformazione web.config, visitare http://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||
|
||||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||
<!--
|
||||
Nell'esempio seguente, la trasformazione "SetAttributes" modifica il valore di
|
||||
"connectionString" in modo da utilizzare "ReleaseSQLServer" solo quando il localizzatore "Match"
|
||||
individua un attributo "name" con valore "MyDB".
|
||||
|
||||
<connectionStrings>
|
||||
<add name="MyDB"
|
||||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||
</connectionStrings>
|
||||
-->
|
||||
<system.web>
|
||||
<!--
|
||||
|
||||
Nell'esempio seguente, la trasformazione "Replace" sostituisce l'intera
|
||||
sezione <customErrors> del file web.config.
|
||||
Poiché è presente un'unica sezione customErrors nel
|
||||
nodo <system.web>, non è necessario utilizzare l'attributo "xdt:Locator".
|
||||
|
||||
<customErrors defaultRedirect="GenericError.htm"
|
||||
mode="RemoteOnly" xdt:Transform="Replace">
|
||||
<error statusCode="500" redirect="InternalError.htm"/>
|
||||
</customErrors>
|
||||
-->
|
||||
</system.web>
|
||||
</configuration>
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- Per ulteriori informazioni sull'utilizzo della trasformazione web.config, visitare http://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||
|
||||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||
<!--
|
||||
Nell'esempio seguente, la trasformazione "SetAttributes" modifica il valore di
|
||||
"connectionString" in modo da utilizzare "ReleaseSQLServer" solo quando il localizzatore "Match"
|
||||
individua un attributo "name" con valore "MyDB".
|
||||
|
||||
<connectionStrings>
|
||||
<add name="MyDB"
|
||||
connectionString="Data Source=ReleaseSQLServer;Initial Catalog=MyReleaseDB;Integrated Security=True"
|
||||
xdt:Transform="SetAttributes" xdt:Locator="Match(name)"/>
|
||||
</connectionStrings>
|
||||
-->
|
||||
<system.web>
|
||||
<compilation xdt:Transform="RemoveAttributes(debug)" />
|
||||
<!--
|
||||
|
||||
Nell'esempio seguente, la trasformazione "Replace" sostituisce l'intera
|
||||
sezione <customErrors> del file web.config.
|
||||
Poiché è presente un'unica sezione customErrors nel
|
||||
nodo <system.web>, non è necessario utilizzare l'attributo "xdt:Locator".
|
||||
|
||||
<customErrors defaultRedirect="GenericError.htm"
|
||||
mode="RemoteOnly" xdt:Transform="Replace">
|
||||
<error statusCode="500" redirect="InternalError.htm"/>
|
||||
</customErrors>
|
||||
-->
|
||||
</system.web>
|
||||
</configuration>
|
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
For more information on how to configure your ASP.NET application, please visit
|
||||
http://go.microsoft.com/fwlink/?LinkId=169433
|
||||
-->
|
||||
<configuration>
|
||||
<!--
|
||||
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
|
||||
|
||||
The following attributes can be set on the <httpRuntime> tag.
|
||||
<system.Web>
|
||||
<httpRuntime targetFramework="4.7.2" />
|
||||
</system.Web>
|
||||
-->
|
||||
<system.web>
|
||||
<compilation debug="true" targetFramework="4.7.2" />
|
||||
<httpRuntime targetFramework="4.5.1" />
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<staticContent>
|
||||
<remove fileExtension=".crn" />
|
||||
<remove fileExtension=".eot" />
|
||||
<remove fileExtension=".ttf" />
|
||||
<remove fileExtension=".woff" />
|
||||
<remove fileExtension=".woff2" />
|
||||
<remove fileExtension=".wasm" />
|
||||
|
||||
<mimeMap fileExtension=".crn" mimeType="text/plain" />
|
||||
<mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
|
||||
<mimeMap fileExtension=".ttf" mimeType="application/font-sfnt" />
|
||||
<mimeMap fileExtension=".woff" mimeType="application/font-woff" />
|
||||
<mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
|
||||
<mimeMap fileExtension=".wasm" mimeType="application/wasm" />
|
||||
</staticContent>
|
||||
<httpProtocol>
|
||||
<!--<customHeaders>
|
||||
<add name="Cache-Control" value="no-cache, no-store" />
|
||||
<add name="Pragma" value="no-cache" />
|
||||
<add name="Expires" value="-1" />
|
||||
</customHeaders>-->
|
||||
</httpProtocol>
|
||||
<rewrite>
|
||||
<rules>
|
||||
<clear />
|
||||
<rule name="Redirect HTTP to HTTPS" stopProcessing="true">
|
||||
<match url="^(.*)$" />
|
||||
<conditions>
|
||||
<add input="{HTTPS}" pattern="^OFF$" />
|
||||
<add input="{HTTP_HOST}" matchType="Pattern" pattern="^localhost(:\d+)?$" negate="true" />
|
||||
<add input="{HTTP_HOST}" matchType="Pattern" pattern="^127\.0\.0\.1(:\d+)?$" negate="true" />
|
||||
</conditions>
|
||||
<action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="SeeOther" />
|
||||
</rule>
|
||||
<rule name="dist serve" stopProcessing="true">
|
||||
<match url=".*" />
|
||||
<conditions>
|
||||
<add input="{PATH_INFO}" pattern="^/dist/" negate="true" />
|
||||
<!-- this is to manage dev/deploy, move everything to ASP.NET Core to resolve this sensibly -->
|
||||
<add input="{HTTP_HOST}" pattern=".azurewebsites.net" negate="true" />
|
||||
</conditions>
|
||||
<action type="Rewrite" url="\dist\{R:0}" />
|
||||
</rule>
|
||||
</rules>
|
||||
</rewrite>
|
||||
</system.webServer>
|
||||
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.7.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding></runtime></configuration>
|
|
@ -0,0 +1,138 @@
|
|||
/// <binding AfterBuild='Run - Development' />
|
||||
"use strict";
|
||||
var webpack = require('webpack');
|
||||
var HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
var CleanWebpackPlugin = require('clean-webpack-plugin');
|
||||
var WorkboxPlugin = require('workbox-webpack-plugin');
|
||||
var path = require('path');
|
||||
var MonacoWebpackPlugin = require('monaco-editor-webpack-plugin');
|
||||
var CopyWebpackPlugin = require('copy-webpack-plugin');
|
||||
|
||||
module.exports = env => {
|
||||
if (env === undefined || env === null)
|
||||
env = {};
|
||||
if (env.mode === undefined || env === null)
|
||||
env.mode = "development";
|
||||
console.log("Mode is set to " + env.mode);
|
||||
return {
|
||||
mode: env.mode,
|
||||
entry: {
|
||||
app: "./Scripts/app.js"
|
||||
},
|
||||
output: {
|
||||
filename: "./[name].[chunkhash].js",
|
||||
path: path.resolve(__dirname, 'dist')
|
||||
},
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
chunks: 'all'
|
||||
}
|
||||
},
|
||||
// Suppress warnings about large file sizes. This is a complex app and we have a lot of code. That's why we have a loading screen.
|
||||
performance: { hints: false },
|
||||
resolve: {
|
||||
alias: {
|
||||
idd$: path.resolve(__dirname, '../../node_modules/interactive-data-display/dist/idd_knockout.js'),
|
||||
svg$: path.resolve(__dirname, '../../node_modules/svgjs'),
|
||||
filesaver$: path.resolve(__dirname, '../../node_modules/file-saver'),
|
||||
jquery$: path.resolve(__dirname, '../../node_modules/jquery')
|
||||
}
|
||||
},
|
||||
node: {
|
||||
fs: 'empty'
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
// https://github.com/webpack/webpack/issues/1406
|
||||
// Possible long-term fix: switch from KO to TKO.
|
||||
test: require.resolve('jquery'),
|
||||
use: [{
|
||||
loader: 'expose-loader',
|
||||
options: 'jQuery'
|
||||
}]
|
||||
},
|
||||
{
|
||||
test: /\.css$/,
|
||||
use: ['style-loader', 'css-loader']
|
||||
},
|
||||
{
|
||||
test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
|
||||
use: [{
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: '[name].[ext]',
|
||||
outputPath: 'fonts/'
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
test: /\.(svg|png)(\?v=\d+\.\d+\.\d+)?$/,
|
||||
use: [{
|
||||
loader: 'file-loader',
|
||||
options: {
|
||||
name: '[name].[ext]',
|
||||
outputPath: 'img/'
|
||||
}
|
||||
}]
|
||||
},
|
||||
{
|
||||
test: /\.wasm$/,
|
||||
type: "javascript/auto",
|
||||
loader: "file-loader"
|
||||
}
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
new CleanWebpackPlugin(['dist']),
|
||||
new CopyWebpackPlugin([{
|
||||
from: 'Examples/**',
|
||||
to: '.',
|
||||
context: '../',
|
||||
flatten: false
|
||||
}, {
|
||||
from: 'Examples/**',
|
||||
to: '.',
|
||||
context: '../../CRNEngine/',
|
||||
flatten: false,
|
||||
}, {
|
||||
from: '../../HTML5SharedGUI/GenericComponents/Styles/shared.css',
|
||||
to: 'shared.css',
|
||||
flatten: true
|
||||
}, {
|
||||
from: '../../HTML5SharedGUI/SimulationViewer/Img/refresh_icon.png',
|
||||
to: 'img/refresh_icon.png',
|
||||
flatten: true
|
||||
}, {
|
||||
from: '../../CRNEngine/HTML5CRN/favicon.ico',
|
||||
to: 'favicon.ico',
|
||||
flatten: true
|
||||
}, {
|
||||
from: './web.config',
|
||||
to: '.',
|
||||
flatten: true
|
||||
}]),
|
||||
new webpack.ProvidePlugin({
|
||||
$: 'jquery',
|
||||
jQuery: 'jquery',
|
||||
Rx: 'rx',
|
||||
ko: 'knockout',
|
||||
SVG: 'svgjs',
|
||||
saveAs: 'file-saver',
|
||||
jQuery_mousewheel: 'jquery-mousewheel'
|
||||
}),
|
||||
new MonacoWebpackPlugin({ languages: [] }),
|
||||
new HtmlWebpackPlugin({
|
||||
template: './Templates/index.html',
|
||||
filename: './index.html' //relative to root of the application
|
||||
}),
|
||||
new WorkboxPlugin.GenerateSW({
|
||||
swDest: './service-worker.js',
|
||||
clientsClaim: true,
|
||||
skipWaiting: true,
|
||||
// We have quite a lot of code, but we still want to precache it.
|
||||
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024
|
||||
})
|
||||
]
|
||||
}
|
||||
};
|
|
@ -0,0 +1,41 @@
|
|||
namespace ClassicGECIntegrationTests.AssemblyInfo
|
||||
|
||||
open System.Reflection
|
||||
open System.Runtime.CompilerServices
|
||||
open System.Runtime.InteropServices
|
||||
|
||||
// General Information about an assembly is controlled through the following
|
||||
// set of attributes. Change these attribute values to modify the information
|
||||
// associated with an assembly.
|
||||
[<assembly: AssemblyTitle("ClassicGECIntegrationTests")>]
|
||||
[<assembly: AssemblyDescription("")>]
|
||||
[<assembly: AssemblyConfiguration("")>]
|
||||
[<assembly: AssemblyCompany("")>]
|
||||
[<assembly: AssemblyProduct("ClassicGECIntegrationTests")>]
|
||||
[<assembly: AssemblyCopyright("Copyright © Microsoft Research Cambridge 2019-2020")>]
|
||||
[<assembly: AssemblyTrademark("")>]
|
||||
[<assembly: AssemblyCulture("")>]
|
||||
|
||||
// Setting ComVisible to false makes the types in this assembly not visible
|
||||
// to COM components. If you need to access a type in this assembly from
|
||||
// COM, set the ComVisible attribute to true on that type.
|
||||
[<assembly: ComVisible(false)>]
|
||||
|
||||
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||
[<assembly: Guid("02883acf-2e55-42e6-b437-ae8446695435")>]
|
||||
|
||||
// Version information for an assembly consists of the following four values:
|
||||
//
|
||||
// Major Version
|
||||
// Minor Version
|
||||
// Build Number
|
||||
// Revision
|
||||
//
|
||||
// You can specify all the values or you can default the Build and Revision Numbers
|
||||
// by using the '*' as shown below:
|
||||
// [<assembly: AssemblyVersion("1.0.*")>]
|
||||
[<assembly: AssemblyVersion("1.0.0.0")>]
|
||||
[<assembly: AssemblyFileVersion("1.0.0.0")>]
|
||||
|
||||
do
|
||||
()
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<Platforms>x64</Platforms>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<PublishChromeDriver>true</PublishChromeDriver>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<None Include="build.fsx" />
|
||||
<Compile Include="AssemblyInfo.fs" />
|
||||
<Compile Include="Tests.fs" />
|
||||
<Compile Include="Program.fs" />
|
||||
<None Include="paket.references" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\CRNEngine\CRNIntegrationTestLib\CRNIntegrationTestLib.fsproj" />
|
||||
<ProjectReference Include="..\ClassicGECWebServer\ClassicGECWebServer.fsproj" />
|
||||
<Reference Include="Oslo.FSharp">
|
||||
<HintPath>..\..\Lib\Oslo.FSharp\Oslo.FSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Target Name="AfterBuildFAKE" AfterTargets="AfterBuild">
|
||||
<Message Importance="high" Text="Running FAKE target Build" />
|
||||
<Exec Command="dotnet tool restore" />
|
||||
<Exec Command="dotnet fake build --target Build ProjectDir='$(ProjectDir)' Configuration=$(Configuration) OutDir='$(OutDir)'" />
|
||||
</Target>
|
||||
<Target Name="PublishFAKE" AfterTargets="Publish">
|
||||
<Message Importance="high" Text="Running FAKE target Publish" />
|
||||
<Exec Command="dotnet tool restore" />
|
||||
<Exec Command="dotnet fake build --target Publish ProjectDir='$(ProjectDir)' Configuration=$(Configuration) PublishDir='$(PublishDir)'" />
|
||||
</Target>
|
||||
<Import Project="..\..\.paket\Paket.Restore.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,35 @@
|
|||
open System
|
||||
open System.IO
|
||||
open Expecto
|
||||
open canopy
|
||||
open canopy.classic
|
||||
open canopy.types
|
||||
open Microsoft.AspNetCore.Hosting
|
||||
open Microsoft.Research.CRNEngineServerLib
|
||||
open Microsoft.Research.ClassicGECWebServer
|
||||
open Microsoft.Research.CRNIntegrationTestLib
|
||||
|
||||
[<EntryPoint>]
|
||||
let main args =
|
||||
System.Globalization.CultureInfo.DefaultThreadCurrentCulture <- System.Globalization.CultureInfo.InvariantCulture
|
||||
|
||||
let (groups,timeout,args) = Program.separateArgs args
|
||||
|
||||
let server = Server.startWebServer Program.processRequest Program.homeFolder Program.jobsFolder Program.port
|
||||
|
||||
let result =
|
||||
try
|
||||
let url = Server.starturl Program.port
|
||||
BrowserSetup.configureCanopy timeout
|
||||
let tests = Tests.tests groups Tests.Localhost url
|
||||
Program.run args tests
|
||||
finally
|
||||
printfn "Shutting down server..."
|
||||
server.StopAsync() |> ignore
|
||||
canopy.classic.quit()
|
||||
|
||||
if System.Diagnostics.Debugger.IsAttached then
|
||||
printf "Press any key to exit"
|
||||
System.Console.ReadKey() |> ignore
|
||||
|
||||
result
|
|
@ -0,0 +1,49 @@
|
|||
module Tests
|
||||
|
||||
open Expecto
|
||||
open canopy
|
||||
open canopy.classic
|
||||
open OpenQA.Selenium
|
||||
open Microsoft.Research.CRNIntegrationTestLib.Tests
|
||||
|
||||
let testCaseExample address = testCaseExample address "#gec-editor"
|
||||
|
||||
let tests groups mode address =
|
||||
let groups = if groups = [||] then [|"default"|] else groups
|
||||
printfn "Testing: %s" (System.String.Join(", ",groups))
|
||||
testList "UI" [
|
||||
if Array.contains "all_examples" groups then yield testList "all_examples" [
|
||||
load address
|
||||
let options = (element "#gecCode").FindElement(By.CssSelector ".c-examples").FindElements(By.CssSelector "option") |> Seq.map (fun (opt:IWebElement) -> opt.Text) |> Seq.skip 1
|
||||
for ex in options do yield testCaseExample address ex
|
||||
]
|
||||
if Array.contains "default" groups then yield testList "default" [
|
||||
//Direct URL request
|
||||
(*yield testCase "Smoke" <| fun _ ->
|
||||
let body =
|
||||
Request.createUrl Get Microsoft.Research.ClassicDSDServer.Program.url
|
||||
|> Request.responseAsString
|
||||
|> run
|
||||
|
||||
Expect.stringContains body "<title>Classic DSD Tool</title>" "It really should"*)
|
||||
//Canopy browser automation
|
||||
yield testCase "Canopy Smoke" <| fun _ ->
|
||||
load address
|
||||
()
|
||||
|
||||
yield testCase "Simulation Smoke" <| fun _ ->
|
||||
load address
|
||||
selectExample "#gec-editor" "Basic"
|
||||
simulate false
|
||||
()
|
||||
|
||||
(*yield testCase "Inference Smoke" <| fun _ ->
|
||||
load ()
|
||||
|
||||
selectExample "Join - Inference"
|
||||
|
||||
infer()
|
||||
|
||||
()*)
|
||||
]
|
||||
]
|
|
@ -0,0 +1,33 @@
|
|||
#r "paket: groupref Build //"
|
||||
#load ".fake/build.fsx/intellisense.fsx"
|
||||
open Fake.Core
|
||||
open Fake.DotNet
|
||||
open Fake.IO
|
||||
open Fake.IO.FileSystemOperators
|
||||
open Fake.IO.Globbing.Operators
|
||||
open BlackFox.Fake
|
||||
|
||||
#load "../../Builds/Builds/PublishHelper.fs"
|
||||
open PublishHelper
|
||||
#load "../ClassicGECWebServer/BuildSettings.fs"
|
||||
|
||||
let copyRequiredFilestoOutput projectDir outDir configuration =
|
||||
copySundials projectDir outDir configuration
|
||||
copyWebStuff projectDir outDir ClassicGECServer.BuildSettings.homeFolder
|
||||
copyJobStuff projectDir outDir ClassicGECServer.BuildSettings.jobsFolder
|
||||
|
||||
let build = BuildTask.createFn "Build" [] (fun args ->
|
||||
let settings = parseSettings args.Context.Arguments
|
||||
copyRequiredFilestoOutput settings.["ProjectDir"] settings.["OutDir"] settings.["Configuration"]
|
||||
)
|
||||
|
||||
//Example:
|
||||
//dotnet fake build --target Publish ProjectDir="E:\dev\biocomputing\ClassicGEC\ClassicGECServer\" PublishDir="bin\Debug\netcoreapp3.0\publish\" Configuration=Debug
|
||||
let publish = BuildTask.createFn "Publish" [] (fun args ->
|
||||
let settings = parseSettings args.Context.Arguments
|
||||
copyRequiredFilestoOutput settings.["ProjectDir"] settings.["PublishDir"] settings.["Configuration"]
|
||||
)
|
||||
|
||||
let nothing = BuildTask.createEmpty "Nothing" []
|
||||
|
||||
BuildTask.runOrDefaultWithArguments nothing
|
|
@ -0,0 +1,9 @@
|
|||
group DOTNETCORE
|
||||
|
||||
Canopy
|
||||
Expecto
|
||||
FSharp.Core
|
||||
Selenium.WebDriver
|
||||
Selenium.WebDriver.ChromeDriver
|
||||
Selenium.WebDriver.GeckoDriver.Win64
|
||||
Selenium.WebDriver.MicrosoftWebDriver
|
|
@ -0,0 +1,111 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DefineConstants>TRACE;JavaScript</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DefineConstants>TRACE;JavaScript</DefineConstants>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\ClassicGECDotNet\logicGEC.fs">
|
||||
<Link>logicGEC.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\options.fsi">
|
||||
<Link>options.fsi</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\options.fs">
|
||||
<Link>options.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\keywords.fs">
|
||||
<Link>keywords.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\ast.fs">
|
||||
<Link>ast.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\subst.fsi">
|
||||
<Link>subst.fsi</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\subst.fs">
|
||||
<Link>subst.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\gecspecies.fs">
|
||||
<Link>gecspecies.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\gecreaction.fsi">
|
||||
<Link>gecreaction.fsi</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\gecreaction.fs">
|
||||
<Link>gecreaction.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\directivesParser.fs">
|
||||
<Link>directivesParser.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\settings.fs">
|
||||
<Link>settings.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\database.fsi">
|
||||
<Link>database.fsi</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\database.fs">
|
||||
<Link>database.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\cssubst.fsi">
|
||||
<Link>cssubst.fsi</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\cssubst.fs">
|
||||
<Link>cssubst.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\solver.fsi">
|
||||
<Link>solver.fsi</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\solver.fs">
|
||||
<Link>solver.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\NumUtil.fs">
|
||||
<Link>NumUtil.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\trans.fs">
|
||||
<Link>trans.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\hypothesis.fs">
|
||||
<Link>hypothesis.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\program.fs">
|
||||
<Link>program.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\main.fs">
|
||||
<Link>main.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\transCrn.fs">
|
||||
<Link>transCrn.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\gec.fs">
|
||||
<Link>gec.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\ClassicGECDotNet\jsapi.fs">
|
||||
<Link>jsapi.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="jsonapi.fs" />
|
||||
<None Include="paket.references" />
|
||||
<None Include="wsconfig.json" />
|
||||
<Content Include="app.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\FSBOLWrapper\FSBOLWrapperJS\FSBOLWrapperJS.fsproj" />
|
||||
<ProjectReference Include="..\..\PDESolvers\ReactionDiffusionJS\ReactionDiffusionJS.fsproj" />
|
||||
<ProjectReference Include="..\..\CRNEngine\CRNEngineJS\CRNEngineJS.fsproj" />
|
||||
<ProjectReference Include="..\..\Filzbach.FSharp.JS\Filzbach.FSharp.JS.fsproj" />
|
||||
<ProjectReference Include="..\..\ParserCombinators\ParserCombinatorsJS\ParserCombinatorsJS.fsproj" />
|
||||
<ProjectReference Include="..\..\RulesDSD\RulesDSDJS\RulesDSDJS.fsproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Oslo.FSharp.WebSharper">
|
||||
<HintPath>..\..\Lib\Oslo-FSharp.websharper\Oslo.FSharp.WebSharper.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\.paket\Paket.Restore.targets" />
|
||||
</Project>
|
|
@ -0,0 +1 @@
|
|||
// This file takes the place of the W# output, in cases where W# is not invoked (i.e. server mode). A file must exist, even if it's empty, so that Webpack can handle references properly.
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
|
||||
<startup>
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
|
||||
</startup>
|
||||
<runtime><assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<Paket>True</Paket>
|
||||
<assemblyIdentity name="FSharp.Core" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="4.7.0.0" />
|
||||
</dependentAssembly>
|
||||
</assemblyBinding></runtime></configuration>
|
|
@ -0,0 +1,14 @@
|
|||
[<JavaScriptExport>]
|
||||
module Microsoft.Research.GEC.JSONAPI
|
||||
|
||||
open WebSharper
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
let compile (code:string) (parts:string) (reactions:string) : obj =
|
||||
let result = JSAPI.compile code parts reactions
|
||||
WebSharper.Json.Encode result
|
||||
|
||||
let get_solution (o:obj) (idx:int) : obj =
|
||||
let o = WebSharper.Json.Decode<JSAPI.solve_result> o
|
||||
let result = JSAPI.get_solution o idx
|
||||
WebSharper.Json.Encode result
|
|
@ -0,0 +1,4 @@
|
|||
group NETSTANDARD
|
||||
WebSharper.FSharp
|
||||
FSharp.Core
|
||||
FSBOLJS
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"project": "bundle",
|
||||
"outputDir": "Content",
|
||||
"javascriptExport": ["Microsoft.Research.CRNEngine.JSONAPI"]
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp3.1</TargetFramework>
|
||||
<OutputType>Exe</OutputType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Platforms>x64</Platforms>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Program.fs" />
|
||||
<None Include="paket.references" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\MomentClosure\MomentClosure\MomentClosure.fsproj" />
|
||||
<ProjectReference Include="..\..\CRNEngine\CliLibrary\CliLibrary.fsproj" />
|
||||
<ProjectReference Include="..\..\CRNEngine\CRNEngineDotNet\CRNEngineDotNet.fsproj" />
|
||||
<ProjectReference Include="..\ClassicGECDotNet\ClassicGECDotNet.fsproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="Oslo.FSharp">
|
||||
<HintPath>..\..\Lib\Oslo.FSharp\Oslo.FSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<Target Name="Copying Sundials" AfterTargets="AfterBuild" Condition="$(OS) == Windows_NT">
|
||||
<Exec Command="xcopy /y /q /d "$(ProjectDir)..\x64\$(Configuration)\SundialsSolver15.dll" "$(OutDir)"" />
|
||||
<Exec Command="xcopy /y /q /d "$(ProjectDir)..\x64\$(Configuration)\SundialsSolver15.pdb" "$(OutDir)"" />
|
||||
</Target>
|
||||
<Import Project="..\..\.paket\Paket.Restore.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,15 @@
|
|||
module Microsoft.Research.CRNEngine.RunAllExamples.Program
|
||||
open Microsoft.Research.CRNEngine
|
||||
open Microsoft.Research.CliLibrary.Testing
|
||||
|
||||
// Here we assume that we are only interested in the first solution, equivalent to how the GUI handles inference from a GEC program
|
||||
let parser code =
|
||||
let solveResult = Microsoft.Research.GEC.GECEngine.solveGEC (ref false) code Microsoft.Research.GEC.Databases.defaultParts Microsoft.Research.GEC.Databases.defaultReactions
|
||||
let firstSolution = Microsoft.Research.GEC.GECEngine.getCrnAssignment solveResult.graph solveResult.solution 0
|
||||
firstSolution.model
|
||||
|
||||
[<EntryPoint>]
|
||||
let main(args) =
|
||||
System.Threading.Thread.CurrentThread.CurrentCulture <- System.Globalization.CultureInfo.InvariantCulture
|
||||
System.Threading.Thread.CurrentThread.CurrentUICulture <- System.Globalization.CultureInfo.InvariantCulture
|
||||
testValidate (fun _ -> None) parser args
|
|
@ -0,0 +1,4 @@
|
|||
group DOTNETCORE
|
||||
|
||||
argu
|
||||
FSharp.Core
|
|
@ -0,0 +1,183 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.29503.13
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CRNEngineDotNet", "..\CRNEngine\CRNEngineDotNet\CRNEngineDotNet.fsproj", "{AE45211A-A65D-4827-A1F9-07A20EB0F154}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Filzbach.FSharp.Portable", "..\Filzbach.FSharp\Filzbach.FSharp.Portable.fsproj", "{2849368F-AC32-4D1E-B6D6-9C52261A5F2D}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "MomentClosure", "..\MomentClosure\MomentClosure\MomentClosure.fsproj", "{5D417D97-CC0E-4415-968D-97E16FF131D5}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ParserCombinators", "..\ParserCombinators\ParserCombinators\ParserCombinators.fsproj", "{DD8FEC26-6D1D-4642-A706-04070B6D5494}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ReactionDiffusion", "..\PDESolvers\ReactionDiffusion\ReactionDiffusion.fsproj", "{529BEDB7-C73A-4A77-BFD9-1628D75C321B}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SundialsSolver15", "..\SundialsSolver\SundialsSolver15\SundialsSolver15.vcxproj", "{866880DC-BF1E-4C12-8238-72E7EFF44AFB}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CRNEngineTests", "..\CRNEngine\CRNEngineTests\CRNEngineTests.fsproj", "{8E0427CB-DD8F-46BE-A5BC-C02CF55F152D}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ClassicGECWebServer", "ClassicGECWebServer\ClassicGECWebServer.fsproj", "{1DE5B345-EA66-4B52-8807-8E115F666215}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{866880DC-BF1E-4C12-8238-72E7EFF44AFB} = {866880DC-BF1E-4C12-8238-72E7EFF44AFB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ClassicGECDotNet", "ClassicGECDotNet\ClassicGECDotNet.fsproj", "{74DDCD31-9968-4B9B-8E5D-F07EDB7CE332}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassicGECHTML5", "ClassicGECHTML5\ClassicGECHTML5.csproj", "{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InferenceViewer", "..\HTML5SharedGUI\InferenceViewer\InferenceViewer.csproj", "{179FDF3E-67B8-4E2F-9089-650BB1319AF2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimulationViewer", "..\HTML5SharedGUI\SimulationViewer\SimulationViewer.csproj", "{0ECCE305-85C0-403F-A980-EEB9379BD5A4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSAGL_JS", "..\HTML5SharedGUI\MSAGL_JS\MSAGL_JS.csproj", "{2F3B8603-CFF1-4946-B242-6F848801B49A}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeEditor", "..\HTML5SharedGUI\CodeEditor\CodeEditor.csproj", "{B234C1D7-96F4-40A2-A323-3B18646BF95C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CRNComponent", "..\HTML5SharedGUI\CRNComponent\CRNComponent.csproj", "{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CRNEngineTSWrapper", "..\CRNEngine\CRNEngineTSWrapper\CRNEngineTSWrapper.csproj", "{FB1F1936-AC22-41B4-AF2F-E20A486E3416}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CRNEngineServerLib", "..\CRNEngine\CRNEngineServerLib\CRNEngineServerLib.fsproj", "{4522F647-5919-41E3-82E7-F886A640680B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ClassicGECTSWrapper", "ClassicGECTSWrapper\ClassicGECTSWrapper.csproj", "{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CliLibrary", "..\CRNEngine\CliLibrary\CliLibrary.fsproj", "{EEF843A3-43F8-4E6B-AB7F-9ADE3A5AF022}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HTML5CRN_Lib", "..\HTML5SharedGUI\HTML5CRN_Lib\HTML5CRN_Lib.csproj", "{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "FSBOLWrapper", "..\FSBOLWrapper\FSBOLWrapper\FSBOLWrapper.fsproj", "{AD19FE90-3663-4161-AC2D-08B4381D4808}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ClassicGECIntegrationTests", "ClassicGECIntegrationTests\ClassicGECIntegrationTests.fsproj", "{0278F0E2-D752-47C1-A2E5-EF4BB7828C93}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{866880DC-BF1E-4C12-8238-72E7EFF44AFB} = {866880DC-BF1E-4C12-8238-72E7EFF44AFB}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CRNJobsManager", "..\CRNEngine\CRNJobsManager\CRNJobsManager.csproj", "{20DDF233-1536-4C13-92E1-B2F578142811}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenericComponents", "..\HTML5SharedGUI\GenericComponents\GenericComponents.csproj", "{B1130E5F-166A-45BC-A966-EA9053557788}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CRNIntegrationTestLib", "..\CRNEngine\CRNIntegrationTestLib\CRNIntegrationTestLib.fsproj", "{0A50EC28-1F57-483F-809F-3153BD887261}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CRNEngineCloudLib", "..\CRNEngine\CRNEngineCloudLib\CRNEngineCloudLib.fsproj", "{66A501F9-427B-4DB8-9C72-9A844D917D2A}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "RulesDSD", "..\RulesDSD\RulesDSD\RulesDSD.fsproj", "{30177D74-4775-4629-BB08-CA533C6EB294}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{AE45211A-A65D-4827-A1F9-07A20EB0F154}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{AE45211A-A65D-4827-A1F9-07A20EB0F154}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{AE45211A-A65D-4827-A1F9-07A20EB0F154}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{AE45211A-A65D-4827-A1F9-07A20EB0F154}.Release|x64.Build.0 = Release|Any CPU
|
||||
{2849368F-AC32-4D1E-B6D6-9C52261A5F2D}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{2849368F-AC32-4D1E-B6D6-9C52261A5F2D}.Debug|x64.Build.0 = Debug|x64
|
||||
{2849368F-AC32-4D1E-B6D6-9C52261A5F2D}.Release|x64.ActiveCfg = Release|x64
|
||||
{2849368F-AC32-4D1E-B6D6-9C52261A5F2D}.Release|x64.Build.0 = Release|x64
|
||||
{5D417D97-CC0E-4415-968D-97E16FF131D5}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{5D417D97-CC0E-4415-968D-97E16FF131D5}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{5D417D97-CC0E-4415-968D-97E16FF131D5}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{5D417D97-CC0E-4415-968D-97E16FF131D5}.Release|x64.Build.0 = Release|Any CPU
|
||||
{DD8FEC26-6D1D-4642-A706-04070B6D5494}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{DD8FEC26-6D1D-4642-A706-04070B6D5494}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{DD8FEC26-6D1D-4642-A706-04070B6D5494}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{DD8FEC26-6D1D-4642-A706-04070B6D5494}.Release|x64.Build.0 = Release|Any CPU
|
||||
{529BEDB7-C73A-4A77-BFD9-1628D75C321B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{529BEDB7-C73A-4A77-BFD9-1628D75C321B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{529BEDB7-C73A-4A77-BFD9-1628D75C321B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{529BEDB7-C73A-4A77-BFD9-1628D75C321B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{866880DC-BF1E-4C12-8238-72E7EFF44AFB}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{866880DC-BF1E-4C12-8238-72E7EFF44AFB}.Debug|x64.Build.0 = Debug|x64
|
||||
{866880DC-BF1E-4C12-8238-72E7EFF44AFB}.Release|x64.ActiveCfg = Release|x64
|
||||
{866880DC-BF1E-4C12-8238-72E7EFF44AFB}.Release|x64.Build.0 = Release|x64
|
||||
{8E0427CB-DD8F-46BE-A5BC-C02CF55F152D}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{8E0427CB-DD8F-46BE-A5BC-C02CF55F152D}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{8E0427CB-DD8F-46BE-A5BC-C02CF55F152D}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{8E0427CB-DD8F-46BE-A5BC-C02CF55F152D}.Release|x64.Build.0 = Release|Any CPU
|
||||
{1DE5B345-EA66-4B52-8807-8E115F666215}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{1DE5B345-EA66-4B52-8807-8E115F666215}.Debug|x64.Build.0 = Debug|x64
|
||||
{1DE5B345-EA66-4B52-8807-8E115F666215}.Release|x64.ActiveCfg = Release|x64
|
||||
{1DE5B345-EA66-4B52-8807-8E115F666215}.Release|x64.Build.0 = Release|x64
|
||||
{74DDCD31-9968-4B9B-8E5D-F07EDB7CE332}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{74DDCD31-9968-4B9B-8E5D-F07EDB7CE332}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{74DDCD31-9968-4B9B-8E5D-F07EDB7CE332}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{74DDCD31-9968-4B9B-8E5D-F07EDB7CE332}.Release|x64.Build.0 = Release|Any CPU
|
||||
{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{CBC756D7-8BB7-4CEC-95C7-FDB9363BAC63}.Release|x64.Build.0 = Release|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Release|x64.Build.0 = Release|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Release|x64.Build.0 = Release|Any CPU
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Release|x64.Build.0 = Release|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Release|x64.Build.0 = Release|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Release|x64.Build.0 = Release|Any CPU
|
||||
{4522F647-5919-41E3-82E7-F886A640680B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{4522F647-5919-41E3-82E7-F886A640680B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{4522F647-5919-41E3-82E7-F886A640680B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4522F647-5919-41E3-82E7-F886A640680B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{A7A666E0-2ADE-4496-A84A-267BBE68B5A1}.Release|x64.Build.0 = Release|Any CPU
|
||||
{EEF843A3-43F8-4E6B-AB7F-9ADE3A5AF022}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{EEF843A3-43F8-4E6B-AB7F-9ADE3A5AF022}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{EEF843A3-43F8-4E6B-AB7F-9ADE3A5AF022}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{EEF843A3-43F8-4E6B-AB7F-9ADE3A5AF022}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Release|x64.Build.0 = Release|Any CPU
|
||||
{AD19FE90-3663-4161-AC2D-08B4381D4808}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{AD19FE90-3663-4161-AC2D-08B4381D4808}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{AD19FE90-3663-4161-AC2D-08B4381D4808}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{AD19FE90-3663-4161-AC2D-08B4381D4808}.Release|x64.Build.0 = Release|Any CPU
|
||||
{0278F0E2-D752-47C1-A2E5-EF4BB7828C93}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0278F0E2-D752-47C1-A2E5-EF4BB7828C93}.Debug|x64.Build.0 = Debug|x64
|
||||
{0278F0E2-D752-47C1-A2E5-EF4BB7828C93}.Release|x64.ActiveCfg = Release|x64
|
||||
{0278F0E2-D752-47C1-A2E5-EF4BB7828C93}.Release|x64.Build.0 = Release|x64
|
||||
{20DDF233-1536-4C13-92E1-B2F578142811}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{20DDF233-1536-4C13-92E1-B2F578142811}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{20DDF233-1536-4C13-92E1-B2F578142811}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{20DDF233-1536-4C13-92E1-B2F578142811}.Release|x64.Build.0 = Release|Any CPU
|
||||
{B1130E5F-166A-45BC-A966-EA9053557788}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{B1130E5F-166A-45BC-A966-EA9053557788}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{B1130E5F-166A-45BC-A966-EA9053557788}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{B1130E5F-166A-45BC-A966-EA9053557788}.Release|x64.Build.0 = Release|Any CPU
|
||||
{0A50EC28-1F57-483F-809F-3153BD887261}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{0A50EC28-1F57-483F-809F-3153BD887261}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{0A50EC28-1F57-483F-809F-3153BD887261}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{0A50EC28-1F57-483F-809F-3153BD887261}.Release|x64.Build.0 = Release|Any CPU
|
||||
{66A501F9-427B-4DB8-9C72-9A844D917D2A}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{66A501F9-427B-4DB8-9C72-9A844D917D2A}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{66A501F9-427B-4DB8-9C72-9A844D917D2A}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{66A501F9-427B-4DB8-9C72-9A844D917D2A}.Release|x64.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E643CAE2-AD10-4B8C-ADD6-C5A3EC142FAE}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,12 @@
|
|||
Samples/**/*.d.ts
|
||||
Samples/**/*.js
|
||||
Samples/**/*.js.map
|
||||
Scripts/*.d.ts
|
||||
Scripts/*.js
|
||||
Scripts/*.wasm
|
||||
Scripts/*.js.map
|
||||
!Scripts/declarations.d.ts
|
||||
|
||||
#residual files from before webpack
|
||||
Scripts/CRNEngine
|
||||
Scripts/src
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче