Adding Strand Graphs code (#6)
* Adding Strand Graphs code and fixing builds. * Regenerated TS interfaces for CRNEngine, ClassicGEC, ClassicDSD and SiteGraphReactor.
This commit is contained in:
Родитель
c98603c729
Коммит
cf6d21e089
|
@ -43,4 +43,10 @@ jobs:
|
|||
run: dotnet restore ClassicDSD/ClassicDSDHTML5.sln
|
||||
- name: Build DSD
|
||||
shell: cmd
|
||||
run: msbuild ClassicDSD/ClassicDSDHTML5.sln /p:Configuration=Release /p:Platform=x64
|
||||
run: msbuild ClassicDSD/ClassicDSDHTML5.sln /p:Configuration=Release /p:Platform=x64
|
||||
|
||||
- name: Restore Strand Graphs dependencies
|
||||
run: dotnet restore HTML5StrandGraphs/HTML5StrandGraphs.sln
|
||||
- name: Build Strand Graphs
|
||||
shell: cmd
|
||||
run: msbuild HTML5StrandGraphs/HTML5StrandGraphs.sln /p:Configuration=Release
|
||||
|
|
|
@ -339,7 +339,7 @@ let simulateFloatJIT (gui:GuiModel) (jit:jit<'a>) (output : Row<float> -> unit)
|
|||
let gui = { task = None; nodes = [("",gui)] |> Map.ofList; edges = Map.empty; expanded = false }
|
||||
output_program gui
|
||||
|
||||
let simulator_to_value_type (settings:Crn_settings<_>) =
|
||||
let simulator_to_value_type (settings:Crn_settings<Functional>) =
|
||||
match settings.simulator with
|
||||
| Simulator.LNA -> MeanStdev
|
||||
| Simulator.CME | Simulator.CMESundials -> MeanStdevProbabilities
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
//These interfaces are code generated from F#, any changes to this file will be lost.
|
||||
export namespace WebSharperGeneratedInterfaces {
|
||||
|
||||
|
@ -84,6 +81,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
sweeps: Array<Microsoft.Research.CRNEngine.Sweep>;
|
||||
rates: { [key: string]: e };
|
||||
plot: Microsoft.Research.CRNEngine.Plot_settings<e>;
|
||||
quiet: boolean;
|
||||
}
|
||||
export interface Ctmc {
|
||||
graph: Microsoft.Research.CRNEngine.Dictionary.t<Opaque.FSharpMap<number, number>, Array<Microsoft.Research.CRNEngine.Transition>>;
|
||||
|
@ -244,6 +242,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
seed?: number;
|
||||
kinetics: Microsoft.Research.CRNEngine.Kinetics;
|
||||
times: Array<number>;
|
||||
prune: boolean;
|
||||
multicore: boolean;
|
||||
data: Array<string>;
|
||||
sweeps: Array<string>;
|
||||
|
@ -273,8 +272,8 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
assignments: Array<Microsoft.Research.CRNEngine.Assignment>;
|
||||
}
|
||||
export interface Synthesis_settings {
|
||||
mode: Microsoft.Research.CRNEngine.Synthesis_mode
|
||||
solver: Microsoft.Research.CRNEngine.Z3Solver
|
||||
mode: Microsoft.Research.CRNEngine.Synthesis_mode;
|
||||
solver: Microsoft.Research.CRNEngine.Z3Solver;
|
||||
timeout?: number;
|
||||
seed?: number;
|
||||
}
|
||||
|
@ -283,7 +282,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
columns: Array<Microsoft.Research.CRNEngine.Column<v>>;
|
||||
}
|
||||
export interface Task {
|
||||
task_type: Microsoft.Research.CRNEngine.TaskType;
|
||||
task_type?: Microsoft.Research.CRNEngine.TaskType;
|
||||
copies: number;
|
||||
copy_id: number;
|
||||
nodes: number;
|
||||
|
@ -386,129 +385,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
}
|
||||
}
|
||||
|
||||
export namespace System {
|
||||
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.Filzbach.Filzbach {
|
||||
export interface Burnin {
|
||||
space: Microsoft.Research.Filzbach.DataStructures.AssociativeArray<Microsoft.Research.Filzbach.Parameters.ParameterRange>;
|
||||
state: Microsoft.Research.Filzbach.Parameters.EvaluatedValues;
|
||||
thinningSkippedCount: number;
|
||||
chain: Array<Microsoft.Research.Filzbach.Parameters.EvaluatedValues>;
|
||||
stats: Array<Microsoft.Research.Filzbach.Parameters.AcceptanceStatistics>;
|
||||
randGen: Microsoft.Research.Filzbach.Lib.IRng;
|
||||
innovationGens: Opaque.FSharpMap<number, Microsoft.Research.Filzbach.Lib.NormalGenerator>;
|
||||
mle: Microsoft.Research.Filzbach.Parameters.EvaluatedValues;
|
||||
priors: Array<Microsoft.Research.Filzbach.Parameters.PriorValue | null>;
|
||||
indexes: Array<number>;
|
||||
}
|
||||
export interface Sampling {
|
||||
space: Microsoft.Research.Filzbach.DataStructures.AssociativeArray<Microsoft.Research.Filzbach.Parameters.ParameterRange>;
|
||||
state: Microsoft.Research.Filzbach.Parameters.EvaluatedValues;
|
||||
thinningSkippedCount: number;
|
||||
chain: Array<Microsoft.Research.Filzbach.Parameters.EvaluatedValues>;
|
||||
burnin: Array<Microsoft.Research.Filzbach.Parameters.EvaluatedValues>;
|
||||
randGen: Microsoft.Research.Filzbach.Lib.IRng;
|
||||
innovationGens: Opaque.FSharpMap<number, Microsoft.Research.Filzbach.Lib.NormalGenerator>;
|
||||
mle: Microsoft.Research.Filzbach.Parameters.EvaluatedValues;
|
||||
priors: Array<Microsoft.Research.Filzbach.Parameters.PriorValue | null>;
|
||||
indexes: Array<number>;
|
||||
accepted: number;
|
||||
}
|
||||
export interface RunPhase {
|
||||
BurninPhase?: Microsoft.Research.Filzbach.Filzbach.Burnin;
|
||||
SamplingPhase?: Microsoft.Research.Filzbach.Filzbach.Sampling;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.CRNEngine.InferenceSiteGraph {
|
||||
export interface IGraph {
|
||||
task?: Microsoft.Research.CRNEngine.Task;
|
||||
nodes: Opaque.FSharpMap<string, Microsoft.Research.CRNEngine.Model>;
|
||||
edges: Opaque.FSharpMap<Microsoft.Research.CRNEngine.InferenceSiteGraph.Location, Array<Opaque.FSharpTuple>>;
|
||||
expanded: boolean;
|
||||
}
|
||||
export interface Location {
|
||||
NodeLoc?: string;
|
||||
SystemLoc?: Opaque.FSharpTuple;
|
||||
}
|
||||
export type PriorKind = "Fixed2" | "Normal" | "LogNormal" | "TruncatedNormal"
|
||||
export const PriorKindSelect = ["Fixed2", "Normal", "LogNormal", "TruncatedNormal"]
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.Filzbach.Lib {
|
||||
export interface IRng {
|
||||
//NextDouble : () => Opaque.FSharpTuple;
|
||||
//NextInt32 : () => Opaque.FSharpTuple;
|
||||
}
|
||||
export interface NormalGenerator {
|
||||
//Mean : () => number;
|
||||
//Sigma : () => number;
|
||||
//State : () => Microsoft.Research.Filzbach.Lib.NormalGeneratorState;
|
||||
//nextDouble : () => Opaque.FSharpTuple;
|
||||
}
|
||||
export interface NormalGeneratorState {
|
||||
rnorm_phase: boolean;
|
||||
rnorm_2: number;
|
||||
rnorm_f: number;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.CRNEngine.Graph {
|
||||
export type LineStyle = "Normal" | "Dashed"
|
||||
export type Shape = "Ellipse" | "Box"
|
||||
export interface Node {
|
||||
id: string;
|
||||
label?: string;
|
||||
stroke?: string;
|
||||
fill?: string;
|
||||
shape?: Shape;
|
||||
}
|
||||
export interface Edge {
|
||||
source: string;
|
||||
destination: string;
|
||||
label?: string;
|
||||
style?: LineStyle;
|
||||
stroke?: string;
|
||||
}
|
||||
export interface Graph {
|
||||
nodes: Node[];
|
||||
edges: Edge[];
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.CRNEngine.JSAPI {
|
||||
export interface SynthesisDispersionResult {
|
||||
markersX: number[];
|
||||
markersY: number[];
|
||||
plotX: number[];
|
||||
plotY: number[];
|
||||
xMin: number;
|
||||
xMax: number;
|
||||
yMin: number;
|
||||
yMax: number;
|
||||
}
|
||||
export interface SynthesisValue {
|
||||
value: number;
|
||||
lowerBound?: number;
|
||||
upperBound?: number;
|
||||
}
|
||||
export interface SynthesisEquations {
|
||||
rateEquations: string;
|
||||
jacobian: string;
|
||||
diffusion: string;
|
||||
csts: string;
|
||||
}
|
||||
export interface SynthesisResult {
|
||||
message: string;
|
||||
values: { [variable: string]: SynthesisValue };
|
||||
equations: Microsoft.Research.CRNEngine.JSAPI.SynthesisEquations;
|
||||
dispersion?: Microsoft.Research.CRNEngine.JSAPI.SynthesisDispersionResult;
|
||||
jacobian?: Microsoft.Research.CRNEngine.Graph.Graph;
|
||||
crn?: Gui;
|
||||
code?: string;
|
||||
}
|
||||
export interface BistabilityPlot {
|
||||
speciesX: string;
|
||||
speciesY: string;
|
||||
|
@ -516,12 +393,12 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
state1y: number;
|
||||
state2x: number;
|
||||
state2y: number;
|
||||
initialsX: number[];
|
||||
initialsY: number[];
|
||||
state1simsX: number[][];
|
||||
state1simsY: number[][];
|
||||
state2simsX: number[][];
|
||||
state2simsY: number[][];
|
||||
initialsX: Array<number>;
|
||||
initialsY: Array<number>;
|
||||
state1simsX: Array<Array<number>>;
|
||||
state1simsY: Array<Array<number>>;
|
||||
state2simsX: Array<Array<number>>;
|
||||
state2simsY: Array<Array<number>>;
|
||||
}
|
||||
export interface InferenceParameter {
|
||||
name: string;
|
||||
|
@ -537,6 +414,36 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
nodeId: string;
|
||||
parameters: Array<Microsoft.Research.CRNEngine.JSAPI.InferenceParameter>;
|
||||
}
|
||||
export interface SynthesisDispersionResult {
|
||||
markersX: Array<number>;
|
||||
markersY: Array<number>;
|
||||
plotX: Array<number>;
|
||||
plotY: Array<number>;
|
||||
xMin: number;
|
||||
xMax: number;
|
||||
yMin: number;
|
||||
yMax: number;
|
||||
}
|
||||
export interface SynthesisEquations {
|
||||
rateEquations: string;
|
||||
jacobian: string;
|
||||
diffusion: string;
|
||||
csts: string;
|
||||
}
|
||||
export interface SynthesisResult {
|
||||
message: string;
|
||||
values: { [key: string]: Microsoft.Research.CRNEngine.JSAPI.SynthesisValue };
|
||||
equations: Microsoft.Research.CRNEngine.JSAPI.SynthesisEquations;
|
||||
dispersion?: Microsoft.Research.CRNEngine.JSAPI.SynthesisDispersionResult;
|
||||
jacobian?: Microsoft.Research.CRNEngine.Graph.Graph;
|
||||
crn?: Microsoft.Research.CRNEngine.Gui;
|
||||
code?: string;
|
||||
}
|
||||
export interface SynthesisValue {
|
||||
value: number;
|
||||
lowerBound?: number;
|
||||
upperBound?: number;
|
||||
}
|
||||
export interface column_array<v> {
|
||||
name: string;
|
||||
values: Array<v>;
|
||||
|
@ -547,7 +454,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
display_name: string;
|
||||
node_id?: string;
|
||||
instance?: string;
|
||||
content?: string[];
|
||||
content?: Array<string>;
|
||||
save_content?: string;
|
||||
}
|
||||
export interface inference_burnin {
|
||||
|
@ -619,6 +526,100 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
}
|
||||
}
|
||||
|
||||
export namespace System {
|
||||
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.Filzbach.Filzbach {
|
||||
export interface Burnin {
|
||||
space: Microsoft.Research.Filzbach.DataStructures.AssociativeArray<Microsoft.Research.Filzbach.Parameters.ParameterRange>;
|
||||
state: Microsoft.Research.Filzbach.Parameters.EvaluatedValues;
|
||||
thinningSkippedCount: number;
|
||||
chain: Array<Microsoft.Research.Filzbach.Parameters.EvaluatedValues>;
|
||||
stats: Array<Microsoft.Research.Filzbach.Parameters.AcceptanceStatistics>;
|
||||
randGen: Microsoft.Research.Filzbach.Lib.IRng;
|
||||
innovationGens: Opaque.FSharpMap<number, Microsoft.Research.Filzbach.Lib.NormalGenerator>;
|
||||
mle: Microsoft.Research.Filzbach.Parameters.EvaluatedValues;
|
||||
priors: Array<Microsoft.Research.Filzbach.Parameters.PriorValue | null>;
|
||||
indexes: Array<number>;
|
||||
}
|
||||
export interface Sampling {
|
||||
space: Microsoft.Research.Filzbach.DataStructures.AssociativeArray<Microsoft.Research.Filzbach.Parameters.ParameterRange>;
|
||||
state: Microsoft.Research.Filzbach.Parameters.EvaluatedValues;
|
||||
thinningSkippedCount: number;
|
||||
chain: Array<Microsoft.Research.Filzbach.Parameters.EvaluatedValues>;
|
||||
burnin: Array<Microsoft.Research.Filzbach.Parameters.EvaluatedValues>;
|
||||
randGen: Microsoft.Research.Filzbach.Lib.IRng;
|
||||
innovationGens: Opaque.FSharpMap<number, Microsoft.Research.Filzbach.Lib.NormalGenerator>;
|
||||
mle: Microsoft.Research.Filzbach.Parameters.EvaluatedValues;
|
||||
priors: Array<Microsoft.Research.Filzbach.Parameters.PriorValue | null>;
|
||||
indexes: Array<number>;
|
||||
accepted: number;
|
||||
}
|
||||
export interface RunPhase {
|
||||
BurninPhase?: Microsoft.Research.Filzbach.Filzbach.Burnin;
|
||||
SamplingPhase?: Microsoft.Research.Filzbach.Filzbach.Sampling;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.CRNEngine.Graph {
|
||||
export interface Edge {
|
||||
source: string;
|
||||
destination: string;
|
||||
label?: string;
|
||||
style?: Microsoft.Research.CRNEngine.Graph.LineStyle;
|
||||
stroke?: string;
|
||||
}
|
||||
export interface Graph {
|
||||
nodes: Array<Microsoft.Research.CRNEngine.Graph.Node>;
|
||||
edges: Array<Microsoft.Research.CRNEngine.Graph.Edge>;
|
||||
}
|
||||
export interface Node {
|
||||
id: string;
|
||||
label?: string;
|
||||
stroke?: string;
|
||||
fill?: string;
|
||||
shape?: Microsoft.Research.CRNEngine.Graph.Shape;
|
||||
}
|
||||
export type LineStyle = "Dashed"
|
||||
export const LineStyleSelect = ["Dashed"]
|
||||
export type Shape = "Ellipse" | "Box"
|
||||
export const ShapeSelect = ["Ellipse", "Box"]
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.CRNEngine.InferenceSiteGraph {
|
||||
export interface IGraph {
|
||||
task?: Microsoft.Research.CRNEngine.Task;
|
||||
nodes: Opaque.FSharpMap<string, Microsoft.Research.CRNEngine.Model>;
|
||||
edges: Opaque.FSharpMap<Microsoft.Research.CRNEngine.InferenceSiteGraph.Location, Array<Opaque.FSharpTuple>>;
|
||||
expanded: boolean;
|
||||
}
|
||||
export interface Location {
|
||||
NodeLoc?: string;
|
||||
SystemLoc?: Opaque.FSharpTuple;
|
||||
}
|
||||
export type PriorKind = "Fixed2" | "Normal" | "LogNormal" | "TruncatedNormal"
|
||||
export const PriorKindSelect = ["Fixed2", "Normal", "LogNormal", "TruncatedNormal"]
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.Filzbach.Lib {
|
||||
export interface IRng {
|
||||
//NextDouble : () => Opaque.FSharpTuple;
|
||||
//NextInt32 : () => Opaque.FSharpTuple;
|
||||
}
|
||||
export interface NormalGenerator {
|
||||
//Mean : () => number;
|
||||
//Sigma : () => number;
|
||||
//State : () => Microsoft.Research.Filzbach.Lib.NormalGeneratorState;
|
||||
//nextDouble : () => Opaque.FSharpTuple;
|
||||
}
|
||||
export interface NormalGeneratorState {
|
||||
rnorm_phase: boolean;
|
||||
rnorm_2: number;
|
||||
rnorm_f: number;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.CRNEngine.Jit {
|
||||
export interface JitReaction<s, v, e> {
|
||||
id: number;
|
||||
|
@ -859,6 +860,10 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
(gui: Microsoft.Research.CRNEngine.GuiModel, jit: Microsoft.Research.CRNEngine.JSAPI.jit<a>, output: (p0: Microsoft.Research.CRNEngine.Row<number>) => void, output_plottable: (p0: Microsoft.Research.CRNEngine.Jit.newplottable) => void, output_export: (p0: Microsoft.Research.CRNEngine.JSAPI.export_def) => void, output_program: (p0: Microsoft.Research.CRNEngine.GuiIG) => void, cancel: Microsoft.FSharp.Core.Ref<boolean>): void
|
||||
}
|
||||
|
||||
export interface simulator_to_value_type {
|
||||
(settings: Microsoft.Research.CRNEngine.Crn_settings<Microsoft.Research.CRNEngine.Expression.t<Microsoft.Research.CRNEngine.Key<Microsoft.Research.CRNEngine.Species>>>): Microsoft.Research.CRNEngine.JSAPI.ValueType
|
||||
}
|
||||
|
||||
export interface user_get_sim_runs {
|
||||
(guiig: Microsoft.Research.CRNEngine.GuiIG, model_id: string): Microsoft.Research.CRNEngine.JSAPI.sim_run
|
||||
}
|
||||
|
@ -888,7 +893,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
}
|
||||
|
||||
export interface convert_inference_result {
|
||||
(nodeId: string, res: Microsoft.Research.CRNEngine.Inference.mcmc_intermediate_result, lkIncreased: boolean): Microsoft.Research.CRNEngine.JSAPI.inference_result
|
||||
(nodeId: string, res: Microsoft.Research.CRNEngine.Inference.mcmc_intermediate_result, lkincreased: boolean): Microsoft.Research.CRNEngine.JSAPI.inference_result
|
||||
}
|
||||
|
||||
export interface combine_dynchar_exports {
|
||||
|
|
|
@ -61,7 +61,8 @@ function getHardcoded() {
|
|||
times: [],
|
||||
multicore: false,
|
||||
data: [],
|
||||
sweeps: []
|
||||
sweeps: [],
|
||||
prune: true
|
||||
},
|
||||
simulations: [],
|
||||
data: [{
|
||||
|
@ -116,7 +117,8 @@ function getHardcoded() {
|
|||
synthesis: {
|
||||
mode: "Multistability",
|
||||
solver: "NLSat"
|
||||
}
|
||||
},
|
||||
quiet: false
|
||||
},
|
||||
reactions: [{
|
||||
reactants: [{ element: "A", multiplicity: 1 }],
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
//These interfaces are code generated from F#, any changes to this file will be lost.
|
||||
export namespace WebSharperGeneratedInterfaces {
|
||||
|
||||
|
@ -37,6 +34,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
sweeps: Array<Microsoft.Research.CRNEngine.Sweep>;
|
||||
rates: { [key: string]: e };
|
||||
plot: Microsoft.Research.CRNEngine.Plot_settings<e>;
|
||||
quiet: boolean;
|
||||
}
|
||||
export interface Dataset {
|
||||
file: string;
|
||||
|
@ -167,6 +165,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
seed?: number;
|
||||
kinetics: Microsoft.Research.CRNEngine.Kinetics;
|
||||
times: Array<number>;
|
||||
prune: boolean;
|
||||
multicore: boolean;
|
||||
data: Array<string>;
|
||||
sweeps: Array<string>;
|
||||
|
@ -193,16 +192,17 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
assignments: Array<Microsoft.Research.CRNEngine.Assignment>;
|
||||
}
|
||||
export interface Synthesis_settings {
|
||||
mode: Microsoft.Research.CRNEngine.Synthesis_mode
|
||||
solver: Microsoft.Research.CRNEngine.Z3Solver
|
||||
mode: Microsoft.Research.CRNEngine.Synthesis_mode;
|
||||
solver: Microsoft.Research.CRNEngine.Z3Solver;
|
||||
timeout?: number;
|
||||
seed?: number;
|
||||
}
|
||||
export interface Table<v> {
|
||||
times: Array<number>;
|
||||
columns: Array<Microsoft.Research.CRNEngine.Column<v>>;
|
||||
}
|
||||
export interface Task {
|
||||
task_type: Microsoft.Research.CRNEngine.TaskType;
|
||||
task_type?: Microsoft.Research.CRNEngine.TaskType;
|
||||
copies: number;
|
||||
copy_id: number;
|
||||
nodes: number;
|
||||
|
@ -274,60 +274,33 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
export const Z3SolverSelect = ["NLSat", "Portfolio"]
|
||||
}
|
||||
|
||||
export namespace RulesDSD.Syntax {
|
||||
export interface Clause {
|
||||
head: RulesDSD.Syntax.Predicate;
|
||||
body: Array<RulesDSD.Syntax.Literal>;
|
||||
}
|
||||
export namespace Microsoft.Research.DNA.LogicDSD {
|
||||
export interface Domain {
|
||||
name: string;
|
||||
isComplementary: boolean;
|
||||
isToehold: boolean;
|
||||
tag?: RulesDSD.Syntax.Term;
|
||||
tag: Microsoft.Research.DNA.LogicDSD.Tag;
|
||||
}
|
||||
export interface Bond {
|
||||
Bond?: number;
|
||||
Var?: Opaque.FSharpTuple;
|
||||
}
|
||||
export interface DomainT {
|
||||
Dom?: RulesDSD.Syntax.Domain;
|
||||
Var?: (Opaque.FSharpTuple | RulesDSD.Syntax.Term | null)[];
|
||||
}
|
||||
export interface Literal {
|
||||
Pos?: RulesDSD.Syntax.Predicate;
|
||||
Neg?: RulesDSD.Syntax.Predicate;
|
||||
}
|
||||
export interface Pattern {
|
||||
Nicking?: Array<Opaque.FSharpTuple>[];
|
||||
Inner?: Array<Opaque.FSharpTuple>;
|
||||
Strand?: Array<Opaque.FSharpTuple>;
|
||||
ThreePrime?: Array<Opaque.FSharpTuple>;
|
||||
FivePrime?: Array<Opaque.FSharpTuple>;
|
||||
Nihil?: string;
|
||||
}
|
||||
export interface Predicate {
|
||||
Pred: (string | Array<RulesDSD.Syntax.Term>)[];
|
||||
}
|
||||
export interface Process {
|
||||
Proc: Opaque.FSharpMap<number, Array<RulesDSD.Syntax.SiteT>>;
|
||||
Dom?: Microsoft.Research.DNA.LogicDSD.Domain;
|
||||
Var?: (Opaque.FSharpTuple | Microsoft.Research.DNA.LogicDSD.Tag)[];
|
||||
}
|
||||
export interface Site {
|
||||
Unbound?: RulesDSD.Syntax.DomainT;
|
||||
Bound?: (RulesDSD.Syntax.DomainT | RulesDSD.Syntax.Bond)[];
|
||||
Unbound?: Microsoft.Research.DNA.LogicDSD.DomainT;
|
||||
Bound?: (Microsoft.Research.DNA.LogicDSD.DomainT | Microsoft.Research.DNA.LogicDSD.Bond)[];
|
||||
}
|
||||
export interface SiteT {
|
||||
Site?: RulesDSD.Syntax.Site;
|
||||
Site?: Microsoft.Research.DNA.LogicDSD.Site;
|
||||
Var?: Opaque.FSharpTuple;
|
||||
}
|
||||
export interface Term {
|
||||
Var?: (number | string)[];
|
||||
Const?: string;
|
||||
Float?: number;
|
||||
Func?: (string | Array<RulesDSD.Syntax.Term>)[];
|
||||
TList?: Array<RulesDSD.Syntax.Term>;
|
||||
TCons?: RulesDSD.Syntax.Term[];
|
||||
Proc?: RulesDSD.Syntax.Process;
|
||||
Pat?: RulesDSD.Syntax.Pattern;
|
||||
export interface Tag {
|
||||
NoTag?: string;
|
||||
AnyTag?: string;
|
||||
Tag?: RulesDSD.Syntax.Term<Microsoft.Research.DNA.LogicDSD.SiteT>;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -350,12 +323,12 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
dsdOptions: Microsoft.Research.DNA.Options.t;
|
||||
}
|
||||
export interface RulesBundle {
|
||||
settings: Microsoft.Research.CRNEngine.Crn_settings<Microsoft.Research.CRNEngine.Expression.t<Microsoft.Research.CRNEngine.Key<RulesDSD.Syntax.Process>>>;
|
||||
initials: Array<Microsoft.Research.CRNEngine.Initial<RulesDSD.Syntax.Process, Microsoft.Research.CRNEngine.Expression.t<string>>>;
|
||||
reactions: Array<Microsoft.Research.CRNEngine.Reaction<RulesDSD.Syntax.Process, Microsoft.Research.CRNEngine.Expression.t<string>, Microsoft.Research.CRNEngine.Expression.t<Microsoft.Research.CRNEngine.Key<RulesDSD.Syntax.Process>>>>;
|
||||
plotsCache: Opaque.Dictionary<RulesDSD.Syntax.Process, string>;
|
||||
settings: Microsoft.Research.CRNEngine.Crn_settings<Microsoft.Research.CRNEngine.Expression.t<Microsoft.Research.CRNEngine.Key<RulesDSD.Syntax.Process<Microsoft.Research.DNA.LogicDSD.SiteT>>>>;
|
||||
initials: Array<Microsoft.Research.CRNEngine.Initial<RulesDSD.Syntax.Process<Microsoft.Research.DNA.LogicDSD.SiteT>, Microsoft.Research.CRNEngine.Expression.t<string>>>;
|
||||
reactions: Array<Microsoft.Research.CRNEngine.Reaction<RulesDSD.Syntax.Process<Microsoft.Research.DNA.LogicDSD.SiteT>, Microsoft.Research.CRNEngine.Expression.t<string>, Microsoft.Research.CRNEngine.Expression.t<Microsoft.Research.CRNEngine.Key<RulesDSD.Syntax.Process<Microsoft.Research.DNA.LogicDSD.SiteT>>>>>;
|
||||
plotsCache: Opaque.Dictionary<RulesDSD.Syntax.Process<Microsoft.Research.DNA.LogicDSD.SiteT>, string>;
|
||||
dsdOptions: Microsoft.Research.DNA.Options.t;
|
||||
rules: Opaque.Dictionary<Opaque.FSharpTuple, Array<RulesDSD.Syntax.Clause>>;
|
||||
rules: Opaque.Dictionary<Opaque.FSharpTuple, Array<RulesDSD.Syntax.Clause<Microsoft.Research.DNA.LogicDSD.SiteT>>>;
|
||||
}
|
||||
export interface metadata {
|
||||
meta: Microsoft.Research.DNA.Sequence.mapping;
|
||||
|
@ -369,6 +342,43 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
}
|
||||
}
|
||||
|
||||
export namespace RulesDSD.Syntax {
|
||||
export interface Clause<s> {
|
||||
head: RulesDSD.Syntax.Predicate<s>;
|
||||
body: Array<RulesDSD.Syntax.Literal<s>>;
|
||||
}
|
||||
export interface Literal<s> {
|
||||
Pos?: RulesDSD.Syntax.Predicate<s>;
|
||||
Neg?: RulesDSD.Syntax.Predicate<s>;
|
||||
}
|
||||
export interface Pattern<s> {
|
||||
Nicking?: Array<Opaque.FSharpTuple>[];
|
||||
Inner?: Array<Opaque.FSharpTuple>;
|
||||
Strand?: Array<Opaque.FSharpTuple>;
|
||||
ThreePrime?: Array<Opaque.FSharpTuple>;
|
||||
FivePrime?: Array<Opaque.FSharpTuple>;
|
||||
Nihil?: string;
|
||||
}
|
||||
export interface Predicate<s> {
|
||||
Pred: (string | Array<RulesDSD.Syntax.Term<s>>)[];
|
||||
}
|
||||
export interface Process<s> {
|
||||
Proc: Opaque.FSharpMap<number, Array<s>>;
|
||||
}
|
||||
export interface Term<s> {
|
||||
Var?: (number | string)[];
|
||||
Const?: string;
|
||||
Float?: number;
|
||||
Func?: (string | Array<RulesDSD.Syntax.Term<s>>)[];
|
||||
TList?: Array<RulesDSD.Syntax.Term<s>>;
|
||||
TCons?: RulesDSD.Syntax.Term<s>[];
|
||||
TCRN?: Array<RulesDSD.Syntax.Term<s>>;
|
||||
TMSet?: Array<Opaque.FSharpTuple>;
|
||||
Proc?: RulesDSD.Syntax.Process<s>;
|
||||
Pat?: RulesDSD.Syntax.Pattern<s>;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.CRNEngine.Jit {
|
||||
export interface JitReaction<s, v, e> {
|
||||
id: number;
|
||||
|
@ -457,14 +467,11 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
}
|
||||
|
||||
export namespace Microsoft.Research.DNA.Options {
|
||||
export interface renderer_branches {
|
||||
rotate_labels: boolean;
|
||||
arrange: Microsoft.Research.DNA.Options.arrange_mode;
|
||||
}
|
||||
export interface rendering {
|
||||
renderer: Microsoft.Research.DNA.Options.renderer;
|
||||
branches: Microsoft.Research.DNA.Options.renderer_branches;
|
||||
classic: Microsoft.Research.DNA.Options.renderer_classic;
|
||||
mode: Microsoft.Research.DNA.Options.renderer_mode;
|
||||
rotate_labels: boolean;
|
||||
arrange: Microsoft.Research.DNA.Options.arrange_mode;
|
||||
}
|
||||
export interface t {
|
||||
rules: Microsoft.Research.DNA.Options.semantics;
|
||||
|
@ -500,7 +507,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
generate_predicates: Microsoft.Research.DNA.Options.generate_predicates;
|
||||
rendering: Microsoft.Research.DNA.Options.rendering;
|
||||
is_jit: boolean;
|
||||
rulesProgram?: Opaque.FSharpMap<Opaque.FSharpTuple, Array<RulesDSD.Syntax.Clause>>;
|
||||
rulesProgram?: Opaque.FSharpMap<Opaque.FSharpTuple, Array<RulesDSD.Syntax.Clause<Microsoft.Research.DNA.LogicDSD.SiteT>>>;
|
||||
}
|
||||
export type arrange_mode = "Wide" | "Babylon"
|
||||
export const arrange_modeSelect = ["Wide", "Babylon"]
|
||||
|
@ -508,8 +515,8 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
export const generate_predicatesSelect = ["All_predicates", "No_predicates"]
|
||||
export type renderer = "Classic" | "Circles" | "Branches"
|
||||
export const rendererSelect = ["Classic", "Circles", "Branches"]
|
||||
export type renderer_classic = "Complement" | "Condensed" | "Nucleotides"
|
||||
export const renderer_classicSelect = ["Complement", "Condensed", "Nucleotides"]
|
||||
export type renderer_mode = "Complement" | "Condensed" | "Nucleotides"
|
||||
export const renderer_modeSelect = ["Complement", "Condensed", "Nucleotides"]
|
||||
export type semantics = "Infinite" | "Default" | "Finite" | "Detailed"
|
||||
export const semanticsSelect = ["Infinite", "Default", "Finite", "Detailed"]
|
||||
}
|
||||
|
@ -621,6 +628,8 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
Show?: (Microsoft.Research.DNA.Value.t | Opaque.FSharpTuple | null)[];
|
||||
Function?: (Microsoft.Research.DNA.Value.fn | Microsoft.Research.DNA.Value.t | Opaque.FSharpTuple | null)[];
|
||||
Tuple?: (Array<Microsoft.Research.DNA.Value.t> | Opaque.FSharpTuple | null)[];
|
||||
Ceiling?: (Microsoft.Research.DNA.Value.t | Opaque.FSharpTuple | null)[];
|
||||
Floor?: (Microsoft.Research.DNA.Value.t | Opaque.FSharpTuple | null)[];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -645,7 +654,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
GATE?: Array<Array<Microsoft.Research.DNA.Segment.t>>;
|
||||
ORIGAMI?: Array<Microsoft.Research.DNA.Origami.content>;
|
||||
UNKNOWN?: string;
|
||||
LogicDsdProcess?: RulesDSD.Syntax.Process;
|
||||
LogicDsdProcess?: RulesDSD.Syntax.Process<Microsoft.Research.DNA.LogicDSD.SiteT>;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -693,7 +702,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
}
|
||||
|
||||
export interface parser {
|
||||
(): (p0: string) => (p0: string) => (p0: string) => Microsoft.Research.DNA.Dsd.bundle
|
||||
(): (p0: string) => (p0: string) => (p0: string) => Opaque.FSharpTuple
|
||||
}
|
||||
|
||||
export interface user_parse {
|
||||
|
@ -721,7 +730,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
}
|
||||
|
||||
export interface get_jit_rules {
|
||||
(bundle: Microsoft.Research.DNA.Dsd.bundle): Microsoft.Research.CRNEngine.JSAPI.jit<RulesDSD.Syntax.Process>
|
||||
(bundle: Microsoft.Research.DNA.Dsd.bundle): Microsoft.Research.CRNEngine.JSAPI.jit<RulesDSD.Syntax.Process<Microsoft.Research.DNA.LogicDSD.SiteT>>
|
||||
}
|
||||
|
||||
export interface is_jit {
|
||||
|
|
|
@ -34,10 +34,10 @@ function handleCompile(code: string, parts: string, reactions: string) {
|
|||
local_result = compile(code, parts, reactions);
|
||||
local_solution = null;
|
||||
// Send the solution count to the main thread.
|
||||
var count = (<any>local_result.solution).solution[1].numSolutions;
|
||||
var count = (<any>local_result.ClassicGEC.solution).solution[1].numSolutions;
|
||||
var solsmsg: Interfaces.WorkerResponse_GECSolutions = { mtype: "gec.solutions", count: count };
|
||||
self.postMessage(solsmsg, undefined);
|
||||
var jsbolmsg: Interfaces.WorkerResponse_JSBOL = { mtype: "gec.jsbol", document: local_result.jsbol };
|
||||
var jsbolmsg: Interfaces.WorkerResponse_JSBOL = { mtype: "gec.jsbol", document: local_result.ClassicGEC.jsbol };
|
||||
self.postMessage(jsbolmsg, undefined);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ function processMessageGEC(e: any) {
|
|||
if (local_solution != null)
|
||||
exportmsg = jsbolToExport(local_solution.jsbol);
|
||||
else if (local_result != null)
|
||||
exportmsg = jsbolToExport(local_result.jsbol);
|
||||
exportmsg = jsbolToExport(local_result.ClassicGEC.jsbol);
|
||||
if (exportmsg != null)
|
||||
self.postMessage(exportmsg, undefined);
|
||||
break;
|
||||
|
|
|
@ -5,7 +5,59 @@ import * as CRN from '../../../CRNEngine/CRNEngineTSWrapper/Scripts/InternalInte
|
|||
import { WebSharperGeneratedInterfaces as WGI } from "./WebSharperGeneratedInterfaces";
|
||||
import * as Interfaces from '../../../CRNEngine/CRNEngineTSWrapper/Scripts/Interfaces';
|
||||
|
||||
export type jSBOLDocument = WGI.FSBOL.JsonSerializer.rSBOLDocument;
|
||||
// The public FSBOL (github.com/SynBioDex/fSBOL) doesn't support TypesTSFS, so the auto-generated interfaces don't work
|
||||
// TODO: Update FSBOL and re-plumb SBOL components
|
||||
//export type jSBOLDocument = WGI.FSBOL.JsonSerializer.rSBOLDocument;
|
||||
|
||||
// Workaround: define the structure that is used, to prevent build errors
|
||||
export type rRange = {
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
version: string;
|
||||
uri: string;
|
||||
startIndex: number;
|
||||
endIndex: number;
|
||||
orientation: string;
|
||||
}
|
||||
export type rSequenceAnnotation = {
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
version: string;
|
||||
uri: string;
|
||||
ranges: Array<rRange>;
|
||||
roles: Array<string>;
|
||||
}
|
||||
export type rComponent = {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
definition: string;
|
||||
access: string;
|
||||
}
|
||||
export type rComponentDefinition = {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
attachments: Array<string>;
|
||||
description: string;
|
||||
components: Array<rComponent>;
|
||||
sequenceAnnotations: Array<rSequenceAnnotation>;
|
||||
sequences: Array<string>;
|
||||
types: Array<string>;
|
||||
roles: Array<string>;
|
||||
}
|
||||
export type rSBOLDocument = {
|
||||
componentDefinitions: Array<rComponentDefinition>;
|
||||
}
|
||||
export type jSBOLDocument = rSBOLDocument
|
||||
|
||||
|
||||
export type CompileGECObservables = {
|
||||
solution_count: Rx.Observable<number>,
|
||||
|
|
|
@ -24,11 +24,9 @@ export function jsbolToObject(jsbol: Interfaces.jSBOLDocument) {
|
|||
component.persistentIdentity = comp.persistentIdentity;
|
||||
component.version = comp.version;
|
||||
component.uri = comp.uri;
|
||||
|
||||
component.definition = comp.definition
|
||||
component.definition = comp.definition;
|
||||
component.access = comp.access;
|
||||
|
||||
|
||||
compdef.addComponent(component);
|
||||
});
|
||||
|
||||
|
|
|
@ -1,14 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
import { rSBOLDocument } from "./Interfaces"
|
||||
|
||||
//These interfaces are code generated from F#, any changes to this file will be lost.
|
||||
export namespace WebSharperGeneratedInterfaces {
|
||||
|
||||
export namespace FSBOL.ComponentInstance {
|
||||
export type Access = "Public" | "Private"
|
||||
export const AccessSelect = ["Public", "Private"]
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.CRNEngine {
|
||||
export interface Assignment {
|
||||
variables: Array<string>;
|
||||
|
@ -39,6 +33,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
sweeps: Array<Microsoft.Research.CRNEngine.Sweep>;
|
||||
rates: { [key: string]: e };
|
||||
plot: Microsoft.Research.CRNEngine.Plot_settings<e>;
|
||||
quiet: boolean;
|
||||
}
|
||||
export interface Dataset {
|
||||
file: string;
|
||||
|
@ -148,6 +143,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
seed?: number;
|
||||
kinetics: Microsoft.Research.CRNEngine.Kinetics;
|
||||
times: Array<number>;
|
||||
prune: boolean;
|
||||
multicore: boolean;
|
||||
data: Array<string>;
|
||||
sweeps: Array<string>;
|
||||
|
@ -174,16 +170,17 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
assignments: Array<Microsoft.Research.CRNEngine.Assignment>;
|
||||
}
|
||||
export interface Synthesis_settings {
|
||||
mode: Microsoft.Research.CRNEngine.Synthesis_mode
|
||||
solver: Microsoft.Research.CRNEngine.Z3Solver
|
||||
mode: Microsoft.Research.CRNEngine.Synthesis_mode;
|
||||
solver: Microsoft.Research.CRNEngine.Z3Solver;
|
||||
timeout?: number;
|
||||
seed?: number;
|
||||
}
|
||||
export interface Table<v> {
|
||||
times: Array<number>;
|
||||
columns: Array<Microsoft.Research.CRNEngine.Column<v>>;
|
||||
}
|
||||
export interface Task {
|
||||
task_type: Microsoft.Research.CRNEngine.TaskType;
|
||||
task_type?: Microsoft.Research.CRNEngine.TaskType;
|
||||
copies: number;
|
||||
copy_id: number;
|
||||
nodes: number;
|
||||
|
@ -241,131 +238,34 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
export const Z3SolverSelect = ["NLSat", "Portfolio"]
|
||||
}
|
||||
|
||||
export namespace FSBOL.Attachment {
|
||||
export interface Attachment {
|
||||
//format : () => string | null;
|
||||
//hash : () => string | null;
|
||||
//size : () => System.Int64 | null;
|
||||
//source : () => string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace System {
|
||||
|
||||
}
|
||||
|
||||
export namespace FSBOL.Implementation {
|
||||
export interface Implementation {
|
||||
//built : () => FSBOL.Implementation.Built | null;
|
||||
export namespace Microsoft.Research.GEC.JSAPI {
|
||||
export interface ClassicResult {
|
||||
solution: Microsoft.Research.GEC.GECEngine.t;
|
||||
solutionCount: number;
|
||||
model: Microsoft.Research.CRNEngine.GuiIG;
|
||||
jsbol: rSBOLDocument;
|
||||
sbol: System.Object;
|
||||
}
|
||||
export interface Built {
|
||||
CD?: FSBOL.ComponentDefinition.ComponentDefinition;
|
||||
MD?: FSBOL.ModuleDefinition.ModuleDefinition;
|
||||
export interface LogicResult {
|
||||
solution: Microsoft.Research.GEC.GECEngine.t;
|
||||
solutionCount: number;
|
||||
model: Microsoft.Research.CRNEngine.GuiIG;
|
||||
jsbol: rSBOLDocument;
|
||||
sbol: System.Object;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.Collection {
|
||||
export interface Collection {
|
||||
//members : () => Array<string>;
|
||||
export interface solution_result {
|
||||
model: Microsoft.Research.CRNEngine.GuiIG;
|
||||
jsbol: rSBOLDocument;
|
||||
sbol: System.Object;
|
||||
crnstring: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.CombinatorialDerivation {
|
||||
export interface CombinatorialDerivation {
|
||||
//strategy : () => FSBOL.CombinatorialDerivation.Strategy | null;
|
||||
//template : () => string;
|
||||
//variableComponents : () => Array<FSBOL.VariableComponent.VariableComponent>;
|
||||
}
|
||||
export type Strategy = "Enumerate" | "Sample"
|
||||
export const StrategySelect = ["Enumerate", "Sample"]
|
||||
}
|
||||
|
||||
export namespace FSBOL.Component {
|
||||
export interface Component {
|
||||
//roleIntegrations : () => Array<FSBOL.Component.RoleIntegration>;
|
||||
//roles : () => Array<FSBOL.Role.Role>;
|
||||
}
|
||||
export type RoleIntegration = "OverrideRoles" | "MergeRoles"
|
||||
export const RoleIntegrationSelect = ["OverrideRoles", "MergeRoles"]
|
||||
}
|
||||
|
||||
export namespace FSBOL.ComponentDefinition {
|
||||
export interface ComponentDefinition {
|
||||
//components : () => Array<FSBOL.Component.Component>;
|
||||
//roles : () => Array<FSBOL.Role.Role>;
|
||||
//sequenceAnnotations : () => Array<FSBOL.SequenceAnnotation.SequenceAnnotation>;
|
||||
//sequenceConstraints : () => Array<FSBOL.SequenceConstraint.SequenceConstraint>;
|
||||
//sequences : () => Array<FSBOL.Sequence.Sequence>;
|
||||
//types : () => Array<FSBOL.ComponentDefinition.ComponentDefinitionType>;
|
||||
}
|
||||
export interface ComponentDefinitionType {
|
||||
DNA?: string;
|
||||
RNA?: string;
|
||||
Protein?: string;
|
||||
SmallMolecule?: string;
|
||||
Complex?: string;
|
||||
Linear?: string;
|
||||
Circular?: string;
|
||||
SingleStranded?: string;
|
||||
DoubleStranded?: string;
|
||||
OtherType?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.FunctionalComponent {
|
||||
export interface FunctionalComponent {
|
||||
//direction : () => FSBOL.FunctionalComponent.Direction;
|
||||
}
|
||||
export type Direction = "In" | "Out" | "InOut" | "NoDirection"
|
||||
export const DirectionSelect = ["In", "Out", "InOut", "NoDirection"]
|
||||
}
|
||||
|
||||
export namespace FSBOL.Sequence {
|
||||
export interface Sequence {
|
||||
//elements : () => string;
|
||||
//encoding : () => FSBOL.Sequence.Encoding;
|
||||
}
|
||||
export interface Encoding {
|
||||
IUPACDNA?: string;
|
||||
IUPACPROTEIN?: string;
|
||||
SMILES?: string;
|
||||
OtherEncoding?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.Model {
|
||||
export interface Model {
|
||||
//framework : () => FSBOL.Model.Framework;
|
||||
//language : () => FSBOL.Model.Language;
|
||||
//source : () => string;
|
||||
}
|
||||
export interface Framework {
|
||||
Continuous?: string;
|
||||
Discrete?: string;
|
||||
OtherFramework?: string;
|
||||
}
|
||||
export interface Language {
|
||||
SBML?: string;
|
||||
CellML?: string;
|
||||
BioPax?: string;
|
||||
OtherLanguage?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.Interaction {
|
||||
export interface Interaction {
|
||||
//participations : () => Array<FSBOL.Participation.Participation>;
|
||||
//types : () => Array<FSBOL.Interaction.InteractionType>;
|
||||
}
|
||||
export interface InteractionType {
|
||||
Inhibition?: string;
|
||||
Stimulation?: string;
|
||||
BiochemicalReaction?: string;
|
||||
NonCovalentBinding?: string;
|
||||
Degradation?: string;
|
||||
GeneticProduction?: string;
|
||||
Control?: string;
|
||||
OtherInteractionType?: string;
|
||||
export interface solve_result {
|
||||
ClassicGEC?: Microsoft.Research.GEC.JSAPI.ClassicResult;
|
||||
LogicGEC?: Microsoft.Research.GEC.JSAPI.LogicResult;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -378,143 +278,10 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
export const PriorKindSelect = ["Fixed2", "Normal", "LogNormal", "TruncatedNormal"]
|
||||
}
|
||||
|
||||
export namespace FSBOL.Location {
|
||||
export interface Location {
|
||||
//orientation : () => FSBOL.Location.Orientation;
|
||||
}
|
||||
export interface Orientation {
|
||||
Inline?: string;
|
||||
ReverseComplement?: string;
|
||||
OtherOrientation?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.MapsTo {
|
||||
export interface MapsTo {
|
||||
//local : () => string;
|
||||
//refinement : () => FSBOL.MapsTo.Refinement;
|
||||
//remote : () => string;
|
||||
}
|
||||
export interface Refinement {
|
||||
UseRemote?: string;
|
||||
UseLocal?: string;
|
||||
VerifyIdentical?: string;
|
||||
Merge?: string;
|
||||
OtherRefinement?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.Module {
|
||||
export interface Module {
|
||||
//definition : () => string;
|
||||
//mapsTos : () => Array<FSBOL.MapsTo.MapsTo>;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.ModuleDefinition {
|
||||
export interface ModuleDefinition {
|
||||
//functionalComponents : () => Array<FSBOL.FunctionalComponent.FunctionalComponent>;
|
||||
//interactions : () => Array<FSBOL.Interaction.Interaction>;
|
||||
//models : () => Array<FSBOL.Model.Model>;
|
||||
//modules : () => Array<FSBOL.Module.Module>;
|
||||
//roles : () => Array<FSBOL.Role.Role>;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.VariableComponent {
|
||||
export interface VariableComponent {
|
||||
//operator : () => FSBOL.VariableComponent.Operator;
|
||||
//variable : () => string;
|
||||
//variantCollections : () => Array<string>;
|
||||
//variantDerivations : () => Array<string>;
|
||||
//variants : () => Array<string>;
|
||||
}
|
||||
export type Operator = "ZeroOrOne" | "One" | "ZeroOrMore" | "OneOrMore"
|
||||
export const OperatorSelect = ["ZeroOrOne", "One", "ZeroOrMore", "OneOrMore"]
|
||||
}
|
||||
|
||||
export namespace Microsoft.FSharp.Core {
|
||||
|
||||
}
|
||||
|
||||
export namespace FSBOL.Participation {
|
||||
export interface Participation {
|
||||
//participant : () => FSBOL.FunctionalComponent.FunctionalComponent;
|
||||
//roles : () => Array<FSBOL.Participation.ParticipationRole>;
|
||||
}
|
||||
export interface ParticipationRole {
|
||||
Inhibitor?: string;
|
||||
Inhibited?: string;
|
||||
Stimulator?: string;
|
||||
Stimulated?: string;
|
||||
Reactant?: string;
|
||||
Product?: string;
|
||||
PromoterParticipation?: string;
|
||||
Modifier?: string;
|
||||
Modified?: string;
|
||||
Template?: string;
|
||||
OtherParticipationRole?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.SequenceConstraint {
|
||||
export interface SequenceConstraint {
|
||||
//object : () => FSBOL.Component.Component;
|
||||
//restriction : () => FSBOL.SequenceConstraint.Restriction;
|
||||
//subject : () => FSBOL.Component.Component;
|
||||
}
|
||||
export interface Restriction {
|
||||
Precedes?: string;
|
||||
SameOrientationAs?: string;
|
||||
OppositeOrientationAs?: string;
|
||||
DifferentFrom?: string;
|
||||
OtherRestriction?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.Role {
|
||||
export interface Role {
|
||||
Promoter?: string;
|
||||
RBS?: string;
|
||||
CDS?: string;
|
||||
Terminator?: string;
|
||||
Gene?: string;
|
||||
Operator?: string;
|
||||
EngineeredGene?: string;
|
||||
MRNA?: string;
|
||||
Effector?: string;
|
||||
TranscriptionFactor?: string;
|
||||
OtherRole?: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.SBOLDocument {
|
||||
export interface SBOLDocument {
|
||||
//attachments : () => Array<FSBOL.Attachment.Attachment>;
|
||||
//collections : () => Array<FSBOL.Collection.Collection>;
|
||||
//combinatorialDerivations : () => Array<FSBOL.CombinatorialDerivation.CombinatorialDerivation>;
|
||||
//componentDefinitions : () => Array<FSBOL.ComponentDefinition.ComponentDefinition>;
|
||||
//implementations : () => Array<FSBOL.Implementation.Implementation>;
|
||||
//models : () => Array<FSBOL.Model.Model>;
|
||||
//moduleDefinitions : () => Array<FSBOL.ModuleDefinition.ModuleDefinition>;
|
||||
//sequences : () => Array<FSBOL.Sequence.Sequence>;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.SequenceAnnotation {
|
||||
export interface SequenceAnnotation {
|
||||
//componentObj : () => FSBOL.Component.Component | null;
|
||||
//locations : () => Array<FSBOL.Location.Location>;
|
||||
//roles : () => Array<FSBOL.Role.Role>;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.TopLevel {
|
||||
export interface TopLevel {
|
||||
//attachments : () => Array<string>;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.GEC.Ast {
|
||||
export interface aexp {
|
||||
FloatAExp?: number;
|
||||
|
@ -637,307 +404,6 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
}
|
||||
}
|
||||
|
||||
export namespace FSBOL.JsonSerializer {
|
||||
export interface rAnnotation {
|
||||
qName: FSBOL.JsonSerializer.rQName;
|
||||
valueType: string;
|
||||
literal: FSBOL.JsonSerializer.rLiteral;
|
||||
uri: string;
|
||||
nestedQName: FSBOL.JsonSerializer.rQName;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
}
|
||||
export interface rAttachment {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
attachments: Array<string>;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
source: string;
|
||||
format: string;
|
||||
size: number;
|
||||
hash: string;
|
||||
}
|
||||
export interface rCollection {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
attachments: Array<string>;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
members: Array<string>;
|
||||
}
|
||||
export interface rCombinatorialDerivation {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
attachments: Array<string>;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
strategy: string;
|
||||
template: string;
|
||||
variableComponents: Array<FSBOL.JsonSerializer.rVariableComponent>;
|
||||
}
|
||||
export interface rComponent {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
definition: string;
|
||||
access: string;
|
||||
mapsTos: Array<FSBOL.JsonSerializer.rMapsTo>;
|
||||
roles: Array<string>;
|
||||
roleIntegrations: Array<string>;
|
||||
}
|
||||
export interface rComponentDefinition {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
attachments: Array<string>;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
components: Array<FSBOL.JsonSerializer.rComponent>;
|
||||
sequenceAnnotations: Array<FSBOL.JsonSerializer.rSequenceAnnotation>;
|
||||
sequenceConstraints: Array<FSBOL.JsonSerializer.rSequenceConstraint>;
|
||||
sequences: Array<string>;
|
||||
types: Array<string>;
|
||||
roles: Array<string>;
|
||||
}
|
||||
export interface rCut {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
orientation: string;
|
||||
at: number;
|
||||
}
|
||||
export interface rFunctionalComponent {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
definition: string;
|
||||
access: string;
|
||||
mapsTos: Array<FSBOL.JsonSerializer.rMapsTo>;
|
||||
direction: string;
|
||||
}
|
||||
export interface rGenericLocation {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
orientation: string;
|
||||
}
|
||||
export interface rImplementation {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
attachments: Array<string>;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
built: string;
|
||||
}
|
||||
export interface rInteraction {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
types: Array<string>;
|
||||
participations: Array<FSBOL.JsonSerializer.rParticipation>;
|
||||
}
|
||||
export interface rLiteral {
|
||||
literalType: string;
|
||||
string: string;
|
||||
int: number;
|
||||
int64: number;
|
||||
double: number;
|
||||
bool: boolean;
|
||||
}
|
||||
export interface rMapsTo {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
local: string;
|
||||
remote: string;
|
||||
refinment: string;
|
||||
}
|
||||
export interface rModel {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
attachments: Array<string>;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
source: string;
|
||||
language: string;
|
||||
framework: string;
|
||||
}
|
||||
export interface rModule {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
definition: string;
|
||||
mapsTos: Array<FSBOL.JsonSerializer.rMapsTo>;
|
||||
}
|
||||
export interface rModuleDefinition {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
attachments: Array<string>;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
roles: Array<string>;
|
||||
functionalComponents: Array<FSBOL.JsonSerializer.rFunctionalComponent>;
|
||||
interactions: Array<FSBOL.JsonSerializer.rInteraction>;
|
||||
modules: Array<FSBOL.JsonSerializer.rModule>;
|
||||
models: Array<string>;
|
||||
}
|
||||
export interface rParticipation {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
roles: Array<string>;
|
||||
participant: string;
|
||||
}
|
||||
export interface rQName {
|
||||
qNameType: string;
|
||||
name: string;
|
||||
prefix: string;
|
||||
nameSpaceUri: string;
|
||||
}
|
||||
export interface rRange {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
orientation: string;
|
||||
startIndex: number;
|
||||
endIndex: number;
|
||||
}
|
||||
export interface rSBOLDocument {
|
||||
attachments: Array<FSBOL.JsonSerializer.rAttachment>;
|
||||
sequences: Array<FSBOL.JsonSerializer.rSequence>;
|
||||
componentDefinitions: Array<FSBOL.JsonSerializer.rComponentDefinition>;
|
||||
moduleDefinitions: Array<FSBOL.JsonSerializer.rModuleDefinition>;
|
||||
models: Array<FSBOL.JsonSerializer.rModel>;
|
||||
implementations: Array<FSBOL.JsonSerializer.rImplementation>;
|
||||
collections: Array<FSBOL.JsonSerializer.rCollection>;
|
||||
CombinatorialDerivation: Array<FSBOL.JsonSerializer.rCombinatorialDerivation>;
|
||||
}
|
||||
export interface rSequence {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
attachments: Array<string>;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
elements: string;
|
||||
encoding: string;
|
||||
}
|
||||
export interface rSequenceAnnotation {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
ranges: Array<FSBOL.JsonSerializer.rRange>;
|
||||
cuts: Array<FSBOL.JsonSerializer.rCut>;
|
||||
genericLocations: Array<FSBOL.JsonSerializer.rGenericLocation>;
|
||||
roles: Array<string>;
|
||||
componentObj: string;
|
||||
}
|
||||
export interface rSequenceConstraint {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
subject: string;
|
||||
object: string;
|
||||
restriction: string;
|
||||
}
|
||||
export interface rVariableComponent {
|
||||
uri: string;
|
||||
version: string;
|
||||
name: string;
|
||||
displayId: string;
|
||||
persistentIdentity: string;
|
||||
description: string;
|
||||
annotations: Array<FSBOL.JsonSerializer.rAnnotation>;
|
||||
operator: string;
|
||||
variants: Array<string>;
|
||||
variantCollections: Array<string>;
|
||||
variantDerivations: Array<string>;
|
||||
variable: string;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.GEC.JSAPI {
|
||||
export interface solution_result {
|
||||
model: Microsoft.Research.CRNEngine.GuiIG;
|
||||
jsbol: FSBOL.JsonSerializer.rSBOLDocument;
|
||||
sbol: FSBOL.SBOLDocument.SBOLDocument;
|
||||
crnstring: string;
|
||||
}
|
||||
export interface solve_result {
|
||||
solution: Microsoft.Research.GEC.GECEngine.t;
|
||||
solutionCount: number;
|
||||
model: Microsoft.Research.CRNEngine.GuiIG;
|
||||
jsbol: FSBOL.JsonSerializer.rSBOLDocument;
|
||||
sbol: FSBOL.SBOLDocument.SBOLDocument;
|
||||
}
|
||||
}
|
||||
|
||||
export namespace Microsoft.Research.GEC.GECEngine {
|
||||
export interface t {
|
||||
options: Microsoft.Research.GEC.Options.t;
|
||||
|
@ -977,7 +443,7 @@ export namespace WebSharperGeneratedInterfaces {
|
|||
}
|
||||
|
||||
export interface get_solution {
|
||||
(o: Microsoft.Research.GEC.JSAPI.solve_result, i: number): Microsoft.Research.GEC.JSAPI.solution_result
|
||||
(so: Microsoft.Research.GEC.JSAPI.solve_result, i: number): Microsoft.Research.GEC.JSAPI.solution_result
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,133 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30011.22
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ParserCombinatorsJS", "..\ParserCombinators\ParserCombinatorsJS\ParserCombinatorsJS.fsproj", "{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "SiteGraphReactorJS", "..\SiteGraphReactor\SiteGraphReactorJS\SiteGraphReactorJS.fsproj", "{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "SiteGraphCRNJS", "..\SiteGraphReactor\SiteGraphCRNJS\SiteGraphCRNJS.fsproj", "{82903A27-E535-4D30-8449-2AD9D2A9769E}"
|
||||
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}") = "CRNEngineJS", "..\CRNEngine\CRNEngineJS\CRNEngineJS.fsproj", "{836AF075-6448-4CD9-8020-434B963FF5E2}"
|
||||
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}") = "HTML5StrandGraphs", "HTML5StrandGraphs\HTML5StrandGraphs.csproj", "{27DB11BA-BCFB-47CC-9132-47349008673C}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E} = {82903A27-E535-4D30-8449-2AD9D2A9769E}
|
||||
{C8AE8A28-89AD-4048-8302-D144C205360D} = {C8AE8A28-89AD-4048-8302-D144C205360D}
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C} = {E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2} = {836AF075-6448-4CD9-8020-434B963FF5E2}
|
||||
{4DF94589-6870-4A4C-BFAE-5825EF4634E7} = {4DF94589-6870-4A4C-BFAE-5825EF4634E7}
|
||||
{8AC1E8EB-E9A2-45DC-9E07-15398B4362B1} = {8AC1E8EB-E9A2-45DC-9E07-15398B4362B1}
|
||||
{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9} = {2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CodeEditor", "..\HTML5SharedGUI\CodeEditor\CodeEditor.csproj", "{B234C1D7-96F4-40A2-A323-3B18646BF95C}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SiteGraphReactorTSWrapper", "..\SiteGraphReactor\SiteGraphReactorTSWrapper\SiteGraphReactorTSWrapper.csproj", "{8AC1E8EB-E9A2-45DC-9E07-15398B4362B1}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CRNEngineTSWrapper", "..\CRNEngine\CRNEngineTSWrapper\CRNEngineTSWrapper.csproj", "{FB1F1936-AC22-41B4-AF2F-E20A486E3416}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CRNComponent", "..\HTML5SharedGUI\CRNComponent\CRNComponent.csproj", "{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A} = {2F3B8603-CFF1-4946-B242-6F848801B49A}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimulationViewer", "..\HTML5SharedGUI\SimulationViewer\SimulationViewer.csproj", "{0ECCE305-85C0-403F-A980-EEB9379BD5A4}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "InferenceViewer", "..\HTML5SharedGUI\InferenceViewer\InferenceViewer.csproj", "{179FDF3E-67B8-4E2F-9089-650BB1319AF2}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HTML5DSD_Generic", "..\HTML5SharedGUI\HTML5DSD_Generic\HTML5DSD_Generic.csproj", "{C8AE8A28-89AD-4048-8302-D144C205360D}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ReactionDiffusionJS", "..\PDESolvers\ReactionDiffusionJS\ReactionDiffusionJS.fsproj", "{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HTML5CRN_Lib", "..\HTML5SharedGUI\HTML5CRN_Lib\HTML5CRN_Lib.csproj", "{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GenericComponents", "..\HTML5SharedGUI\GenericComponents\GenericComponents.csproj", "{F9C3A92C-4AAD-4E45-A809-0C997188DDF0}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4DF94589-6870-4A4C-BFAE-5825EF4634E7}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2F3B8603-CFF1-4946-B242-6F848801B49A}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{27DB11BA-BCFB-47CC-9132-47349008673C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{27DB11BA-BCFB-47CC-9132-47349008673C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{27DB11BA-BCFB-47CC-9132-47349008673C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{27DB11BA-BCFB-47CC-9132-47349008673C}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B234C1D7-96F4-40A2-A323-3B18646BF95C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8AC1E8EB-E9A2-45DC-9E07-15398B4362B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8AC1E8EB-E9A2-45DC-9E07-15398B4362B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8AC1E8EB-E9A2-45DC-9E07-15398B4362B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8AC1E8EB-E9A2-45DC-9E07-15398B4362B1}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{6DF7A0C1-2048-4A51-8599-E1C0B958A5E2}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0ECCE305-85C0-403F-A980-EEB9379BD5A4}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{179FDF3E-67B8-4E2F-9089-650BB1319AF2}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{C8AE8A28-89AD-4048-8302-D144C205360D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{C8AE8A28-89AD-4048-8302-D144C205360D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{C8AE8A28-89AD-4048-8302-D144C205360D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{C8AE8A28-89AD-4048-8302-D144C205360D}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}.Release|Any CPU.Build.0 = 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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{B4C3F008-B6CA-4D63-9B98-6AC2D97B4E9B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{F9C3A92C-4AAD-4E45-A809-0C997188DDF0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{F9C3A92C-4AAD-4E45-A809-0C997188DDF0}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F9C3A92C-4AAD-4E45-A809-0C997188DDF0}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F9C3A92C-4AAD-4E45-A809-0C997188DDF0}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {E22C3A78-A332-4E31-A784-F2B368093FDF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,24 @@
|
|||
Scripts/**/*.js
|
||||
!Scripts/src/WorkerBoot.js
|
||||
Scripts/**/*.js.map
|
||||
Scripts/**/*.d.ts
|
||||
!Scripts/typings/**/*.d.ts
|
||||
Tests/**/*.js
|
||||
Tests/**/*.js.map
|
||||
Tests/**/*.d.ts
|
||||
|
||||
#residual files from before webpack
|
||||
vs/
|
||||
Scripts/CodeEditor/
|
||||
Scripts/InferenceViewer
|
||||
Scripts/Common/
|
||||
Scripts/CRN
|
||||
Scripts/CrnApp
|
||||
Scripts/CRNEngine
|
||||
Scripts/KnockoutGrid
|
||||
Scripts/DsdGeneric
|
||||
Scripts/MSAGL
|
||||
Scripts/SimulationViewer
|
||||
Scripts/StrandGraphs
|
||||
Scripts/IDD
|
||||
offlineServiceWorker.js
|
|
@ -0,0 +1 @@
|
|||
{"version":3,"file":"AppBootstrap.js","sourceRoot":"","sources":["AppBootstrap.ts"],"names":[],"mappings":";AAAA,OAAO,CAAC,CAAC,UAAU,CAAC,EAAE;IACd,OAAO,CAAC,CAAC,eAAe,CAAC,CAAC,EAAE;IAC5B,CAAC,CAAA;AACT,CAAC,CAAC,CAAC"}
|
|
@ -0,0 +1,5 @@
|
|||
1000 * [ <tether T2^!a X*!b T1^>
|
||||
| <A X!b T2^*!a> ]
|
||||
| 1200 * [ <T1^* X!c RA>
|
||||
| <X*!c A*!d>
|
||||
| <A!d> ]
|
|
@ -0,0 +1,6 @@
|
|||
new 3@ 4.2E-4 , 4.0E-2
|
||||
new 5@ 6.5E-4 , 4.0E-3
|
||||
|
||||
13 * [ <2 3^ 4> ]
|
||||
| 10 * [ <4 5^> ]
|
||||
| 10 * [ <1 2!a> | <6 3^!b 4!c> | <5^* 4*!c 3^*!b 2*!a> ]
|
|
@ -0,0 +1,9 @@
|
|||
X + Y ->{0.001} X + B |
|
||||
Y + X ->{0.002} Y + B |
|
||||
Z ~ X + B ->{0.0005} X + X |
|
||||
Y + B <->{0.003}{0.001} Y + Y |
|
||||
Y <->{0.002}{0.0003} Z |unexpected string
|
||||
|
||||
init X 30 |
|
||||
init Y 20 |
|
||||
init B 0
|
|
@ -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,8DAA8D;KACxE;IACD,IAAI,EAAE;QACF,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,41 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>License</title>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<pre>
|
||||
Microsoft Research License Agreement
|
||||
Non-Commercial Use Only
|
||||
Visual DSD (v0.14-20120902-1634)
|
||||
The Visual DSD manual is available from: http://research.microsoft.com/dna/manual.pdf
|
||||
_____________________________________________________________________
|
||||
This Microsoft Research License Agreement, including all exhibits (""MSR-LA"") is a legal agreement between you and Microsoft Corporation (“Microsoft” or “we”) for the software or data identified above, which may include source code, and any associated materials, text or speech files, associated media and ""online"" or electronic documentation and any updates we provide in our discretion (together, the ""Software"").
|
||||
By installing, copying, or otherwise using this Software, found at http://lepton.research.microsoft.com/webdna, you agree to be bound by the terms of this MSR-LA. If you do not agree, do not install copy or use the Software. The Software is protected by copyright and other intellectual property laws and is licensed, not sold.
|
||||
SCOPE OF RIGHTS:
|
||||
You may use, copy, reproduce, and distribute this Software for any non-commercial purpose, subject to the restrictions in this MSR-LA. Some purposes which can be non-commercial are teaching, academic research, public demonstrations and personal experimentation. You may also distribute this Software with books or other teaching materials, or publish the Software on websites, that are intended to teach the use of the Software for academic or other non-commercial purposes.
|
||||
You may not use or distribute this Software or any derivative works in any form for commercial purposes. Examples of commercial purposes would be running business operations, licensing, leasing, or selling the Software, distributing the Software for use with commercial products, using the Software in the creation or use of commercial products or any other activity which purpose is to procure a commercial gain to you or others.
|
||||
If the Software includes source code or data, you may create derivative works of such portions of the Software and distribute the modified Software for non-commercial purposes, as provided herein.
|
||||
If you distribute the Software or any derivative works of the Software, you will distribute them under the same terms and conditions as in this license, and you will not grant other rights to the Software or derivative works that are different from those provided by this MSR-LA.
|
||||
If you have created derivative works of the Software, and distribute such derivative works, you will cause the modified files to carry prominent notices so that recipients know that they are not receiving the original Software. Such notices must state: (i) that you have changed the Software; and (ii) the date of any changes.
|
||||
You may not distribute this Software or any derivative works.
|
||||
In return, we simply require that you agree:
|
||||
1. That you will not remove any copyright or other notices from the Software.
|
||||
2. That if any of the Software is in binary format, you will not attempt to modify such portions of the Software, or to reverse engineer or decompile them, except and only to the extent authorized by applicable law.
|
||||
3. That Microsoft is granted back, without any restrictions or limitations, a non-exclusive, perpetual, irrevocable, royalty-free, assignable and sub-licensable license, to reproduce, publicly perform or display, install, use, modify, post, distribute, make and have made, sell and transfer your modifications to and/or derivative works of the Software source code or data, for any purpose.
|
||||
4. That any feedback about the Software provided by you to us is voluntarily given, and Microsoft shall be free to use the feedback as it sees fit without obligation or restriction of any kind, even if the feedback is designated by you as confidential.
|
||||
5. THAT THE SOFTWARE COMES ""AS IS"", WITH NO WARRANTIES. THIS MEANS NO EXPRESS, IMPLIED OR STATUTORY WARRANTY, INCLUDING WITHOUT LIMITATION, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, ANY WARRANTY AGAINST INTERFERENCE WITH YOUR ENJOYMENT OF THE SOFTWARE OR ANY WARRANTY OF TITLE OR NON-INFRINGEMENT. THERE IS NO WARRANTY THAT THIS SOFTWARE WILL FULFILL ANY OF YOUR PARTICULAR PURPOSES OR NEEDS. ALSO, YOU MUST PASS THIS DISCLAIMER ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.
|
||||
6. THAT NEITHER MICROSOFT NOR ANY CONTRIBUTOR TO THE SOFTWARE WILL BE LIABLE FOR ANY DAMAGES RELATED TO THE SOFTWARE OR THIS MSR-LA, INCLUDING DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL OR INCIDENTAL DAMAGES, TO THE MAXIMUM EXTENT THE LAW PERMITS, NO MATTER WHAT LEGAL THEORY IT IS BASED ON. ALSO, YOU MUST PASS THIS LIMITATION OF LIABILITY ON WHENEVER YOU DISTRIBUTE THE SOFTWARE OR DERIVATIVE WORKS.
|
||||
7. That we have no duty of reasonable care or lack of negligence, and we are not obligated to (and will not) provide technical support for the Software.
|
||||
8. That if you breach this MSR-LA or if you sue anyone over patents that you think may apply to or read on the Software or anyone's use of the Software, this MSR-LA (and your license and rights obtained herein) terminate automatically. Upon any such termination, you shall destroy all of your copies of the Software immediately. Sections 3, 4, 5, 6, 7, 8, 11 and 12 of this MSR-LA shall survive any termination of this MSR-LA.
|
||||
9. That the patent rights, if any, granted to you in this MSR-LA only apply to the Software, not to any derivative works you make.
|
||||
10. That the Software may be subject to U.S. export jurisdiction at the time it is licensed to you, and it may be subject to additional export or import laws in other places. You agree to comply with all such laws and regulations that may apply to the Software after delivery of the software to you.
|
||||
11. That all rights not expressly granted to you in this MSR-LA are reserved.
|
||||
12. That this MSR-LA shall be construed and controlled by the laws of the State of Washington, USA, without regard to conflicts of law. If any provision of this MSR-LA shall be deemed unenforceable or contrary to law, the rest of this MSR-LA shall remain in full effect and interpreted in an enforceable manner that most nearly captures the intent of the original language.
|
||||
_____________________________________________________________________
|
||||
By using this software you accept all of the terms of the preceding MSR-LA license agreement.
|
||||
Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,10 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Manual</title>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,59 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Tutorial</title>
|
||||
<meta charset="utf-8" />
|
||||
</head>
|
||||
<body>
|
||||
<pre>
|
||||
Visual DSD Tutorial
|
||||
Background
|
||||
Visual DSD is a programming language for designing, simulating and analysing systems of DNA molecules that interact via strand displacement. The tool is intended for use by researchers and students with an understanding of basic concepts of DNA computing.
|
||||
Preliminary: Installing Visual DSD
|
||||
1. Navigate to http://research.microsoft.com/dna and click on the “Web Simulator” link.
|
||||
2. Visual DSD requires Silverlight 4 to be installed on your machine. If this is not the case, you should receive a notification in your browser together with installation instructions. Silverlight 4 is available for Windows and Mac as a plugin for most major web browsers.
|
||||
3. In the top-right corner, click on the “Install” button. This will install the software to your local machine for offline use. You will be presented with options to create shortcuts on the Start menu and/or the Desktop. If you have already installed the tool, the “Install” button will read “Update” and will check if a newer version of the tool is available to download.
|
||||
I: Basic compilation and simulation
|
||||
1. Load the “Catalytic” example from the “Examples:” drop-down menu. The program code will appear in the “Code” tab on the left-hand side. This system implements a catalytic gate using DNA strand displacement, as described by Zhang et al (Science 318, pages 1121-1125, 2007). The goal of the catalytic gate is to release large quantities of output if a particular catalyst species is present.
|
||||
2. The code describes a collection of DNA species which interact to produce the behaviour of a catalytic gate. Use the “Compile” button to calculate all possible interactions between these species and their products. This produces output in the various sub-tabs of the “Compilation” tab on the right-hand side. In particular, observe the graphical representation of the chemical reactions in the “Graph” sub-tab. The compilation also produces a graphical representation of the input species in the “Input” tab on the left hand side. Use the top four options in the “View” drop-down menu to modify the graphical presentation. The “Complement” view is selected by default, which illustrates the binding of DNA strands along complementary regions of their DNA sequence.
|
||||
3. Having compiled the reactions we can now simulate them. Switch to the “Simulation” tab on the right-hand side and select the “Plot” sub-tab. Use the “Simulate” button to run a stochastic simulation of the catalytic gate system. This produces output in the sub-tabs of the “Simulation” tab, including the time course “Plot”, a data “Table” and visualisations of the “Initial state” and “Last state” of the system. In the time course, note that the populations of the <6 3^ 4>
|
||||
and <1 2>
|
||||
strands increase over time as they are produced by the catalytic cycle of the gate in response to the presence of the <4 5^>
|
||||
catalyst species.
|
||||
4. The first line of the program code controls the duration of the simulation run and the number of population samples to take during that time. Modify the code to run for 2000 time units, with a sample taken every 4 time units, then re-compile the code and re-run the stochastic simulation.
|
||||
5. Visual DSD supports multiple levels of abstraction for compiling the interactions between DNA species. These are selected from the “Compilation:” drop-down menu, where “Infinite” is the most abstract semantics and “Detailed” is the most complex. Use the “Compilation:” menu to switch between the different semantics and re-compile the program in each case. Observe how the complexity of the reaction graph (in the “Graph” sub-tab) changes. You can also use the “Text” sub-tab to compare the numbers of different species and reactions produced in each case. Notice that in the simpler models, multiple reactions are condensed into a single step. How many reactions are there in the “Detailed” model? (Count a reversible reaction as two reactions.)
|
||||
6. The DSD tool also includes a deterministic simulator which constructs and solves an Ordinary Differential Equation representation of the system. Select “Deterministic” from the “Simulation:” drop-down menu, then re-run the simulation. Run the deterministic and stochastic simulations for the various compilation options, taking note of the difference in performance.
|
||||
II: State space analysis and modular programming
|
||||
1. Load the “Two-domain transducer” example program and select the “Infinite” semantics from the “Compilation:” menu. This simple example implements a DNA gate which converts a “<t^ x>
|
||||
” input strand into a “<t^ y>
|
||||
” output strand. Compile the reactions and observe the inputs and outputs on the reaction graph in the “Compilation” tab.
|
||||
2. Visual DSD supports construction and visualisation of continuous-time Markov chains which represent the “state space” of a system. This can be thought of as a state transition system where the states represent a particular set of species populations and the transitions correspond to reactions involving the DNA species. Switch to the “Analysis” tab on the right-hand side and select the “Graph” sub-tab. Use the “Analyse” button to compute the state space and investigate the resulting graphical visualisation. The “Graph” sub-tab includes numerous options to adjust the layout of the graph. The “Visualise” sub-tab displays just the initial state and any states from which no further reactions are possible (“terminal” states). This is helpful if the graph is too large to see clearly.
|
||||
3. In the graph, the initial state of the system is highlighted with a thick black outline, and any terminal states are highlighted with a thick red outline. How many terminal states are there in this case? Check that the “<t^ y>
|
||||
” output strand is produced in the terminal state(s) of this system.
|
||||
4. The DSD language supports modular programming to allow reuse of common design patterns. In this example, the definition of the “T(N,x,y)” module produces N copies of a transducer gate which turns “<t^ x>
|
||||
” into “<t^ y>
|
||||
”. This is instantiated as “T(1,x,y)” in the last line of the code. Add a second transducer of the form “T(1,y,z)” to the system, by placing it within the parentheses on the final line, separated from the other transducer declaration by a vertical bar (for parallel composition). The last line should now read ( <t^ x>
|
||||
| T(1,x,y) | T(1,y,z) ) The resulting system should turn “<t^ x>
|
||||
” into “<t^ y>
|
||||
” using the first transducer and then turn “<t^ y>
|
||||
” into “<t^ z>
|
||||
” using the second transducer. To check this, recompute the state space graph. Check that the “t z” output appears in the terminal state.
|
||||
5. The “new a” declaration within the definition of the “T(N,x,y)” module ensures that each instantiation of the transducer module chooses a fresh domain “a”. This prevents crosstalk between gates and allows them to function correctly. Delete the “new a” declaration from your modified program and re-compute the state space. How many terminal states (shown in red) are there now? Use the “Visualise” sub-tab to investigate them and try to identify which is the desired terminal state and which is the undesired one, bearing in mind the functionality of the transducer gate (Hint: in the Terminal state, all of the colour (toehold) domains in the gate complexes should be closed off, i.e. double-stranded).
|
||||
III: Modelling interference
|
||||
1. Load the “Buffered Transducer” example program and set the compilation rules to “Default” and the simulation to “Stochastic”. This program implements another kind of transducer which receives “x” strands and outputs “y” strands.
|
||||
2. Compile the program, view the reaction graph and note down the number of species and reactions (from the “Text” sub-tab of the “Compilation” tab). Run a stochastic simulation to familiarise yourself with the correct behaviour.
|
||||
3. Visual DSD allows the modelling of interference via “leak reactions”. These formalise a particular kind of unwanted interaction between strands and gates. Enable leaks by checking the “Leaks” checkbox in the “Options:” drop-down menu and recompile the program. How do the compilation time and the size of the reaction graph compare to the non-leak case? Run a simulation and compare the behaviour to the non-leak case. In this case, enabling leaks has qualitatively changed the behaviour of this system by allowing spurious additional “y” strands to be emitted.
|
||||
4. Visual DSD supports a just-in-time (JIT) compilation and simulation algorithm which allows larger systems to be simulated without pre-computing all of the possible reactions, which can take a long time (as in the case of this leak example). Without disabling leaks, select “JIT” from the “Simulation:” drop-down menu to enable the JIT simulator, then click “Compile” to recompile the system. Note that the “Compilation” tab is not populated in this case, because the JIT compiler does not pre-compute the full reaction network. Run the simulator and check that the time series is similar to that produced by the stochastic simulator for this example. When the simulation finishes, the “Compilation” tab will be populated as normal.
|
||||
5. The JIT compiler only calculates new species and reactions as and when they are needed. Compare the number of species and reactions in the reaction network produced by the “JIT” compiler to the numbers from the full reaction network computed when “Stochastic” simulation was selected. The discrepancy is due to the fact that leak reactions have very low rates and hence many of the reactions in the full reaction network never actually occur. The JIT simulator allows us to efficiently handle very large reaction networks, such as those produced using leaks.
|
||||
Answers:
|
||||
Part I, number 4: “directive duration 2000.0 points 500”.
|
||||
Part I, number 5: There are 19 reactions, if you count a reversible reaction as 2 reactions.
|
||||
Part I, number 6: The Detailed model runs really slowly under stochastic (because the explicit migration reactions are very fast and bog down the simulation) but fairly well in deterministic mode. The other models are simple enough to run very fast in both modes.
|
||||
Part II, number 3: There is 1 terminal state.
|
||||
Part II, number 5. There are 2 terminal states. Removing “new a” allows strands from the first transducer gate to interfere with the second transducer gate, allowing it to produce its output prematurely. Thus in the incorrect terminal state there are gates still waiting to receive input whereas in the correct terminal state all the gate structures have been completely closed off (they are totally double stranded).
|
||||
Part III, number 3: The graph will be much bigger with leaks enabled, and much slower to compile.
|
||||
Part III, number 5: The numbers for the JIT case should be lower. The numbers are different for each simulation run because the JIT simulation is stochastic, so the species and reactions encountered may be different each time.
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,49 @@
|
|||
<?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>
|
||||
</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="..\..\SiteGraphReactor\SiteGraphReactorTSWrapper\SiteGraphReactorTSWrapper.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,21 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import * as GenericExpandingParser from '../../../../HTML5SharedGUI/HTML5DSD_Generic/Scripts/Adapters/GenericExpandingParser';
|
||||
import SG from '../../../../SiteGraphReactor/SiteGraphReactorTSWrapper/Scripts/StrandGraphs';
|
||||
import Options from '../../../../HTML5SharedGUI/GenericComponents/Scripts/Options';
|
||||
|
||||
//Uses ModellingEngine.ts layer to aquire parsed CRN code
|
||||
export class Parser extends GenericExpandingParser.ExpandingParser<void, Options> {
|
||||
constructor(private sg: SG) {
|
||||
super();
|
||||
};
|
||||
|
||||
failureHandler(failure: any) {
|
||||
this.sg.Abort();
|
||||
};
|
||||
|
||||
getCRNStreams(code: string): GenericExpandingParser.IResultStreams<void> {
|
||||
return this.sg.UserExpand(code);
|
||||
};
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import * as GenericDSDParser from '../../../../HTML5SharedGUI/HTML5DSD_Generic/Scripts/Adapters/GenericDSDParser';
|
||||
import SG from '../../../../SiteGraphReactor/SiteGraphReactorTSWrapper/Scripts/StrandGraphs';
|
||||
import Options from '../../../../HTML5SharedGUI/GenericComponents/Scripts/Options';
|
||||
|
||||
//Uses ModellingEngine.ts layer to aquire parsed CRN code
|
||||
export class Parser extends GenericDSDParser.Parser<void, Options> {
|
||||
constructor(private sg: SG) {
|
||||
super();
|
||||
};
|
||||
|
||||
failureHandler(failure: any) {
|
||||
this.sg.Abort();
|
||||
};
|
||||
|
||||
getCRNStreams(code: string): GenericDSDParser.IResultStreams<void> {
|
||||
return this.sg.UserParse(code);
|
||||
};
|
||||
}
|
|
@ -0,0 +1,179 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
var StrandGraphsLanguage = {
|
||||
displayName: 'StrandGraphs', // start by writing your language name here
|
||||
name: 'strandGraphs',
|
||||
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",
|
||||
"circle",
|
||||
"comp",
|
||||
"conc",
|
||||
"copy",
|
||||
"default",
|
||||
"directive",
|
||||
"ff",
|
||||
"float",
|
||||
"force",
|
||||
"gen",
|
||||
"if",
|
||||
"init",
|
||||
"inside",
|
||||
"int",
|
||||
"kappa",
|
||||
"module",
|
||||
"mutation",
|
||||
"new",
|
||||
"not",
|
||||
"or",
|
||||
"phos",
|
||||
"plot",
|
||||
"plot_settings",
|
||||
"rate",
|
||||
"rates",
|
||||
"render_mode",
|
||||
"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 StrandGraphsLanguage;
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import { Launch as Bootstrap } from '../../../HTML5SharedGUI/HTML5DSD_Generic/Scripts/GenericApp';
|
||||
import { Parser as NotExpandingParser } from './Adapters/SGCRNUnexpandedParser';
|
||||
import { Parser as ExpandingParser } from './Adapters/SGCRNExpandedParser';
|
||||
import StrandGraphsLanguage from './StrandGraphsLang';
|
||||
import StrandGraphs from '../../../SiteGraphReactor/SiteGraphReactorTSWrapper/Scripts/StrandGraphs';
|
||||
import Options from '../../../HTML5SharedGUI/GenericComponents/Scripts/Options';
|
||||
|
||||
var examples: ExamplesGroup[] = [
|
||||
{
|
||||
// NOTE: the URLs here are supposed to be resolved relativly to the HTML page that runs the CodeEditor/CodePad.js 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: "Group 1",
|
||||
Correspondence: {
|
||||
"Catalytic": "CodeExamples/Catalytic.txt",
|
||||
"3-initiated, 4-way strand displacement": "CodeExamples/4-wayStrandReplacement.txt"
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
var engine = new StrandGraphs(Options.Server());
|
||||
var options = new Options(engine);
|
||||
var expandingParser = new ExpandingParser(engine);
|
||||
var notExpandingParser = new NotExpandingParser(engine);
|
||||
|
||||
Bootstrap(<any>StrandGraphsLanguage, examples, notExpandingParser, expandingParser, engine, options, null);
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Strand Graphs Tool</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="shared.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,22 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
declare module "raw-loader*"
|
||||
declare module "idd" {
|
||||
var InteractiveDataDisplay: any;
|
||||
export = InteractiveDataDisplay;
|
||||
}
|
||||
declare module "tinycolor" {
|
||||
var tinycolor: any;
|
||||
export = tinycolor;
|
||||
}
|
||||
declare module "monaco-editor" {
|
||||
var monaco: any;
|
||||
export = monaco;
|
||||
}
|
||||
declare module "worker-loader*" {
|
||||
class WebpackWorker extends Worker {
|
||||
constructor();
|
||||
}
|
||||
export default WebpackWorker;
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
group JavaScriptBuild
|
||||
|
||||
#FAKE
|
||||
Yarn.MSBuild
|
||||
Node.js.redist
|
||||
Microsoft.TypeScript.MSBuild
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"extends": "../../tsconfig.common",
|
||||
"include": [
|
||||
"*.ts",
|
||||
"Scripts/*.ts",
|
||||
"Scripts/Adapters/*.ts"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||
|
||||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||
<!--
|
||||
In the example below, the "SetAttributes" transform will change the value of
|
||||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
|
||||
finds an attribute "name" that has a value of "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>
|
||||
<!--
|
||||
In the example below, the "Replace" transform will replace the entire
|
||||
<customErrors> section of your web.config file.
|
||||
Note that because there is only one customErrors section under the
|
||||
<system.web> node, there is no need to use the "xdt:Locator" attribute.
|
||||
|
||||
<customErrors defaultRedirect="GenericError.htm"
|
||||
mode="RemoteOnly" xdt:Transform="Replace">
|
||||
<error statusCode="500" redirect="InternalError.htm"/>
|
||||
</customErrors>
|
||||
-->
|
||||
</system.web>
|
||||
</configuration>
|
|
@ -0,0 +1,31 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!-- For more information on using web.config transformation visit http://go.microsoft.com/fwlink/?LinkId=125889 -->
|
||||
|
||||
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
|
||||
<!--
|
||||
In the example below, the "SetAttributes" transform will change the value of
|
||||
"connectionString" to use "ReleaseSQLServer" only when the "Match" locator
|
||||
finds an attribute "name" that has a value of "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)" />
|
||||
<!--
|
||||
In the example below, the "Replace" transform will replace the entire
|
||||
<customErrors> section of your web.config file.
|
||||
Note that because there is only one customErrors section under the
|
||||
<system.web> node, there is no need to use the "xdt:Locator" attribute.
|
||||
|
||||
<customErrors defaultRedirect="GenericError.htm"
|
||||
mode="RemoteOnly" xdt:Transform="Replace">
|
||||
<error statusCode="500" redirect="InternalError.htm"/>
|
||||
</customErrors>
|
||||
-->
|
||||
</system.web>
|
||||
</configuration>
|
|
@ -0,0 +1,58 @@
|
|||
<?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" />
|
||||
</system.web>
|
||||
<system.webServer>
|
||||
<staticContent>
|
||||
<remove fileExtension=".crn" />
|
||||
<remove fileExtension=".wasm" />
|
||||
|
||||
<mimeMap fileExtension=".crn" mimeType="text/plain" />
|
||||
<mimeMap fileExtension=".wasm" mimeType="application/wasm" />
|
||||
</staticContent>
|
||||
<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,143 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
/// <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: "development",
|
||||
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: 'CodeExamples/**',
|
||||
to: 'CodeExamples',
|
||||
flatten: true
|
||||
}, {
|
||||
from: '../../CRNEngine/HTML5CRN/Data/Code/*',
|
||||
to: 'Code',
|
||||
flatten: true
|
||||
}, {
|
||||
from: '../../CRNEngine/HTML5CRN/Data/Observations/*',
|
||||
to: 'Observations',
|
||||
flatten: true
|
||||
}, {
|
||||
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
|
||||
})
|
||||
]
|
||||
};
|
||||
};
|
29
README.md
29
README.md
|
@ -8,9 +8,11 @@ Chemical Reaction Networks Engine (CRN-Engine) is an open source repository that
|
|||
|
||||
## Getting Started
|
||||
|
||||
For building on Windows, the following are required:
|
||||
The instructions for building on Windows are as follows:
|
||||
|
||||
- Visual Studio 2019
|
||||
1. Install Visual Studio 2019
|
||||
|
||||
The components required are:
|
||||
- Workloads tab:
|
||||
- .NET desktop development
|
||||
- Desktop development with C++
|
||||
|
@ -26,11 +28,24 @@ For building on Windows, the following are required:
|
|||
- F# language support for web projects
|
||||
- Individual Components tab, "SDKs, libraries, and frameworks" section:
|
||||
- Windows 10 SDK (10.0.17763.0)
|
||||
- .NET Core SDK 3.0.*
|
||||
- .NET Core SDK 3.1.*
|
||||
- NodeJS (this may involve restarting your computer several times)
|
||||
- Yarn
|
||||
- C++ CRT (C Run Time Library)
|
||||
|
||||
2. Install .NET Core SDKs
|
||||
|
||||
Required versions:
|
||||
- 2.2.*
|
||||
- 3.0.*
|
||||
- 3.1.*
|
||||
|
||||
3. Install NodeJS
|
||||
|
||||
N.B. This may involve restarting your computer several times.
|
||||
|
||||
4. Install Yarn
|
||||
|
||||
The instructions (for Windows) are [here](https://classic.yarnpkg.com/en/docs/install/#windows-stable).
|
||||
|
||||
5. Install C++ CRT (C Run Time Library)
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<tether T2^!a X*!b T1^>
|
||||
| <A X!b T2^*!a>
|
||||
| <T1^* X!c RA>
|
||||
| <X*!c A*!d>
|
||||
| <A!d>
|
||||
| <RA!e>
|
||||
| <RA*!e X*!f>
|
||||
| <B X!f T2^*>
|
|
@ -0,0 +1,5 @@
|
|||
1000 * [ <tether T2^!a X*!b T1^>
|
||||
| <A X!b T2^*!a> ]
|
||||
| 1200 * [ <T1^* X!c RA>
|
||||
| <X*!c A*!d>
|
||||
| <A!d> ]
|
|
@ -0,0 +1,5 @@
|
|||
1 * [ <a*!1 b!2 a!3 c!4>
|
||||
| <c*!4 a*!3 b*!2 a!1 d*!5 f*!6 g* f!6 e*!7>
|
||||
| <a*!8 b a!8 c e!7 h!9 l x k h*!9 d!5> ]
|
||||
| 1 * [ <d* e* c*> ]
|
||||
| 1 * [ <e f*!1 g f!1 d a*!2 b a!2 c> ]
|
|
@ -0,0 +1,107 @@
|
|||
State space
|
||||
species: 16
|
||||
states: 12
|
||||
transitions: 15
|
||||
|
||||
States
|
||||
state0 (Initial state):
|
||||
|
||||
1 of species0 : [ <d* e* c*> ]
|
||||
1 of species1 : [ <e f*!0 g f!0 d a*!1 b a!1 c> ]
|
||||
1 of species2 : [ <a*!0 b!1 a!2 c!3>
|
||||
| <c*!3 a*!2 b*!1 a!0 d*!4 f*!5 g* f!5 e*!6>
|
||||
| <a*!7 b a!7 c e!6 h!8 l x k h*!8 d!4> ]
|
||||
state1 :
|
||||
|
||||
1 of species1 : [ <e f*!0 g f!0 d a*!1 b a!1 c> ]
|
||||
1 of species3 : [ <a*!0 b!1 a!2 c!3>
|
||||
| <c*!3 a*!2 b*!1 a!0 d* f*!4 g* f!4 e*> ]
|
||||
1 of species4 : [ <a*!0 b a!0 c!1 e!2 h!3 l x k h*!3 d!4>
|
||||
| <d*!4 e*!2 c*!1> ]
|
||||
state2 :
|
||||
|
||||
1 of species5 : [ <a*!0 b a!0 c!1 e!2 h!3 l x k h*!3 d>
|
||||
| <d* e*!2 c*!1> ]
|
||||
1 of species6 : [ <a*!0 b a!0 c!1>
|
||||
| <c*!1 a*!2 b*!3 a!4 d*!5 f*!6 g* f!7 e*!8>
|
||||
| <e!8 f*!7 g f!6 d!5 a*!4 b!3 a!2 c> ]
|
||||
state3 :
|
||||
|
||||
1 of species4 : [ <a*!0 b a!0 c!1 e!2 h!3 l x k h*!3 d!4>
|
||||
| <d*!4 e*!2 c*!1> ]
|
||||
1 of species7 : [ <a*!0 b a!0 c!1>
|
||||
| <c*!1 a*!2 b*!3 a!4 d*!5 f*!6 g* f!7 e*>
|
||||
| <e f*!7 g f!6 d!5 a*!4 b!3 a!2 c> ]
|
||||
state4 :
|
||||
|
||||
1 of species4 : [ <a*!0 b a!0 c!1 e!2 h!3 l x k h*!3 d!4>
|
||||
| <d*!4 e*!2 c*!1> ]
|
||||
1 of species8 : [ <a*!0 b!1 a!2 c!3>
|
||||
| <c*!3 a*!2 b*!1 a!0 d* f*!4 g* f!5 e*!6>
|
||||
| <e!6 f*!5 g f!4 d a*!7 b a!7 c> ]
|
||||
state5 :
|
||||
|
||||
1 of species9 : [ <d*!0 e*!1 c*>
|
||||
| <e!1 f*!2 g f!2 d!0 a*!3 b a!3 c> ]
|
||||
1 of species2 : [ <a*!0 b!1 a!2 c!3>
|
||||
| <c*!3 a*!2 b*!1 a!0 d*!4 f*!5 g* f!5 e*!6>
|
||||
| <a*!7 b a!7 c e!6 h!8 l x k h*!8 d!4> ]
|
||||
state6 :
|
||||
|
||||
1 of species10: [ <d*!0 e* c*!1>
|
||||
| <e f*!2 g f!2 d!0 a*!3 b a!3 c!1> ]
|
||||
1 of species2 : [ <a*!0 b!1 a!2 c!3>
|
||||
| <c*!3 a*!2 b*!1 a!0 d*!4 f*!5 g* f!5 e*!6>
|
||||
| <a*!7 b a!7 c e!6 h!8 l x k h*!8 d!4> ]
|
||||
state7 :
|
||||
|
||||
1 of species11: [ <d*!0 e* c*>
|
||||
| <e f*!1 g f!1 d!0 a*!2 b a!2 c> ]
|
||||
1 of species2 : [ <a*!0 b!1 a!2 c!3>
|
||||
| <c*!3 a*!2 b*!1 a!0 d*!4 f*!5 g* f!5 e*!6>
|
||||
| <a*!7 b a!7 c e!6 h!8 l x k h*!8 d!4> ]
|
||||
state8 :
|
||||
|
||||
1 of species12: [ <d* e*!0 c*!1>
|
||||
| <e!0 f*!2 g f!2 d a*!3 b a!3 c!1> ]
|
||||
1 of species2 : [ <a*!0 b!1 a!2 c!3>
|
||||
| <c*!3 a*!2 b*!1 a!0 d*!4 f*!5 g* f!5 e*!6>
|
||||
| <a*!7 b a!7 c e!6 h!8 l x k h*!8 d!4> ]
|
||||
state9 :
|
||||
|
||||
1 of species13: [ <d* e*!0 c*>
|
||||
| <e!0 f*!1 g f!1 d a*!2 b a!2 c> ]
|
||||
1 of species2 : [ <a*!0 b!1 a!2 c!3>
|
||||
| <c*!3 a*!2 b*!1 a!0 d*!4 f*!5 g* f!5 e*!6>
|
||||
| <a*!7 b a!7 c e!6 h!8 l x k h*!8 d!4> ]
|
||||
state10:
|
||||
|
||||
1 of species14: [ <d* e* c*!0>
|
||||
| <e f*!1 g f!1 d a*!2 b a!2 c!0> ]
|
||||
1 of species2 : [ <a*!0 b!1 a!2 c!3>
|
||||
| <c*!3 a*!2 b*!1 a!0 d*!4 f*!5 g* f!5 e*!6>
|
||||
| <a*!7 b a!7 c e!6 h!8 l x k h*!8 d!4> ]
|
||||
state11:
|
||||
|
||||
1 of species15: [ <a*!0 b!1 a!2 c!3>
|
||||
| <c*!3 a*!2 b*!1 a!0 d*!4 f*!5 g* f!5 e*!6>
|
||||
| <a*!7 b a!7 c!8 e!6 h!9 l x k h*!9 d!4>
|
||||
| <d*!10 e* c*!8>
|
||||
| <e f*!11 g f!11 d!10 a*!12 b a!12 c> ]
|
||||
|
||||
Transitions
|
||||
state0 -> state1 (0.003)
|
||||
state0 -> state7 (0.003)
|
||||
state0 -> state9 (0.003)
|
||||
state0 -> state10 (0.003)
|
||||
state1 -> state3 (0.003)
|
||||
state1 -> state4 (0.003)
|
||||
state7 -> state5 (0.003)
|
||||
state7 -> state6 (0.003)
|
||||
state7 -> state11 (0.003)
|
||||
state9 -> state2 (0.003)
|
||||
state9 -> state4 (0.003)
|
||||
state9 -> state5 (0.003)
|
||||
state9 -> state8 (0.003)
|
||||
state10 -> state6 (0.003)
|
||||
state10 -> state8 (0.003)
|
|
@ -0,0 +1,5 @@
|
|||
1 * [ <a^*!1 b^!2 a^!3 c^!4>
|
||||
| <c^*!4 a^*!3 b^*!2 a^!1 d^*!5 f^*!6 g^* f^!6 e^*!7>
|
||||
| <a^*!8 b^ a^!8 c^ e^!7 h^!9 l x k h^*!9 d^!5> ]
|
||||
| 1 * [ <d^* e^* c^*> ]
|
||||
| 1 * [ <e^ f^*!1 g^ f^!1 d^ a^*!2 b^ a^!2 c^> ]
|
|
@ -0,0 +1,3 @@
|
|||
1 * [ <a*!1 b a!1 c> ]
|
||||
| 1 * [ <c* a*!1 b* a!1 d* f*!2 g* f!2 e*> ]
|
||||
| 1 * [ <a*!1 b a!1 c e h!2 l x k h*!2 d> ]
|
|
@ -0,0 +1,88 @@
|
|||
State space
|
||||
species: 14
|
||||
states: 12
|
||||
transitions: 20
|
||||
|
||||
States
|
||||
state0 (Initial state):
|
||||
|
||||
1 of species0 : [ <a*!0 b a!0 c> ]
|
||||
1 of species1 : [ <c* a*!0 b* a!0 d* f*!1 g* f!1 e*> ]
|
||||
1 of species2 : [ <a*!0 b a!0 c e h!1 l x k h*!1 d> ]
|
||||
state1 :
|
||||
|
||||
1 of species0 : [ <a*!0 b a!0 c> ]
|
||||
1 of species3 : [ <c*!0 a*!1 b* a!2 d*!3 f*!4 g* f!4 e*!5>
|
||||
| <a*!2 b a!1 c!0 e!5 h!6 l x k h*!6 d!3> ]
|
||||
state2 :
|
||||
|
||||
1 of species0 : [ <a*!0 b a!0 c> ]
|
||||
1 of species4 : [ <c*!0 a*!1 b* a!2 d*!3 f*!4 g* f!4 e*>
|
||||
| <a*!2 b a!1 c!0 e h!5 l x k h*!5 d!3> ]
|
||||
state3 :
|
||||
|
||||
1 of species0 : [ <a*!0 b a!0 c> ]
|
||||
1 of species5 : [ <c*!0 a*!1 b* a!2 d* f*!3 g* f!3 e*!4>
|
||||
| <a*!2 b a!1 c!0 e!4 h!5 l x k h*!5 d> ]
|
||||
state4 :
|
||||
|
||||
1 of species0 : [ <a*!0 b a!0 c> ]
|
||||
1 of species6 : [ <c*!0 a*!1 b* a!2 d* f*!3 g* f!3 e*>
|
||||
| <a*!2 b a!1 c!0 e h!4 l x k h*!4 d> ]
|
||||
state5 :
|
||||
|
||||
1 of species0 : [ <a*!0 b a!0 c> ]
|
||||
1 of species7 : [ <c* a*!0 b* a!0 d*!1 f*!2 g* f!2 e*!3>
|
||||
| <a*!4 b a!4 c e!3 h!5 l x k h*!5 d!1> ]
|
||||
state6 :
|
||||
|
||||
1 of species0 : [ <a*!0 b a!0 c> ]
|
||||
1 of species8 : [ <c* a*!0 b* a!0 d*!1 f*!2 g* f!2 e*>
|
||||
| <a*!3 b a!3 c e h!4 l x k h*!4 d!1> ]
|
||||
state7 :
|
||||
|
||||
1 of species0 : [ <a*!0 b a!0 c> ]
|
||||
1 of species9 : [ <c* a*!0 b* a!0 d* f*!1 g* f!1 e*!2>
|
||||
| <a*!3 b a!3 c e!2 h!4 l x k h*!4 d> ]
|
||||
state8 :
|
||||
|
||||
1 of species2 : [ <a*!0 b a!0 c e h!1 l x k h*!1 d> ]
|
||||
1 of species10: [ <a*!0 b a!1 c!2>
|
||||
| <c*!2 a*!1 b* a!0 d* f*!3 g* f!3 e*> ]
|
||||
state9 :
|
||||
|
||||
1 of species11: [ <a*!0 b a!1 c!2>
|
||||
| <c*!2 a*!1 b* a!0 d*!3 f*!4 g* f!4 e*!5>
|
||||
| <a*!6 b a!6 c e!5 h!7 l x k h*!7 d!3> ]
|
||||
state10:
|
||||
|
||||
1 of species12: [ <a*!0 b a!1 c!2>
|
||||
| <c*!2 a*!1 b* a!0 d*!3 f*!4 g* f!4 e*>
|
||||
| <a*!5 b a!5 c e h!6 l x k h*!6 d!3> ]
|
||||
state11:
|
||||
|
||||
1 of species13: [ <a*!0 b a!1 c!2>
|
||||
| <c*!2 a*!1 b* a!0 d* f*!3 g* f!3 e*!4>
|
||||
| <a*!5 b a!5 c e!4 h!6 l x k h*!6 d> ]
|
||||
|
||||
Transitions
|
||||
state0 -> state4 (0.003)
|
||||
state0 -> state6 (0.003)
|
||||
state0 -> state7 (0.003)
|
||||
state0 -> state8 (0.003)
|
||||
state2 -> state1 (0.003)
|
||||
state3 -> state1 (0.003)
|
||||
state4 -> state2 (0.003)
|
||||
state4 -> state3 (0.003)
|
||||
state5 -> state1 (0.003)
|
||||
state5 -> state9 (0.003)
|
||||
state6 -> state2 (0.003)
|
||||
state6 -> state5 (0.003)
|
||||
state6 -> state10 (0.003)
|
||||
state7 -> state3 (0.003)
|
||||
state7 -> state5 (0.003)
|
||||
state7 -> state11 (0.003)
|
||||
state8 -> state10 (0.003)
|
||||
state8 -> state11 (0.003)
|
||||
state10 -> state9 (0.003)
|
||||
state11 -> state9 (0.003)
|
|
@ -0,0 +1,9 @@
|
|||
enzymes
|
||||
[ nick (Gt^*,Gp1* Gp2* Gp3*)
|
||||
; nick (Bp3* Bp2* Bp1*, Bt^*) ]
|
||||
|
||||
1 * [ [Gt^* Gp1* Gp2* Gp3*]<tethergreenstart>
|
||||
| {Bt^*}<Gt^* Gp1* Gp2* Gp3*>[Bp1]<Bp2 Bp3!2>{Bp2m Bp3*!2}:[Gt^* Gp1*]<Gp2m Gp3*!1>{Gp2 Gp3!1 tetherjunction}
|
||||
| <Gt^* Gp1* Gp2* Gp3* tethergreenend>
|
||||
| [Bt^ Bp1 Bp2 Bp3]<Gt^*>{tetherbluestart}
|
||||
]
|
|
@ -0,0 +1,6 @@
|
|||
new 3@ 4.2E-4 , 4.0E-2
|
||||
new 5@ 6.5E-4 , 4.0E-3
|
||||
|
||||
13 * [ <2 3^ 4> ]
|
||||
| 10 * [ <4 5^> ]
|
||||
| 10 * [ <1 2!a> | <6 3^!b 4!c> | <5^* 4*!c 3^*!b 2*!a> ]
|
|
@ -0,0 +1,6 @@
|
|||
new 3@ 4.2E-4 , 4.0E-2
|
||||
new 5@ 6.5E-4 , 4.0E-3
|
||||
|
||||
13 * [ <2 3^ 4 7> ]
|
||||
| 10 * [ <4 7 5^> ]
|
||||
| 10 * [ <1 2!a> | <6 3^!b 4!c 7!d> | <5^* 7*!d 4*!c 3^*!b 2*!a> ]
|
|
@ -0,0 +1 @@
|
|||
<X*!a> | <X!a Y!b> | <Y*!b X*!c> | <X!c Z!e> | <Z*!e X*>
|
|
@ -0,0 +1,8 @@
|
|||
<X!a Y!b Z!c>
|
||||
| <Z*!c Y*!b X*!e>
|
||||
| <X!e Y!f Z!g>
|
||||
| <Z*!g Y*!f X*!h>
|
||||
| <X!h Y!i Z!j>
|
||||
| <Z*!j Y*!i X*!k>
|
||||
| <X!k Y!l Z!m>
|
||||
| <Z*!m Y*!l X*!a>
|
|
@ -0,0 +1 @@
|
|||
<X X*> | <X* X>
|
|
@ -0,0 +1 @@
|
|||
<Y!c> | <Y!d> | <X!a Y*!c Y*!d X*!b> | <X!b Y*!e Y*!f X*!a> | <Y!e> | <Y!f>
|
|
@ -0,0 +1,7 @@
|
|||
[ <y* b* x* a*> ]
|
||||
|
||||
| [ <a x!a1 b!a2 y!a3 z* c* y*!a3 b*!a2 x*!a1> ]
|
||||
|
||||
| [ <b y!b1 c!b2 z!b3 x* a* z*!b3 c*!b2 y*!b1> ]
|
||||
|
||||
| [ <c z!c1 a!c2 x!c3 y* b* x*!c3 a*!c2 z*!c1> ]
|
|
@ -0,0 +1,4 @@
|
|||
<x* a*>
|
||||
| <a x!a1 b x*!a1>
|
||||
| <x b*!b1 c b!b1>
|
||||
| <c* x*!c1 a* x!c1>
|
|
@ -0,0 +1 @@
|
|||
<X Y*>
|
|
@ -0,0 +1,6 @@
|
|||
enzymes [ nick (Gt^*,Gp1* Gp2* Gp3*) ]
|
||||
|
||||
1 * [ [Gt^* Gp1* Gp2* Gp3*]<tethergreenstart>
|
||||
| {Bt^*}<Gt^* Gp1* Gp2* Gp3*>[Bp]:[Gt^* Gp1*]<Gp2m Gp3*!1>{Gp2 Gp3!1 tetherjunction}
|
||||
| <Gt^* Gp1* Gp2* Gp3* tethergreenend>
|
||||
]
|
|
@ -0,0 +1,9 @@
|
|||
enzymes
|
||||
[ nick (Gt^*,Gp1* Gp2* Gp3*)
|
||||
; nick (Bp3^* Bp2* Bp1*, Bt^*) ]
|
||||
|
||||
1 * [ [Gt^* Gp1* Gp2* Gp3*]<tethergreenstart>
|
||||
| {Bt^*}<Gt^* Gp1* Gp2* Gp3*>[Bp1]<Bp2 Bp3^!2>{Bp2m Bp3^*!2}:[Gt^* Gp1*]<Gp2* Gp3*!1>{Gp2m Gp3!1 tetherjunction}
|
||||
| <Gt^* Gp1* Gp2* Gp3* tethergreenend>
|
||||
| [Bt^ Bp1 Bp2 Bp3^]<Gt^*>{tetherbluestart}
|
||||
]
|
|
@ -0,0 +1,9 @@
|
|||
enzymes
|
||||
[ nick (Gt^*,Gp1* Gp2* Gp3*)
|
||||
; nick (Bp3^* Bp2m Bp1*, Bt^*) ]
|
||||
|
||||
1 * [ [Gt^* Gp1* Gp2* Gp3*]<tethergreenstart>
|
||||
| {Bt^*}<Gt^* Gp1* Gp2* Gp3*>[Bp1 Bp2 Bp3^]:[Gt^* Gp1*]<Gp2* Gp3*!1>{Gp2m Gp3!1 tetherjunction}
|
||||
| <Gt^* Gp1* Gp2* Gp3* tethergreenend>
|
||||
| [Bt^ Bp1]<Bp2 Bp3^!2 Gt^*>{Bp2m Bp3^*!2 tetherbluestart}
|
||||
]
|
|
@ -0,0 +1,9 @@
|
|||
enzymes
|
||||
[ nick (Gt^*,Gp1* Gp2* Gp3*)
|
||||
; nick (Bp3* Bp2* Bp1*, Bt^*) ]
|
||||
|
||||
1 * [ [Gt^* Gp1* Gp2* Gp3*]<tethergreenstart>
|
||||
| {Bt^*}<Gt^* Gp1* Gp2* Gp3*>[Bp1]<Bp2 Bp3!2>{Bp2m Bp3*!2}:[Gt^* Gp1*]<Gp2m Gp3*!1>{Gp2 Gp3!1 tetherjunction}
|
||||
| <Gt^* Gp1* Gp2* Gp3* tethergreenend>
|
||||
| [Bt^ Bp1 Bp2 Bp3]<Gt^*>{tetherbluestart}
|
||||
]
|
|
@ -0,0 +1,3 @@
|
|||
1 * [ [a]<b>:<a!1>[c]
|
||||
| <a*!1>
|
||||
]
|
|
@ -0,0 +1 @@
|
|||
<X*!a Z X!a Y!b Z Y*!b X*!c Z X!c Y!e Z Y*!e X*>
|
|
@ -0,0 +1,11 @@
|
|||
[ <c^ y^!e0 d^!e1 a^!e2 x^!e3 y^* c^* b^* x^*!e3 a^*!e2 d^*!e1 y^*!e0> ]
|
||||
| [ <TRK1!t0 s1^ a^!a0 x^!a1 b^!a2 c^!a3 y^!a4 x^*!a5 a^* d^* y^* c^* b^* x^*>
|
||||
| <TRK2!t1 TRK3!t2>
|
||||
| <TRK1!t3 s1^ a^!c5 x^!c4 b^!c3 c^!c2 y^!c1 x^*!c0 a^* d^* y^* c^* b^* x^*>
|
||||
| <TRK2!t4 TRK3!t5>
|
||||
| <TRK1!t6 s1^ a^ x^!d0 b^!d1 c^!d2 y^!d3 x^* a^* d^* y^*!d3 c^*!d2 b^*!d1 x^*!d0>
|
||||
| <TRK2!t7 TRK3!t8>
|
||||
| <TRK3*!t8 TRK2*!t7 TRK1*!t6 TRK3*!t5>
|
||||
| <TRK2*!t4 TRK1*!t3 TRK3*!t2 TRK2*!t1 TRK1*!t0>
|
||||
| <BRACE!b0 s2^ x^!a5 y^*!a4 c^*!a3 b^*!a2 x^*!a1 a^*!a0>
|
||||
| <BRACE*!b0 s2^ x^!c0 y^*!c1 c^*!c2 b^*!c3 x^*!c4 a^*!c5> ]
|
|
@ -0,0 +1,44 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
namespace SiteGraphCRN.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("SiteGraphCRN")>]
|
||||
[<assembly: AssemblyDescription("")>]
|
||||
[<assembly: AssemblyConfiguration("")>]
|
||||
[<assembly: AssemblyCompany("")>]
|
||||
[<assembly: AssemblyProduct("SiteGraphCRN")>]
|
||||
[<assembly: AssemblyCopyright("Copyright © 2016")>]
|
||||
[<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("6df46f40-6251-4f0e-bebb-b3fd7a0318d8")>]
|
||||
|
||||
// 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,151 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.Compile
|
||||
open Parser
|
||||
open Microsoft.Research.CRNEngine
|
||||
|
||||
let set_plots (crn:Crn) =
|
||||
{ crn with settings = { crn.settings with simulation = { crn.settings.simulation with plots = crn.initials |> List.map (fun i -> Expression.Key (Key.Species i.species)) } } }
|
||||
|
||||
type Render_mode = Default | Circle | Force
|
||||
|
||||
let to_crn strands ss species reactions render_mode =
|
||||
let init_ss = ss |> Seq.toList |> List.map snd
|
||||
let init_map = ss |> Seq.map (fun (n,s) -> s,n) |> Map.ofSeq
|
||||
|
||||
let renderer = match render_mode with
|
||||
| Default -> SiteGraphReactor.Species.to_svg
|
||||
| Circle -> SiteGraphReactor.CirclesRenderer.to_circle_svg
|
||||
| Force -> SiteGraphReactor.Species.to_svg_forces Species.forces
|
||||
let renderer = renderer (new System.Collections.Generic.Dictionary<string,string>())
|
||||
|
||||
let crn_attributes_map =
|
||||
species |> Set.toSeq
|
||||
|> Seq.mapi (fun i s -> s, { Attributes.name = i |> sprintf "species_%i"
|
||||
; Attributes.structure = s |> SiteGraphReactor.Species.to_string strands
|
||||
; Attributes.svg = s |> renderer strands })
|
||||
|> Map.ofSeq in
|
||||
|
||||
let crn_attributes s = crn_attributes_map.[s] in
|
||||
let crn_species s = (crn_attributes s).name |> Species.create
|
||||
let crn_value = float >> Expression.Float
|
||||
let crn_initial s =
|
||||
match init_map |> Map.tryFind s with
|
||||
| Some n -> Initial.create(false, (crn_value n), (crn_species s), None, None)
|
||||
| None -> Initial.create(false, (crn_value 0), (crn_species s), None, None)
|
||||
|
||||
let crn_reaction (r: SiteGraphReactor.Calculus.reaction<Species.rep>) : Reaction<Species,Value,Functional> =
|
||||
Reaction.create(
|
||||
[],
|
||||
(r.reactants |> List.map crn_species),
|
||||
(None, Rate.MassAction (r.rate |> Expression.Float)),
|
||||
(r.products |> List.map crn_species)
|
||||
)
|
||||
let crn = { Crn.empty with
|
||||
initials = species |> Set.toList |> List.map crn_initial
|
||||
; reactions = reactions |> Set.toList |> List.map crn_reaction }
|
||||
|> set_plots
|
||||
|> Crn.group_reactions
|
||||
let allSpecies = crn.saturate_initials().initials
|
||||
let attributes = Set.fold (fun m i -> Stringmap.add (crn_attributes i).name (crn_attributes i) m) Stringmap.empty species
|
||||
{ crn with attributes = attributes}
|
||||
|
||||
|
||||
let convert_expand limit (enzymes, toehold_map, strands, ss) render_mode =
|
||||
let init_ss = ss |> Seq.toList |> List.map snd
|
||||
|
||||
let fast_mono sg =
|
||||
[ Reactions.displacing_actions strands sg
|
||||
; Reactions.complementary_binding_actions strands sg ]
|
||||
|> Seq.concat
|
||||
|> Set.ofSeq
|
||||
|> Set.map (Reactions.to_calc_react toehold_map strands)
|
||||
let slow_mono sg =
|
||||
[ Reactions.isolated_toehold_unbinding_actions strands sg
|
||||
; enzymes |> Seq.collect (fun e -> Reactions.nicking_actions strands e sg) ]
|
||||
|> Seq.concat
|
||||
|> Seq.toList
|
||||
|> List.map (Reactions.to_calc_react toehold_map strands)
|
||||
|
||||
let calculus =
|
||||
SiteGraphReactor.Reactions.calculus enzymes toehold_map strands init_ss
|
||||
|> TimeSeparation.lift fast_mono slow_mono
|
||||
let species, reactions = SiteGraphReactor.ReactionGraph.reaction_graph limit calculus
|
||||
|
||||
to_crn strands ss species reactions render_mode
|
||||
|
||||
let compile limit = SiteGraphReactor.Sitegraphs.compile >> convert_expand limit
|
||||
|
||||
//type bundle = seq<Strands.domain [] * Strands.domain []> * Map<string,(float * float)> * Strands.t * seq<int * Species.rep>
|
||||
|
||||
//Remove tuple from interface, I'd like us to push types types into the core code. Colin
|
||||
type Enzyme =
|
||||
{ left_of_cut: Strands.domain []
|
||||
; right_of_cut: Strands.domain [] }
|
||||
|
||||
type toehold_rate =
|
||||
{ binding: float
|
||||
; unbinding: float }
|
||||
|
||||
type counted_species =
|
||||
{ count: int
|
||||
; representative: Species.rep }
|
||||
|
||||
type sg_settings =
|
||||
{ inference: Inference_settings option
|
||||
render_mode: Render_mode }
|
||||
|
||||
let default_settings = { inference = None
|
||||
render_mode = Default }
|
||||
|
||||
type bundle =
|
||||
{ enzymes:seq<Enzyme>
|
||||
; toehold_map:Map<string,toehold_rate>
|
||||
; strands:Strands.t
|
||||
; initial_species:seq<counted_species>
|
||||
; settings: sg_settings }
|
||||
|
||||
let convert_unexpanded (enzymes, toehold_map, strands, ss) settings =
|
||||
let init_ss = ss |> Seq.toList |> List.map snd |> Set.ofList
|
||||
let enzymes_record = enzymes |> Seq.map (fun enzyme -> { left_of_cut = fst enzyme; right_of_cut = snd enzyme})
|
||||
let toehold_rate_record = toehold_map |> Map.map(fun _ value -> {binding=fst value; unbinding=snd value})
|
||||
let species_something_record = ss |> Seq.map (fun initial_specie -> {count = fst initial_specie; representative = snd initial_specie})
|
||||
( { enzymes = enzymes_record; toehold_map = toehold_rate_record; strands = strands; initial_species = species_something_record; settings = settings }
|
||||
, to_crn strands ss init_ss Set.empty settings.render_mode )
|
||||
|
||||
let parse = SiteGraphReactor.Sitegraphs.compile >> convert_unexpanded
|
||||
|
||||
let expand limit (bundle:bundle) =
|
||||
let enzymes_tuples = bundle.enzymes |> Seq.map (fun enzyme -> enzyme.left_of_cut, enzyme.right_of_cut)
|
||||
let toehold_rates_tuples = bundle.toehold_map |> Map.map (fun _ value -> value.binding, value.unbinding)
|
||||
let inital_species_tuples = bundle.initial_species |> Seq.map (fun initial_specie -> initial_specie.count, initial_specie.representative)
|
||||
convert_expand limit (enzymes_tuples, toehold_rates_tuples, bundle.strands, inital_species_tuples) bundle.settings.render_mode
|
||||
|
||||
type sgDirective = Inference of Inference_settings
|
||||
| Rendering of Render_mode
|
||||
let parse_enzymes =
|
||||
let dirs = many ( pTry (kw "directive"
|
||||
>>. choice [
|
||||
kw "inference" >>. Inference_settings.parse |>> Inference
|
||||
kw "render_mode" >>. choice [
|
||||
kw "circle" >>. preturn Circle |>> Rendering
|
||||
kw "force" >>. preturn Force |>> Rendering
|
||||
kw "default" >>. preturn Default |>> Rendering
|
||||
]
|
||||
]) )
|
||||
|>> List.fold (fun (acc:sg_settings) x ->
|
||||
match x with
|
||||
| Inference i -> { acc with inference = Some i }
|
||||
| Rendering r -> { acc with render_mode = r }
|
||||
) default_settings
|
||||
let es = sepEndBy (ExtendedSyntax.enzyme Syntax.parse_name) (Syntax.kw ";") |> Syntax.bracket "[" "]"
|
||||
let enzymes = (SiteGraphReactor.Syntax.kw "enzymes" >>. es) |> opt |>> function Some es -> es | None -> []
|
||||
let basic = Syntax.parse_name |> Syntax.parse_site |> ExtendedSyntax.parse_syntax |>> ExtendedSyntax.to_basic
|
||||
spaces >>. dirs .>>. enzymes .>>. basic
|
||||
|
||||
let parse_with_settings s =
|
||||
let (settings,domains),syntax = (parse_enzymes |> Syntax.run_parser) s in
|
||||
let sitegraphs = (domains,syntax) |> SiteGraphReactor.Sitegraphs.semantics in
|
||||
(settings,sitegraphs)
|
|
@ -0,0 +1,8 @@
|
|||
// Learn more about F# at http://fsharp.org. See the 'F# Tutorial' project
|
||||
// for more guidance on F# programming.
|
||||
|
||||
#load "Library1.fs"
|
||||
open SiteGraphCRN
|
||||
|
||||
// Define your library scripting code here
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AssemblyInfo.fs" />
|
||||
<Compile Include="Compile.fs" />
|
||||
<None Include="Script.fsx" />
|
||||
<None Include="paket.references" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\CRNEngine\CRNEngineDotNet\CRNEngineDotNet.fsproj" />
|
||||
<ProjectReference Include="..\..\Filzbach.FSharp\Filzbach.FSharp.Portable.fsproj" />
|
||||
<ProjectReference Include="..\..\ParserCombinators\ParserCombinators\ParserCombinators.fsproj" />
|
||||
<ProjectReference Include="..\..\PDESolvers\ReactionDiffusion\ReactionDiffusion.fsproj" />
|
||||
<ProjectReference Include="..\SiteGraphReactor\SiteGraphReactor.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,3 @@
|
|||
group NETSTANDARD
|
||||
|
||||
FSharp.Core
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
</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="..\SiteGraphCRN\Compile.fs">
|
||||
<Link>Compile.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="jsapi.fs" />
|
||||
<Compile Include="jsonapi.fs" />
|
||||
<None Include="paket.references" />
|
||||
<None Include="wsconfig.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\CRNEngine\CRNEngineJS\CRNEngineJS.fsproj" />
|
||||
<ProjectReference Include="..\..\Filzbach.FSharp.JS\Filzbach.FSharp.JS.fsproj" />
|
||||
<ProjectReference Include="..\..\ParserCombinators\ParserCombinatorsJS\ParserCombinatorsJS.fsproj" />
|
||||
<ProjectReference Include="..\SiteGraphReactorJS\SiteGraphReactorJS.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,40 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScriptExport>]
|
||||
module SiteGraphReactor.JSAPI
|
||||
open WebSharper
|
||||
open Microsoft.Research.CRNEngine
|
||||
open SiteGraphReactor.Compile
|
||||
|
||||
type ParseResult =
|
||||
{ bundle : bundle
|
||||
; unexpanded : Gui }
|
||||
|
||||
let user_parse (code:string) : ParseResult =
|
||||
let (settings,sitegraphs) = parse_with_settings code in
|
||||
let bundle, crn = convert_unexpanded sitegraphs settings in
|
||||
let crn = match settings.inference with
|
||||
| None -> crn
|
||||
| Some i -> { crn with settings = {crn.settings with inference = i} }
|
||||
let crn = crn.initialise()
|
||||
let gui = Gui.from_crn crn
|
||||
{ bundle = bundle
|
||||
; unexpanded = gui }
|
||||
|
||||
let user_expand (bundle:bundle) : Gui =
|
||||
let crn = expand 0 bundle in
|
||||
let crn = crn.initialise()
|
||||
let gui = Gui.from_crn crn
|
||||
gui
|
||||
|
||||
let user_compile (code:string) : Gui =
|
||||
let (settings,sitegraphs) = parse_with_settings code in
|
||||
let no_limit = 0
|
||||
let crn = convert_expand no_limit sitegraphs settings.render_mode
|
||||
let crn = match settings.inference with
|
||||
| None -> crn
|
||||
| Some i -> { crn with settings = {crn.settings with inference = i} }
|
||||
let crn = crn.initialise()
|
||||
let gui = Gui.from_crn crn
|
||||
gui
|
|
@ -0,0 +1,27 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScriptExport>]
|
||||
module SiteGraphReactor.JSONAPI
|
||||
open WebSharper
|
||||
open SiteGraphReactor.JSAPI
|
||||
open SiteGraphReactor.Compile
|
||||
|
||||
type ParseResult =
|
||||
{ bundle : bundle
|
||||
; unexpanded : obj }
|
||||
|
||||
let user_parse (code:string) : ParseResult =
|
||||
let pr = JSAPI.user_parse code in
|
||||
let ret = WebSharper.Json.Encode pr.unexpanded in
|
||||
{ bundle = pr.bundle ; unexpanded = ret }
|
||||
|
||||
let user_expand (bundle:bundle) : obj =
|
||||
let gui = JSAPI.user_expand bundle in
|
||||
let ret = WebSharper.Json.Encode gui in
|
||||
ret
|
||||
|
||||
let user_compile (code:string) : obj =
|
||||
let gui = JSAPI.user_compile code in
|
||||
let ret = WebSharper.Json.Encode gui in
|
||||
ret
|
|
@ -0,0 +1,4 @@
|
|||
group NETSTANDARD
|
||||
|
||||
WebSharper.FSharp
|
||||
FSharp.Core
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"project": "bundle",
|
||||
"outputDir": "Content"
|
||||
}
|
|
@ -0,0 +1,103 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.27130.2027
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "SiteGraphReactor", "SiteGraphReactor\SiteGraphReactor.fsproj", "{DD8A92D8-9520-4BF2-B399-08ED9B6E1F95}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "SiteGraphReactorJS", "SiteGraphReactorJS\SiteGraphReactorJS.fsproj", "{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}"
|
||||
EndProject
|
||||
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "SiteGraphCRN", "SiteGraphCRN\SiteGraphCRN.fsproj", "{6DF46F40-6251-4F0E-BEBB-B3FD7A0318D8}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ParserCombinators", "..\ParserCombinators\ParserCombinators\ParserCombinators.fsproj", "{DD8FEC26-6D1D-4642-A706-04070B6D5494}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ParserCombinatorsJS", "..\ParserCombinators\ParserCombinatorsJS\ParserCombinatorsJS.fsproj", "{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}"
|
||||
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}") = "SiteGraphCRNJS", "SiteGraphCRNJS\SiteGraphCRNJS.fsproj", "{82903A27-E535-4D30-8449-2AD9D2A9769E}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "Filzbach.FSharp.JS", "..\Filzbach.FSharp.JS\Filzbach.FSharp.JS.fsproj", "{4DF94589-6870-4A4C-BFAE-5825EF4634E7}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SundialsSolver15", "..\SundialsSolver\SundialsSolver15\SundialsSolver15.vcxproj", "{866880DC-BF1E-4C12-8238-72E7EFF44AFB}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CliLibrary", "..\CRNEngine\CliLibrary\CliLibrary.fsproj", "{EEF843A3-43F8-4E6B-AB7F-9ADE3A5AF022}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CRNEngineDotNet", "..\CRNEngine\CRNEngineDotNet\CRNEngineDotNet.fsproj", "{AE45211A-A65D-4827-A1F9-07A20EB0F154}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "CRNEngineJS", "..\CRNEngine\CRNEngineJS\CRNEngineJS.fsproj", "{836AF075-6448-4CD9-8020-434B963FF5E2}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ReactionDiffusionJS", "..\PDESolvers\ReactionDiffusionJS\ReactionDiffusionJS.fsproj", "{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ReactionDiffusion", "..\PDESolvers\ReactionDiffusion\ReactionDiffusion.fsproj", "{529BEDB7-C73A-4A77-BFD9-1628D75C321B}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x64 = Debug|x64
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{DD8A92D8-9520-4BF2-B399-08ED9B6E1F95}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{DD8A92D8-9520-4BF2-B399-08ED9B6E1F95}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{DD8A92D8-9520-4BF2-B399-08ED9B6E1F95}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{DD8A92D8-9520-4BF2-B399-08ED9B6E1F95}.Release|x64.Build.0 = Release|Any CPU
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}.Release|x64.Build.0 = Release|Any CPU
|
||||
{6DF46F40-6251-4F0E-BEBB-B3FD7A0318D8}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{6DF46F40-6251-4F0E-BEBB-B3FD7A0318D8}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{6DF46F40-6251-4F0E-BEBB-B3FD7A0318D8}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{6DF46F40-6251-4F0E-BEBB-B3FD7A0318D8}.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
|
||||
{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|x64.ActiveCfg = Release|Any CPU
|
||||
{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}.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
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E}.Release|x64.Build.0 = Release|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|x64.ActiveCfg = Release|Any CPU
|
||||
{4DF94589-6870-4A4C-BFAE-5825EF4634E7}.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
|
||||
{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
|
||||
{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
|
||||
{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|x64.ActiveCfg = Release|Any CPU
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2}.Release|x64.Build.0 = Release|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|x64.ActiveCfg = Release|Any CPU
|
||||
{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}.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
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {24EC02A2-A1B1-4C16-852B-5B4CACE8BCAF}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -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,50 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.Calculus
|
||||
|
||||
(* Maybe later..
|
||||
type 's mset = ('s * int) list
|
||||
let map_mset f (m: 's mset) = m |> List.map (fun (s,n) -> f s, n)
|
||||
*)
|
||||
|
||||
// TODO: Add rate
|
||||
type 's reaction =
|
||||
{ reactants : 's list
|
||||
; products : 's list
|
||||
; rate : float }
|
||||
|
||||
let map_reaction f (r: 's reaction) =
|
||||
{ reactants = r.reactants |> List.map f
|
||||
; products = r.products |> List.map f
|
||||
; rate = r.rate }
|
||||
|
||||
type 's t when 's:comparison =
|
||||
{ mono : 's -> Set<'s reaction>
|
||||
; bin : 's -> 's -> Set<'s reaction>
|
||||
; reactions : Set<'s> -> 's -> Set<'s reaction>
|
||||
; initial_species : 's list }
|
||||
|
||||
let from_mono_bin mono bin is =
|
||||
let reactions ss s =
|
||||
seq {
|
||||
yield mono s
|
||||
yield bin s s
|
||||
yield! ss |> Seq.map (bin s)
|
||||
} |> Set.unionMany
|
||||
{ mono = mono; bin = bin; reactions = reactions; initial_species = is }
|
||||
|
||||
let reaction_graph limit (c: 's t) =
|
||||
let positivite_propensity (r: 's reaction) = true // TODO: should look at rate of r
|
||||
let rec work rs all_ss l =
|
||||
match l with
|
||||
| [] -> all_ss, rs
|
||||
| w::ws ->
|
||||
if limit > 0 && (Set.count all_ss > limit) then (w::ws |> Set.ofList |> Set.union all_ss), rs else
|
||||
printfn "Species: %d" (Set.count all_ss)
|
||||
let new_rs = c.reactions all_ss w - rs |> Set.filter positivite_propensity
|
||||
let is_new s = Set.contains s all_ss |> not
|
||||
let new_ss = new_rs |> Seq.collect (fun r -> r.products) |> Seq.distinct |> Seq.filter is_new |> Seq.toList
|
||||
work (Set.union new_rs rs) (Set.add w all_ss) (ws @ new_ss)
|
||||
work Set.empty Set.empty c.initial_species
|
|
@ -0,0 +1,477 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.CirclesRenderer
|
||||
open Species
|
||||
open SiteGraphReactor.Strands
|
||||
|
||||
//---------------------------
|
||||
// Circle based visualisation
|
||||
// (NuPack-style)
|
||||
// From DnaModelling solution, DnaStructures project, Visualizations.fs file
|
||||
//---------------------------
|
||||
|
||||
(* Algorithm:
|
||||
- build a circle with edges
|
||||
- collapse edges until they are all turned into children
|
||||
- collapse edges in children recursively
|
||||
*)
|
||||
|
||||
type svg_domain =
|
||||
| Domain of Strands.domain
|
||||
| Xing of Strands.domain
|
||||
| Hole
|
||||
member this.text =
|
||||
match this with
|
||||
| Domain dom -> (Strands.domain_to_string dom).Replace("^", "")
|
||||
| Xing _ -> "X"
|
||||
| Hole -> "O"
|
||||
member this.compl =
|
||||
match this with
|
||||
| Domain dom -> Domain { dom with complemented = not dom.complemented }
|
||||
| _ -> this
|
||||
|
||||
/// Represents a circle. The circle is made of ports (which mostly correspond to domains), and may have children (which are other circles connected to it). A circle may be itself the child of another circle, but does not maintain a reference to its parent.
|
||||
type circle =
|
||||
/// The center of the circle.
|
||||
{ center : float * float
|
||||
/// A rotation to be applied to the circle (to align its ports correctly).
|
||||
; angle : float
|
||||
/// The circle radius.
|
||||
; radius : float // Invariant: radius = ports.Length |> circle_radius
|
||||
/// The ports that make up the circle.
|
||||
; ports : svg_domain[]
|
||||
/// The circle's children. The type of a child is a tuple of: an integer which is the index in the port sequence on which the child is connected to the parent; a domain which is the edge domain connecting the two circles, and the actual child circle.
|
||||
; children : (int * svg_domain * circle) list
|
||||
/// Edges within the circle, i.e. sites that ought to connect. If there are edges, then the circle can be collapsed further.
|
||||
; edges : (int*int) []
|
||||
}
|
||||
|
||||
let min_side_length = 100.0
|
||||
let xing_length_per_char = 30.0
|
||||
let circle_has_overhangs ports = Array.exists (fun d -> match d with Domain d -> true | _ -> false) ports
|
||||
/// Determines the radius of a circle, based on the ports (domains) in it. The radius is determined so that each arc is min_side_length units long.
|
||||
let circle_radius ports =
|
||||
match ports with [|Xing _; Xing _|] -> 4.0
|
||||
| _ -> 0.5*(min_side_length * float ports.Length)/twopi * (if circle_has_overhangs ports then 1.0 else 0.4)
|
||||
|
||||
/// Make crossings longer when domain names are long.
|
||||
let xing_side_length (b:svg_domain) =
|
||||
match b with
|
||||
| Hole ->
|
||||
min_side_length
|
||||
| Xing dom
|
||||
| Domain dom ->
|
||||
let l = float dom.name.Length * xing_length_per_char
|
||||
max l min_side_length
|
||||
|
||||
/// Normalize the tuple so that the smaller int goes first.
|
||||
let sort_e (p1:int, p2:int) = min p1 p2, max p1 p2
|
||||
|
||||
/// This function receives a circle and an edge within the circle (in the form of a couple of indexes within the circle's ports array). It returns the same circle, except that now it has an additional child. The ports array is split between the parent and the child, and each side of the edge becomes a crossing port, where they join.
|
||||
let circle_split (p1, p2) (c:circle) = // Do not split on an edge with a right neighbour
|
||||
/// The ports, sorted so that p1 is guaranteeed to be the lowest.
|
||||
let p1, p2 = sort_e (p1,p2)
|
||||
/// The length (in sites count) of the current circle.
|
||||
let n = c.ports.Length
|
||||
/// The length of the first new circle (parent).
|
||||
let n1 = n - (p2-p1)
|
||||
/// The length of the second new circle (child).
|
||||
let n2 = p2-p1
|
||||
/// This function takes the index of a site in the new parent circle, and returns the index of the corresponding site in the original circle.
|
||||
let m1_inv i = if i < p1 then i
|
||||
else i-p1+p2 // Note that if i == p1 this will return the index of one side of the edge.
|
||||
/// This function takes the index of a site in the original circle, and returns the index of the corresponding site in the new parent circle. Note that this will return a negative number if the site in the original circle is not actually in the new parent circle (i.e. it's in the child circle).
|
||||
let m1 i = if i < p1 then i
|
||||
else i+p1-p2 // Note that if i == p1 this will return the index of one side of the edge.
|
||||
/// This function takes the index of a site in the child circle, and returns the index of the corresponding site in the original circle. Note that the child circle is formed of the sites originally contained between the edge sites; this is why this function doesn't need to take p2 into account.
|
||||
let m2_inv i = i+p1+1
|
||||
/// This function takes the index of a site in the original circle, and returns the index of the corresponding site in the new child circle. Note that the child circle is formed of the sites originally contained between the edge sites; this is why this function doesn't need to take p2 into account. Note that this will return a negative number if the site in the original circle is not actually in the new child circle (i.e. it's in the parent circle).
|
||||
let m2 i = i-p1-1
|
||||
/// Turns a Domain port into a Xing port. Note: if this gets called on a port that's not a Domain, then something went wrong in the earlier phases (edges can only logically be between Domain ports).
|
||||
let make_xing port = match port with Domain dom -> Xing dom | _ -> failwith ""
|
||||
/// The ports of the new parent circle. In the new parent circle's index, the crossing is at index p1.
|
||||
let ports1 = Array.init n1 (fun i -> let port = c.ports.[m1_inv i]
|
||||
if i = p1 then make_xing port
|
||||
else port)
|
||||
/// The ports of the new child circle. In the new parent circle's index, the crossing is always at the last site (i.e. index n2-1).
|
||||
let ports2 = Array.init n2 (fun i -> let port = c.ports.[m2_inv i]
|
||||
if i = n2-1 then make_xing port
|
||||
else port)
|
||||
/// Takes a port index (in the original circle). Returns true if this port will end up in the new parent circle. If called on one of the edge ports, will always return false.
|
||||
let in_c1 p = p < p1 || p > p2
|
||||
/// Divide any existing children between the two circles, according to which circle the child's port belongs to. Note that this assumes that no children is at p1 or p2 (this should be impossible).
|
||||
let cs1, cs2 = c.children |> List.partition (fun (p,_,_) -> in_c1 p)
|
||||
/// This function takes as input the characteristics of a parent circle (port count and radius); the connection port on the parent side; the characteristics of a child circle. It returns the coordinates and rotation angle of the child circle. This will be used both to place the new child relative to the parent, and to reposition any pre-existing children of both of them.
|
||||
let port_circle (pn, pr) (ports:svg_domain[]) (p:int) (cn, cr) =
|
||||
let side_length = xing_side_length ports.[p]
|
||||
let angle = (float p / float pn) * twopi
|
||||
let d = pr + 0.5 * side_length + cr
|
||||
let center = (d * cos angle, d * sin angle)
|
||||
let angle2X = -twopi / float cn
|
||||
( center
|
||||
, angle - angle2X + pi )
|
||||
|
||||
/// Radius of the new parent circle.
|
||||
let radius1 = circle_radius ports1
|
||||
/// Radius of the new child circle.
|
||||
let radius2 = circle_radius ports2
|
||||
|
||||
/// Takes a pre-existing child of the parent circle, and the port on which it is connected to the parent. Returns the same child, translated and rotated into a position that matches the new shape of the parent circle.
|
||||
let child1 p ch =
|
||||
let center, angle = port_circle (n1, radius1) ports1 p (ch.ports.Length, ch.radius)
|
||||
{ ch with center = center; angle = angle }
|
||||
/// Remap the pre-existing children of the new parent circle, so that they are correctly placed.
|
||||
let children1 = cs1 |> List.map (fun (p,s,ch) -> m1 p, s, child1 (m1 p) ch)
|
||||
|
||||
/// Location (center, angle) of the new child circle.
|
||||
let center2, angle2 = port_circle (n1, radius1) ports1 p1 (n2, radius2)
|
||||
|
||||
/// Takes a pre-existing child of the new child circle, and the port on which it is connected to the parent. Returns the same child, translated and rotated into a position that matches the new shape of its parent circle (which is the new child circle).
|
||||
let child2 p ch =
|
||||
let center, angle = port_circle (n2, radius2) ports2 p (ch.ports.Length, ch.radius)
|
||||
{ ch with center = center; angle = angle }
|
||||
/// Remap the pre-existing children of the new child circle, so that they are correctly placed.
|
||||
let children2 = cs2 |> List.map (fun (p,s,ch) -> m2 p, s, child2 (m2 p) ch)
|
||||
|
||||
/// Divide the edges of the original circle between the two new circles. Note that this looks at the first site alone because we assume no crossings; if there are crossings, the algorithm will produce wrong results. Also, the edge currently being handled will end up in the child circle at this stage (but we'll remove it soon).
|
||||
let es1, es2 = c.edges |> Array.partition (fst >> in_c1)
|
||||
/// Map the site indexes of the edges that end up in the parent circle, so that they are in the space of its sites.
|
||||
let edges1 = es1 |> Array.map (fun (i,j) -> m1 i, m1 j)
|
||||
/// Map the site indexes of the edges that end up in the child circle, so that they are in the space of its sites. Also, remove the edge currently being handled.
|
||||
let edges2 = es2 |> Array.filter (fun e -> sort_e e <> (p1,p2))
|
||||
|> Array.map (fun (i,j) -> m2 i, m2 j)
|
||||
|
||||
/// The new child circle.
|
||||
let circle2 =
|
||||
{ center = center2
|
||||
; angle = angle2
|
||||
; radius = radius2
|
||||
; ports = ports2
|
||||
; children = children2
|
||||
; edges = edges2 }
|
||||
|
||||
// The parent circle is different from the old circle, because sites have been removed from it. Therefore, its own position and angle relative to its own parent need to get changed.
|
||||
|
||||
let angleX = -twopi / float n
|
||||
let angle1X = -twopi / float n1
|
||||
let angle1 = c.angle + angleX - angle1X
|
||||
|
||||
let Xx, Xy = c.radius * cos (c.angle + angleX), c.radius * sin (c.angle + angleX)
|
||||
let X1x, X1y = radius1 * cos (angle1 + angle1X), radius1 * sin (angle1 + angle1X)
|
||||
let center1 = fst c.center + Xx - X1x, snd c.center + Xy - X1y
|
||||
|
||||
{ center = center1
|
||||
; angle = angle1
|
||||
; radius = radius1
|
||||
; ports = ports1
|
||||
; children = (p1, c.ports.[p1], circle2)::children1
|
||||
; edges = edges1
|
||||
}
|
||||
|
||||
/// Collapse all edges in the given circle; each collapse will cause the circle to be split, generating a child circle, joined by a crossing.
|
||||
let rec collapse_circle (c:circle) =
|
||||
if c.edges.Length = 0 then
|
||||
// If this circle has no edges, then recursively collapse all children.
|
||||
let children = c.children |> List.map (fun (i, s, ch) -> (i, s, collapse_circle ch))
|
||||
{ c with children = children }
|
||||
else
|
||||
// If this circle has edges, collapse the first and then recurse on the resulting circle.
|
||||
c |> circle_split c.edges.[0] |> collapse_circle
|
||||
|
||||
/// Padding around a rendering.
|
||||
let pad = 12.0
|
||||
|
||||
/// Translates the circle so that the entire figure is in the first quadrant. Also returns the width and height of the figure.
|
||||
let into_view (c:circle) =
|
||||
/// Returns an enumeration of the corners of the circle and its children (in this context, by corner of a circle, we mean a corner of a box that contains the circle). Returned corners are in the top-level space; in order to do this, I provide the function with the angular and location delta of the current child.
|
||||
let rec corners da (dx, dy) (c:circle) =
|
||||
let rotate (x,y) =
|
||||
( x * cos da - y * sin da
|
||||
, x * sin da + y * cos da )
|
||||
let translate (x,y) = (x + dx, y + dy)
|
||||
let transform = rotate >> translate
|
||||
seq {
|
||||
// Transform the center and return its corners.
|
||||
let x, y = c.center |> transform
|
||||
yield (x + c.radius * 2.0, y + c.radius * 2.0)
|
||||
yield (x - c.radius * 2.0, y - c.radius * 2.0)
|
||||
// Recurse on the children, passing along the parent's delta angle and position.
|
||||
yield! c.children |> Seq.collect (fun (i,_,ch) -> corners (c.angle+da) (x, y) ch)
|
||||
}
|
||||
// Start the enumeration on the topmost circle, which has angle 0 and is centered on the origin.
|
||||
let corners = corners 0.0 (0.0, 0.0) c
|
||||
// Determine the corners of the box that contains all corners (this could be done more efficiently, but it's very unlikely to be a long enumeration anyway).
|
||||
let min_x = corners |> Seq.map fst |> Seq.min
|
||||
let max_x = corners |> Seq.map fst |> Seq.max
|
||||
let min_y = corners |> Seq.map snd |> Seq.min
|
||||
let max_y = corners |> Seq.map snd |> Seq.max
|
||||
// Determine the width and height of the box.
|
||||
let width = max_x - min_x
|
||||
let height = max_y - min_y
|
||||
// Translate the center of the topmost circle so that the entire figure is in positive coordinates. Add some padding, too.
|
||||
let cx, cy = c.center
|
||||
( { c with center = (cx - min_x + pad, cy - min_y + pad) }
|
||||
, width + 2.0*pad
|
||||
, height + 2.0*pad )
|
||||
|
||||
/// Size of an empty overhang, in site units (e.g. 0.2 means it's 20% the length of a regular domain).
|
||||
let overhang_to_hole = 0.2
|
||||
|
||||
/// Generates the SVG string for the given circle. The supplied style, scale, width and height are not used, but they are integrated in the resulting string.
|
||||
let circle_to_svg style scale (c:circle, width, height) =
|
||||
/// Generates the SVG class for the given domain (so that it can be styled), for a path element.
|
||||
let path_class (dom:svg_domain) = match dom with Hole -> "" | Domain dom | Xing dom -> if dom.toehold then sprintf "toe_%s" dom.name else ""
|
||||
/// Generates the SVG class for the given domain (so that it can be styled), for a text element.
|
||||
let label_class (dom:svg_domain) = match dom with Hole -> "" | Domain dom | Xing dom -> if dom.toehold then sprintf "toe_%s_text" dom.name else ""
|
||||
/// Converts a circle to SVG; note that this will be recursed over the circle's children. Parameters include the delta angle and position from the parent; these need to be applied to the circle's SVG elements.
|
||||
let rec convert da (dx,dy) (c:circle) =
|
||||
// Each site will get an equal portion of the circle.
|
||||
let n = c.ports.Length
|
||||
/// This is the size in radians of the arc for a site.
|
||||
let a = twopi / (float n)
|
||||
/// Rotates a point by the delta angle.
|
||||
let rotate (x,y) =
|
||||
( x * cos da - y * sin da
|
||||
, x * sin da + y * cos da )
|
||||
/// Translates a point by the delta position.
|
||||
let translate (x,y) = (x + dx, y + dy)
|
||||
/// Transforms a point by the delta angle and position; this brings it into the correct reference for rendering.
|
||||
let transform = rotate >> translate
|
||||
/// Transforms a site index into a position on the circle. Note that the size index may be fractional in this context (so we can get positions between sites).
|
||||
let pos i =
|
||||
let x, y = c.center
|
||||
let v = a * i + c.angle
|
||||
( x + c.radius*cos v
|
||||
, y + c.radius*sin v) |> transform
|
||||
/// Makes an arc between two positions on the circle, specified as site indexes (e.g. 0.5 indicates a point on the circle between the center of the first two sites). The domain passed as a parameter determines the CSS class of the arc.
|
||||
let rim v1 v2 b =
|
||||
let x1, y1 = v1 |> pos
|
||||
let x2, y2 = v2 |> pos
|
||||
let v = a * 0.5*(v1+v2) + c.angle + da
|
||||
let r = v * 360.0 / twopi
|
||||
sprintf "<path class=\"%s\" d=\"M %f,%f A %f,%f %f 0, 1 %f, %f\"/>" (path_class b) x1 y1 c.radius c.radius r x2 y2
|
||||
/// Draws the arc for a normal domain. It covers 0.5 site units to either side of the domain site.
|
||||
let arc i b = rim (float i - 0.5) (float i + 0.5) b
|
||||
/// Draws the label for a normal domain.
|
||||
let label i b =
|
||||
// Determine the position of the site on the circle.
|
||||
let x, y = i |> float |> pos
|
||||
// Determine the angular position of the site, in radians.
|
||||
let v = a * float i + c.angle + da
|
||||
// Determine the rotation of the text, in degrees (for SVG).
|
||||
let r = 90.0 + v * 360.0 / twopi
|
||||
// Output the text element. It is at the same position as the center of the site, except it's rotated by 90°.
|
||||
sprintf "<text class=\"%s\" x=\"%f\" y=\"%f\" transform=\"rotate(%f %f,%f)\" dy=\"-4\">%s</text>" (label_class b) x y r x y b.text
|
||||
/// Experimental: in a "degenerate" circle (one where all domains are either crossings or holes), hole terminators will get drawn along the crossing axis, rather than along the circle.
|
||||
let degenerate = not (circle_has_overhangs c.ports)
|
||||
let port_width = 4.0
|
||||
/// Generates the SVG string for a port.
|
||||
let port i prev b next =
|
||||
// The port can be a domain, a hole, or a crossing.
|
||||
match b with
|
||||
| Hole ->
|
||||
// Figure out where the neighboring overhangs start. If they were Xing type domains, then this hole needs to be wider. This can happen on either or both sides, or none.
|
||||
let overhang_dist_prev = match prev with Xing _ -> (1.0 - overhang_to_hole) | _ -> 0.5
|
||||
let overhang_dist_next = match next with Xing _ -> (1.0 - overhang_to_hole) | _ -> 0.5
|
||||
// This is a hole. It gets rendered as a perpendicular dash at the start of the next port, plus an arrow at the end of the previous port.
|
||||
let l = 3.0
|
||||
// Draw the arrow. Note that this needs to be styled as the _previous_ domain.
|
||||
// Determine the arrow's vector, expressed in radians. This can be determined as the angular position of the terminator on the circle. In the degenerate case, the angular position of the previous domain is used instead, plus a 90° rotation to make it point towards the center (this way, it points along the crossing's axis).
|
||||
let arrv = if degenerate then
|
||||
a * (float i - 1.0) + c.angle + da + 0.5*pi
|
||||
else
|
||||
a * (float i - overhang_dist_prev) + c.angle + da
|
||||
// Determine the arrow's placement. This is obtained by taking the angular position of the terminator on the circle, and using the 'pos' function to convert it to Cartesian. In the degenerate case, we use the angular position of the previous domain (plus the port width, converted to an angular distance).
|
||||
let arrx, arry = if degenerate then
|
||||
float i - 1.0 + (asin (port_width / c.radius) / a) |> pos
|
||||
else
|
||||
float i - overhang_dist_prev |> pos
|
||||
let arr1x, arr1y = arrx - l * cos arrv, arry - l * sin arrv
|
||||
let arr2x, arr2y = arrx + l * cos arrv, arry + l * sin arrv
|
||||
let arr3x, arr3y = arrx + 3.0 * l * cos (arrv + 0.5*pi), arry + 3.0 * l * sin (arrv + 0.5*pi)
|
||||
let arr = sprintf "<path class=\"%s\" d=\"M %f,%f L %f,%f L %f, %f z\"/>" (path_class prev) arr1x arr1y arr2x arr2y arr3x arr3y
|
||||
// Draw the dash. Note that this needs to be styled as the _next_ domain.
|
||||
// Determine the dash's vector, expressed in radians. This can be determined as the angular position of the terminator on the circle. In the degenerate case, the angular position of the next domain is used instead, plus a 90° rotation to make it point towards the center (this way, it points along the crossing's axis).
|
||||
let ev = if degenerate then
|
||||
a * (float i + 1.0) + c.angle + da - 0.5*pi
|
||||
else
|
||||
a * (float i + overhang_dist_next) + c.angle + da
|
||||
// Determine the dash's placement. This is obtained by taking the angular position of the terminator on the circle, and using the 'pos' function to convert it to Cartesian. In the degenerate case, we use the angular position of the next domain (minus the port width, converted to an angular distance).
|
||||
let ex,ey = if degenerate then
|
||||
float i + 1.0 - (asin (port_width / c.radius) / a) |> pos
|
||||
else
|
||||
float i + overhang_dist_next |> pos
|
||||
let e1x, e1y = ex - l * cos ev, ey - l * sin ev
|
||||
let e2x, e2y = ex + l * cos ev, ey + l * sin ev
|
||||
let e = sprintf "<path class=\"%s\" d=\"M %f,%f L %f,%f\"/>" (path_class next) e1x e1y e2x e2y
|
||||
// Output the SVG text combining both parts.
|
||||
sprintf "%s\n%s" arr e
|
||||
| Xing d ->
|
||||
// This is a crossing. It gets rendered as two parallel lines directed outwards from the circle, plus two arc segments to connect it to the rest of the circle. Note that, because both circles are going to draw this, there are going to be two overlapping paths for each side in the final SVG.
|
||||
let overhang_size_next = match next with Hole -> overhang_to_hole | _ -> 0.5
|
||||
let overhang_size_prev = match prev with Hole -> overhang_to_hole | _ -> 0.5
|
||||
// Figure out the positions of the attachment points of the straight lines. I'll need them in site index angular units for the arc function, and in Cartesian coordinates for the path statements.
|
||||
let dv = asin (port_width/ c.radius) / a
|
||||
let ax1, ay1 = float i - dv |> pos
|
||||
let ax2, ay2 = float i + dv |> pos
|
||||
let v = a * float i + c.angle + da
|
||||
// I'm extending the line a little bit in order to fake a miter join with the arc. The magic number here depends on the line thickness. A better solution would require rewriting this so that there is only one path declaration per side, instead of two.
|
||||
let side_length = 3.7 + xing_side_length b
|
||||
let bx1, by1 = ax1 + 0.5 * side_length * cos v, ay1 + 0.5 * side_length * sin v
|
||||
let bx2, by2 = ax2 + 0.5 * side_length * cos v, ay2 + 0.5 * side_length * sin v
|
||||
// Output the SVG text. Note that we are not adding the labels here. This is done further down, in the 'child' function.
|
||||
[ rim (float i - overhang_size_prev) (float i - dv) b
|
||||
; rim (float i + dv) (float i + overhang_size_next) b
|
||||
; sprintf "<path class=\"%s\" d=\"M %f,%f L %f,%f\"/>" (path_class b) ax1 ay1 bx1 by1
|
||||
; sprintf "<path class=\"%s\" d=\"M %f,%f L %f,%f\"/>" (path_class b) ax2 ay2 bx2 by2 ]
|
||||
|> String.concat "\n"
|
||||
| b ->
|
||||
// This is a domain. It gets rendered as an arc.
|
||||
sprintf "%s\n%s" (arc i b) (label i b)
|
||||
/// Gathers all renderings of sites on the circle as SVG strings. Note that I am retrieving the previous and next port at each step; the changes I made to the renderer need knowledge of neighbors for some types of ports.
|
||||
let port_str = c.ports |> Array.mapi (fun i dom ->
|
||||
let prev = c.ports.[if i = 0 then c.ports.Length-1 else i-1]
|
||||
let next = c.ports.[if i = c.ports.Length-1 then 0 else i+1]
|
||||
port i prev dom next)
|
||||
/// This function draws a straight edge between two sites. I don't know in which cases this is supposed to happen, if any.
|
||||
let edge (i, j) =
|
||||
let x1, y1 = i |> float |> pos
|
||||
let x2, y2 = j |> float |> pos
|
||||
sprintf "<path class=\"circle_edge\" d=\"M %f,%f L %f,%f\"/>" x1 y1 x2 y2
|
||||
/// This would render any remaining circle edges (as straight lines) and gather them in a set of SVG strings, but from what I understand there should never be any circle edges at this stage. I couldn't find any case where this would happen.
|
||||
let edges_str = c.edges |> Array.map edge
|
||||
/// This function renders a child circle recursively. It requires the position (in site index units) of the attachment point, the domain that connects the circles, and the child circle itself. Note that at this stage the child circle is already centered at the correct distance from the origin (i.e. the parent).
|
||||
let child (i, b:svg_domain, ch) =
|
||||
/// The Cartesian coordinates of the attachment point position.
|
||||
let x, y = i |> float |> pos
|
||||
/// The angle of the attachment point position, in radians.
|
||||
let v = a * float i + c.angle + da
|
||||
/// The rotation of the label text, in degrees.
|
||||
let r = v * 360.0 / twopi
|
||||
let dx = xing_side_length b / 4.0
|
||||
// Add the labels for the connecting domain, then add the recursively generated circle (giving it the angular and Cartesian deltas required to transform it back into top-level space).
|
||||
[ sprintf "<text class=\"%s\" x=\"%f\" y=\"%f\" transform=\"rotate(%f %f,%f)\" dx=\"%f\" dy=\"-8\">%s</text>" (label_class b) x y r x y dx b.text
|
||||
; sprintf "<text class=\"%s\" x=\"%f\" y=\"%f\" transform=\"rotate(%f %f,%f)\" dx=\"-%f\" dy=\"-8\">%s</text>" (label_class b) x y (r+180.0) x y dx b.compl.text
|
||||
; convert (c.angle + da) (transform c.center) ch ]
|
||||
|> String.concat "\n"
|
||||
let children_str = c.children |> List.map child |> Array.ofList
|
||||
[| port_str; edges_str; children_str |] |> Array.concat |> String.concat "\n"
|
||||
// Recursively convert the circle, bracket it with an SVG element, add style, scale and size.
|
||||
c |> convert 0.0 (0.0, 0.0) |> sprintf "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"%f\" height=\"%f\">\n%s\n<g transform=\"scale(%f)\">\n%s\n</g>\n</svg>" (width*scale) (height*scale) style scale
|
||||
|
||||
|
||||
|
||||
// The following functions are used to convert a strand graph object into the initial circle.
|
||||
|
||||
/// Converts the edges to their representation in a global sequence made by arranging all strands one after the other. In this representation, an edge is an int couple where each int is the index of a site in the global sequence, and the two sites match. Returned edges are reverse-ordered by the position of their lowest-index site (e.g. [(9,12),(5,8),(1,4)]).
|
||||
let get_edges (S:Strands.strand[]) (E:Set<edge>) =
|
||||
/// The offsets array. This maps each strand (by index) to its starting position in a sequence of all sites, plus holes between strands (e.g. if S contains three strands, respectively made of 2, 3 and 2 sites, then the offsets array is [0,3,7]).
|
||||
let offsets = Array.init S.Length (fun i -> if i = 0 then 0 else i + (S.[0..i-1] |> Array.map(fun s -> s.Length) |> Array.sum))
|
||||
//S
|
||||
//|> Seq.fold (fun (n,l) st -> (n+1, (n,1+st.Length)::l)) (1,[0,0])
|
||||
//|> snd
|
||||
//|> Map.ofSeq
|
||||
/// Maps a port (i.e. an int*int where the first item is the strand index and the second is the site index within the strand) to a port in the global sequence (i.e. an int).
|
||||
let port_map (a,b) = offsets.[a] + b
|
||||
/// Maps an edge (i.e. a couple of ports) to an edge in the global sequence (i.e. two ints that are the indexes of two matching sites in the global sequence).
|
||||
let edge_map (a,b) = port_map a, port_map b
|
||||
|
||||
E
|
||||
|> Set.toArray
|
||||
|> Array.map(fun (p,p') -> (p.strand, p.site), (p'.strand, p'.site))
|
||||
|> Seq.map edge_map
|
||||
// I now have the edges as represented in the global sequence.
|
||||
|> Seq.map sort_e
|
||||
|> Seq.toArray
|
||||
// I now have the edges in the global sequence, normalized so that the lowest index site is always first.
|
||||
// I will reverse sort them on the first site.
|
||||
|> Array.sortWith (fun (a1,b1) (a2,b2) -> a2-a1) //ensure right-neighbours are taken first
|
||||
|
||||
/// Reorders the set of strands (with corresponding edges) according to the order supplied (the input order array must be a permutation of 0..S.Length-1). Returns the reordered set of strands, and the edges as represented in the global sequence.
|
||||
let reorderBy (order:int[]) (S:Strands.strand[]) (E:Set<edge>) =
|
||||
/// The order is a map from a strand's index in the old array, to the strand's index in the new array.
|
||||
/// The strands array, reordered according to the specified order.
|
||||
let S' = Array.zeroCreate S.Length
|
||||
Array.iteri (fun i v -> Array.set S' v S.[i]) order
|
||||
//let S' = [|0..S.Length-1|] |> Array.map(fun i -> S.[order.[i]])
|
||||
/// The edges, changed so that they refer to the correct strands in the reordered strands array.
|
||||
let E' =
|
||||
E
|
||||
|> Set.map(fun (p,p') ->
|
||||
{p with site = p.site; strand = order.[p.strand]},
|
||||
{p' with site = p'.site; strand = order.[p'.strand]})
|
||||
S', get_edges S' E'
|
||||
|
||||
/// Returns a permutation of the strands array that avoids pseudoknots. Returns the reordered set of strands, and the edges as represented in the global sequence.
|
||||
let find_perm (S:Strands.strand[]) (E:Set<edge>) =
|
||||
|
||||
/// Takes an element and a list. Returns the set of all lists generated by inserting that element at each possible position within the list.
|
||||
let distrib e L =
|
||||
let rec aux pre post =
|
||||
seq {
|
||||
match post with
|
||||
| [] -> yield (L @ [e])
|
||||
| h::t -> yield (List.rev pre @ [e] @ post)
|
||||
yield! aux (h::pre) t
|
||||
}
|
||||
aux [] L
|
||||
|
||||
/// Takes a list of objects, returns a set of lists that are all possible permutations of the original list.
|
||||
let rec perms = function
|
||||
| [] -> Seq.singleton []
|
||||
| h::t -> Seq.collect (distrib h) (perms t)
|
||||
|
||||
/// Returns true if the edges would cross. We call this situation a pseudoknot. Pseudoknots cannot be rendered by this algorithm.
|
||||
let pseudoknot (e1,e1') (e2, e2') =
|
||||
(e1>e2 && e1<e2' && (e1'>e2'||e1'<e2)) ||
|
||||
(e1'>e2 && e1'<e2' && (e1>e2'||e1<e2))
|
||||
|
||||
/// Get all possible reorderings of the strands after the first (the first always remains the first).
|
||||
[1..S.Length-1]
|
||||
|> perms
|
||||
|> Seq.map(fun l -> 0::l |> List.toArray)
|
||||
|> Seq.map(fun order -> reorderBy order S E)
|
||||
// Now I have the set of all possible ways to reorder the strands; for each of these orderings, I also have the set of edges, expressed as couples of ints where each int is the index of a site in the sequence formed by arranging the strands one after the other in the specified order. I search this set for an ordering that has no pseudoknots.
|
||||
|> Seq.tryFind(fun (_, E') ->
|
||||
E'|> Seq.forall (fun e ->
|
||||
E' |> Seq.forall(fun e' -> not (pseudoknot e e' || pseudoknot e' e))))
|
||||
|
||||
/// Converts a species in an uncollapsed circle representation. Requires the strands and the species (only the strand graph of the species is actually used).
|
||||
let to_circle (strands:Strands.t) (rep:rep) =
|
||||
let rep = match rep with Rep rep -> rep
|
||||
let s = rep.sg
|
||||
/// The strands and edges, rearranged so that there are no pseudoknots (if possible). The edges will be remapped so that their sites are indexes in the global sequence (all the strands one after the other, with holes between strands).
|
||||
let S, E =
|
||||
let SS = s.strands |> Array.map(fun i -> strands.strand_types.[i])
|
||||
let EE = s.edges
|
||||
match find_perm SS EE with
|
||||
| Some (a,b) -> a,b
|
||||
| None -> failwith "Cannot visualize pseudoknot"
|
||||
|
||||
/// The global sequence. This is a sequence of sites (in the form of svg_domain objects) which corresponds to all the strands aligned one after the other, in the order determined above. A 'hole' domain is inserted after each strand, making the total length of the sequence equal to the sum of all domains, plus number of strands.
|
||||
let ports =
|
||||
S
|
||||
|> Array.fold (fun acc st ->
|
||||
let d =
|
||||
st
|
||||
|> Array.map (fun d -> Domain d)
|
||||
|> List.ofArray
|
||||
|> List.rev
|
||||
Hole::d@acc) List.empty
|
||||
|> List.rev
|
||||
|> List.toArray
|
||||
|
||||
// Returns the circle made of all the domains in all the strands in the given species. This circle will then require collapsing.
|
||||
{ center = (0.0, 0.0)
|
||||
; angle = 0.0
|
||||
; radius = ports |> circle_radius
|
||||
; ports = ports
|
||||
; children = []
|
||||
; edges = E
|
||||
}
|
||||
|
||||
let to_circle_svg assigned strands = to_circle strands >> collapse_circle >> into_view >> circle_to_svg (svg_style assigned strands) 1.0
|
||||
let to_scaled_circle_svg assigned scale strands = to_circle strands >> collapse_circle >> into_view >> circle_to_svg (svg_style assigned strands) scale
|
||||
//let export_circle_svg filename = to_circle >> collapse_circle >> into_view >> circle_to_svg 1.0 >> (fun svg -> System.IO.File.WriteAllText (filename, svg))
|
|
@ -0,0 +1,213 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.ExtendedSyntax
|
||||
open Parser
|
||||
|
||||
type 'site strand = 'site list
|
||||
|
||||
(* Syntax *)
|
||||
type 'site hpl =
|
||||
{ loop : 'site strand
|
||||
; middle : 'site strand
|
||||
; upper_right : 'site strand
|
||||
; lower_right : 'site strand }
|
||||
|
||||
type 'site m =
|
||||
{ upper_left : 'site strand
|
||||
; lower_left : 'site strand
|
||||
; middle : 'site strand
|
||||
; upper_right : 'site strand
|
||||
; lower_right : 'site strand }
|
||||
|
||||
type 'site hpr =
|
||||
{ loop : 'site strand
|
||||
; middle : 'site strand
|
||||
; upper_left : 'site strand
|
||||
; lower_left : 'site strand }
|
||||
|
||||
type 'site segment =
|
||||
| HairpinLeft of 'site hpl
|
||||
| Middle of 'site m
|
||||
| HairpinRight of 'site hpr
|
||||
|
||||
type 'site gate =
|
||||
| Singleton of 'site segment
|
||||
| JoinLower of 'site gate * 'site gate
|
||||
| JoinUpper of 'site gate * 'site gate
|
||||
|
||||
type 'site species =
|
||||
| Strand of 'site strand
|
||||
| Gate of 'site gate
|
||||
|
||||
type 'site complex = int * 'site species list
|
||||
|
||||
type 'site t = Syntax.toehold list * 'site complex list
|
||||
|
||||
(* Conversion *)
|
||||
let binding_counter = ref 0
|
||||
let fresh_number () =
|
||||
let r = !binding_counter
|
||||
binding_counter := !binding_counter + 1
|
||||
r
|
||||
let fresh_binding = fresh_number >> sprintf "!%d" (* this cannot be generated by user *)
|
||||
|
||||
let melt_double s =
|
||||
let complement_domain (d: Strands.domain) =
|
||||
{ Strands.name = d.name
|
||||
; Strands.complemented = d.complemented |> not
|
||||
; Strands.toehold = d.toehold }
|
||||
let complement (site: Syntax.site) =
|
||||
{ Syntax.domain = site.domain |> complement_domain
|
||||
; Syntax.binding = site.binding }
|
||||
let freshen_binding (site: Syntax.site) =
|
||||
{ Syntax.domain = site.domain
|
||||
; Syntax.binding = fresh_binding () |> Some }
|
||||
let s = s |> List.map freshen_binding
|
||||
s, s |> List.map complement |> List.rev
|
||||
|
||||
type view =
|
||||
| One of Syntax.strand
|
||||
| Two of Syntax.strand * Syntax.strand
|
||||
|
||||
let melt_view = function
|
||||
| One s -> [s]
|
||||
| Two (u,l) -> [u; l]
|
||||
|
||||
let view_segment = function
|
||||
| HairpinLeft hpl ->
|
||||
let upper, lower = melt_double hpl.middle
|
||||
let u = [hpl.lower_right |> List.rev; lower |> List.rev; hpl.loop; upper; hpl.upper_right] |> List.concat
|
||||
One u
|
||||
| Middle m ->
|
||||
let upper, lower = melt_double m.middle
|
||||
let u = [m.upper_left; upper; m.upper_right] |> List.concat
|
||||
let l = [m.lower_right |> List.rev; lower; m.lower_left |> List.rev] |> List.concat
|
||||
Two (u, l)
|
||||
| HairpinRight hpr ->
|
||||
let upper, lower = melt_double hpr.middle
|
||||
let u = [hpr.upper_left; upper; hpr.loop |> List.rev; lower; hpr.lower_left |> List.rev] |> List.concat
|
||||
One u
|
||||
|
||||
let rec view = function
|
||||
| Singleton s -> view_segment s, []
|
||||
| JoinLower (l, r) ->
|
||||
match view l, view r with
|
||||
| (One s1, _), (One s2, _) -> failwith "Circular DNA not yet supported"
|
||||
| (One s, al), (Two (u, l), ar) -> Two (u, l @ s), al@ar
|
||||
| (Two (u, l), al), (One s, ar) -> One (s @ l), u::al@ar
|
||||
| (Two (u1, l1), al), (Two (u2, l2), ar) -> Two (u2, l2 @ l1), u1::al@ar
|
||||
| JoinUpper (l, r) ->
|
||||
match view l, view r with
|
||||
| (One s1, _), (One s2, _) -> failwith "Circular DNA not yet supported"
|
||||
| (One s, al), (Two (u, l), ar) -> Two (s @ u, l), al@ar
|
||||
| (Two (u, l), al), (One s, ar) -> One (u @ s), l::al@ar
|
||||
| (Two (u1, l1), al), (Two (u2, l2), ar) -> Two (u1 @ u2, l2), l1::al@ar
|
||||
|
||||
let melt g =
|
||||
let v, s = view g
|
||||
s @ melt_view v
|
||||
|
||||
let to_basic_species = function
|
||||
| Strand c -> [c]
|
||||
| Gate g -> g |> melt
|
||||
|
||||
let to_basic_complexes = (fun (i, s) -> (i, List.collect to_basic_species s)) |> List.map
|
||||
let to_basic ((ts,cs): Syntax.site t) = (ts, to_basic_complexes cs) : Syntax.t
|
||||
|
||||
(* Parsing *)
|
||||
let mk_hpl loop m (u, l) =
|
||||
{ loop = loop
|
||||
; middle = m
|
||||
; upper_right = u
|
||||
; lower_right = l }
|
||||
|> HairpinLeft |> Singleton
|
||||
|
||||
let mk_m (ul, ll) m (ur, lr) =
|
||||
{ upper_left = ul
|
||||
; lower_left = ll
|
||||
; middle = m
|
||||
; upper_right = ur
|
||||
; lower_right = lr }
|
||||
|> Middle |> Singleton
|
||||
|
||||
let mk_hpr (u, l) m loop =
|
||||
{ loop = loop
|
||||
; middle = m
|
||||
; upper_left = u
|
||||
; lower_left = l }
|
||||
|> HairpinRight |> Singleton
|
||||
|
||||
let alternatives l =
|
||||
match l |> List.map Parser.pTry |> List.rev with
|
||||
| [] -> choice []
|
||||
| h::t ->
|
||||
h :: (t |> List.map attempt) |> List.rev |> choice
|
||||
|
||||
let strand_gate site =
|
||||
let sites = sepBy1 site spaces1
|
||||
|
||||
let upper = sites |> Syntax.bracket "<" ">"
|
||||
let lower = sites |> Syntax.bracket "{" "}"
|
||||
let double = sites |> Syntax.bracket "[" "]"
|
||||
let left_hp = sites |> Syntax.bracket "<" "}"
|
||||
let right_hp = sites |> Syntax.bracket "{" ">"
|
||||
|
||||
let overhangs =
|
||||
alternatives
|
||||
[ upper .>>. lower
|
||||
; lower .>>. upper |>> fun (b, a) -> (a, b)
|
||||
; upper |>> fun a -> (a, [])
|
||||
; lower |>> fun b -> ([], b)
|
||||
; skipString "" |>> fun () -> ([], []) ]
|
||||
|
||||
let hpl = pipe3 left_hp double overhangs mk_hpl
|
||||
let m = pipe3 overhangs double overhangs mk_m
|
||||
let hpr = pipe3 overhangs double right_hp mk_hpr
|
||||
let segment = alternatives [hpl; m; hpr]
|
||||
|
||||
let connect_upper = Syntax.kw "::" |>> fun _ l r -> JoinUpper (l, r)
|
||||
let connect_lower = Syntax.kw ":" |>> fun _ l r -> JoinLower (l, r)
|
||||
let connect = attempt connect_upper <|> connect_lower
|
||||
let gate = chainl1 segment connect |>> Gate
|
||||
|
||||
let strand = upper <|> (lower |>> List.rev) |>> Strand
|
||||
|
||||
strand, gate
|
||||
|
||||
let parse_species site =
|
||||
let strand, gate = strand_gate site
|
||||
attempt gate <|> strand
|
||||
|
||||
let parse_syntax site =
|
||||
let strand, gate = strand_gate site
|
||||
|
||||
let strands = (attempt gate <|> strand) |> Syntax.sep_by_bars
|
||||
|
||||
let complex = strands |> Syntax.bracket "[" "]" |> Syntax.counted
|
||||
let complexes = complex |> Syntax.sep_by_bars
|
||||
|
||||
let species = attempt (strands |>> fun s -> [(1,s)]) <|> complexes
|
||||
|
||||
spaces >>. sepEndBy Syntax.parse_toehold spaces1 .>>. species .>> spaces .>> eof
|
||||
|
||||
let parser = Syntax.parse_name |> Syntax.parse_site |> parse_syntax
|
||||
let parse = parser |> Syntax.run_parser
|
||||
|
||||
let parse_basic = parse >> to_basic
|
||||
|
||||
let enzyme name =
|
||||
let domain = Syntax.parse_domain name
|
||||
let domains = sepBy1 domain spaces1 |>> Array.ofList
|
||||
let pair = domains .>>. (Syntax.kw "," >>. domains) |> Syntax.bracket "(" ")"
|
||||
Syntax.kw "nick" >>. pair
|
||||
|
||||
let parser_enzymes =
|
||||
let es = sepEndBy (enzyme Syntax.parse_name) (Syntax.kw ";") |> Syntax.bracket "[" "]"
|
||||
let enzymes = (Syntax.kw "enzymes" >>. es) |> opt |>> function Some es -> es | None -> []
|
||||
let basic = Syntax.parse_name |> Syntax.parse_site |> parse_syntax |>> to_basic
|
||||
spaces >>. enzymes .>>. basic
|
||||
|
||||
let parse_enzymes = parser_enzymes |> Syntax.run_parser
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.ReactionGraph
|
||||
|
||||
let reaction_graph limit (c: 's Calculus.t) =
|
||||
let positivite_propensity (r: 's Calculus.reaction) = r.rate > 0.0
|
||||
let rec work rs all_ss l =
|
||||
match l with
|
||||
| [] -> all_ss, rs
|
||||
| w::ws ->
|
||||
if limit > 0 && (Set.count all_ss > limit) then (w::ws |> Set.ofList |> Set.union all_ss), rs else
|
||||
printfn "Species: %d" (Set.count all_ss)
|
||||
let new_rs = c.reactions all_ss w - rs |> Set.filter positivite_propensity
|
||||
let is_new s = not <| Set.contains s all_ss
|
||||
let new_ss = new_rs |> Seq.collect (fun r -> r.products) |> Seq.distinct |> Seq.filter is_new |> Seq.toList
|
||||
work (Set.union new_rs rs) (Set.add w all_ss) (ws @ new_ss)
|
||||
work Set.empty Set.empty c.initial_species
|
||||
|
||||
#if JavaScript
|
||||
#else
|
||||
let reaction_graph_to_svgdot out_dir limit species_to_svg (c: 's Calculus.t) =
|
||||
let all_ss, rs = reaction_graph limit c
|
||||
let init_ss = c.initial_species |> Set.ofList
|
||||
let sname = sprintf "species%d"
|
||||
let r_att = "[penwidth=2.0,dir=none]"
|
||||
let style = ""
|
||||
let init_style = ",penwidth=\"3.0\""
|
||||
let sid s = Seq.findIndex ((=) s) all_ss |> sname
|
||||
let rr (r: 's Calculus.reaction) = r.rate
|
||||
let r_to_n rid r = sprintf "r%d [label=\"%.3f\"];" rid (rr r)
|
||||
let r_to_e rid (r: 's Calculus.reaction) =
|
||||
let react_str =
|
||||
r.reactants
|
||||
|> List.map sid
|
||||
|> String.concat " "
|
||||
|> sprintf "{%s}"
|
||||
let prod_str =
|
||||
r.products
|
||||
|> List.map sid
|
||||
|> String.concat " "
|
||||
|> sprintf "{%s}"
|
||||
[ sprintf "%s -> r%d%s" react_str rid r_att
|
||||
; sprintf "r%d -> %s[arrowhead=onormal]" rid prod_str]
|
||||
let export_species i s =
|
||||
let out_file = System.IO.Path.Combine(out_dir, (sprintf "%s.svg" (sname i)))
|
||||
System.IO.File.WriteAllText (out_file, species_to_svg s)
|
||||
all_ss |> Seq.iteri export_species
|
||||
( all_ss
|
||||
, rs
|
||||
, seq {
|
||||
yield "digraph reaction_graph {"
|
||||
yield! all_ss |> Seq.mapi (fun i s -> sprintf "%s [image=\"%s.png\",label=\"\",shape=\"box\",style=\"rounded\"%s];" (sname i) (sname i) (if Set.contains s init_ss then init_style else style))
|
||||
yield "node [shape=box];"
|
||||
yield! rs |> Seq.mapi r_to_n
|
||||
yield! rs |> Seq.mapi r_to_e |> Seq.concat
|
||||
yield "}"
|
||||
} |> String.concat "\n" )
|
||||
#endif
|
||||
|
|
@ -0,0 +1,508 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.Reactions
|
||||
|
||||
type edge = Species.edge
|
||||
type nick = Strands.domain * Strands.domain
|
||||
|
||||
type rep_perm = Species.rep * Map<int,int>
|
||||
|
||||
type t =
|
||||
| Isolated_toehold of Species.rep * edge * rep_perm list
|
||||
| Complement_int of Species.rep * edge * rep_perm
|
||||
| Complement_ext of Species.rep * Species.rep * edge * rep_perm
|
||||
| Displacing of Species.rep * edge list * rep_perm list
|
||||
| Nick of Species.rep * Strands.port * rep_perm
|
||||
|
||||
let reactants = function
|
||||
| Isolated_toehold (p,_,_) -> [p]
|
||||
| Complement_int (p,_,_) -> [p]
|
||||
| Complement_ext (p1,p2,_,_) -> [p1;p2]
|
||||
| Displacing (p,_,_) -> [p]
|
||||
| Nick (p,_,_) -> [p]
|
||||
|
||||
let products = function
|
||||
| Isolated_toehold (_,_,ps) -> ps
|
||||
| Complement_int (_,_,p) -> [p]
|
||||
| Complement_ext (_,_,_,p) -> [p]
|
||||
| Displacing (_,_,ps) -> ps
|
||||
| Nick (_,_,p) -> [p]
|
||||
|
||||
let is_binding_edge strands sg (np1:Strands.port, np2:Strands.port) =
|
||||
Species.is_legal_edge strands sg (np1, np2) &&
|
||||
sg.edges |> Set.contains (np1, np2)
|
||||
|
||||
let left_neighbour (p1:Strands.port, p2:Strands.port) =
|
||||
({Strands.port.strand=p1.strand; Strands.port.site=p1.site-1},
|
||||
{Strands.port.strand=p2.strand; Strands.port.site=p2.site+1})
|
||||
let right_neighbour (port1:Strands.port, port2:Strands.port) =
|
||||
({Strands.port.strand=port1.strand; Strands.port.site=port1.site+1},
|
||||
{Strands.port.strand=port2.strand; Strands.port.site=port2.site-1})
|
||||
|
||||
let adjacent_left strands sg e =
|
||||
e |> left_neighbour |> is_binding_edge strands sg
|
||||
|
||||
let adjacent_right strands sg e =
|
||||
e |> right_neighbour |> Species.normalize_edge |> is_binding_edge strands sg // normalize is needed if n1=n2 and p2=p1+1
|
||||
|
||||
let has_adjacent strands sg e = adjacent_left strands sg e || adjacent_right strands sg e
|
||||
let isolated strands sg e = has_adjacent strands sg e |> not
|
||||
|
||||
let is_toehold_edge (strands:Strands.t) (sg:Species.strand_graph) (p1:Strands.port, p2:Strands.port) =
|
||||
strands.admissible_edges |> Map.find (Species.normalize_edge ({Strands.port.strand=sg.strands.[p1.strand]; Strands.port.site=p1.site}, {Strands.port.strand=sg.strands.[p2.strand]; Strands.port.site=p2.site}) |> fun edge -> {Strands.port_pair.port1=fst edge;Strands.port_pair.port2=snd edge})
|
||||
|
||||
let isolated_toehold strands sg e = is_toehold_edge strands sg e && isolated strands sg e
|
||||
|
||||
let aproximal_toehold strands (s:Species.t) e = is_toehold_edge strands s.sg e && (Set.contains e s.proximal |> not)
|
||||
|
||||
let in_hairpin (sg:Species.strand_graph) (n,p) =
|
||||
sg.edges |> Set.filter (fun (p1, p2) -> p1.strand = n && p1.site < p && p2.strand = n && p < p2.site) |> Set.isEmpty |> not
|
||||
|
||||
let in_bulge (sg:Species.strand_graph) (n,p) =
|
||||
sg.edges |> Set.toSeq |> Seq.choose (fun ((p1:Strands.port), (p2:Strands.port)) -> if p1.strand = n && p1.site < p then Some p2
|
||||
elif p2.strand = n && p2.site < p then Some p1
|
||||
else None)
|
||||
|> Seq.filter (fun port -> sg.edges |> Set.exists (fun (port1a,port2a) -> (port.strand = port1a.strand && n = port2a.strand && p < port2a.site && port2a.site < port.site) || (port.strand = port2a.strand && n = port2a.strand && p < port1a.site && port2a.site < port.site)))
|
||||
|> Seq.isEmpty |> not
|
||||
|
||||
let hidden sg np = in_hairpin sg np || in_bulge sg np
|
||||
|
||||
// Toeholds unbinding
|
||||
let isolated_toehold_bindings strands sg = Set.filter (isolated_toehold strands sg) sg.edges
|
||||
let aproximal_toehold_bindings strands s = Set.filter (aproximal_toehold strands s) s.sg.edges
|
||||
let isolated_toehold_unbinding_actions strands (Species.Rep s as r) =
|
||||
let build (e:edge) = (r, e, Species.break_bond strands s.sg e) |> Isolated_toehold
|
||||
aproximal_toehold_bindings strands s |> Set.map build |> Set.toSeq
|
||||
|
||||
let complementary_unbounds strands (s:Species.t) =
|
||||
let edge_free (p1, p2) = not (Set.contains p1 s.bound_ports || Set.contains p2 s.bound_ports)
|
||||
s.admissible_bindings |> Set.filter edge_free
|
||||
|
||||
let complementary_binding_actions strands (Species.Rep s as r) =
|
||||
let act e =
|
||||
{ s.sg with Species.edges = Set.add e s.sg.edges } |> Species.rep strands
|
||||
let build e = (r, e, act e) |> Complement_int
|
||||
complementary_unbounds strands s |> Set.map build |> Set.toSeq
|
||||
|
||||
// Bindings across species
|
||||
let admissible_cross_bindings (strands:Strands.t) (sg1:Species.strand_graph) (sg2:Species.strand_graph) =
|
||||
let possible_bindings a b =
|
||||
let ta = sg1.strands.[a]
|
||||
let tb = sg2.strands.[b]
|
||||
let choose_edge (pair : Strands.port_pair) =
|
||||
let t1, p1_, t2, p2_ = if tb < ta then pair.port2.strand, pair.port2.site, pair.port1.strand, pair.port1.site else pair.port1.strand, pair.port1.site, pair.port2.strand, pair.port2.site
|
||||
if ta=t1 && tb=t2 then Some {Strands.port_pair.port1={Strands.port.strand=a;Strands.port.site=p1_}; Strands.port_pair.port2={Strands.port.strand=b;Strands.port.site=p2_}} else None
|
||||
strands.admissible_edges |> Map.toSeq |> Seq.choose (fst >> choose_edge) |> Set.ofSeq
|
||||
seq {
|
||||
for i in 0..sg1.strands.Length-1 do
|
||||
for j in 0..sg2.strands.Length-1 do
|
||||
yield possible_bindings i j
|
||||
} |> Set.unionMany
|
||||
|
||||
let complementary_cross_unbounds strands (s1:Species.t) (s2:Species.t) =
|
||||
let edge_free (pair:Strands.port_pair) = not (Set.contains pair.port1 s1.bound_ports || Set.contains pair.port2 s2.bound_ports)
|
||||
admissible_cross_bindings strands s1.sg s2.sg |> Set.filter edge_free |> Set.map (fun pair -> pair.port1, pair.port2)
|
||||
|
||||
let complementary_cross_binding_actions strands (Species.Rep s1 as r1) (Species.Rep s2 as r2) =
|
||||
let edge_to_pair (edge:edge) = {Strands.port_pair.port1=fst edge; Strands.port_pair.port2=snd edge}
|
||||
let build (edge:edge) = (r1, r2, edge, Species.form_bond strands s1.sg s2.sg edge) |> Complement_ext
|
||||
complementary_cross_unbounds strands s1 s2 |> Set.map build |> Set.toSeq
|
||||
|
||||
type path = Strands.port * edge list * Strands.port
|
||||
|
||||
let do_all f es m = Seq.fold f m es
|
||||
|
||||
// Displacing actions
|
||||
let displacing_paths strands (s:Species.t) =
|
||||
(*let can_be_added = s.proximal - s.sg.edges*)
|
||||
let one_free (p1, p2) = (Set.contains p1 s.bound_ports && Set.contains p2 s.bound_ports) |> not
|
||||
let can_be_added = s.proximal - s.sg.edges |> Set.filter (fun e -> one_free e || has_adjacent strands s.sg e)
|
||||
let can_be_removed = s.sg.edges
|
||||
|
||||
// Extension: loops can be closed by unanchored edges
|
||||
let can_close_loops = s.admissible_bindings - can_be_added
|
||||
|
||||
// build map from ports to paths from this port
|
||||
// invariant is that active paths have edges from can_be_removed at both ends
|
||||
// start from can_be_removed
|
||||
let add_path (np:Strands.port) (p:edge list * Strands.port) m =
|
||||
match Map.tryFind np m with
|
||||
| None -> Map.add np [p] m
|
||||
| Some paths -> Map.add np (p::paths) m
|
||||
|
||||
let add_rem m ((np1, np2) as e) =
|
||||
m |> add_path np1 ([e], np2)
|
||||
|> add_path np2 ([e], np1)
|
||||
|
||||
let m = can_be_removed |> Seq.fold add_rem Map.empty
|
||||
|
||||
// to be applied to completed paths in order to achieve vectorised semantics
|
||||
// TODO: flip edges to direction of path rather than normalised direction
|
||||
|
||||
// returns None if there is no neighbouring displacing path
|
||||
let admits_adding = s.admissible_bindings - s.sg.edges
|
||||
let fatten_once nb (sp, path:Species.edge list) =
|
||||
let nsp = (sp,sp) |> nb |> fst
|
||||
let rec loop to_add acc p = function
|
||||
| [] ->
|
||||
if not <| Set.contains p s.bound_ports then
|
||||
Some (nsp, acc)
|
||||
else None // could try to extend the path here
|
||||
| (pa,pb)::es ->
|
||||
let e, np =
|
||||
let flip = (p = pb) <> to_add
|
||||
if flip then (pb,pa), pa
|
||||
else (pa,pb), pb
|
||||
let n = nb e |> Species.normalize_edge
|
||||
if to_add && Set.contains n admits_adding then
|
||||
loop false (n::acc) np es
|
||||
elif (not to_add) && Set.contains n can_be_removed then
|
||||
loop true (n::acc) np es
|
||||
elif (not to_add) && acc <> [] && (not <| Set.contains p s.bound_ports) then
|
||||
Some (nsp, acc)
|
||||
else None
|
||||
loop false [] sp path
|
||||
|
||||
let fatten_up fo path =
|
||||
let rec loop acc (sp: Strands.port, p: Species.edge list) =
|
||||
match fo (sp, p) with
|
||||
| None -> acc
|
||||
| Some (np,es) -> loop (es::acc) (np,es)
|
||||
loop [] path
|
||||
|
||||
let fatten sp path =
|
||||
let left_fat = fatten_up (fatten_once left_neighbour) (sp, path)
|
||||
let right_fat = fatten_up (fatten_once right_neighbour) (sp, path)
|
||||
path::left_fat@right_fat |> List.concat // all edges are inverted when the reaction is enacted
|
||||
|
||||
let fatten_loop_once nb (sp, path:Species.edge list) =
|
||||
let nsp = (sp,sp) |> nb |> fst
|
||||
let rec loop to_add acc p = function
|
||||
| [] -> Some (nsp, acc)
|
||||
| (pa,pb)::es ->
|
||||
let e, np =
|
||||
if p = pa then (pa,pb), pb
|
||||
else (pb,pa), pa
|
||||
let n = nb e
|
||||
if to_add && Set.contains n admits_adding then
|
||||
loop false (n::acc) np es
|
||||
elif (not to_add) && Set.contains n can_be_removed then
|
||||
loop true (n::acc) np es
|
||||
else None
|
||||
loop false [] sp path
|
||||
|
||||
let fatten_loop sp path =
|
||||
let left_fat = fatten_up (fatten_loop_once left_neighbour) (sp, path)
|
||||
let right_fat = fatten_up (fatten_loop_once right_neighbour) (sp, path)
|
||||
path::left_fat@right_fat |> List.concat // all edges are inverted when the reaction is enacted
|
||||
|
||||
let add_edge (paths, m) ((np1, np2) as e) =
|
||||
match Map.tryFind np1 m, Map.tryFind np2 m with
|
||||
| None, None -> (paths, m)
|
||||
| None, Some ps2 -> // paths can be terminated at np1
|
||||
let ps = ps2 |> List.map (fun (es, ep) -> e::es |> List.rev |> fatten ep)
|
||||
(ps@paths, m)
|
||||
| Some ps1, None -> // paths can be terminated at np2
|
||||
let ps = ps1 |> List.map (fun (es, ep) -> e::es |> List.rev |> fatten ep)
|
||||
(ps@paths, m)
|
||||
| Some ps1, Some ps2 -> // paths should be merged, check for loops
|
||||
let split_loops sp = List.partition (fun (_:edge list,ep) -> e = Species.normalize_edge (sp, ep))
|
||||
let ps1_loops, ps1_paths = ps1 |> split_loops np1
|
||||
let ps2_loops, ps2_paths = ps2 |> split_loops np2
|
||||
let non_crossing (es1, ep1:Strands.port) (es2, ep2:Strands.port) =
|
||||
let ports1 = es1 |> List.map (fun (a:Strands.port,b) -> Set.ofList [a; b]) |> Set.unionMany
|
||||
let ports2 = es2 |> List.map (fun (a,b) -> Set.ofList [a; b]) |> Set.unionMany
|
||||
Set.intersect ports1 ports2 |> Set.isEmpty
|
||||
let pairs_to_merge =
|
||||
ps1_paths
|
||||
|> List.fold
|
||||
(fun ps_o p1 ->
|
||||
ps2_paths
|
||||
|> List.fold
|
||||
(fun ps_i p2 ->
|
||||
if non_crossing p1 p2 then
|
||||
(p1, p2)::ps_i
|
||||
else ps_i)
|
||||
ps_o)
|
||||
[]
|
||||
let merged_paths = pairs_to_merge |> List.collect (fun ((es1,ep1),(es2,ep2)) -> [(ep1, (List.rev es1)@[e]@es2, ep2); (ep2, (List.rev es2)@[e]@es1, ep1)])
|
||||
let loops = ps1_loops |> List.map (fun (es,ep) -> e::es |> List.rev |> fatten_loop ep)
|
||||
let new_m = merged_paths |> List.fold (fun m (sp,es,ep) -> add_path sp (es, ep) m) m
|
||||
(loops@paths, new_m)
|
||||
|
||||
let close_loops (paths: Species.edge list list, m) ((np1, np2) as e) =
|
||||
match Map.tryFind np1 m, Map.tryFind np2 m with
|
||||
| Some ps, Some _ -> // only interesting case, check for loops
|
||||
let ps_loops = ps |> List.filter (fun (es, ep) -> ep = np2 && List.length es > 2)
|
||||
let loops = ps_loops |> List.map (fun (es,_) -> e::es)
|
||||
(loops@paths, m)
|
||||
| _, _ -> (paths, m)
|
||||
|
||||
([], m) |> do_all add_edge can_be_added
|
||||
|> do_all close_loops can_close_loops // Enable this extension
|
||||
|> fst |> Seq.distinct
|
||||
|
||||
//can_be_added |> Seq.fold add_edge ([], m) |> fst |> Seq.distinct
|
||||
|
||||
let invert edge_set e =
|
||||
if Set.contains e edge_set
|
||||
then Set.remove e edge_set
|
||||
else Set.add e edge_set
|
||||
|
||||
let act_displacing strands es sg =
|
||||
let sg_displaced = { sg with Species.edges = es |> List.fold invert sg.edges }
|
||||
Species.split_ccs strands sg_displaced |> List.ofSeq // split into connected components
|
||||
|
||||
let displacing_actions strands (Species.Rep s as r) =
|
||||
let build es = (r, es, act_displacing strands es s.sg) |> Displacing
|
||||
displacing_paths strands s |> Seq.map build
|
||||
|
||||
let nicking_actions (strands:Strands.t) (before_nick, after_nick) (Species.Rep s as r) =
|
||||
let to_nick = Array.append before_nick after_nick
|
||||
let shift = before_nick.Length-1
|
||||
let nick_sites st = strands.strand_types.[st] |> Seq.windowed to_nick.Length
|
||||
|> Seq.mapi (fun i w -> i+shift, w = to_nick)
|
||||
|> Seq.filter snd |> Seq.map fst
|
||||
|> Seq.toArray
|
||||
let sites = s.sg.strands |> Array.mapi (fun i st -> i, nick_sites st)
|
||||
|
||||
let site_valid (i, b) =
|
||||
s.sg.edges |> Set.toSeq
|
||||
|> Seq.choose (fun (np1, np2) -> if np1 = {Strands.port.strand=i;Strands.port.site=b-shift} then Some np2 else if np2 = {Strands.port.strand=i;Strands.port.site=b-shift} then Some np1 else None)
|
||||
|> Seq.filter (fun port -> ([1..to_nick.Length-1] |> List.map (fun j -> {Strands.port.strand=port.strand; Strands.port.site=port.site-j}, {Strands.port.strand=i;Strands.port.site=b-shift+j})) |> List.map Species.normalize_edge
|
||||
|> List.forall (fun e -> Set.contains e s.sg.edges))
|
||||
|> Seq.isEmpty |> not
|
||||
|
||||
let build (i,b) =
|
||||
let st_i = strands.strand_types.[s.sg.strands.[i]]
|
||||
let prefix = Array.init (b+1) (fun d -> st_i.[d])
|
||||
let prefix_type = Array.findIndex ((=) prefix) strands.strand_types
|
||||
let postfix = Array.init (st_i.Length-b-1) (fun d -> st_i.[d+b+1])
|
||||
let postfix_type = Array.findIndex ((=) postfix) strands.strand_types
|
||||
|
||||
let map_port (port:Strands.port) =
|
||||
if port.strand = i && port.site > b then {Strands.port.strand=port.strand+1; Strands.port.site=port.site-b-1}
|
||||
elif port.strand > i then {Strands.port.strand=port.strand+1; Strands.port.site=port.site}
|
||||
else port
|
||||
let map_edge (np1:Strands.port, np2:Strands.port) = map_port np1, map_port np2
|
||||
//let map_edge_b (e,b) = map_edge e, b
|
||||
|
||||
let strand_type n =
|
||||
if n = i then prefix_type
|
||||
elif n = i+1 then postfix_type
|
||||
elif n > i+1 then s.sg.strands.[n-1]
|
||||
else s.sg.strands.[n]
|
||||
let new_sg =
|
||||
{ Species.strands = Array.init (s.sg.strands.Length+1) strand_type
|
||||
; Species.edges = s.sg.edges |> Set.map map_edge }
|
||||
|
||||
Nick (r, {Strands.port.strand=i;Strands.port.site=b}, Species.rep strands new_sg)
|
||||
|
||||
sites |> Array.collect (fun (i,bs) -> bs |> Array.map (fun b -> i,b))
|
||||
|> Array.filter site_valid
|
||||
|> Seq.map build
|
||||
|
||||
let mono_actions enzymes strands sg =
|
||||
Seq.concat [ isolated_toehold_unbinding_actions strands sg
|
||||
; complementary_binding_actions strands sg
|
||||
; displacing_actions strands sg
|
||||
; enzymes |> Seq.collect (fun e -> nicking_actions strands e sg) ]
|
||||
|> Set.ofSeq
|
||||
|
||||
let bin_actions enzymes strands sg1 sg2 =
|
||||
complementary_cross_binding_actions strands sg1 sg2
|
||||
|> Set.ofSeq
|
||||
|
||||
let actions enzymes strands sgs sg =
|
||||
seq {
|
||||
yield mono_actions enzymes strands sg
|
||||
yield bin_actions enzymes strands sg sg
|
||||
yield! sgs |> Seq.map (bin_actions enzymes strands sg)
|
||||
} |> Set.unionMany
|
||||
(*
|
||||
Seq.concat [ isolated_toehold_unbinding_actions strands sg
|
||||
; complementary_binding_actions strands sg
|
||||
; displacing_actions strands sg
|
||||
; complementary_cross_binding_actions strands sg sg
|
||||
; sgs |> Seq.collect (complementary_cross_binding_actions strands sg)
|
||||
; enzymes |> Seq.collect (fun e -> nicking_actions strands e sg) ]
|
||||
|> Set.ofSeq
|
||||
*)
|
||||
let get_binding_rate (toehold_map:Map<string,float*float>) (strands : Strands.t) (sg1 : Species.strand_graph) (sg2 : Species.strand_graph) ((port1,port2) as e:edge) =
|
||||
if hidden sg1 (port1.strand, port1.site) || hidden sg2 (port2.strand,port2.site) then 0.0
|
||||
else Map.find strands.strand_types.[sg1.strands.[port1.strand]].[port1.site].name toehold_map |> fst
|
||||
|
||||
let get_unbinding_rate (toehold_map:Map<string,float*float>) (strands : Strands.t) (sg : Species.strand_graph) ((port1,_) as e:edge) =
|
||||
Map.find strands.strand_types.[sg.strands.[port1.strand]].[port1.site].name toehold_map |> snd
|
||||
|
||||
let get_rate toehold_map strands = function
|
||||
| Isolated_toehold (Species.Rep s, e, _) -> get_unbinding_rate toehold_map strands s.sg e
|
||||
| Complement_int (Species.Rep s, e, _) -> get_binding_rate toehold_map strands s.sg s.sg e
|
||||
| Complement_ext (Species.Rep s1, Species.Rep s2, e, _) -> get_binding_rate toehold_map strands s1.sg s2.sg e
|
||||
| Displacing (_, _, _) -> 1.0 //20.0
|
||||
| Nick _ -> 3.0
|
||||
|
||||
let to_calc_react toehold_map strands r =
|
||||
{ Calculus.reactants = r |> reactants
|
||||
; Calculus.products = r |> products |> List.map fst
|
||||
; Calculus.rate = r |> get_rate toehold_map strands }
|
||||
let calculus enzymes toehold_map strands =
|
||||
let mono = mono_actions enzymes strands >> Set.map (to_calc_react toehold_map strands)
|
||||
let bin s1 s2 = bin_actions enzymes strands s1 s2 |> Set.map (to_calc_react toehold_map strands)
|
||||
Calculus.from_mono_bin mono bin
|
||||
|
||||
// Visualization
|
||||
|
||||
let no _ = false
|
||||
|
||||
let to_dot_node strands title attr sid = function
|
||||
| Isolated_toehold (r, e, _) ->
|
||||
Species.to_dot_node_mod strands r title attr sid ((=) e) Set.empty no
|
||||
| Complement_int (r, e, _) ->
|
||||
Species.to_dot_node_mod strands r title attr sid no (Set.singleton e) no
|
||||
| Complement_ext (r1, r2, (port1,port2), _) ->
|
||||
let d1 = Species.to_dot_node_mod strands r1 "subgraph g1" None (sid >> sprintf "s1_%s") no Set.empty no
|
||||
let d2 = Species.to_dot_node_mod strands r2 "subgraph g2" None (sid >> sprintf "s2_%s") no Set.empty no
|
||||
seq {
|
||||
yield sprintf "%s {" title
|
||||
yield Option.fold (sprintf "%s %s") "" attr
|
||||
yield d1
|
||||
yield d2
|
||||
yield sprintf "s1_%s:p%d -- s2_%s:p%d%s;" (sid port1.strand) port1.site (sid port2.strand) port2.site Species.add_edge_attr
|
||||
yield "}"
|
||||
} |> String.concat "\n"
|
||||
// add e in green
|
||||
| Displacing (r, es, _) ->
|
||||
let added, removed = es |> List.mapi (fun i e -> i % 2 = 0, e) |> List.partition fst
|
||||
let edges_added = added |> List.map snd |> Set.ofList
|
||||
let edges_removed = removed |> List.map snd |> Set.ofList
|
||||
let edge_removed e = Set.contains e edges_removed
|
||||
Species.to_dot_node_mod strands r title attr sid edge_removed edges_added no
|
||||
| Nick (r, p, _) ->
|
||||
Species.to_dot_node_mod strands r title attr sid no Set.empty ((=) p)
|
||||
|
||||
let to_dot (strands:Strands.t) = to_dot_node strands "graph g" None (sprintf "s%d")
|
||||
|
||||
let s_to_dot i render st added_edes =
|
||||
let sname = sprintf "cluster%d_%d"
|
||||
let style = "style=\"rounded,filled\"\nfillcolor=beige\ncolor=cornsilk3\npenwidth=2.0"
|
||||
let sid a = sprintf "st_%d_sp_%d_str%d" i a
|
||||
let sp_seq = st |> Map.toSeq
|
||||
let sp_id sp =
|
||||
let rev_map = sp_seq |> Seq.mapi (fun i (sp,_) -> sp, i) |> Map.ofSeq
|
||||
Map.find sp rev_map
|
||||
seq {
|
||||
yield sprintf "subgraph cluster%d {" i;
|
||||
if i = 0 then yield "style=filled\nfillcolor=dodgerblue4"
|
||||
yield "color=dodgerblue4"
|
||||
yield "penwidth=3.0"
|
||||
yield! sp_seq |> Seq.mapi (fun j (s,n) -> render s (sprintf "subgraph %s" (sname i j)) (sprintf "label=\"%d\"\n%s" n style |> Some) (sid j) )
|
||||
yield! added_edes |> Set.map (fun ((s1,(ax:Strands.port)),(s2,(by:Strands.port))) -> sprintf "%s:p%d -- %s:p%d%s;" (sid (sp_id s1) ax.strand) ax.site (sid (sp_id s2) by.strand) by.site Species.add_edge_attr)
|
||||
yield "}"
|
||||
} |> String.concat "\n"
|
||||
|
||||
let state_to_dot strands i state = function
|
||||
| Isolated_toehold (r, e, _) ->
|
||||
let render s title attr sid =
|
||||
if s = r then Species.to_dot_node_mod strands r title attr sid ((=) e) Set.empty no
|
||||
else Species.to_dot_node strands s title attr sid
|
||||
s_to_dot i render state Set.empty
|
||||
| Complement_int (r, e, _) ->
|
||||
let render s title attr sid =
|
||||
if s = r then Species.to_dot_node_mod strands r title attr sid no (Set.singleton e) no
|
||||
else Species.to_dot_node strands s title attr sid
|
||||
s_to_dot i render state Set.empty
|
||||
| Complement_ext (r1, r2, (np1, np2), _) ->
|
||||
let render = Species.to_dot_node strands
|
||||
s_to_dot i render state (Set.singleton ((r1,np1),(r2,np2)))
|
||||
| Displacing (r, es, _) ->
|
||||
let added, removed = es |> List.mapi (fun i e -> i % 2 = 0, e) |> List.partition fst
|
||||
let edges_added = added |> List.map snd |> Set.ofList
|
||||
let edges_removed = removed |> List.map snd |> Set.ofList
|
||||
let edge_removed e = Set.contains e edges_removed
|
||||
let render s title attr sid =
|
||||
if s = r then Species.to_dot_node_mod strands r title attr sid edge_removed edges_added no
|
||||
else Species.to_dot_node strands s title attr sid
|
||||
s_to_dot i render state Set.empty
|
||||
| Nick (r, p, _) ->
|
||||
let render s title attr sid =
|
||||
if s = r then Species.to_dot_node_mod strands r title attr sid no Set.empty ((=) p)
|
||||
else Species.to_dot_node strands s title attr sid
|
||||
s_to_dot i render state Set.empty
|
||||
|
||||
let trace_to_dot (strands:Strands.t) final rs =
|
||||
seq {
|
||||
yield "graph g {"
|
||||
yield "layout=fdp"
|
||||
yield! ["style=filled"; "fillcolor=ivory"]
|
||||
// yield! rs |> Seq.mapi (fun i r -> to_dot_node strands (sprintf "subgraph cluster%d" i) None (sprintf "r_%d_str%d" i) r)
|
||||
yield! rs |> Seq.mapi (fun i (st,r,_) -> state_to_dot strands i st r)
|
||||
yield s_to_dot (rs |> Seq.length) (Species.to_dot_node strands) final Set.empty
|
||||
yield "node [style=filled,fillcolor=azure,color=dodgerblue4,penwidth=3.0];"
|
||||
yield "edge [color=dodgerblue4,penwidth=3.0];"
|
||||
yield! rs |> Seq.mapi (fun i (_,_,p) -> sprintf "cluster%d -- cluster%d; [label=\" %.3f \"];" i (i+1) p)
|
||||
yield "}"
|
||||
} |> String.concat "\n"
|
||||
|
||||
let reindex_sgraph (pi: Map<int,int>) (g: Species.s_graph) =
|
||||
let pi_rev = pi |> Map.toSeq |> Seq.map (fun (i, j) -> j, i) |> Map.ofSeq
|
||||
{ g with
|
||||
Species.s_graph.strands = g.strands |> Array.permute (fun i -> Map.find i pi_rev) }
|
||||
|
||||
let rep_perm_to_graph strands (r, pi) = Species.to_graph strands r |> reindex_sgraph pi
|
||||
|
||||
let stack gs =
|
||||
let fold (stacked: Species.s_graph) (g: Species.s_graph) =
|
||||
let npoints = stacked.s_points.Length
|
||||
let stacked_x, stacked_y = stacked.dim
|
||||
let points = Array.append stacked.s_points (g.s_points |> Array.map (fun (x, y) -> x, y + stacked_y))
|
||||
let ndoms = stacked.domains.Length
|
||||
let strands = Array.append stacked.strands (g.strands |> Array.map (Array.map ((+) ndoms)))
|
||||
let g_x, g_y = g.dim
|
||||
{ Species.s_points = points
|
||||
; Species.s_graph.strands = strands
|
||||
; Species.s_graph.domains = Array.append stacked.domains g.domains
|
||||
; Species.s_graph.dim = max stacked_x g_x, stacked_y + g_y}
|
||||
match gs with
|
||||
| [] -> failwith "cannot stack empty list of graphs"
|
||||
| g::rest -> List.fold fold g rest
|
||||
|
||||
let stack_perm strands ss =
|
||||
let fold (stacked_m: Map<int,int>) m =
|
||||
let n = stacked_m.Count
|
||||
let shifted = m |> Map.map (fun _ j -> j + n)
|
||||
Map.foldBack Map.add shifted stacked_m
|
||||
match ss with
|
||||
| [] -> failwith "cannot stack empty list of species"
|
||||
| (s,p)::rest ->
|
||||
let rs, ps = rest |> List.unzip
|
||||
let stacked_p = List.fold fold p ps
|
||||
(s::rs) |> List.map (Species.to_graph strands) |> stack |> reindex_sgraph stacked_p
|
||||
|
||||
|
||||
let to_svg assigned strands = function
|
||||
| Isolated_toehold (r, _, ps) ->
|
||||
let gr = r |> Species.to_graph strands
|
||||
let gp = ps |> stack_perm strands
|
||||
Species.s_graphs_to_svg gr gp
|
||||
| Complement_int (r, _, p) ->
|
||||
let gr = r |> Species.to_graph strands
|
||||
let gp = p |> rep_perm_to_graph strands
|
||||
Species.s_graphs_to_svg gr gp
|
||||
| Complement_ext (r1, r2, _, p) ->
|
||||
let gr = [ Species.to_graph strands r1
|
||||
; Species.to_graph strands r2 ] |> stack
|
||||
let gp = p |> rep_perm_to_graph strands
|
||||
Species.s_graphs_to_svg gr gp
|
||||
| Displacing (r, _, ps) ->
|
||||
let gr = r |> Species.to_graph strands
|
||||
let gp = ps |> stack_perm strands
|
||||
Species.s_graphs_to_svg gr gp
|
||||
| Nick (r, _, (p,_)) ->
|
||||
let gr = r |> Species.to_graph strands
|
||||
let gp = p |> Species.to_graph strands
|
||||
[ Species.wrap_group (Species.dom_style assigned strands) gr
|
||||
; Species.wrap_group (Species.dom_style assigned strands) gp ]
|
||||
|> String.concat "<h1>→</h1>"
|
|
@ -0,0 +1,215 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
module Rudimentary
|
||||
|
||||
type node = int
|
||||
type port = int
|
||||
type edge = (node*port)*(node*port)
|
||||
|
||||
let rec list_to_string f s = function
|
||||
| [] -> ""
|
||||
| [e] -> f e
|
||||
| e::es -> sprintf "%s%s%s" (f e) s (list_to_string f s es)
|
||||
|
||||
let edge_to_string ((n1, p1), (n2, p2)) = sprintf "%d:%d -> %d:%d" n1 p1 n2 p2
|
||||
|
||||
// weights:
|
||||
// -2 unbound long complementary
|
||||
// -1 unbound toehold
|
||||
// 0 not complementary - same as edge not included
|
||||
// 1 bound toehold
|
||||
// 2 bound long domain
|
||||
|
||||
// To avoid storing each edge twice,
|
||||
// an edge is stored with lower node index first
|
||||
// if the node indices are the same, then lower port index first
|
||||
type strand_graph =
|
||||
{ nodes : Map<node, int> // id -> arity
|
||||
; edges : Map<edge, int> } // id, port , id, port -> weight
|
||||
|
||||
let set_edges sg es = { sg with edges = es }
|
||||
|
||||
let get_arity sg n = Map.find n sg.nodes
|
||||
|
||||
let is_legal_port sg (n, p) =
|
||||
p >= 0 && p < get_arity sg n
|
||||
|
||||
// This should probably be either pre-computed or stored in the data structure
|
||||
let free_port sg np =
|
||||
Map.exists (fun (np1, np2) w -> w > 0 && (np1 = np || np2 = np)) sg.edges |> not
|
||||
|
||||
let normalize (((n1, p1), (n2, p2)) as e) =
|
||||
if n1 < n2 then e
|
||||
else if n2 < n1 then ((n2, p2), (n1, p1))
|
||||
else ((n1, min p1 p2), (n2, max p1 p2))
|
||||
|
||||
let get_weight sg e = Map.tryFind (normalize e) sg.edges |> (function None -> 0 | Some x -> x)
|
||||
|
||||
let is_binding_edge sg (np1, np2) =
|
||||
is_legal_port sg np1 && is_legal_port sg np2 &&
|
||||
get_weight sg (np1, np2) > 0
|
||||
|
||||
let adjacent_right sg ((n1, p1), (n2, p2)) =
|
||||
((n1, p1+1), (n2, p2-1)) |> normalize |> is_binding_edge sg // normalize is needed if n1=n2 and p2=p1+1
|
||||
|
||||
let adjacent_left sg ((n1, p1), (n2, p2)) =
|
||||
((n1, p1-1), (n2, p2+1)) |> is_binding_edge sg
|
||||
|
||||
// Three types of action edges:
|
||||
// - isolated toehold unbinding
|
||||
// - complementary domain binding
|
||||
// - displacing path
|
||||
type action =
|
||||
| Isolated_toehold of edge
|
||||
| Complementary of edge
|
||||
| Displacing of edge list
|
||||
|
||||
let action_to_string = function
|
||||
| Isolated_toehold e -> sprintf "Toehold unbinding: %s" (edge_to_string e)
|
||||
| Complementary e -> sprintf "Complementary: %s" (edge_to_string e)
|
||||
| Displacing es -> sprintf "Displacing: [%s]" (list_to_string edge_to_string ", " es)
|
||||
|
||||
let action_edges = function
|
||||
| Isolated_toehold e -> [e]
|
||||
| Complementary e -> [e]
|
||||
| Displacing es -> es
|
||||
|
||||
let has_adjacent sg e = adjacent_left sg e || adjacent_right sg e
|
||||
let isolated sg e = has_adjacent sg e |> not
|
||||
|
||||
let collect_edges f = Map.map (fun k _ -> f k) >> Map.toSeq >> Seq.map snd
|
||||
|
||||
let isolated_toehold_bindings sg = sg.edges |> Map.filter (fun e w -> w = 1 && isolated sg e)
|
||||
let isolated_toehold_unbinding_actions = isolated_toehold_bindings >> collect_edges Isolated_toehold
|
||||
|
||||
let complementary_unbounds sg = sg.edges |> Map.filter (fun (np1, np2) w -> w < 0 && free_port sg np1 && free_port sg np2)
|
||||
let complemtary_binding_actions = complementary_unbounds >> collect_edges Complementary
|
||||
|
||||
let displacing_paths sg =
|
||||
let can_be_added = sg.edges |> Map.filter (fun e w -> w < 0 && has_adjacent sg e) |> Map.toSeq |> Seq.map fst
|
||||
let can_be_removed = sg.edges |> Map.filter (fun _ w -> w > 0) |> Map.toSeq |> Seq.map fst
|
||||
|
||||
// build map from ports to paths from this port
|
||||
// invariant is that active paths have edges from can_be_removed at both ends
|
||||
// start from can_be_removed
|
||||
let add_path np p m =
|
||||
match Map.tryFind np m with
|
||||
| None -> Map.add np [p] m
|
||||
| Some paths -> Map.add np (p::paths) m
|
||||
|
||||
let add_rem m ((np1, np2) as e) =
|
||||
m |> add_path np1 ([e], np2)
|
||||
|> add_path np2 ([e], np1)
|
||||
|
||||
let m = can_be_removed |> Seq.fold add_rem Map.empty
|
||||
|
||||
let add_edge (paths, m) ((np1, np2) as e) =
|
||||
match Map.tryFind np1 m, Map.tryFind np2 m with
|
||||
| None, None -> (paths, m)
|
||||
| None, Some ps2 -> // paths can be terminated at np1
|
||||
let ps = ps2 |> List.map (fun (es, ep) -> (np1, e::es, ep))
|
||||
(ps@paths, m)
|
||||
| Some ps1, None -> // paths can be terminated at np2
|
||||
let ps = ps1 |> List.map (fun (es, ep) -> (np2, e::es, ep))
|
||||
(ps@paths, m)
|
||||
| Some ps1, Some ps2 -> // paths should be merged, check for loops
|
||||
let pairs_to_merge = ps1 |> List.fold (fun ps_o p1 -> ps2 |> List.fold (fun ps_i p2 -> (p1, p2)::ps_i) ps_o) []
|
||||
let merged_paths = pairs_to_merge |> List.collect (fun ((es1,ep1),(es2,ep2)) -> [(ep1, (List.rev es1)@[e]@es2, ep2); (ep2, (List.rev es2)@[e]@es1, ep1)])
|
||||
let loops, active_ps = merged_paths |> List.partition (fun (sp,_,ep) -> e = normalize (sp, ep))
|
||||
let new_m = active_ps |> List.fold (fun m (sp,es,ep) -> add_path sp (es, ep) m) m
|
||||
(loops@paths, new_m)
|
||||
|
||||
can_be_added |> Seq.fold add_edge ([], m) |> fst |> List.map (fun (_, es, _) -> Set.ofList es) |> List.toSeq |> Seq.distinct
|
||||
|
||||
let displacing_actions = displacing_paths >> Seq.map (Set.toList >> Displacing)
|
||||
|
||||
let actions sg =
|
||||
Seq.concat [ isolated_toehold_unbinding_actions sg
|
||||
; complemtary_binding_actions sg
|
||||
; displacing_actions sg ]
|
||||
|
||||
let execute_action_edges sg es =
|
||||
let invert sg e =
|
||||
let w = Map.find e sg
|
||||
Map.add e -w sg
|
||||
es |> List.fold invert sg
|
||||
|
||||
let execute_action sg = action_edges >> execute_action_edges sg.edges >> set_edges sg
|
||||
|
||||
type state_node = (action * strand_graph) seq
|
||||
|
||||
// Should only be called on systems with finite state space
|
||||
let compute_state_space sg =
|
||||
let rec work ss = function
|
||||
| [] -> ss
|
||||
| w::ws ->
|
||||
let links = w |> actions |> Seq.map (fun a -> a, execute_action w a)
|
||||
let new_ss = Map.add w links ss
|
||||
let new_ws = links |> Seq.choose (fun (_,sg) -> if Map.containsKey sg new_ss then None else Some sg)
|
||||
work new_ss (Seq.toList new_ws @ ws)
|
||||
work Map.empty [sg]
|
||||
|
||||
// meant to replace the one above, but duplicates some states atm
|
||||
let state_space sg =
|
||||
let rec work ss l =
|
||||
seq {
|
||||
match l with
|
||||
| [] -> ()
|
||||
| w::ws ->
|
||||
let links = w |> actions |> Seq.map (fun a -> a, execute_action w a)
|
||||
let new_ss = Map.add w links ss
|
||||
let new_ws = links |> Seq.choose (fun (_,sg) -> if Map.containsKey sg new_ss then None else Some sg)
|
||||
yield w, links
|
||||
yield! work new_ss (Seq.toList new_ws @ ws)
|
||||
}
|
||||
work Map.empty [sg]
|
||||
|
||||
let print_state_space ss_seq =
|
||||
let state_to_string i (sg, a) =
|
||||
sprintf
|
||||
"%d: %d edges\n %s\n %d actions\n %s"
|
||||
i
|
||||
(sg.edges |> Map.toSeq |> Seq.length)
|
||||
(sg.edges |> Map.toList |> list_to_string (fun (e,w) -> sprintf "%s @ %d" (edge_to_string e) w) "\n ")
|
||||
(Seq.length a)
|
||||
(a |> Seq.toList |> list_to_string (fun (a, sg) -> sprintf "to %d via %s" (Seq.findIndex (fst >> (=) sg) ss_seq) (action_to_string a)) "\n ")
|
||||
ss_seq |> Seq.iteri (fun i s -> printfn "%s" (state_to_string i s))
|
||||
|
||||
let catalytic =
|
||||
{ nodes = Map.ofList [ (0, 2); (1, 3); (2, 3); (3, 2); (4, 4) ]
|
||||
; edges = Map.ofList [ ((0, 1), (4, 3)), 2
|
||||
; ((1, 0), (4, 3)), -2
|
||||
; ((1, 1), (4, 2)), -1
|
||||
; ((1, 2), (4, 1)), -2
|
||||
; ((2, 1), (4, 2)), 1
|
||||
; ((2, 2), (4, 1)), 2
|
||||
; ((3, 0), (4, 1)), -2
|
||||
; ((3, 1), (4, 0)), -1 ] }
|
||||
|
||||
let eight_way = // transcription of the latex code
|
||||
{ nodes = Map.ofList [ (0, 3); (1, 3); (2, 3); (3, 3); (4, 3); (5, 3); (6, 3); (7, 3) ]
|
||||
; edges = Map.ofList [ ((0, 0), (7, 2)), 2
|
||||
; ((0, 1), (7, 1)), 2
|
||||
; ((0, 2), (7, 0)), -2
|
||||
; ((0, 0), (1, 2)), -2
|
||||
; ((0, 1), (1, 1)), -2
|
||||
; ((0, 2), (1, 0)), 2
|
||||
; ((1, 0), (2, 2)), -2
|
||||
; ((1, 1), (2, 1)), 2
|
||||
; ((1, 2), (2, 0)), 2
|
||||
; ((2, 0), (3, 2)), -2
|
||||
; ((2, 1), (3, 1)), -2
|
||||
; ((2, 2), (3, 0)), 2
|
||||
; ((3, 0), (4, 2)), -2
|
||||
; ((3, 1), (4, 1)), 2
|
||||
; ((3, 2), (4, 0)), 2
|
||||
; ((4, 0), (5, 2)), -2
|
||||
; ((4, 1), (5, 1)), -2
|
||||
; ((4, 2), (5, 0)), 2
|
||||
; ((5, 0), (6, 2)), -2
|
||||
; ((5, 1), (6, 1)), 2
|
||||
; ((5, 2), (6, 0)), 2
|
||||
; ((6, 0), (7, 2)), -2
|
||||
; ((6, 1), (7, 1)), -2
|
||||
; ((6, 2), (7, 0)), 2 ] }
|
|
@ -0,0 +1,28 @@
|
|||
#r @"bin\Debug\SiteGraphReactor.dll"
|
||||
let program = "
|
||||
new 3@ 4.2E-4 , 4.0E-2
|
||||
new 5@ 6.5E-4 , 4.0E-3
|
||||
|
||||
13 * [ <2 3^ 4> ]
|
||||
| 10 * [ <4 5^> ]
|
||||
| 10 * [ <1>[2]:<6>[3^ 4]{5^*} ]"
|
||||
|
||||
let enzymes, toehold_map, strands, ss = SiteGraphReactor.Sitegraphs.compile program
|
||||
|
||||
let all_ss, rs = SiteGraphReactor.Sitegraphs.reaction_graph 0 enzymes toehold_map strands (ss |> Seq.map snd |> List.ofSeq)
|
||||
|
||||
let svg_species = all_ss |> Set.map (SiteGraphReactor.Species.to_svg strands)
|
||||
|
||||
type Svg = { svg : string }
|
||||
let svg t = { svg = t }
|
||||
|
||||
fsi.AddHtmlPrinter(fun (s:Svg) -> s.svg |> sprintf "<div style=\"background:white\">%s</div>")
|
||||
fsi.AddHtmlPrinter(fun (s:seq<Svg>) -> Seq.map (fun s -> s.svg) s |> String.concat "<br/>" |> sprintf "<div style=\"background:white\">%s</div>")
|
||||
|
||||
svg_species |> Seq.head |> svg
|
||||
|
||||
svg_species |> Seq.map svg
|
||||
|
||||
let svg_reactions = rs |> Set.map (SiteGraphReactor.Reactions.to_svg strands)
|
||||
|
||||
svg_reactions |> Seq.map svg
|
|
@ -0,0 +1,27 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Calculus.fs" />
|
||||
<Compile Include="TimeSeparation.fs" />
|
||||
<Compile Include="Tiles.fs" />
|
||||
<Compile Include="Strands.fs" />
|
||||
<Compile Include="Species.fs" />
|
||||
<Compile Include="CirclesRenderer.fs" />
|
||||
<Compile Include="Reactions.fs" />
|
||||
<Compile Include="States.fs" />
|
||||
<Compile Include="ReactionGraph.fs" />
|
||||
<Compile Include="Syntax.fs" />
|
||||
<Compile Include="ExtendedSyntax.fs" />
|
||||
<Compile Include="sitegraphs.fs" />
|
||||
<None Include="paket.references" />
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ParserCombinators\ParserCombinators\ParserCombinators.fsproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\.paket\Paket.Restore.targets" />
|
||||
</Project>
|
|
@ -0,0 +1,923 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.Species
|
||||
|
||||
let safe = true
|
||||
let debug = false
|
||||
|
||||
// A connected strand graph
|
||||
// The field [strands] refers to strand types in a Strands.t object
|
||||
type edge = Strands.port * Strands.port
|
||||
|
||||
type strand_graph =
|
||||
{ strands : int array
|
||||
; edges : Set<edge> } // add also loop itervals
|
||||
|
||||
type t =
|
||||
{ sg : strand_graph
|
||||
; proximal : Set<edge>
|
||||
; bound_ports : Set<Strands.port>
|
||||
; admissible_bindings : Set<edge> } // add also loop itervals
|
||||
|
||||
type rep = Rep of t
|
||||
|
||||
let port_to_string (p:Strands.port) = sprintf "%d:%d" p.strand p.site
|
||||
let edge_to_string (p1, p2) = sprintf "%s -> %s" (port_to_string p1) (port_to_string p2)
|
||||
|
||||
let normalize_edge ((p1, p2) as edge:edge) =
|
||||
if p1.strand < p2.strand then edge
|
||||
else if p2.strand < p1.strand then (p2, p1)
|
||||
else ({Strands.port.strand=p1.strand; Strands.port.site=min p1.site p2.site}, {Strands.port.strand=p2.strand; Strands.port.site=max p1.site p2.site})
|
||||
|
||||
let pairup a b = a, b
|
||||
|
||||
let map_edge f (p1:Strands.port, p2:Strands.port) =
|
||||
({Strands.port.strand=f p1.strand; Strands.port.site=p1.site},
|
||||
{Strands.port.strand=f p2.strand; Strands.port.site=p2.site}) |> normalize_edge
|
||||
|
||||
let permute_edges f = Set.map (map_edge f)
|
||||
|
||||
let invert ap x = Array.findIndex ((=) x) ap
|
||||
|
||||
// helper type for rep
|
||||
// invariant:
|
||||
// [seen_nr] = [seen_map] |> Map.toSeq |> Seq.length
|
||||
type seen_state =
|
||||
{ seen_set : Set<int>
|
||||
; seen_map : Map<int,int>
|
||||
; seen_nr : int }
|
||||
|
||||
let state_of_map seen_map =
|
||||
let seen_seq = seen_map |> Map.toSeq
|
||||
{ seen_set = seen_seq |> Seq.map fst |> Set.ofSeq
|
||||
; seen_map = seen_map
|
||||
; seen_nr = seen_seq |> Seq.length }
|
||||
|
||||
let add_map st s =
|
||||
{ seen_set = st.seen_set
|
||||
; seen_map = st.seen_map |> Map.add s st.seen_nr
|
||||
; seen_nr = st.seen_nr + 1 }
|
||||
|
||||
let add_seen st s =
|
||||
{ seen_set = st.seen_set |> Set.add s
|
||||
; seen_map = st.seen_map
|
||||
; seen_nr = st.seen_nr }
|
||||
|
||||
// Unfolding a strand graph from a particular strand
|
||||
// This is used in the definiton of the canonical representation
|
||||
let unfold_from s a =
|
||||
let get_seen seen a =
|
||||
match Map.tryFind a seen.seen_map with
|
||||
| None -> add_map seen a, seen.seen_nr
|
||||
| Some b -> seen, b
|
||||
let rec work (uf, seen) l =
|
||||
match l with
|
||||
| [] -> (List.rev uf, seen.seen_map)
|
||||
| w::ws ->
|
||||
let link (port1:Strands.port, port2:Strands.port) =
|
||||
let sa, sb = s.strands.[port1.strand], s.strands.[port2.strand]
|
||||
match port1.strand=w, port2.strand=w with
|
||||
| true, true -> Some (w, if port1.site < port2.site then (port1.strand,sa,port1.site,port2.strand,sb,port2.site) else (port2.strand,sb,port2.site,a,sa,port1.site))
|
||||
| true, false -> if Set.contains port2.strand seen.seen_set then None else Some (port2.strand, (port1.strand,sa,port1.site,port2.strand,sb,port2.site))
|
||||
| false, true -> if Set.contains port1.strand seen.seen_set then None else Some (port1.strand, (port2.strand,sb,port2.site,port1.strand,sa,port1.site))
|
||||
| false, false -> None
|
||||
let links = s.edges |> Set.toSeq |> Seq.choose link |> Seq.sortBy (fun (_,(_,_,p, _,_,_)) -> p) // TODO: this could be slow, consider representation with neighbours
|
||||
let convert (seen, acc) (_:int, (a,sa,i, b,sb,j)) =
|
||||
let (seen, a_mapped) = get_seen seen a
|
||||
let (seen, b_mapped) = get_seen seen b
|
||||
(seen, j :: b_mapped :: sb :: i :: a_mapped :: sa :: acc)
|
||||
let (seen, new_uf) = links |> Seq.fold convert (seen, uf)
|
||||
let new_seen = add_seen seen w
|
||||
let new_ws = links |> Seq.choose (fun (a,_) -> if a = w then None else Some a) |> Seq.distinct |> Seq.toList
|
||||
work (new_uf, new_seen) (ws@new_ws)
|
||||
work ([], Map.empty |> Map.add a 0 |> state_of_map) [a]
|
||||
|
||||
let min_pi s =
|
||||
// Compute the colour to choose within
|
||||
let comp (c:int, is:seq<int>) (k, js:seq<int>) =
|
||||
match compare (Seq.length is) (Seq.length js) with
|
||||
| 0 -> compare c k
|
||||
| r -> r
|
||||
let pending = ({0..s.strands.Length-1} |> Seq.groupBy (Array.get s.strands) |> Array.ofSeq |> Array.sortWith comp).[0] |> snd |> Set.ofSeq
|
||||
|
||||
// Run algorithm 2 from "Canonical Labelling of Site Graphs"let v = Set.minElement pending
|
||||
let v = Set.minElement pending
|
||||
let pending = Set.remove v pending
|
||||
let (uf_min, pi_min) = unfold_from s v
|
||||
let rec work (uf_min, pi_min) pending =
|
||||
if Set.isEmpty pending then pi_min
|
||||
else
|
||||
let v = Set.minElement pending
|
||||
let (uf, pi) = unfold_from s v
|
||||
let c = Seq.compareWith compare uf uf_min
|
||||
if c < 0 then work (uf, pi) (Set.remove v pending)
|
||||
else if c > 0 then work (uf_min, pi_min) (Set.remove v pending)
|
||||
else
|
||||
let new_pending = pending |> Set.filter (fun i -> Set.exists (fun j -> Map.find i pi = Map.find j pi_min) pending)
|
||||
work (uf, pi) (Set.remove v new_pending)
|
||||
work (uf_min, pi_min) pending
|
||||
|
||||
let normalize s =
|
||||
let pi = min_pi s
|
||||
let p x = Map.find x pi
|
||||
( { strands = s.strands |> Array.permute p
|
||||
; edges = s.edges |> permute_edges p }
|
||||
, pi )
|
||||
|
||||
let is_legal_port (strands:Strands.t) (sg:strand_graph) (p:Strands.port) =
|
||||
p.site >= 0 && p.site < strands.strand_types.[sg.strands.[p.strand]].Length
|
||||
|
||||
let is_legal_edge strands sg (np1:Strands.port, np2) =
|
||||
is_legal_port strands sg np1 && is_legal_port strands sg np2
|
||||
|
||||
(* Old version of proximal, seems faster on the laptop, possibly it is less memory intensive?
|
||||
let left_neighbour ((n1, p1), (n2, p2)) = ((n1, p1-1), (n2, p2+1))
|
||||
let right_neighbour ((n1, p1), (n2, p2)) = ((n1, p1+1), (n2, p2-1))
|
||||
|
||||
// Rather than proximal left and proximal right, flip the bond
|
||||
let rec proximal_neighbour strands (sg:strand_graph) edge_to neighbour e0 =
|
||||
let edges = Set.remove e0 sg.edges
|
||||
let rec proximal ((np1, np2) as e) =
|
||||
if edges |> Set.contains (normalize_edge e) then true else
|
||||
let (nnp1, nnp2) as ne = neighbour e
|
||||
if is_legal_edge strands sg ne |> not then false
|
||||
else if edges |> Set.contains (normalize_edge ne) then true
|
||||
else
|
||||
match edge_to nnp1 with
|
||||
| None -> false
|
||||
| Some new_np1 ->
|
||||
let new_e = (new_np1, np2) (*|> Species.normalize_edge*)
|
||||
if new_e = e0 then false
|
||||
else proximal new_e
|
||||
proximal e0
|
||||
|
||||
let proximal_left strands sg edge_to = proximal_neighbour strands sg edge_to left_neighbour
|
||||
|
||||
let proximal_right strands sg edge_to = proximal_neighbour strands sg edge_to right_neighbour
|
||||
|
||||
let proximal strands sg edge_to e = proximal_left strands sg edge_to e || proximal_right strands sg edge_to e
|
||||
*)
|
||||
|
||||
let to_set p x = if p x then Set.singleton x else Set.empty
|
||||
let to_the_left (port:Strands.port) = {Strands.port.strand=port.strand; Strands.port.site=port.site-1}
|
||||
let to_the_right (port:Strands.port) = {Strands.port.strand=port.strand; Strands.port.site=port.site+1}
|
||||
|
||||
let proximal (strands:Strands.t) (sg:strand_graph) admissible_bindings =
|
||||
let tl = to_the_left >> to_set (is_legal_port strands sg)
|
||||
let tr = to_the_right >> to_set (is_legal_port strands sg)
|
||||
let add_bond (close_left, close_right) (np1, np2) =
|
||||
let get_left (v, m) = match Map.tryFind v m with None -> tl v | Some x -> x
|
||||
let get_right (v, m) = match Map.tryFind v m with None -> tr v | Some x -> x
|
||||
let add_close get b c (p:Strands.port) =
|
||||
let cb = get (p, c)
|
||||
Map.add p (b + cb) c
|
||||
let bagl1, bagr1 = get_left (np1, close_left), get_right (np1, close_right)
|
||||
let bagl2, bagr2 = get_left (np2, close_left), get_right (np2, close_right)
|
||||
let close_left = bagr2 |> Set.fold (add_close get_left bagl1) close_left
|
||||
let close_right = bagl1 |> Set.fold (add_close get_right bagr2) close_right
|
||||
let close_left = bagr1 |> Set.fold (add_close get_left bagl2) close_left
|
||||
let close_right = bagl2 |> Set.fold (add_close get_right bagr1) close_right
|
||||
close_left, close_right
|
||||
let close_left, close_right = sg.edges |> Set.fold add_bond (Map.empty, Map.empty)
|
||||
close_left
|
||||
|> Map.toSeq
|
||||
|> Seq.map (fun (p, ps) -> ps |> Set.map (fun x -> (p,x) |> normalize_edge))
|
||||
|> Set.unionMany
|
||||
|> Set.intersect admissible_bindings
|
||||
|
||||
let admissible_bindings (strands:Strands.t) (sg:strand_graph) =
|
||||
let c_inv = sg.strands |> Array.mapi pairup |> Array.toSeq |> Seq.groupBy snd |> Map.ofSeq |> Map.map (fun _ s -> Seq.map fst s)
|
||||
let translate ((p1:Strands.port),(p2:Strands.port)) =
|
||||
match Map.tryFind p1.strand c_inv, Map.tryFind p2.strand c_inv with
|
||||
| Some cs1, Some cs2 ->
|
||||
let ss1 = cs1 |> Seq.map (fun s -> {Strands.port.strand=s;Strands.port.site=p1.site})
|
||||
let ss2 = cs2 |> Seq.map (fun s -> {Strands.port.strand=s;Strands.port.site=p2.site})
|
||||
ss1 |> Seq.collect (fun (np1:Strands.port) -> ss2 |> Seq.map (fun np2 -> (np1, np2) |> normalize_edge)) |> Some
|
||||
| _ -> None
|
||||
strands.admissible_edges |> Map.toSeq |> Seq.choose (fun (e,_) -> translate (e.port1, e.port2)) |> Seq.concat |> Set.ofSeq
|
||||
|
||||
// Check certain criteria of the species representation
|
||||
let check (strands:Strands.t) sg =
|
||||
let edge_sorted (p1:Strands.port, p2:Strands.port) =
|
||||
if p1.strand = p2.strand then p1.site < p2.site else p1.strand < p2.strand
|
||||
|
||||
// check that edges are admissible
|
||||
let check_edge ((p1, p2) as e :edge) =
|
||||
if p1.strand < 0 || p1.strand >= sg.strands.Length || p2.strand < 0 || p2.strand >= sg.strands.Length then failwith (sprintf "illegal edge: %s" (edge_to_string e))
|
||||
if p1.site < 0 || p1.site >= strands.strand_types.[sg.strands.[p1.strand]].Length then failwith (sprintf "illegal port: %d on strand %d" p1.site p1.strand)
|
||||
if p2.site < 0 || p2.site >= strands.strand_types.[sg.strands.[p2.strand]].Length then failwith (sprintf "illegal port: %d on strand %d" p2.site p2.strand)
|
||||
if strands.admissible_edges |> Map.containsKey (normalize_edge ({Strands.port.strand=sg.strands.[p1.strand]; Strands.port.site=p1.site}, {Strands.port.strand=sg.strands.[p2.strand];Strands.port.site= p2.site}) |> fun edge -> {Strands.port_pair.port1=fst edge;Strands.port_pair.port2=snd edge}) |> not then failwith (sprintf "phantom edge: %s" (edge_to_string e))
|
||||
if edge_sorted e |> not then failwith (sprintf "unsorted edge: %s" (edge_to_string e))
|
||||
sg.edges |> Set.iter check_edge;
|
||||
|
||||
// check that ports are only used once
|
||||
let check_ports used (p1, p2) =
|
||||
if p1 = p2 then failwith (sprintf "port used twice in same edge: %s" (port_to_string p1))
|
||||
if Set.contains p1 used then failwith (sprintf "port used twice: %s" (port_to_string p1))
|
||||
if Set.contains p2 used then failwith (sprintf "port used twice: %s" (port_to_string p2))
|
||||
used |> Set.add p1 |> Set.add p2
|
||||
sg.edges |> Set.fold check_ports Set.empty |> ignore
|
||||
|
||||
let rep strands s =
|
||||
// let debug = s.strands.Length
|
||||
let sg, pi = normalize s
|
||||
if safe then check strands sg
|
||||
|
||||
//printfn "Species with\n\tStrands: %i Edges: %i" s.strands.Length s.edges.Count
|
||||
|
||||
let admissible_bindings = admissible_bindings strands sg
|
||||
(* Old computation
|
||||
let edge_map = sg.edges |> Set.fold (fun m (np1, np2) -> m |> Map.add np1 np2 |> Map.add np2 np1) Map.empty
|
||||
let edge_to np = Map.tryFind np edge_map
|
||||
let proximal = admissible_bindings |> Set.filter (proximal strands sg edge_to)
|
||||
*)
|
||||
let proximal = proximal strands sg admissible_bindings
|
||||
let bound_ports = sg.edges |> Set.fold (fun ports (p1,p2) -> ports |> Set.add p1 |> Set.add p2) Set.empty
|
||||
( { sg = sg
|
||||
; proximal = proximal
|
||||
; bound_ports = bound_ports
|
||||
; admissible_bindings = admissible_bindings } |> Rep
|
||||
, pi )
|
||||
|
||||
// Split off a connected component
|
||||
let split s cc =
|
||||
let p x = Set.contains x cc
|
||||
let kps, lps = s.strands |> Array.mapi pairup |> Array.partition (fst >> p)
|
||||
let kp, ks = kps |> Array.unzip
|
||||
let lp, ls = lps |> Array.unzip
|
||||
let k_edge (p1:Strands.port,(p2:Strands.port)) = kp |> Array.exists (fun i -> p1.strand=i || p2.strand=i)
|
||||
let ke, le = s.edges |> Set.partition k_edge // links across will end up in k
|
||||
( ( { strands = ks
|
||||
; edges = ke |> permute_edges (invert kp) }
|
||||
, kp |> Array.mapi (fun i j -> j, i) |> Map.ofArray )
|
||||
, ( { strands = ls
|
||||
; edges = le |> permute_edges (invert lp) }
|
||||
, lp |> Array.mapi (fun i j -> j, i) |> Map.ofArray ) )
|
||||
|
||||
let reachable s a =
|
||||
let rec work rs = function
|
||||
| [] -> rs
|
||||
| w::ws ->
|
||||
let r (p1:Strands.port,(p2:Strands.port)) =
|
||||
match p1.strand=w, p2.strand=w with
|
||||
| false, false
|
||||
| true, true -> None
|
||||
| false, true -> Some p1.strand
|
||||
| true, false -> Some p2.strand
|
||||
let is_new a = Set.contains a rs |> not
|
||||
let new_ws = s.edges |> Set.toSeq |> Seq.choose r |> Seq.distinct |> Seq.filter is_new |> Seq.toList
|
||||
work (Set.add w rs) (new_ws@ws)
|
||||
work Set.empty [a]
|
||||
|
||||
let compose m1 m2 =
|
||||
m1 |> Map.map (fun _ v -> Map.find v m2)
|
||||
|
||||
let rep_perm strands (s, p) =
|
||||
let r, pi = rep strands s
|
||||
r, compose p pi
|
||||
|
||||
let break_bond strands s ((p1,p2) as e:edge) =
|
||||
let broken_s = { s with edges = Set.remove e s.edges }
|
||||
let rs = reachable broken_s p1.strand
|
||||
if rs |> Set.contains p2.strand then [rep strands broken_s]
|
||||
else
|
||||
let s1, s2 = split broken_s rs
|
||||
[rep_perm strands s1; rep_perm strands s2]
|
||||
|
||||
// [(a,i)] refers to [s1] while [(b,j)] refers to [s2]
|
||||
let form_bond strands s1 s2 ((p1,p2) as e:edge) =
|
||||
{ strands = Array.append s1.strands s2.strands
|
||||
; edges = s2.edges
|
||||
|> permute_edges ((+) s1.strands.Length)
|
||||
|> Set.union s1.edges
|
||||
|> Set.add (p1,{Strands.port.strand=p2.strand+s1.strands.Length; Strands.port.site=p2.site}) }
|
||||
|> rep strands
|
||||
|
||||
let rec split_ccs_perm strands (s,p) =
|
||||
if s.strands.Length = 0 then Seq.empty else
|
||||
seq {
|
||||
let cc = reachable s 0
|
||||
if Set.count cc = s.strands.Length then yield rep_perm strands (s,p) else
|
||||
let s1, s2 = split s cc
|
||||
yield rep_perm strands s1;
|
||||
yield! split_ccs_perm strands s2
|
||||
}
|
||||
|
||||
let split_ccs strands s =
|
||||
let p = s.strands |> Array.mapi (fun i _ -> i,i) |> Map.ofArray
|
||||
split_ccs_perm strands (s, p)
|
||||
|
||||
let add_edge_attr = "[color=lime,penwidth=2.0]"
|
||||
let remove_edge_attr = "[color=red,penwidth=2.0]"
|
||||
|
||||
(* Find nicer way to do this *)
|
||||
let to_dot_node_mod (strands:Strands.t) (Rep s) title attr sid edge_removed edges_added port_nicked =
|
||||
let strand_to_string st =
|
||||
let spacer i = if port_nicked {Strands.port.strand=st; Strands.port.site=i} then " | ~~~v~~~" else ""
|
||||
strands.strand_types.[st] |> Array.mapi (fun i d -> sprintf "<p%d>%s%s" i (Strands.domain_to_string d) (spacer i)) |> String.concat " | "
|
||||
let edge_attr e = if edge_removed e then remove_edge_attr else ""
|
||||
seq {
|
||||
yield sprintf "%s {" title;
|
||||
yield Option.fold (sprintf "%s %s") "" attr;
|
||||
yield " node [shape=record,style=filled,fillcolor=white]";
|
||||
yield! s.sg.strands |> Array.mapi (fun i st -> sprintf " %s [label=\"%s\"];" (sid i) (strand_to_string st));
|
||||
yield! s.sg.edges |> Set.map (fun ((p1,p2) as e:edge) -> sprintf " %s:p%d -- %s:p%d%s;" (sid p1.strand) p1.site (sid p2.strand) p2.site (edge_attr e))
|
||||
yield! edges_added |> Set.map (fun (p1:Strands.port,p2:Strands.port) -> sprintf " %s:p%d -- %s:p%d%s;" (sid p1.strand) p1.site (sid p2.strand) p2.site add_edge_attr)
|
||||
yield "}"
|
||||
} |> String.concat "\n"
|
||||
|
||||
let to_dot_node (strands:Strands.t) (Rep s) title attr sid =
|
||||
let strand_to_string st =
|
||||
strands.strand_types.[st] |> Array.mapi (fun i d -> sprintf "<p%d>%s" i (Strands.domain_to_string d)) |> String.concat " | "
|
||||
seq {
|
||||
yield sprintf "%s {" title;
|
||||
yield Option.fold (sprintf "%s %s") "" attr;
|
||||
yield " node [shape=record,style=filled,fillcolor=white]";
|
||||
yield! s.sg.strands |> Array.mapi (fun i st -> sprintf " %s [label=\"%s\"];" (sid i) (strand_to_string st));
|
||||
yield! s.sg.edges |> Set.map (fun ((p1:Strands.port,p2:Strands.port)) -> sprintf " %s:p%d -- %s:p%d;" (sid p1.strand) p1.site (sid p2.strand) p2.site )
|
||||
yield "}"
|
||||
} |> String.concat "\n"
|
||||
|
||||
let to_dot (strands:Strands.t) s = to_dot_node strands s "graph g" None (sprintf "s%d")
|
||||
|
||||
let to_string_i indent (strands:Strands.t) (Rep s) =
|
||||
let bindings,_ =
|
||||
s.sg.edges |> Set.fold (fun (m,c) (np1,np2) -> m |> Map.add np1 c |> Map.add np2 c, c+1) (Map.empty, 0)
|
||||
let domain port d =
|
||||
let b = match Map.tryFind port bindings with
|
||||
| Some n -> sprintf "!%d" n
|
||||
| None -> ""
|
||||
sprintf "%s%s" (Strands.domain_to_string d) b
|
||||
let sep = sprintf "\n%s| " (String.replicate indent " ")
|
||||
s.sg.strands |> Array.mapi (fun i st -> strands.strand_types.[st] |> Array.mapi (fun j d -> domain {Strands.port.strand=i;Strands.port.site=j} d))
|
||||
|> Array.map (String.concat " " >> sprintf "<%s>")
|
||||
|> String.concat sep |> sprintf "[ %s ]"
|
||||
|
||||
let to_string = to_string_i 0
|
||||
|
||||
let to_html_i indent (strands:Strands.t) (Rep s) =
|
||||
let bindings,_ =
|
||||
s.sg.edges |> Set.fold (fun (m,c) (np1,np2) -> m |> Map.add np1 c |> Map.add np2 c, c+1) (Map.empty, 0)
|
||||
let domain port d =
|
||||
let b = match Map.tryFind port bindings with
|
||||
| Some n -> sprintf "!%d" n
|
||||
| None -> ""
|
||||
sprintf "%s%s" (Strands.domain_to_string d) b
|
||||
let sep = sprintf "\n%s| " (String.replicate indent " ")
|
||||
s.sg.strands |> Array.mapi (fun i st -> strands.strand_types.[st] |> Array.mapi (fun j d -> domain {Strands.port.strand=i;Strands.port.site=j} d))
|
||||
|> Array.map (String.concat " " >> sprintf "<%s>")
|
||||
|> String.concat sep |> sprintf "[ %s ]"
|
||||
|
||||
let to_html = to_html_i 0
|
||||
|
||||
(* Visualisation *)
|
||||
type point = float * float
|
||||
let origo = 0.0, 0.0
|
||||
let pi = 3.14158
|
||||
let twopi = 2.0 * pi
|
||||
|
||||
(* The point_names are understood as in the local space, the points are in global space *)
|
||||
(* The ints are pointers to points *)
|
||||
type line =
|
||||
{ left : int
|
||||
; right : int }
|
||||
|
||||
type spring = int * int
|
||||
|
||||
(* Here are the real points *)
|
||||
type space =
|
||||
{ mutable center : point
|
||||
; mutable angle : float }
|
||||
let o_space =
|
||||
{ center = origo
|
||||
; angle = 0.0 }
|
||||
|
||||
let random = System.Random ()
|
||||
let randomize_space (s: space) =
|
||||
s.center <- (300.0 * random.NextDouble(), 300.0 * random.NextDouble())
|
||||
s.angle <- twopi * random.NextDouble()
|
||||
|
||||
type double =
|
||||
{ d_space : space
|
||||
; dim : point
|
||||
; upper : int
|
||||
; lower : int }
|
||||
|
||||
type single =
|
||||
{ s_space : space
|
||||
; radius : float
|
||||
; line : int }
|
||||
|
||||
let left l = 2 * l
|
||||
let right l = 2 * l + 1
|
||||
|
||||
type graph =
|
||||
{ points : point []
|
||||
; doubles : Set<double>
|
||||
; singles : Set<single> }
|
||||
|
||||
type s_graph =
|
||||
{ s_points : point []
|
||||
; strands : int [] [] // which lines does each strand consist of
|
||||
; domains : Strands.domain []
|
||||
; dim : point }
|
||||
|
||||
(* Helpers *)
|
||||
let v (x1:float,y1:float) (x2,y2) = (x2 - x1, y2 - y1)
|
||||
let n (x,y) = x * x + y * y
|
||||
let d p1 p2 = v p1 p2 |> n |> sqrt
|
||||
let theta = function
|
||||
| (0.0, y) when y < 0.0 -> -pi
|
||||
| (0.0, y) -> pi
|
||||
| (x, y) -> atan (y/x)
|
||||
let a (x1:float,y1:float) (x2,y2) = (x2 + x1, y2 + y1)
|
||||
let t (px,py) a (vx,vy) =
|
||||
(px + vx * cos a - vy * sin a, py + vx * sin a + vy * cos a)
|
||||
|
||||
(* Drawing *)
|
||||
let fontsize = 15
|
||||
let letterwidth = 8
|
||||
let linewidth = 2.5
|
||||
let path_style = sprintf "path { stroke: silver; stroke-width: %f; stroke-linejoin: round; fill: none; }" linewidth
|
||||
let text_style = sprintf "text { stroke: black; fill: black; stroke-width: 0; font-family: Verdana,Arial,sans-serif; font-size: %dpx; text-anchor: middle; }" fontsize
|
||||
|
||||
let palette = [| "red"; "green"; "blue"; "orange"; "purple"
|
||||
; "cyan"; "brown"; "magenta"; "dodgerblue"; "orchid"
|
||||
; "lawngreen"; "lightskyblue"; "darksalmon"; "teal"; "rosybrown"
|
||||
; "navajowhite"; "olive"; "darkseagreen"; "darkgoldenrod"; "pink" |]
|
||||
|
||||
let dom_colour i = if i < palette.Length then palette.[i] else "black"
|
||||
|
||||
let dom_style (assigned:System.Collections.Generic.Dictionary<string,string>) (strands: Strands.t) =
|
||||
let all_doms =
|
||||
strands.strand_types |> Array.collect (fun st -> st |> Array.filter (fun d -> d.toehold) |> Array.map (fun d -> d.name))
|
||||
|> Array.toSeq |> Seq.distinct
|
||||
let get_assignment d =
|
||||
if not (assigned.ContainsKey d) then assigned.Add(d, palette.[assigned.Count % palette.Length])
|
||||
(d, assigned.[d])
|
||||
|
||||
all_doms |> Seq.map get_assignment
|
||||
|> Seq.map (fun (d,c) -> sprintf ".toe_%s { stroke: %s; } .toe_%s_text { fill: %s; }" d c d c)
|
||||
|> String.concat " "
|
||||
|
||||
let svg_style assigned strands = sprintf "<style> %s %s %s </style>" path_style text_style (dom_style assigned strands)
|
||||
|
||||
let s_graph_to_svg g =
|
||||
let xs, ys = g.s_points |> Array.unzip
|
||||
let domain_class l =
|
||||
let d = g.domains.[l]
|
||||
if d.toehold then sprintf "toe_%s" d.name else "normal"
|
||||
let path (a,b) style =
|
||||
let ax, ay = g.s_points.[a]
|
||||
let bx, by = g.s_points.[b]
|
||||
sprintf "<path d=\"M %f %f L %f %f\"%s/>" ax ay bx by style
|
||||
let arrow_path (a,b) style =
|
||||
let ax, ay = g.s_points.[a]
|
||||
let bx, by = g.s_points.[b]
|
||||
let vx, vy = v (ax, ay) (bx, by)
|
||||
let l = d (ax, ay) (bx, by)
|
||||
let cx, cy = t (bx, by) 2.6 (10.0 * vx / l, 10.0 * vy / l)
|
||||
sprintf "<path d=\"M %f %f L %f %f L %f %f\"%s/>" ax ay bx by cx cy style
|
||||
let label l =
|
||||
let pa = g.s_points.[left l]
|
||||
let pb = g.s_points.[right l]
|
||||
let vx, vy = v pa pb
|
||||
let m = a pa (vx * 0.5, vy * 0.5)
|
||||
let r = d pa pb
|
||||
let px, py = a m (-12.0 * vy / r, 12.0 * vx / r)
|
||||
let angle = theta (vx, vy) * 180.0 / pi
|
||||
let label = g.domains.[l] |> Strands.domain_to_string
|
||||
sprintf "<text x=\"%f\" y= \"%f\" transform=\"rotate(%f %f,%f)\" dy=\"6\" class=\"%s\">%s</text>" px py angle px py (sprintf "%s_text" (domain_class l)) label
|
||||
let line l =
|
||||
seq {
|
||||
yield label l
|
||||
yield path (left l, right l) (sprintf " class=\"%s\"" (domain_class l))
|
||||
} |> String.concat "\n"
|
||||
let arrow_line l =
|
||||
seq {
|
||||
yield label l
|
||||
yield arrow_path (left l, right l) (sprintf " class=\"%s\"" (domain_class l))
|
||||
} |> String.concat "\n"
|
||||
let spring (a,b) = path (right a, left b) " stroke=\"silver\""
|
||||
let strand_to_svg s =
|
||||
s |> Array.mapi (fun i l -> if i = s.Length-1 then [| arrow_line l |] else [| line l; spring (s.[i],s.[i+1]) |]) |> Array.concat
|
||||
g.strands |> Array.collect strand_to_svg |> String.concat "\n"
|
||||
|
||||
let wrap_svg dom_style svg (w, h) =
|
||||
seq {
|
||||
yield sprintf "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"%f\" height=\"%f\" stroke=\"black\">" (w + 1.0) (h + 1.0)
|
||||
yield sprintf "<style> %s %s %s </style>" path_style text_style dom_style
|
||||
yield svg
|
||||
yield "</svg>"
|
||||
} |> String.concat "\n"
|
||||
|
||||
let wrap_group dom_style g = wrap_svg dom_style (s_graph_to_svg g) g.dim
|
||||
|
||||
let animation_timing = "keyTimes=\"0; 0.2; 0.8; 1\" dur=\"6s\" begin=\"0s\" repeatCount=\"indefinite\""
|
||||
let animation_values v1 v2 = sprintf "values=\"%s; %s; %s; %s\"" v1 v1 v2 v2
|
||||
|
||||
(* create an animted reaction from one graph to another *)
|
||||
let s_graphs_to_svg g1 g2 =
|
||||
let domain_class l =
|
||||
let d = g1.domains.[l]
|
||||
if d.toehold then sprintf "toe_%s" d.name else "normal"
|
||||
let path (a1,a2,b1,b2) style =
|
||||
let ax1, ay1 = g1.s_points.[a1]
|
||||
let bx1, by1 = g1.s_points.[b1]
|
||||
let d1 = sprintf "M %f %f L %f %f" ax1 ay1 bx1 by1
|
||||
let ax2, ay2 = g2.s_points.[a2]
|
||||
let bx2, by2 = g2.s_points.[b2]
|
||||
let d2 = sprintf "M %f %f L %f %f" ax2 ay2 bx2 by2
|
||||
seq {
|
||||
yield sprintf "<path d=\"%s\"%s>" d1 style
|
||||
yield "<animate"
|
||||
yield "attributeName=\"d\""
|
||||
yield animation_values d1 d2
|
||||
yield animation_timing
|
||||
yield "additive=\"replace\" fill=\"freeze\"/>"
|
||||
yield "</path>"
|
||||
} |> String.concat "\n"
|
||||
|
||||
let arrow_path (a1,a2,b1,b2) style =
|
||||
let ax1, ay1 = g1.s_points.[a1]
|
||||
let bx1, by1 = g1.s_points.[b1]
|
||||
let vx1, vy1 = v (ax1, ay1) (bx1, by1)
|
||||
let l1 = d (ax1, ay1) (bx1, by1)
|
||||
let cx1, cy1 = t (bx1, by1) 2.6 (10.0 * vx1 / l1, 10.0 * vy1 / l1)
|
||||
let d1 = sprintf "M %f %f L %f %f L %f %f" ax1 ay1 bx1 by1 cx1 cy1
|
||||
let ax2, ay2 = g2.s_points.[a2]
|
||||
let bx2, by2 = g2.s_points.[b2]
|
||||
let vx2, vy2 = v (ax2, ay2) (bx2, by2)
|
||||
let l2 = d (ax2, ay2) (bx2, by2)
|
||||
let cx2, cy2 = t (bx2, by2) 2.6 (10.0 * vx2 / l2, 10.0 * vy2 / l2)
|
||||
let d2 = sprintf "M %f %f L %f %f L %f %f" ax2 ay2 bx2 by2 cx2 cy2
|
||||
seq {
|
||||
yield sprintf "<path d=\"%s\"%s>" d1 style
|
||||
yield "<animate"
|
||||
yield "attributeName=\"d\""
|
||||
yield animation_values d1 d2
|
||||
yield animation_timing
|
||||
yield "additive=\"replace\" fill=\"freeze\"/>"
|
||||
yield "</path>"
|
||||
} |> String.concat "\n"
|
||||
let label (l1,l2) =
|
||||
let pa1 = g1.s_points.[left l1]
|
||||
let pb1 = g1.s_points.[right l1]
|
||||
let vx1, vy1 = v pa1 pb1
|
||||
let m1 = a pa1 (vx1 * 0.5, vy1 * 0.5)
|
||||
let r1 = d pa1 pb1
|
||||
let px1, py1 = a m1 (-12.0 * vy1 / r1, 12.0 * vx1 / r1)
|
||||
let angle1 = theta (vx1, vy1) * 180.0 / pi
|
||||
let rot1 = sprintf "%f %f,%f" angle1 px1 py1
|
||||
let t1 = sprintf "x=\"%f\" y=\"%f\"" px1 py1
|
||||
let pa2 = g2.s_points.[left l2]
|
||||
let pb2 = g2.s_points.[right l2]
|
||||
let vx2, vy2 = v pa2 pb2
|
||||
let m2 = a pa2 (vx2 * 0.5, vy2 * 0.5)
|
||||
let r2 = d pa2 pb2
|
||||
let px2, py2 = a m2 (-12.0 * vy2 / r2, 12.0 * vx2 / r2)
|
||||
let angle2 = theta (vx2, vy2) * 180.0 / pi
|
||||
let rot2 = sprintf "%f %f,%f" angle2 px2 py2
|
||||
let t2 = sprintf "%f,%f" (px2-px1) (py2-py1)
|
||||
seq {
|
||||
yield sprintf "<text %s transform=\"rotate(%s)\" dy=\"6\">" t1 rot1
|
||||
yield "<animateTransform attributeName=\"transform\" attributeType=\"XML\""
|
||||
yield "type=\"rotate\""
|
||||
yield animation_values rot1 rot2
|
||||
yield animation_timing
|
||||
yield "additive=\"replace\" fill=\"freeze\"/>"
|
||||
yield "<animateTransform attributeName=\"transform\" attributeType=\"XML\""
|
||||
yield "type=\"translate\""
|
||||
yield animation_values "0,0" t2
|
||||
yield animation_timing
|
||||
yield "additive=\"sum\" fill=\"freeze\"/>"
|
||||
yield g1.domains.[l1] |> Strands.domain_to_string |> sprintf "%s</text>"
|
||||
} |> String.concat "\n"
|
||||
let line (l1,l2) =
|
||||
seq {
|
||||
yield label (l1,l2)
|
||||
yield path (left l1, left l2, right l1, right l2) (sprintf " class=\"%s\"" (domain_class l1))
|
||||
} |> String.concat "\n"
|
||||
let arrow_line (l1,l2) =
|
||||
seq {
|
||||
yield label (l1,l2)
|
||||
yield arrow_path (left l1, left l2, right l1, right l2) (sprintf " class=\"%s\"" (domain_class l1))
|
||||
} |> String.concat "\n"
|
||||
let spring (a1, a2, b1, b2) = path (right a1, right a2, left b1, left b2) " stroke=\"silver\""
|
||||
let strand_to_svg (s1,s2) =
|
||||
Array.zip s1 s2 |> Array.mapi (fun i (l1,l2) -> if i = s1.Length-1 then [| arrow_line (l1,l2) |] else [| line (l1,l2); spring (s1.[i],s2.[i],s1.[i+1],s2.[i+1]) |]) |> Array.concat
|
||||
let w1, h1 = g1.dim
|
||||
let w2, h2 = g2.dim
|
||||
let w, h = max w1 w2, max h1 h2
|
||||
seq {
|
||||
yield sprintf "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"%f\" height=\"%f\" stroke=\"black\">" (w + 1.0) (h + 1.0)
|
||||
yield sprintf "<style> %s %s </style>" path_style text_style
|
||||
yield! Array.zip g1.strands g2.strands |> Array.collect strand_to_svg
|
||||
yield "</svg>"
|
||||
} |> String.concat "\n"
|
||||
|
||||
let graph_to_svg g =
|
||||
let xs, ys = g.points |> Array.unzip
|
||||
let min_x, max_x = Array.min xs, Array.max xs
|
||||
let min_y, max_y = Array.min ys, Array.max ys
|
||||
let path (a,b) style =
|
||||
let ax, ay = g.points.[a]
|
||||
let bx, by = g.points.[b]
|
||||
sprintf "<path d=\"M %f %f L %f %f\" stroke=\"%s\"/>" (ax - min_x) (ay - min_y) (bx - min_x) (by - min_y) style
|
||||
let line l = path (left l, right l) "black"
|
||||
let spring (a,b) = path (right a, left b) "grey"
|
||||
let double_to_svg (d: double) = [ d.upper; d.lower ] |> Seq.map line
|
||||
let single_to_svg (s: single) = line s.line
|
||||
seq {
|
||||
yield sprintf "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"%f\" height=\"%f\" stroke=\"black\">" (max_x - min_x + 1.0) (max_y - min_y + 1.0)
|
||||
yield! g.doubles |> Set.toSeq |> Seq.collect double_to_svg
|
||||
yield! g.singles |> Set.toSeq |> Seq.map single_to_svg
|
||||
yield "</svg>"
|
||||
} |> String.concat "\n"
|
||||
|
||||
#if JavaScript
|
||||
#else
|
||||
let export_graph file_name dom_style g =
|
||||
let svg = g |> wrap_group dom_style //|> sprintf "<!DOCTYPE html>\n<html>\n<body>\n%s\n</body>\n</html>"
|
||||
System.IO.File.WriteAllText (file_name, svg)
|
||||
printfn "Wrote .svg file: %s" file_name
|
||||
#endif
|
||||
|
||||
(* Force constants *)
|
||||
type force_constants =
|
||||
{ pull_factor : float
|
||||
; rot_factor : float
|
||||
; stiffness : float
|
||||
; repulsion : float
|
||||
; repulsion_radius : float }
|
||||
|
||||
let forces =
|
||||
{ pull_factor = 0.2
|
||||
; rot_factor = 1.0
|
||||
; stiffness = 2.0
|
||||
; repulsion = 0.5
|
||||
; repulsion_radius = 15.0 }
|
||||
|
||||
(* Algorithm:
|
||||
Maintain
|
||||
- array of points and springs between points
|
||||
- set of boxes and lines with centres and rotations, knowing which points are their corners and endpoints
|
||||
Each step
|
||||
- calculate forces on all points
|
||||
- translate into translational and rotational forces on boxes and lines
|
||||
- move and rotate boxes and lines
|
||||
- update point coordinates
|
||||
Terminate
|
||||
- when forces are all small
|
||||
- when set number of iterations have occured
|
||||
*)
|
||||
let to_graph_forces force_constants (strands:Strands.t) (Rep s) =
|
||||
(* Setup *)
|
||||
let port_label (i,j) =
|
||||
let st = s.sg.strands.[i]
|
||||
strands.strand_types.[st].[j]
|
||||
let domains_array = s.sg.strands |> Array.mapi (fun i st -> strands.strand_types.[st] |> Array.mapi (fun j _ -> (i,j))) |> Array.concat
|
||||
let domain_map = domains_array |> Array.mapi (fun i d -> {Strands.port.strand=fst d;Strands.port.site=snd d}, i) |> Map.ofArray
|
||||
// usage:
|
||||
// domain_left d = 2 * domain_map.[d]
|
||||
// domain_right d = 2 * domain_map.[d] + 1
|
||||
|
||||
let domain_labels = domains_array |> Array.map port_label
|
||||
let dlength d = domain_labels.[d] |> Strands.domain_to_string |> String.length
|
||||
let dpadding d = if domain_labels.[d].toehold then 0 else 3
|
||||
let line_length d = 8.0 * float (dpadding d + dlength d)
|
||||
|
||||
|
||||
let all_domains = domains_array |> Seq.map (fun domain -> {Strands.port.strand=fst domain; Strands.port.site=snd domain}) |> Set.ofSeq
|
||||
let bound_domains = s.sg.edges |> Set.map (fun (a,b) -> Set.ofList [a; b]) |> Set.unionMany
|
||||
let free_domains = all_domains - bound_domains
|
||||
|
||||
let create_single p =
|
||||
let d = domain_map.[p]
|
||||
{ s_space = { center = origo
|
||||
; angle = 0.0 }
|
||||
; radius = line_length d
|
||||
; line = d }
|
||||
let singles = free_domains |> Set.map create_single
|
||||
|
||||
let create_double (p1,p2) =
|
||||
let d1 = domain_map.[p1]
|
||||
let d2 = domain_map.[p2]
|
||||
{ d_space = { center = origo
|
||||
; angle = 0.0 }
|
||||
; dim = max (line_length d1) (line_length d2), 3.0
|
||||
; upper = d1
|
||||
; lower = d2 }
|
||||
let doubles = s.sg.edges |> Set.map create_double
|
||||
|
||||
let strand_spring i l =
|
||||
[0..l-2] |> List.map (fun j -> right domain_map.[{Strands.port.strand=i;Strands.port.site=j}], left domain_map.[{Strands.port.strand=i;Strands.port.site=j+1}])
|
||||
let springs = s.sg.strands |> Array.mapi (fun i st -> strands.strand_types.[st].Length |> strand_spring i) |> Seq.concat
|
||||
|
||||
let points = Array.create (2 * singles.Count + 4 * doubles.Count) origo
|
||||
let forces = points |> Array.map (fun _ -> origo)
|
||||
|
||||
(* Step functions *)
|
||||
|
||||
(* - calculate forces on all points *)
|
||||
let spring_scale (x,y) = (x * force_constants.pull_factor, y * force_constants.pull_factor)
|
||||
|
||||
let apply_spring (i, j) =
|
||||
let vi = v points.[i] points.[j] |> spring_scale
|
||||
let vj = v points.[j] points.[i] |> spring_scale
|
||||
// here would be a force calculation
|
||||
// but f = d*d, so vi would be normalised then scaled back to itself
|
||||
forces.[i] <- a forces.[i] vi
|
||||
forces.[j] <- a forces.[j] vj
|
||||
|
||||
let apply_springs () =
|
||||
[0..forces.Length-1] |> List.iter (fun i -> forces.[i] <- origo)
|
||||
springs |> Seq.iter apply_spring
|
||||
|
||||
|
||||
(* - translate into translational and rotational forces on boxes and lines *)
|
||||
|
||||
let doubleton a b = new Set<int>(seq [a; b])
|
||||
|
||||
let junctioness = points |> Array.map (fun _ -> 2)
|
||||
let connect_points classes (i:int, j) =
|
||||
let has, has_not = classes |> List.partition (fun c -> Set.contains i c || Set.contains j c)
|
||||
match has with
|
||||
| [] -> (doubleton i j) :: classes
|
||||
| [c] -> Set.union c (doubleton i j) :: has_not
|
||||
| cs -> Set.unionMany cs :: has_not
|
||||
|
||||
let spring_classes = springs |> Seq.fold connect_points []
|
||||
let double_classes = doubles |> Set.toSeq
|
||||
|> Seq.collect (fun d -> [left d.upper, right d.lower; left d.lower, right d.upper])
|
||||
|> Seq.fold connect_points spring_classes
|
||||
let count_class c =
|
||||
let singles_in = singles |> Set.filter (fun s -> Set.contains (left s.line) c
|
||||
|| Set.contains (right s.line) c) |> Set.count
|
||||
let doubles_in = doubles |> Set.filter (fun d -> Set.contains (left d.upper) c
|
||||
|| Set.contains (right d.upper) c
|
||||
|| Set.contains (left d.lower) c
|
||||
|| Set.contains (right d.lower) c) |> Set.count
|
||||
singles_in + doubles_in
|
||||
double_classes |> List.iter (fun c -> let n = count_class c in c |> Set.iter (fun i -> junctioness.[i] <- n))
|
||||
|
||||
let stiff_forces = domains_array |> Array.map (fun _ -> 0.0)
|
||||
let stiffen_springs iteration =
|
||||
[0..stiff_forces.Length-1] |> List.iter (fun i -> stiff_forces.[i] <- 0.0)
|
||||
let line_angles = domains_array |> Array.map (fun _ -> 0.0)
|
||||
singles |> Set.iter (fun s -> line_angles.[s.line] <- s.s_space.angle)
|
||||
doubles |> Set.iter (fun d -> line_angles.[d.upper] <- d.d_space.angle; line_angles.[d.lower] <- d.d_space.angle + pi)
|
||||
let to_line p = p / 2
|
||||
let stiffen_spring (i, j) =
|
||||
let l1 = i |> to_line
|
||||
let l2 = j |> to_line
|
||||
//let double_spring = doubles |> Set.filter (fun d -> d.upper = l1 || d.upper = l2 || d.lower = l1 || d.lower = l2)
|
||||
let target_angle = twopi/(junctioness.[i] |> float) - pi
|
||||
let bend = (target_angle + line_angles.[l2] - line_angles.[l1]) % pi
|
||||
//let double_stiffness = if bend < 0.0 then double_spring.Count + 1 |> float else 1.0
|
||||
stiff_forces.[l1] <- stiff_forces.[l1] + force_constants.stiffness * bend / ((float iteration) * 0.02 + 1.0)
|
||||
stiff_forces.[l2] <- stiff_forces.[l2] - force_constants.stiffness * bend / ((float iteration) * 0.02 + 1.0)
|
||||
springs |> Seq.iter stiffen_spring
|
||||
|
||||
let repel c =
|
||||
let centres =
|
||||
let sc = singles |> Set.map (fun s -> s.s_space.center)
|
||||
let dc = doubles |> Set.map (fun d -> d.d_space.center)
|
||||
sc + dc
|
||||
let profile x = 1.0 - 3.0*x*x + 2.0*x*x*x
|
||||
let f oc =
|
||||
let (vx, vy) = v oc c
|
||||
let r = (d oc c) / force_constants.repulsion_radius |> min 1.0
|
||||
let m = force_constants.repulsion * profile r
|
||||
(m * vx, m * vy)
|
||||
centres |> Set.toSeq |> Seq.map f |> Seq.reduce a
|
||||
|
||||
let compute_box_force (d:double) =
|
||||
let corners =
|
||||
[ left d.lower
|
||||
; right d.lower
|
||||
; left d.upper
|
||||
; right d.upper ]
|
||||
let center_force = corners |> List.map (Array.get forces) |> List.fold a origo
|
||||
let repel_force = repel d.d_space.center
|
||||
let w = n d.dim
|
||||
let rot_force i =
|
||||
let (vx, vy) = v d.d_space.center points.[i]
|
||||
let (fx, fy) = forces.[i]
|
||||
(vx*fy - vy*fx)/(w*w)
|
||||
let angle_force = corners |> List.sumBy rot_force
|
||||
let stiff_force = stiff_forces.[d.lower] + stiff_forces.[d.upper]
|
||||
{ center = a center_force repel_force
|
||||
; angle = force_constants.rot_factor * angle_force + stiff_force }
|
||||
|
||||
let compute_line_force (s:single) =
|
||||
let corners =
|
||||
[ left s.line
|
||||
; right s.line ]
|
||||
let center_force = corners |> List.map (Array.get forces) |> List.fold a origo
|
||||
let repel_force = repel s.s_space.center
|
||||
let w = s.radius
|
||||
let rot_force i =
|
||||
let (vx, vy) = v s.s_space.center points.[i]
|
||||
let (fx, fy) = forces.[i]
|
||||
(vx*fy - vy*fx)/(w*w)
|
||||
let angle_force = corners |> List.sumBy rot_force
|
||||
let stiff_force = stiff_forces.[s.line]
|
||||
{ center = a center_force repel_force
|
||||
; angle = force_constants.rot_factor * angle_force + stiff_force }
|
||||
|
||||
|
||||
(* - move and rotate boxes and lines *)
|
||||
let update_box (d, box_force) =
|
||||
d.d_space.center <- a d.d_space.center box_force.center
|
||||
d.d_space.angle <- d.d_space.angle + box_force.angle
|
||||
|
||||
let update_line (s, line_force) =
|
||||
s.s_space.center <- a s.s_space.center line_force.center
|
||||
s.s_space.angle <- s.s_space.angle + line_force.angle
|
||||
|
||||
let move () =
|
||||
let doubles_forces = doubles |> Set.map (fun d -> d, compute_box_force d)
|
||||
let singles_forces = singles |> Set.map (fun s -> s, compute_line_force s)
|
||||
doubles_forces |> Set.iter update_box
|
||||
singles_forces |> Set.iter update_line
|
||||
|
||||
|
||||
(* - update point coordinates *)
|
||||
let update_points () =
|
||||
let update_double (d:double) =
|
||||
let rx, ry = d.dim
|
||||
let p = t d.d_space.center d.d_space.angle
|
||||
points.[left d.upper] <- p (-rx, ry)
|
||||
points.[right d.upper] <- p ( rx, ry)
|
||||
points.[left d.lower] <- p ( rx, -ry) // lower runs in the other direction
|
||||
points.[right d.lower] <- p (-rx, -ry)
|
||||
let update_single (s:single) =
|
||||
let rx, ry = s.radius, 0.0
|
||||
let p = t s.s_space.center s.s_space.angle
|
||||
points.[left s.line] <- p (-rx, ry)
|
||||
points.[right s.line] <- p ( rx, ry)
|
||||
doubles |> Set.iter update_double
|
||||
singles |> Set.iter update_single
|
||||
|
||||
|
||||
(* Set up *)
|
||||
doubles |> Set.iter (fun d -> d.d_space |> randomize_space)
|
||||
singles |> Set.iter (fun s -> s.s_space |> randomize_space)
|
||||
update_points ()
|
||||
|
||||
(* Report *)
|
||||
let g d =
|
||||
{ s_points = points
|
||||
; strands = s.sg.strands |> Array.mapi (fun i st -> strands.strand_types.[st] |> Array.mapi (fun j _ -> domain_map.[{Strands.port.strand=i;Strands.port.site=j}]))
|
||||
; domains = domain_labels
|
||||
; dim = d }
|
||||
|
||||
(* Iterate *)
|
||||
let max_iterations = 501
|
||||
let to_debug = [0; 1; 2; 4; 12; 31; 64; 120; 204; 328; 500]
|
||||
let mutable i = 0
|
||||
let prefix = (System.DateTime.Now.ToLongTimeString ()).Replace(':', '-')
|
||||
while i < max_iterations do // TODO: consider forces
|
||||
#if JavaScript
|
||||
#else
|
||||
if debug && List.exists ((=) i) to_debug then
|
||||
let xs, ys = points |> Array.unzip
|
||||
let min_x, max_x = Array.min xs - 30.0, Array.max xs + 30.0
|
||||
let min_y, max_y = Array.min ys - 30.0, Array.max ys + 30.0
|
||||
points |> Array.iteri (fun i (x,y) -> points.[i] <- (x - min_x, y - min_y))
|
||||
g (max_x - min_x, max_y - min_y) |> export_graph (sprintf "%s_iteration%d.svg" prefix i) (dom_style (new System.Collections.Generic.Dictionary<string,string>()) strands) // debug
|
||||
#endif
|
||||
apply_springs ()
|
||||
stiffen_springs i
|
||||
move ()
|
||||
update_points ()
|
||||
i <- i + 1
|
||||
|
||||
(* Normalise *)
|
||||
(* - rotation *)
|
||||
let doubles_lengths = doubles |> Set.toSeq |> Seq.map (fun d -> fst d.dim, d.d_space.angle)
|
||||
let singles_lengths = singles |> Set.toSeq |> Seq.map (fun s -> s.radius, s.s_space.angle)
|
||||
let angle = Seq.append doubles_lengths singles_lengths |> Seq.maxBy fst |> snd
|
||||
|
||||
let rotate (x,y) = (x * cos angle + y * sin angle, -x * sin angle + y * cos angle)
|
||||
points |> Array.iteri (fun i p -> points.[i] <- rotate p)
|
||||
(* - translation *)
|
||||
let xs, ys = points |> Array.unzip
|
||||
let min_x, max_x = Array.min xs - 30.0, Array.max xs + 30.0
|
||||
let min_y, max_y = Array.min ys - 30.0, Array.max ys + 30.0
|
||||
points |> Array.iteri (fun i (x,y) -> points.[i] <- (x - min_x, y - min_y))
|
||||
|
||||
g (max_x - min_x, max_y - min_y)
|
||||
let to_graph = to_graph_forces forces
|
||||
|
||||
let to_svg assigned strands = to_graph strands >> wrap_group (dom_style assigned strands)
|
||||
let to_svg_forces force_constants assigned strands = to_graph_forces force_constants strands >> wrap_group (dom_style assigned strands)
|
||||
let to_svg_inner strands = to_graph strands >> s_graph_to_svg
|
||||
|
||||
#if JavaScript
|
||||
#else
|
||||
let export_svg filename strands = to_graph strands >> export_graph filename (dom_style (new System.Collections.Generic.Dictionary<string,string>()) strands)
|
||||
#endif
|
|
@ -0,0 +1,486 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.States
|
||||
|
||||
type t<'s> when 's:comparison = Map<'s,int>
|
||||
|
||||
let groups_to_svg assigned strands =
|
||||
let view_species (max_w, y, svgs) (g: Species.s_graph, i) =
|
||||
let w, h = g.dim
|
||||
let svg = g |> Species.s_graph_to_svg |> sprintf "<g class=\"species\" transform=\"translate(20,%f)\">\n<text transform=\"translate(0,%f)\">%d </text>%s</g>" y (8.0 + h/2.0) i
|
||||
max w max_w, h + y, svg::svgs
|
||||
|
||||
let box_state (width, height, svgs) =
|
||||
let w, h = width + 20.0, height
|
||||
( svgs |> String.concat "\n"
|
||||
|> sprintf "<rect width=\"%f\" height=\"%f\" style=\"fill:none;stroke:black;stroke-width:4\" />\n%s" w h
|
||||
//|> sprintf "<g transform=\"translate(%f,%f)\">%s</g>" (-w/2.0) (-h/2.0)
|
||||
, w
|
||||
, h )
|
||||
|
||||
Seq.fold view_species (0.0, 0.0, [])
|
||||
>> box_state
|
||||
>> fun (s, w, h) -> Species.wrap_svg (Species.dom_style assigned strands) (sprintf "<g class=\"state\">%s</g>" s) (w,h)
|
||||
|
||||
let to_svg assigned strands = Map.toSeq >> Seq.map (fun (s, i) -> s |> Species.to_graph strands, i) >> groups_to_svg assigned strands
|
||||
|
||||
let state_of_species species : 's t = species |> Seq.fold (fun sm (i,s) -> Map.add s i sm) Map.empty
|
||||
|
||||
let reactions_on_state enzymes strands (st: Species.rep t) =
|
||||
st |> Map.toSeq |> Seq.map fst
|
||||
|> Seq.fold (fun (ss,rs) s -> s::ss, rs + Reactions.actions enzymes strands ss s) ([], Set.empty)
|
||||
|> snd
|
||||
|
||||
let decrement state s : 's t =
|
||||
let c = Map.find s state
|
||||
if c = 1 then Map.remove s state
|
||||
else Map.add s (c-1) state
|
||||
|
||||
let increment state s : 's t =
|
||||
match Map.tryFind s state with
|
||||
| None -> Map.add s 1 state
|
||||
| Some c -> Map.add s (c+1) state
|
||||
|
||||
let product_conc state = function
|
||||
| Reactions.Isolated_toehold (s, _, _)
|
||||
| Reactions.Complement_int (s, _, _)
|
||||
| Reactions.Displacing (s, _, _)
|
||||
| Reactions.Nick (s, _, _) -> Map.find s state
|
||||
| Reactions.Complement_ext (Species.Rep s1 as r1, (Species.Rep s2 as r2), _, _) ->
|
||||
if s1.sg = s2.sg then
|
||||
let c = Map.find r1 state
|
||||
(c * (c-1)) / 2
|
||||
else Map.find r1 state * Map.find r2 state
|
||||
|
||||
let reaction_propensity toehold_map strands state r =
|
||||
let rate = Reactions.get_rate toehold_map strands
|
||||
rate r * (product_conc state r |> float)
|
||||
|
||||
let applies toehold_map strands state = reaction_propensity toehold_map strands state >> (<) 0.0
|
||||
|
||||
let apply state = function
|
||||
| Reactions.Isolated_toehold (s, _, ss) -> List.fold increment (decrement state s) (ss |> List.map fst)
|
||||
| Reactions.Complement_int (s1, _, (s2,_)) -> increment (decrement state s1) s2
|
||||
| Reactions.Complement_ext (s1, s2, _, (s3,_)) -> increment (decrement (decrement state s1) s2) s3
|
||||
| Reactions.Displacing (s, _, ss) -> List.fold increment (decrement state s) (ss |> List.map fst)
|
||||
| Reactions.Nick (s1, _, (s2,_)) -> increment (decrement state s1) s2
|
||||
|
||||
let state_space limit enzymes toehold_map strands species =
|
||||
let rate = Reactions.get_rate toehold_map strands
|
||||
let applies = applies toehold_map strands
|
||||
let reactions_on = reactions_on_state enzymes strands
|
||||
|
||||
let rec work transitions states l =
|
||||
match l with
|
||||
| [] -> states, transitions
|
||||
| w::ws ->
|
||||
if limit > 0 && (Set.count states > limit) then (w::ws |> Set.ofList |> Set.union states), transitions else
|
||||
printfn "States: %d" (Set.count states)
|
||||
let rs = reactions_on w |> Set.filter (applies w)
|
||||
let ts = rs |> Set.map (fun r -> w, rate r, apply w r)
|
||||
let is_new s = Set.contains s states |> not
|
||||
let new_ws = ts |> Set.map (fun (_,_,x) -> x) |> Set.filter is_new |> Set.toList
|
||||
work (Set.union transitions ts) (Set.add w states) (ws @ new_ws)
|
||||
work Set.empty Set.empty [state_of_species species]
|
||||
|
||||
let choices (_,l) =
|
||||
let n, c = l |> Seq.fold (fun (n,r) (_,i) -> n + 1, r * (i-n)) (0, 1)
|
||||
c / n
|
||||
|
||||
let state_space_c limit (c: 's Calculus.t) species =
|
||||
let propensity (st: 's t) (r: 's Calculus.reaction) =
|
||||
r.reactants
|
||||
|> Seq.map (fun p -> p, match Map.tryFind p st with None -> 0 | Some c -> c)
|
||||
|> Seq.groupBy fst
|
||||
|> Seq.map (choices >> float)
|
||||
|> Seq.fold (*) r.rate
|
||||
let applies st = propensity st >> (<) 0.0
|
||||
let apply st (r: 's Calculus.reaction) =
|
||||
List.fold increment (List.fold decrement st r.reactants) r.products
|
||||
let reactions_on (st: 's t) =
|
||||
st |> Map.toSeq |> Seq.map fst
|
||||
|> Seq.fold (fun (ss,rs) s -> Set.add s ss, rs + c.reactions ss s) (Set.empty, Set.empty)
|
||||
|> snd
|
||||
|
||||
let rec work transitions states l =
|
||||
match l with
|
||||
| [] ->
|
||||
printfn "States: %d" (Set.count states)
|
||||
states, transitions
|
||||
| w::ws ->
|
||||
let count = states.Count + l.Length
|
||||
if limit > 0 && count > limit then (w::ws |> Set.ofList |> Set.union states), transitions else
|
||||
printfn "States: %d" count
|
||||
let rs = reactions_on w |> Set.filter (applies w)
|
||||
printfn "\t(Current state has %i species and %i reactions)" w.Count rs.Count
|
||||
let ts = rs |> Set.map (fun r -> w, propensity w r, apply w r)
|
||||
let is_new s = not <| Set.contains s states // and not s in ws
|
||||
let new_ws = ts |> Set.map (fun (_,_,x) -> x) |> Set.filter is_new |> Set.toList
|
||||
work (Set.union transitions ts) (Set.add w states) (ws @ new_ws)
|
||||
work Set.empty Set.empty [state_of_species species]
|
||||
|
||||
let state_html assigned strands st i =
|
||||
st |> Map.toSeq
|
||||
|> Seq.map (fun (s, n) -> Species.to_svg assigned strands s |> sprintf "<tr>\n<td><h3>%d of</h3></td>\n<td>%s</td>\n</tr>" n)
|
||||
|> String.concat "\n"
|
||||
|> sprintf "<h1>State %d</h1>\n<table>\n%s\n</table>" i
|
||||
|
||||
let reactions_html assigned strands animations rs =
|
||||
let split_reaction =
|
||||
function
|
||||
| Reactions.Complement_ext (r1, r2, _, p) -> [r1; r2], [p]
|
||||
| Reactions.Complement_int (r, _, p) -> [r], [p]
|
||||
| Reactions.Displacing (r, _, ps) -> [r], ps
|
||||
| Reactions.Isolated_toehold (r, _, ps) -> [r], ps
|
||||
| Reactions.Nick (r, _, p) -> [r], [p]
|
||||
let reaction_row_data (r,rate) =
|
||||
let td_no_border = sprintf "<td style = \"border: 0;\">%s</td>"
|
||||
let rs, ps = split_reaction r
|
||||
seq {
|
||||
if animations then yield r |> Reactions.to_svg assigned strands |> td_no_border
|
||||
else
|
||||
yield rs |> List.map (Species.to_svg assigned strands) |> String.concat "<h3>+</h3>" |> td_no_border
|
||||
yield rate |> sprintf "<h1>→</h1> (%.3f)" |> td_no_border
|
||||
yield ps |> List.map (fst >> Species.to_svg assigned strands) |> String.concat "<h3>+</h3>" |> td_no_border
|
||||
} |> String.concat "\n"
|
||||
rs |> Array.mapi (fun i r -> sprintf "<tr><td><h3>%d:</h3></td>\n%s</tr>" i (reaction_row_data r))
|
||||
|> String.concat "\n"
|
||||
|> sprintf "<h2>Reactions</h2>\n<table>\n%s\n</table>"
|
||||
|
||||
|
||||
#if JavaScript
|
||||
#else
|
||||
(* Interactive mode *)
|
||||
let state_space_interactive assigned next_choice limit animations enzymes toehold_map strands species =
|
||||
let propensity = reaction_propensity toehold_map strands //Reactions.get_rate toehold_map strands
|
||||
let applies = applies toehold_map strands
|
||||
let reactions_on = reactions_on_state enzymes strands
|
||||
|
||||
let states = new System.Collections.Generic.Dictionary<Species.rep t,int>(HashIdentity.Structural)
|
||||
let current = species |> state_of_species
|
||||
states.Add (current, 0)
|
||||
let get_state s =
|
||||
if states.ContainsKey s then states.[s]
|
||||
else
|
||||
let n = states.Count
|
||||
states.Add (s, n)
|
||||
n
|
||||
|
||||
let species_svg = new System.Collections.Generic.Dictionary<Species.rep,_>(HashIdentity.Structural)
|
||||
let get_species_svg s =
|
||||
if species_svg.ContainsKey s then species_svg.[s]
|
||||
else
|
||||
let g = Species.to_graph strands s
|
||||
species_svg.Add (s, g)
|
||||
g
|
||||
|
||||
let states_svg = new System.Collections.Generic.Dictionary<Species.rep t,_>(HashIdentity.Structural)
|
||||
let get_state_svg assigned s =
|
||||
if states_svg.ContainsKey s then states_svg.[s]
|
||||
else
|
||||
let svg =
|
||||
s |> Map.toSeq |> Seq.map (fun (sp, i) -> get_species_svg sp, i) |> groups_to_svg assigned strands
|
||||
states_svg.Add (s, svg)
|
||||
svg
|
||||
|
||||
let trace_choices = ref []
|
||||
let trace_reactions = ref []
|
||||
let trace_states = ref (Set.singleton current)
|
||||
let transitions = ref Set.empty
|
||||
let trace_probability = ref 1.0
|
||||
|
||||
let port_label (s:Species.t) (port:Strands.port) =
|
||||
let d = (strands.strand_types.[s.sg.strands.[port.strand]]).[port.site] |> Strands.domain_to_string
|
||||
sprintf "(%d,%d) %s" port.strand port.site d
|
||||
let edge_label s (np:Strands.port,_:Strands.port) = port_label s np
|
||||
|
||||
let label i =
|
||||
let indent = String.replicate i " "
|
||||
function
|
||||
| Reactions.Isolated_toehold (Species.Rep s as r, e,_) -> sprintf "Unbind %s on\n%s%s" (edge_label s e) indent (Species.to_string_i i strands r)
|
||||
| Reactions.Complement_int (Species.Rep s as r, e,_) -> sprintf "Internal bind %s on\n%s%s" (edge_label s e) indent (Species.to_string_i i strands r)
|
||||
| Reactions.Complement_ext (Species.Rep s as r1, r2, e,_) -> sprintf "External bind %s on\n%s%s\n%sand\n%s%s" (edge_label s e) indent (Species.to_string_i i strands r1) indent indent (Species.to_string_i i strands r2)
|
||||
| Reactions.Displacing (Species.Rep s as r, es,_) -> es |> List.map (edge_label s) |> String.concat " " |> sprintf "Displace %s on\n%s%s" (Species.to_string_i i strands r) indent
|
||||
| Reactions.Nick (Species.Rep s as r,np,_) -> sprintf "Nick %s on\n%s%s" (port_label s np) indent (Species.to_string_i i strands r)
|
||||
|
||||
let export c_s =
|
||||
(*
|
||||
//let state_space = (states.Keys |> Set.ofSeq, !transitions)
|
||||
let state_space = (!trace_states, !transitions)
|
||||
let ss_dot = state_space_to_dot strands state_space species
|
||||
let ss_out_file = "trace.dot"//System.IO.Path.Combine(System.IO.Path.GetDirectoryName !in_file, sprintf "%s_ss.dot" (System.IO.Path.GetFileNameWithoutExtension !in_file))
|
||||
System.IO.File.WriteAllText(ss_out_file, ss_dot);
|
||||
printfn "Wrote state space file %s" ss_out_file;
|
||||
*)
|
||||
let trace_dot = !trace_reactions |> List.rev |> Reactions.trace_to_dot strands c_s
|
||||
let trace_out_file = "trace.dot"
|
||||
System.IO.File.WriteAllText(trace_out_file, trace_dot)
|
||||
printfn "Wrote trace file %s" trace_out_file
|
||||
|
||||
let export_svg cs =
|
||||
let title = !trace_probability |> sprintf "Trace with probability %.3f"
|
||||
let trace_svg =
|
||||
!trace_reactions
|
||||
|> List.collect (fun (c,r,p) -> ["<h1>↓</h1>"; Reactions.to_svg assigned strands r; sprintf "<h1>↓</h1> (%.3f)" p; get_state_svg assigned c ])
|
||||
|> fun l -> get_state_svg assigned cs :: l
|
||||
|> List.rev
|
||||
|> List.map (sprintf "<tr><td>%s</td></tr>")
|
||||
|> String.concat "\n"
|
||||
|> sprintf
|
||||
"<html>\n<head><title>%s</title></head>\n<body>\n<h1>%s</h1>\n<table style=\"text-align: center\" width=\"100%%\">%s</table>\n</body>\n</html>"
|
||||
title title
|
||||
let trace_out_file = "trace.html"
|
||||
System.IO.File.WriteAllText(trace_out_file, trace_svg)
|
||||
printfn "Wrote trace file %s" trace_out_file
|
||||
|
||||
let export_trace () =
|
||||
let trace_txt =
|
||||
!trace_choices |> List.tail |> // remove the choice to export a trace
|
||||
function "e"::cs | "E"::cs | cs -> "q" :: "e" :: cs |> List.rev |> String.concat "\n"
|
||||
let trace_out_file = "trace.txt"
|
||||
System.IO.File.WriteAllText(trace_out_file, trace_txt)
|
||||
printfn "Wrote trace file %s" trace_out_file
|
||||
|
||||
(*
|
||||
let export_state st i =
|
||||
st |> Map.toSeq
|
||||
|> Seq.iteri (fun j (s, n) -> Species.export_svg (sprintf "state_%d_species_%d_count_%d.svg" i j n) strands s)
|
||||
*)
|
||||
|
||||
let export_state st i rs =
|
||||
let state_file = "state.html"
|
||||
let html = sprintf "<html>\n<head></head>\n<body>\n%s\n%s\n</body>\n</html>"
|
||||
(state_html assigned strands st i)
|
||||
(reactions_html assigned strands animations rs)
|
||||
|
||||
System.IO.File.WriteAllText(state_file, html)
|
||||
printfn "Wrote state file %s" state_file
|
||||
|
||||
let rec work c_s c_i =
|
||||
printfn "You are at state %d" c_i
|
||||
printfn "Choose your action:"
|
||||
let rs = reactions_on c_s |> Set.filter (applies c_s) |> Set.toArray
|
||||
let rs_meta = rs |> Array.map (fun r -> let t = apply c_s r in r, c_s, propensity c_s r, t, get_state t)
|
||||
export_state c_s c_i (rs_meta |> Array.map (fun (r, c_s, prop, t, id) -> r, prop)) // debug
|
||||
let ts = rs_meta |> Array.map (fun (_, cs, prop, t, _) -> cs, prop, t)
|
||||
let total_prop = ts |> Array.sumBy (fun (_, prop, _) -> prop)
|
||||
|> function 0.0 -> 1.0 | x -> x // if total_prop is zero, do no division of all the zeroes
|
||||
let choices = rs_meta |> Array.map (fun (r, _, prop, t, target_id) -> r, prop / total_prop, t, target_id)
|
||||
choices |> Array.iteri (fun i (r, prob,_,target_id) ->
|
||||
let g = sprintf " %d: (%f) Goto state %d via" i prob target_id
|
||||
let l = label (String.length g + 1) r
|
||||
printfn "%s %s" g l
|
||||
)
|
||||
printfn "p: Print state"
|
||||
printfn "e: Export traversed path to .svg"
|
||||
printfn "t: Export choices to .txt"
|
||||
printfn "q: Quit"
|
||||
let c = next_choice ()
|
||||
trace_choices := c :: !trace_choices
|
||||
match c with
|
||||
| "p" | "P" -> c_s |> Map.iter (fun s i -> printfn " %d * %s" i (Species.to_string_i 5 strands s)); work c_s c_i
|
||||
| "e" | "E" -> export_svg c_s; work c_s c_i
|
||||
| "t" | "T" -> export_trace (); work c_s c_i
|
||||
| "q" | "Q" -> ()
|
||||
| _ ->
|
||||
try
|
||||
let i = int c
|
||||
let r, prob, target, target_id = choices.[i]
|
||||
trace_reactions := (c_s,r,prob) :: !trace_reactions
|
||||
trace_states := Set.add target !trace_states
|
||||
transitions := Set.add ts.[i] !transitions
|
||||
trace_probability := prob * !trace_probability
|
||||
work target target_id
|
||||
with _ ->
|
||||
printfn "Unrecognized choice %s" c
|
||||
work c_s c_i
|
||||
work current 0
|
||||
|
||||
(* TODO
|
||||
let state_space_interactive_c next_choice limit animations (c: 's Calculus.t) strands species =
|
||||
let propensity (st: 's t) (r: 's Calculus.reaction) =
|
||||
r.reactants
|
||||
|> Seq.map (fun p -> p, match Map.tryFind p st with None -> 0 | Some c -> c)
|
||||
|> Seq.groupBy fst
|
||||
|> Seq.map (choices >> float)
|
||||
|> Seq.fold (*) r.rate
|
||||
let applies st = propensity st >> (<) 0.0
|
||||
let apply st (r: 's Calculus.reaction) =
|
||||
List.fold increment (List.fold decrement st r.reactants) r.products
|
||||
let reactions_on (st: 's t) =
|
||||
st |> Map.toSeq |> Seq.map fst
|
||||
|> Seq.fold (fun (ss,rs) s -> Set.add s ss, rs + c.reactions ss s) (Set.empty, Set.empty)
|
||||
|> snd
|
||||
|
||||
let states = new System.Collections.Generic.Dictionary<Species.rep t,int>(HashIdentity.Structural)
|
||||
let current = species |> state_of_species
|
||||
states.Add (current, 0)
|
||||
let get_state s =
|
||||
if states.ContainsKey s then states.[s]
|
||||
else
|
||||
let n = states.Count
|
||||
states.Add (s, n)
|
||||
n
|
||||
|
||||
let species_svg = new System.Collections.Generic.Dictionary<Species.rep,_>(HashIdentity.Structural)
|
||||
let get_species_svg s =
|
||||
if species_svg.ContainsKey s then species_svg.[s]
|
||||
else
|
||||
let g = Species.to_graph strands s
|
||||
species_svg.Add (s, g)
|
||||
g
|
||||
|
||||
let states_svg = new System.Collections.Generic.Dictionary<Species.rep t,_>(HashIdentity.Structural)
|
||||
let get_state_svg s =
|
||||
if states_svg.ContainsKey s then states_svg.[s]
|
||||
else
|
||||
let svg =
|
||||
s |> Map.toSeq |> Seq.map (fun (sp, i) -> get_species_svg sp, i) |> groups_to_svg strands
|
||||
states_svg.Add (s, svg)
|
||||
svg
|
||||
|
||||
let trace_choices = ref []
|
||||
let trace_reactions = ref []
|
||||
let trace_states = ref (Set.singleton current)
|
||||
let transitions = ref Set.empty
|
||||
let trace_probability = ref 1.0
|
||||
|
||||
let port_label (s:Species.t) (port:Strands.port) =
|
||||
let d = (strands.strand_types.[s.sg.strands.[port.strand]]).[port.site] |> Strands.domain_to_string
|
||||
sprintf "(%d,%d) %s" port.strand port.site d
|
||||
let edge_label s (np:Strands.port,_:Strands.port) = port_label s np
|
||||
|
||||
let label i =
|
||||
let indent = String.replicate i " "
|
||||
function
|
||||
| Reactions.Isolated_toehold (Species.Rep s as r, e,_) -> sprintf "Unbind %s on\n%s%s" (edge_label s e) indent (Species.to_string_i i strands r)
|
||||
| Reactions.Complement_int (Species.Rep s as r, e,_) -> sprintf "Internal bind %s on\n%s%s" (edge_label s e) indent (Species.to_string_i i strands r)
|
||||
| Reactions.Complement_ext (Species.Rep s as r1, r2, e,_) -> sprintf "External bind %s on\n%s%s\n%sand\n%s%s" (edge_label s e) indent (Species.to_string_i i strands r1) indent indent (Species.to_string_i i strands r2)
|
||||
| Reactions.Displacing (Species.Rep s as r, es,_) -> es |> List.map (edge_label s) |> String.concat " " |> sprintf "Displace %s on\n%s%s" (Species.to_string_i i strands r) indent
|
||||
| Reactions.Nick (Species.Rep s as r,np,_) -> sprintf "Nick %s on\n%s%s" (port_label s np) indent (Species.to_string_i i strands r)
|
||||
|
||||
let export c_s =
|
||||
(*
|
||||
//let state_space = (states.Keys |> Set.ofSeq, !transitions)
|
||||
let state_space = (!trace_states, !transitions)
|
||||
let ss_dot = state_space_to_dot strands state_space species
|
||||
let ss_out_file = "trace.dot"//System.IO.Path.Combine(System.IO.Path.GetDirectoryName !in_file, sprintf "%s_ss.dot" (System.IO.Path.GetFileNameWithoutExtension !in_file))
|
||||
System.IO.File.WriteAllText(ss_out_file, ss_dot);
|
||||
printfn "Wrote state space file %s" ss_out_file;
|
||||
*)
|
||||
let trace_dot = !trace_reactions |> List.rev |> Reactions.trace_to_dot strands c_s
|
||||
let trace_out_file = "trace.dot"
|
||||
System.IO.File.WriteAllText(trace_out_file, trace_dot)
|
||||
printfn "Wrote trace file %s" trace_out_file
|
||||
|
||||
let export_svg cs =
|
||||
let title = !trace_probability |> sprintf "Trace with probability %.3f"
|
||||
let trace_svg =
|
||||
!trace_reactions
|
||||
|> List.collect (fun (c,r,p) -> ["<h1>↓</h1>"; Reactions.to_svg strands r; sprintf "<h1>↓</h1> (%.3f)" p; get_state_svg c ])
|
||||
|> fun l -> get_state_svg cs :: l
|
||||
|> List.rev
|
||||
|> List.map (sprintf "<tr><td>%s</td></tr>")
|
||||
|> String.concat "\n"
|
||||
|> sprintf
|
||||
"<html>\n<head><title>%s</title></head>\n<body>\n<h1>%s</h1>\n<table style=\"text-align: center\" width=\"100%%\">%s</table>\n</body>\n</html>"
|
||||
title title
|
||||
let trace_out_file = "trace.html"
|
||||
System.IO.File.WriteAllText(trace_out_file, trace_svg)
|
||||
printfn "Wrote trace file %s" trace_out_file
|
||||
|
||||
let export_trace () =
|
||||
let trace_txt =
|
||||
!trace_choices |> List.tail |> // remove the choice to export a trace
|
||||
function "e"::cs | "E"::cs | cs -> "q" :: "e" :: cs |> List.rev |> String.concat "\n"
|
||||
let trace_out_file = "trace.txt"
|
||||
System.IO.File.WriteAllText(trace_out_file, trace_txt)
|
||||
printfn "Wrote trace file %s" trace_out_file
|
||||
|
||||
(*
|
||||
let export_state st i =
|
||||
st |> Map.toSeq
|
||||
|> Seq.iteri (fun j (s, n) -> Species.export_svg (sprintf "state_%d_species_%d_count_%d.svg" i j n) strands s)
|
||||
*)
|
||||
|
||||
let export_state st i rs =
|
||||
let state_file = "state.html"
|
||||
let html = sprintf "<html>\n<head></head>\n<body>\n%s\n%s\n</body>\n</html>"
|
||||
(state_html strands st i)
|
||||
(reactions_html strands animations rs)
|
||||
|
||||
System.IO.File.WriteAllText(state_file, html)
|
||||
printfn "Wrote state file %s" state_file
|
||||
|
||||
let rec work c_s c_i =
|
||||
printfn "You are at state %d" c_i
|
||||
printfn "Choose your action:"
|
||||
let rs = reactions_on c_s |> Set.filter (applies c_s) |> Set.toArray
|
||||
let rs_meta = rs |> Array.map (fun r -> let t = apply c_s r in r, c_s, propensity c_s r, t, get_state t)
|
||||
export_state c_s c_i (rs_meta |> Array.map (fun (r, c_s, prop, t, id) -> r, prop)) // debug
|
||||
let ts = rs_meta |> Array.map (fun (_, cs, prop, t, _) -> cs, prop, t)
|
||||
let total_prop = ts |> Array.sumBy (fun (_, prop, _) -> prop)
|
||||
|> function 0.0 -> 1.0 | x -> x // if total_prop is zero, do no division of all the zeroes
|
||||
let choices = rs_meta |> Array.map (fun (r, _, prop, t, target_id) -> r, prop / total_prop, t, target_id)
|
||||
choices |> Array.iteri (fun i (r, prob,_,target_id) ->
|
||||
let g = sprintf " %d: (%f) Goto state %d via" i prob target_id
|
||||
let l = label (String.length g + 1) r
|
||||
printfn "%s %s" g l
|
||||
)
|
||||
printfn "p: Print state"
|
||||
printfn "e: Export traversed path to .svg"
|
||||
printfn "t: Export choices to .txt"
|
||||
printfn "q: Quit"
|
||||
let c = next_choice ()
|
||||
trace_choices := c :: !trace_choices
|
||||
match c with
|
||||
| "p" | "P" -> c_s |> Map.iter (fun s i -> printfn " %d * %s" i (Species.to_string_i 5 strands s)); work c_s c_i
|
||||
| "e" | "E" -> export_svg c_s; work c_s c_i
|
||||
| "t" | "T" -> export_trace (); work c_s c_i
|
||||
| "q" | "Q" -> ()
|
||||
| _ ->
|
||||
try
|
||||
let i = int c
|
||||
let r, prob, target, target_id = choices.[i]
|
||||
trace_reactions := (c_s,r,prob) :: !trace_reactions
|
||||
trace_states := Set.add target !trace_states
|
||||
transitions := Set.add ts.[i] !transitions
|
||||
trace_probability := prob * !trace_probability
|
||||
work target target_id
|
||||
with _ ->
|
||||
printfn "Unrecognized choice %s" c
|
||||
work c_s c_i
|
||||
work current 0
|
||||
*)
|
||||
|
||||
// Interactive object
|
||||
type StateGraph (enzymes, toehold_map, strands, ss) =
|
||||
let rate = Reactions.get_rate toehold_map strands
|
||||
let applies = applies toehold_map strands
|
||||
let reactions_on = reactions_on_state enzymes strands
|
||||
let compute_reactions s = reactions_on s |> Set.filter (applies s) |> Set.toArray |> Array.map (fun r -> r, rate r)
|
||||
|
||||
let mutable state = state_of_species ss
|
||||
let mutable state_index = 0
|
||||
let mutable reactions = compute_reactions state
|
||||
|
||||
let states = (new System.Collections.Generic.Dictionary<Species.rep t,int>(HashIdentity.Structural))
|
||||
let _ = states.Add (state, state_index)
|
||||
let get_state_index s =
|
||||
if states.ContainsKey s then states.[s]
|
||||
else
|
||||
let n = states.Count
|
||||
states.Add (s, n)
|
||||
n
|
||||
|
||||
member this.apply_reaction n =
|
||||
state <- apply state (fst reactions.[n])
|
||||
state_index <- get_state_index state
|
||||
reactions <- compute_reactions state
|
||||
|
||||
member this.show_state = state_html (new System.Collections.Generic.Dictionary<string,string>()) strands state state_index
|
||||
|
||||
member this.show_reactions animations = reactions_html (new System.Collections.Generic.Dictionary<string,string>()) strands animations reactions
|
||||
#endif
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.Strands
|
||||
|
||||
type domain =
|
||||
{ name : string
|
||||
; complemented : bool
|
||||
; toehold : bool }
|
||||
|
||||
let domain_to_string d = sprintf "%s%s%s" d.name (if d.toehold then "^" else "") (if d.complemented then "*" else "")
|
||||
|
||||
let complementary d1 d2 = d1.name = d2.name && d1.toehold = d2.toehold && d1.complemented <> d2.complemented
|
||||
|
||||
type strand = domain array
|
||||
|
||||
let strand_to_string = Array.map domain_to_string >> String.concat " " >> sprintf "<%s>"
|
||||
|
||||
type port =
|
||||
{ strand : int
|
||||
; site : int }
|
||||
|
||||
//Probably an edge but files are ordered such "edge" is defined later, can we share definition?
|
||||
type port_pair =
|
||||
{ port1 : port
|
||||
; port2 : port }
|
||||
|
||||
type t =
|
||||
{ strand_types : strand array
|
||||
; admissible_edges : Map<port_pair, bool> } // true is toehold, false is non-toehold
|
||||
|
||||
let type_to_string t i = strand_to_string t.strand_types.[i]
|
|
@ -0,0 +1,83 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.Syntax
|
||||
open Parser
|
||||
|
||||
(* Syntax *)
|
||||
type site =
|
||||
{ domain : Strands.domain
|
||||
; binding : string option }
|
||||
type strand = site list
|
||||
|
||||
type complex = strand list
|
||||
type complexes = (int * complex) list
|
||||
|
||||
type toehold =
|
||||
{ name : string
|
||||
; bind_rate : float
|
||||
; unbind_rate : float }
|
||||
|
||||
type t = toehold list * complexes
|
||||
|
||||
(* Parsing *)
|
||||
let mk_domain ((n, t), c) =
|
||||
{ SiteGraphReactor.Strands.name = n
|
||||
; SiteGraphReactor.Strands.complemented = c
|
||||
; SiteGraphReactor.Strands.toehold = t }
|
||||
|
||||
let mk_site (d, b) =
|
||||
{ domain = d
|
||||
; binding = b }
|
||||
|
||||
let parse_name = many1Satisfy (fun c -> isLetter c || isDigit c || c = '_')
|
||||
|
||||
let after p s = p .>>. opt (pstring s) |>> function n, None -> (n, false) | n,_ -> (n,true)
|
||||
|
||||
let parse_domain name =
|
||||
let domainname = after name "^"
|
||||
after domainname "*" |>> mk_domain
|
||||
|
||||
let parse_site name =
|
||||
name |> parse_domain .>>. (pstring "!" >>. name |> opt) |>> mk_site
|
||||
|
||||
let kw s = pstring s .>> spaces
|
||||
let skw s = spaces >>. kw s
|
||||
|
||||
let bracket l r = between (kw l) (skw r)
|
||||
|
||||
let parse_toehold =
|
||||
kw "new" >>. parse_name .>> kw "@" .>>. (pfloat .>> skw "," .>>. pfloat)
|
||||
|>> fun (n, (b, u)) -> { name = n; bind_rate = b; unbind_rate = u }
|
||||
|
||||
let counted p =
|
||||
p |>> (fun s -> (1,s))
|
||||
<|>
|
||||
((pint32 .>> skw "*") .>>. p)
|
||||
|
||||
let sep_by_bars p = sepBy1 p (skw "|")
|
||||
|
||||
let errMsg msg (r, c) = sprintf "Expecting %s at row %d column %d" msg (r+1) (c+1)
|
||||
let run_parser p s =
|
||||
match run_result p s with
|
||||
| OkEmpty (result, _)
|
||||
| OkConsumed (result, _) -> result
|
||||
| FailEmpty (error, (r,c))
|
||||
| FailConsumed (error, (r,c)) -> raise (Exception(errMsg error (r,c), [|{row=r+1; column=c; text=error}|] ))
|
||||
|
||||
let parser_syntax site =
|
||||
let sites = sepBy1 site spaces1
|
||||
let strands = sites |> bracket "<" ">" |> sep_by_bars
|
||||
|
||||
let complex = strands |> bracket "[" "]"
|
||||
let complexes = complex |> counted |> sep_by_bars
|
||||
|
||||
let species = complexes <|> (strands |>> fun s -> [(1,s)] )
|
||||
|
||||
spaces >>. sepEndBy parse_toehold spaces1 .>>. species .>> spaces .>> eof
|
||||
|
||||
//let parse_syntax site = parser_syntax site |> run_parser
|
||||
|
||||
let parser = parse_name |> parse_site |> parser_syntax
|
||||
let parse = parser |> run_parser
|
|
@ -0,0 +1,61 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.Tiles
|
||||
|
||||
// This module builds a calculus of tiled and free species
|
||||
// based on a calculus of free species and a predicate is_bound
|
||||
|
||||
type 's s =
|
||||
| Free of 's // This species should not be tethered
|
||||
| Tile of 's list // All species in here are meant to be tethered
|
||||
|
||||
let map_reactions rs = rs |> Set.map (Calculus.map_reaction Free)
|
||||
|
||||
let leave1out f l =
|
||||
let rec loop acc e after =
|
||||
match after with
|
||||
| [] -> (f e [])::acc |> List.rev
|
||||
| a::afters -> loop (f e after::acc) a afters
|
||||
match l with
|
||||
| [] -> []
|
||||
| h::t -> loop [] h t
|
||||
|
||||
let lift_mono (c:'s Calculus.t) =
|
||||
function
|
||||
| Free f -> c.mono f |> map_reactions
|
||||
| Tile ss ->
|
||||
let react s rest =
|
||||
seq {
|
||||
yield c.mono s
|
||||
yield! rest |> List.map (c.bin s)
|
||||
} |> Set.unionMany
|
||||
|> Set.map (fun r -> { Calculus.reactants = [r.reactants@rest |> Tile]
|
||||
; Calculus.products = [r.products@rest |> Tile]
|
||||
; Calculus.rate = r.rate }) // TODO: Take local concentration into account
|
||||
ss |> leave1out react
|
||||
|> Set.unionMany
|
||||
|
||||
let lift_bin is_bound (c:'s Calculus.t) s1 s2 =
|
||||
match s1, s2 with
|
||||
| Free f1, Free f2 -> c.bin f1 f2 |> map_reactions
|
||||
| Free f, Tile ss
|
||||
| Tile ss, Free f ->
|
||||
let react s rest =
|
||||
let split fs =
|
||||
let bound, free = fs |> List.partition is_bound
|
||||
(bound |> Tile)::(free |> List.map Free)
|
||||
c.bin s f
|
||||
|> Set.map (fun r -> { Calculus.reactants = r.reactants@rest |> split
|
||||
; Calculus.products = r.products@rest |> split
|
||||
; Calculus.rate = r.rate }) // TODO: Take local concentration into account
|
||||
ss |> leave1out react
|
||||
|> Set.unionMany
|
||||
| Tile _, Tile _ -> Set.empty
|
||||
|
||||
let lift_species is_bound (c:'s Calculus.t) =
|
||||
c.initial_species
|
||||
|> List.map (fun s -> if s |> is_bound then Tile [s] else Free s)
|
||||
|
||||
let lift is_bound c = Calculus.from_mono_bin (lift_mono c) (lift_bin is_bound c) (lift_species is_bound c)
|
|
@ -0,0 +1,221 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.TimeSeparation
|
||||
|
||||
// This module builds a calculus of merged reactions
|
||||
// based on a calculus and a notion of slow/fast mono-reactions
|
||||
|
||||
let rec cartesian ll =
|
||||
match ll with
|
||||
| [] -> [[]]
|
||||
| (l::ls) ->
|
||||
cartesian ls
|
||||
|> List.collect (fun path -> l |> List.map (fun x -> x::path))
|
||||
|
||||
let expand_choices l =
|
||||
l
|
||||
|> List.map Set.toList
|
||||
|> cartesian
|
||||
|> List.map List.concat
|
||||
|> Set.ofList
|
||||
|
||||
let alter_each f l =
|
||||
let rec loop pre = function
|
||||
| [] -> [pre]
|
||||
| [x] -> [pre@[f x]]
|
||||
| x::xs -> (pre@[f x]@xs) :: (loop (pre@[x]) xs)
|
||||
loop [] l
|
||||
|
||||
let collect_each f (l:'a list) =
|
||||
let surround b a (e:'a) = b@[e]@a
|
||||
let rec loop pre = function
|
||||
| [] -> [pre]
|
||||
| [x] -> f x |> List.map (surround pre [])
|
||||
| x::xs -> (f x |> List.map (surround pre xs)) @ (loop (pre@[x]) xs)
|
||||
loop [] l
|
||||
|
||||
let map_context f l =
|
||||
let rec loop pre = function
|
||||
| [] -> []
|
||||
| x::xs -> (f x (pre@xs)) :: (loop (pre@[x]) xs)
|
||||
loop [] l
|
||||
|
||||
let collect_context f l =
|
||||
let rec loop pre = function
|
||||
| [] -> []
|
||||
| x::xs -> (f x (pre@xs)) @ (loop (pre@[x]) xs)
|
||||
loop [] l
|
||||
|
||||
|
||||
(*
|
||||
Variant of Kosaraju's algorithm (to work for a partial equivalence relation)
|
||||
https://en.wikipedia.org/wiki/Kosaraju%27s_algorithm
|
||||
|
||||
Notes:
|
||||
- For a given equivalence class, we are guaranteed to explore the entire equivalence class
|
||||
*)
|
||||
let rec get_stable mono_fast (s:'s) =
|
||||
let V = Set.empty<'s> |> ref
|
||||
let mark_visited i = V := Set.add i !V
|
||||
let is_visited i = Set.contains i !V
|
||||
|
||||
let L = List.empty<'s> |> ref
|
||||
let record i = L := i::!L
|
||||
|
||||
let prevs = Map.empty<'s,Set<'s>> |> ref
|
||||
let add_prev i p =
|
||||
let new_prevs =
|
||||
match Map.tryFind i !prevs with
|
||||
| None -> p |> Set.singleton
|
||||
| Some old_prevs -> Set.add p old_prevs
|
||||
prevs := Map.add i new_prevs !prevs
|
||||
let add_to_prevs p is =
|
||||
is |> Seq.iter (fun i -> add_prev i p)
|
||||
let get_prevs i =
|
||||
match Map.tryFind i !prevs with
|
||||
| None -> Set.empty
|
||||
| Some prevs -> prevs
|
||||
|
||||
let splits = Map.empty<'s,Set<'s list>> |> ref
|
||||
let add_splits i ss =
|
||||
let new_splits =
|
||||
match Map.tryFind i !splits with
|
||||
| None -> ss |> Set.ofList
|
||||
| Some old_splits -> ss |> Set.ofList |> Set.union old_splits
|
||||
splits := Map.add i new_splits !splits
|
||||
let get_splits i = (!splits).[i]
|
||||
|
||||
let rec visit i =
|
||||
if i |> is_visited then ()
|
||||
else
|
||||
i |> mark_visited
|
||||
let nexts, splits =
|
||||
mono_fast i
|
||||
|> Seq.fold (fun (n_acc, s_acc) (r: Calculus.reaction<'s>) ->
|
||||
match r.products with
|
||||
| [p] -> (p::n_acc, s_acc)
|
||||
| ps -> (n_acc, ps::s_acc))
|
||||
([],[])
|
||||
nexts |> add_to_prevs i
|
||||
splits |> add_splits i
|
||||
nexts |> Seq.iter visit
|
||||
record i
|
||||
visit s
|
||||
// Now [L] is generated in proper order
|
||||
|
||||
let root = Map.empty<'s,'s> |> ref
|
||||
let get_root i = (!root).[i]
|
||||
let set_root r i = root := Map.add i r !root
|
||||
let has_root i = Map.containsKey i !root
|
||||
|
||||
let transports = Map.empty<'s,Set<'s>> |> ref
|
||||
let add_transport r1 r2 =
|
||||
match Map.tryFind r1 !transports with
|
||||
| None -> transports := Map.add r1 (Set.singleton r2) !transports
|
||||
| Some set -> transports := Map.add r1 (Set.add r2 set) !transports
|
||||
|
||||
let rec assign r i =
|
||||
if has_root i then
|
||||
let ri = get_root i
|
||||
if ri <> r then add_transport ri r
|
||||
else
|
||||
i |> set_root r
|
||||
i |> get_prevs |> Set.iter (assign r)
|
||||
|
||||
!L |> List.iter (fun i -> if not <| has_root i then assign i i)
|
||||
// Now [roots] is populated
|
||||
|
||||
splits :=
|
||||
!splits
|
||||
|> Map.toSeq
|
||||
|> Seq.map (fun (i,ss) -> get_root i, ss)
|
||||
|> Map.ofSeq
|
||||
// Now [splits] is indexed by roots
|
||||
|
||||
// The function [rep] computes representatives in a manner independent of how the equivalence class was discovered
|
||||
// It should then give the same representative if the same class is discovered by different runs
|
||||
let get_class i =
|
||||
let r = i |> get_root
|
||||
!L
|
||||
|> List.filter (get_root >> ((=) r)) // This is the entire class
|
||||
let rep = get_class >> Seq.min
|
||||
|
||||
(*
|
||||
let rec descendants i =
|
||||
let finish () = [rep i]
|
||||
match Map.tryFind i !transports with
|
||||
| None -> finish ()
|
||||
| Some ds ->
|
||||
if ds |> Set.isEmpty then finish () else
|
||||
ds
|
||||
|> Set.toList
|
||||
|> List.collect (get_root >> descendants)
|
||||
*)
|
||||
let rec stabilisations i =
|
||||
let finish () = [get_class i] |> Set.singleton
|
||||
let singles =
|
||||
match Map.tryFind i !transports with
|
||||
| None -> Set.empty
|
||||
| Some ds -> ds
|
||||
let multiples =
|
||||
match Map.tryFind i !splits with
|
||||
| None -> Set.empty
|
||||
| Some ds -> ds
|
||||
let expand split =
|
||||
split
|
||||
|> List.map (get_stable mono_fast)
|
||||
|> expand_choices
|
||||
if singles |> Set.isEmpty && multiples |> Set.isEmpty then finish ()
|
||||
else
|
||||
[ singles
|
||||
|> Set.toList
|
||||
|> List.map (get_root >> stabilisations)
|
||||
|> Set.unionMany
|
||||
; multiples
|
||||
|> Set.toList
|
||||
|> List.map expand
|
||||
|> Set.unionMany
|
||||
]
|
||||
|> Set.unionMany
|
||||
|
||||
s |> get_root |> stabilisations // get_root is unnecessary here but feels safer
|
||||
|
||||
let stabilise_reaction mono_fast (r:'s Calculus.reaction) =
|
||||
let stable_products =
|
||||
r.products
|
||||
|> List.map (get_stable mono_fast)
|
||||
stable_products
|
||||
|> expand_choices
|
||||
|> Set.map (fun ps -> { r with products = ps |> List.map Seq.min})
|
||||
|
||||
let stabilise_many mono_fast = Set.toSeq >> Seq.map (stabilise_reaction mono_fast) >> Set.unionMany
|
||||
|
||||
let lift_mono mono_fast mono_slow (c:'s Calculus.t) s =
|
||||
(*
|
||||
c.mono s
|
||||
|> stabilise_many mono_fast
|
||||
*)
|
||||
//(*
|
||||
s
|
||||
|> get_stable mono_fast
|
||||
|> Set.toSeq
|
||||
|> Seq.collect (collect_context (fun c cs -> c |> List.collect (mono_slow >> List.map (fun (r:'s Calculus.reaction) -> {r with reactants = [s]; products = r.products @ (cs |> List.map Seq.min)}))))
|
||||
|> Seq.map (stabilise_reaction mono_fast)
|
||||
|> Set.unionMany
|
||||
//*)
|
||||
|
||||
let lift_bin mono_fast (c:'s Calculus.t) s1 s2 =
|
||||
//let ch1 = s1 |> get_stable mono_fast
|
||||
//let ch2 = s2 |> get_stable mono_fast
|
||||
c.bin s1 s2 // TODO: stabilise s1 and s2 first (unstable compounds do not have time to react)
|
||||
|> stabilise_many mono_fast
|
||||
|
||||
let lift_species mono_fast (c:'s Calculus.t) =
|
||||
c.initial_species
|
||||
|> List.map (get_stable mono_fast)
|
||||
|> List.collect (Set.toList >> (List.collect Seq.min))
|
||||
|
||||
let lift mono_fast mono_slow c =
|
||||
Calculus.from_mono_bin (lift_mono mono_fast mono_slow c) (lift_bin mono_fast c) (lift_species mono_fast c)
|
|
@ -0,0 +1,201 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
# 1 "Lexer.fsl"
|
||||
|
||||
module Lexer
|
||||
|
||||
open System
|
||||
open Parser
|
||||
open Microsoft.FSharp.Text.Lexing
|
||||
|
||||
|
||||
let lexeme (lexbuf:Microsoft.FSharp.Text.Lexing.LexBuffer<byte>) = System.Text.UnicodeEncoding.UTF8.GetString(lexbuf.Lexeme, 0, lexbuf.Lexeme.Length)
|
||||
|
||||
# 12 "Lexer.fs"
|
||||
let trans : uint16[] array =
|
||||
[|
|
||||
(* State 0 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 1us; 2us; 65535us; 65535us; 3us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 1us; 7us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 15us; 65535us; 10us; 17us; 65535us; 4us; 16us; 16us; 16us; 16us; 16us; 16us; 16us; 16us; 16us; 16us; 65535us; 65535us; 13us; 65535us; 11us; 65535us; 6us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 12us; 65535us; 14us; 9us; 18us; 65535us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 5us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 18us; 65535us; 8us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 19us; |];
|
||||
(* State 1 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 2 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 3 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 2us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 4 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 36us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 5 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 20us; 20us; 20us; 20us; 34us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 6 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 7 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 8 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 9 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 10 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 11 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 12 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 13 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 14 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 15 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 16 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 23us; 65535us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 31us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 20us; 20us; 20us; 20us; 31us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 17 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 21us; 21us; 21us; 21us; 21us; 21us; 21us; 21us; 21us; 21us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 18 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 19 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 20 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 21 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 23us; 65535us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 22us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 22us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 22 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 28us; 65535us; 65535us; 27us; 27us; 27us; 27us; 27us; 27us; 27us; 27us; 27us; 27us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 23 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 25us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 24 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 23us; 65535us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 24us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 22us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 22us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 25 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 26us; 26us; 26us; 26us; 26us; 26us; 26us; 26us; 26us; 26us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 22us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 22us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 26 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 26us; 26us; 26us; 26us; 26us; 26us; 26us; 26us; 26us; 26us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 22us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 22us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 27 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 29us; 29us; 29us; 29us; 29us; 29us; 29us; 29us; 29us; 29us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 28 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 27us; 27us; 27us; 27us; 27us; 27us; 27us; 27us; 27us; 27us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 29 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 29us; 29us; 29us; 29us; 29us; 29us; 29us; 29us; 29us; 29us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 30 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 23us; 65535us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 30us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 31us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 20us; 20us; 20us; 20us; 31us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 31 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 28us; 65535us; 65535us; 32us; 32us; 32us; 32us; 32us; 32us; 32us; 32us; 32us; 32us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 32 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 33 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 33us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 34 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 35us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 35 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 20us; 65535us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 20us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 36 *)
|
||||
[|39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 37us; 39us; 39us; 38us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 65535us; |];
|
||||
(* State 37 *)
|
||||
[|65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; 65535us; |];
|
||||
(* State 38 *)
|
||||
[|39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 37us; 39us; 39us; 38us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 65535us; |];
|
||||
(* State 39 *)
|
||||
[|39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 37us; 39us; 39us; 38us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 39us; 65535us; |];
|
||||
|]
|
||||
let actions : uint16[] = [|65535us; 0us; 1us; 1us; 65535us; 16us; 4us; 5us; 6us; 7us; 8us; 9us; 10us; 11us; 12us; 13us; 14us; 65535us; 16us; 17us; 16us; 15us; 65535us; 65535us; 15us; 15us; 15us; 15us; 65535us; 15us; 14us; 16us; 15us; 15us; 16us; 3us; 65535us; 2us; 2us; 65535us; |]
|
||||
let _fslex_tables = Microsoft.FSharp.Text.Lexing.AsciiTables.Create(trans,actions)
|
||||
let rec _fslex_dummy () = _fslex_dummy()
|
||||
(* Rule tokenize *)
|
||||
and tokenize (lexbuf : Microsoft.FSharp.Text.Lexing.LexBuffer<_>) = _fslex_tokenize 0 lexbuf
|
||||
(* Rule tokenize *)
|
||||
and _fslex_tokenize _fslex_state lexbuf =
|
||||
match _fslex_tables.Interpret(_fslex_state,lexbuf) with
|
||||
| 0 -> (
|
||||
# 23 "Lexer.fsl"
|
||||
tokenize lexbuf
|
||||
# 107 "Lexer.fs"
|
||||
)
|
||||
| 1 -> (
|
||||
# 24 "Lexer.fsl"
|
||||
lexbuf.EndPos <- lexbuf.EndPos.NextLine; tokenize lexbuf
|
||||
# 112 "Lexer.fs"
|
||||
)
|
||||
| 2 -> (
|
||||
# 25 "Lexer.fsl"
|
||||
lexbuf.EndPos <- lexbuf.EndPos.NextLine; tokenize lexbuf
|
||||
# 117 "Lexer.fs"
|
||||
)
|
||||
| 3 -> (
|
||||
# 28 "Lexer.fsl"
|
||||
NEW
|
||||
# 122 "Lexer.fs"
|
||||
)
|
||||
| 4 -> (
|
||||
# 29 "Lexer.fsl"
|
||||
AT
|
||||
# 127 "Lexer.fs"
|
||||
)
|
||||
| 5 -> (
|
||||
# 30 "Lexer.fsl"
|
||||
BANG
|
||||
# 132 "Lexer.fs"
|
||||
)
|
||||
| 6 -> (
|
||||
# 31 "Lexer.fsl"
|
||||
BAR
|
||||
# 137 "Lexer.fs"
|
||||
)
|
||||
| 7 -> (
|
||||
# 32 "Lexer.fsl"
|
||||
CARAT
|
||||
# 142 "Lexer.fs"
|
||||
)
|
||||
| 8 -> (
|
||||
# 33 "Lexer.fsl"
|
||||
COMMA
|
||||
# 147 "Lexer.fs"
|
||||
)
|
||||
| 9 -> (
|
||||
# 34 "Lexer.fsl"
|
||||
GT
|
||||
# 152 "Lexer.fs"
|
||||
)
|
||||
| 10 -> (
|
||||
# 35 "Lexer.fsl"
|
||||
LB
|
||||
# 157 "Lexer.fs"
|
||||
)
|
||||
| 11 -> (
|
||||
# 36 "Lexer.fsl"
|
||||
LT
|
||||
# 162 "Lexer.fs"
|
||||
)
|
||||
| 12 -> (
|
||||
# 37 "Lexer.fsl"
|
||||
RB
|
||||
# 167 "Lexer.fs"
|
||||
)
|
||||
| 13 -> (
|
||||
# 38 "Lexer.fsl"
|
||||
STAR
|
||||
# 172 "Lexer.fs"
|
||||
)
|
||||
| 14 -> (
|
||||
# 41 "Lexer.fsl"
|
||||
INT (Int32.Parse(lexeme lexbuf))
|
||||
# 177 "Lexer.fs"
|
||||
)
|
||||
| 15 -> (
|
||||
# 42 "Lexer.fsl"
|
||||
FLOAT (Double.Parse(lexeme lexbuf))
|
||||
# 182 "Lexer.fs"
|
||||
)
|
||||
| 16 -> (
|
||||
# 45 "Lexer.fsl"
|
||||
NAME (lexeme lexbuf)
|
||||
# 187 "Lexer.fs"
|
||||
)
|
||||
| 17 -> (
|
||||
# 48 "Lexer.fsl"
|
||||
EOF
|
||||
# 192 "Lexer.fs"
|
||||
)
|
||||
| _ -> failwith "tokenize"
|
||||
|
||||
# 49 "Lexer.fsl"
|
||||
|
||||
# 3000000 "Lexer.fs"
|
|
@ -0,0 +1,3 @@
|
|||
group NETSTANDARD
|
||||
|
||||
FSharp.Core
|
|
@ -0,0 +1,66 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
// Signature file for parser generated by fsyacc
|
||||
module Parser
|
||||
type token =
|
||||
| AT
|
||||
| BANG
|
||||
| BAR
|
||||
| CARAT
|
||||
| COMMA
|
||||
| EOF
|
||||
| GT
|
||||
| LB
|
||||
| LT
|
||||
| NEW
|
||||
| RB
|
||||
| STAR
|
||||
| NAME of (System.String)
|
||||
| FLOAT of (float)
|
||||
| INT of (int)
|
||||
type tokenId =
|
||||
| TOKEN_AT
|
||||
| TOKEN_BANG
|
||||
| TOKEN_BAR
|
||||
| TOKEN_CARAT
|
||||
| TOKEN_COMMA
|
||||
| TOKEN_EOF
|
||||
| TOKEN_GT
|
||||
| TOKEN_LB
|
||||
| TOKEN_LT
|
||||
| TOKEN_NEW
|
||||
| TOKEN_RB
|
||||
| TOKEN_STAR
|
||||
| TOKEN_NAME
|
||||
| TOKEN_FLOAT
|
||||
| TOKEN_INT
|
||||
| TOKEN_end_of_input
|
||||
| TOKEN_error
|
||||
type nonTerminalId =
|
||||
| NONTERM__startstart
|
||||
| NONTERM_start
|
||||
| NONTERM_toehold
|
||||
| NONTERM_toeholds
|
||||
| NONTERM_species
|
||||
| NONTERM_complexes
|
||||
| NONTERM_complex
|
||||
| NONTERM_strands
|
||||
| NONTERM_strand
|
||||
| NONTERM_sites
|
||||
| NONTERM_site
|
||||
| NONTERM_domain
|
||||
| NONTERM_domainname
|
||||
| NONTERM_name
|
||||
/// This function maps integers indexes to symbolic token ids
|
||||
val tagOfToken: token -> int
|
||||
|
||||
/// This function maps integers indexes to symbolic token ids
|
||||
val tokenTagToTokenId: int -> tokenId
|
||||
|
||||
/// This function maps production indexes returned in syntax errors to strings representing the non terminal that would be produced by that production
|
||||
val prodIdxToNonTerminal: int -> nonTerminalId
|
||||
|
||||
/// This function gets the name of a token as a string
|
||||
val token_to_string: token -> string
|
||||
val start : (Microsoft.FSharp.Text.Lexing.LexBuffer<'cty> -> token) -> Microsoft.FSharp.Text.Lexing.LexBuffer<'cty> -> ( SiteGraphReactor.Syntax.t )
|
|
@ -0,0 +1,336 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
[<JavaScript>]
|
||||
module SiteGraphReactor.Sitegraphs
|
||||
|
||||
let parse (s:string) =
|
||||
//Syntax.parse s
|
||||
ExtendedSyntax.parse_enzymes s
|
||||
|
||||
let tryParse s = Parser.run ExtendedSyntax.parser_enzymes s
|
||||
|
||||
let strip_strand : Syntax.strand -> Strands.strand = List.map (fun syn -> syn.domain) >> List.toArray
|
||||
|
||||
let default_bind_rate = 0.0003
|
||||
let default_unbind_rate = 0.1126
|
||||
let default_toehold_rates = default_bind_rate, default_unbind_rate
|
||||
|
||||
let default_domain_bind_rate = 0.003
|
||||
let default_domain_unbind_rate = 0.0
|
||||
let default_domain_rates = default_domain_bind_rate, default_domain_unbind_rate
|
||||
|
||||
let indexed_pairs (a: 'a []) =
|
||||
if a.Length < 2 then [||]
|
||||
else Array.init (a.Length - 1) (fun i -> i, (a.[i], a.[i+1]))
|
||||
|
||||
let all_splits (a: 'a []) (splits: int []) =
|
||||
let last = a.Length - 1
|
||||
let get_start i = if i = 0 then 0 else splits.[i-1] + 1
|
||||
let get_end i = if i = splits.Length then last else splits.[i]
|
||||
let pairs =
|
||||
seq {
|
||||
for i in 0..splits.Length do
|
||||
for j in i..splits.Length do
|
||||
yield get_start i, get_end j
|
||||
done
|
||||
done
|
||||
}
|
||||
pairs |> Seq.map (fun (s, e) -> Array.sub a s (e-s+1))
|
||||
|
||||
let add_default m (t, rates) =
|
||||
match Map.tryFind t m with
|
||||
| None -> Map.add t rates m
|
||||
| Some _ -> m
|
||||
|
||||
let all_maps_to i = Seq.map (fun x -> (x, i))
|
||||
|
||||
let semantics (enzymes, (toeholds, complexes)) =
|
||||
let toehold_map = toeholds |> List.fold (fun m (t:Syntax.toehold) -> Map.add t.name (t.bind_rate, t.unbind_rate) m) Map.empty
|
||||
let syn_strands = complexes |> List.map snd |> List.concat
|
||||
let apply_enzyme (before_nick, after_nick) (s: Strands.strand) =
|
||||
let to_nick = Array.append before_nick after_nick
|
||||
let shift = before_nick.Length-1
|
||||
|
||||
let nick_sites = s |> Seq.windowed to_nick.Length
|
||||
|> Seq.mapi (fun i w -> i+shift, w = to_nick)
|
||||
|> Seq.filter snd |> Seq.map fst
|
||||
|> Seq.toArray
|
||||
all_splits s nick_sites
|
||||
let apply_enzymes strands =
|
||||
enzymes |> Seq.fold (fun ss e -> ss |> Seq.collect (apply_enzyme e)) strands
|
||||
let strand_types = syn_strands |> List.map strip_strand |> List.toSeq |> apply_enzymes |> Seq.distinct |> Seq.toArray
|
||||
let syn_toeholds = strand_types |> Array.collect (Array.map (fun d -> if d.toehold then d.name, default_toehold_rates else d.name, default_domain_rates))
|
||||
let toehold_map = syn_toeholds |> Array.fold add_default toehold_map
|
||||
let strand_types_list =
|
||||
seq { // strand_types |> Array.iteri (fun i st -> st |> Array.iteri (fun j d -> yield ((i,j),d)))
|
||||
for i in 0..strand_types.Length - 1 do
|
||||
let st = strand_types.[i]
|
||||
for j in 0..st.Length - 1 do
|
||||
yield ({Strands.port.strand=i;Strands.port.site=j},st.[j])
|
||||
} |> Seq.toList
|
||||
let rec add_domains m = function
|
||||
| [] -> m
|
||||
| (p:Strands.port,d)::ds ->
|
||||
let cs = ds |> List.filter (snd >> Strands.complementary d)
|
||||
let new_m = cs |> List.fold (fun m_acc (tp,_) -> Map.add {Strands.port_pair.port1=p; Strands.port_pair.port2=tp} d.toehold m_acc) m
|
||||
add_domains new_m ds
|
||||
let admissible_edges = strand_types_list |> add_domains Map.empty
|
||||
let strands =
|
||||
{ Strands.strand_types = strand_types
|
||||
; Strands.admissible_edges = admissible_edges }
|
||||
let complex_to_species c =
|
||||
let species_strands = c |> List.toArray |> Array.map (fun syn -> Array.findIndex (fun st -> st = strip_strand syn) strand_types)
|
||||
let syns_indexed = c |> List.map (List.map (fun syn -> syn.binding) >> List.toArray) |> List.toArray
|
||||
let add_binding es ps =
|
||||
match ps |> Seq.toList with
|
||||
| [p1:Strands.port, _:string; p2, _] -> Set.add (p1, p2) es
|
||||
| _ -> failwith "Invalid binding"
|
||||
let species_edges =
|
||||
seq { // strand_types |> Array.iteri (fun i st -> st |> Array.iteri (fun j d -> yield ((i,j),d)))
|
||||
for i in 0..syns_indexed.Length - 1 do
|
||||
let st = syns_indexed.[i]
|
||||
for j in 0..st.Length - 1 do
|
||||
match st.[j] with
|
||||
| None -> ()
|
||||
| Some b -> yield ({Strands.port.strand=i;Strands.port.site=j}, b)
|
||||
} |> Seq.groupBy snd |> Seq.fold (fun es (_,ps) -> add_binding es ps) Set.empty
|
||||
{ Species.strands = species_strands
|
||||
; Species.edges = species_edges }
|
||||
let ss = complexes
|
||||
|> List.map (fun (i, c) -> c |> complex_to_species |> Species.split_ccs strands |> Seq.map fst |> all_maps_to i)
|
||||
|> Seq.concat |> Seq.groupBy fst
|
||||
|> Seq.map (fun (s, l) -> Seq.sumBy snd l, s)
|
||||
enzymes, toehold_map, strands, ss
|
||||
|
||||
let compile = parse >> semantics
|
||||
let tryCompile s =
|
||||
match Parser.run ExtendedSyntax.parser_enzymes s with
|
||||
| Parser.Success (result, r, p) -> Parser.Success (semantics result, r, p)
|
||||
| Parser.Failure (error, m, r) -> Parser.Failure (error, m, r)
|
||||
|
||||
let lift_tiles (strands: Strands.t) =
|
||||
let bound_strand_types = strands.strand_types |> Array.map (Array.exists (fun d -> d.name = "tether"))
|
||||
let is_bound (Species.Rep sg) = sg.sg.strands |> Array.exists (fun i -> bound_strand_types.[i])
|
||||
Tiles.lift is_bound
|
||||
|
||||
let calculus_detailed s =
|
||||
let enzymes, toehold_map, strands, ss = compile s
|
||||
Reactions.calculus enzymes toehold_map strands (ss |> Seq.map snd |> Seq.toList)
|
||||
//|> lift_tiles strands
|
||||
|
||||
let calculus_default s =
|
||||
let enzymes, toehold_map, strands, ss = compile s
|
||||
let fast_mono sg =
|
||||
[ Reactions.displacing_actions strands sg
|
||||
; Reactions.complementary_binding_actions strands sg ]
|
||||
|> Seq.concat
|
||||
|> Set.ofSeq
|
||||
|> Set.map (Reactions.to_calc_react toehold_map strands)
|
||||
let slow_mono sg =
|
||||
[ Reactions.isolated_toehold_unbinding_actions strands sg
|
||||
; enzymes |> Seq.collect (fun e -> Reactions.nicking_actions strands e sg) ]
|
||||
|> Seq.concat
|
||||
|> Seq.toList
|
||||
|> List.map (Reactions.to_calc_react toehold_map strands)
|
||||
Reactions.calculus enzymes toehold_map strands (ss |> Seq.map snd |> Seq.toList)
|
||||
|> TimeSeparation.lift fast_mono slow_mono
|
||||
//|> lift_tiles strands
|
||||
|
||||
let reaction_graph limit enzymes toehold_map strands ss =
|
||||
let positivite_propensity = Reactions.get_rate toehold_map strands >> (<) 0.0
|
||||
let rec work rs all_ss l =
|
||||
match l with
|
||||
| [] -> all_ss, rs
|
||||
| w::ws ->
|
||||
if limit > 0 && (Set.count all_ss > limit) then (w::ws |> Set.ofList |> Set.union all_ss), rs else
|
||||
printfn "Species: %d" (Set.count all_ss)
|
||||
let new_rs = Reactions.actions enzymes strands all_ss w - rs |> Set.filter positivite_propensity
|
||||
let is_new s = Set.contains s all_ss |> not
|
||||
let new_ss = new_rs |> Seq.collect Reactions.products |> Seq.map fst |> Seq.distinct |> Seq.filter is_new |> Seq.toList
|
||||
work (Set.union new_rs rs) (Set.add w all_ss) (ws @ new_ss)
|
||||
work Set.empty Set.empty ss
|
||||
|
||||
let reaction_graph_to_dot limit enzymes toehold_map strands ss =
|
||||
let all_ss, rs = reaction_graph limit enzymes toehold_map strands ss
|
||||
let init_ss = ss |> Set.ofList
|
||||
let sname = sprintf "cluster%d"
|
||||
let r_att = "[penwidth=3.0]"
|
||||
let style = Some "style=\"rounded,filled\"\nfillcolor=beige\ncolor=cornsilk3\npenwidth=2.0"
|
||||
let init_style = Some "style=\"rounded,filled\"\nfillcolor=dodgerblue4\ncolor=dodgerblue4\npenwidth=2.0\nedge [color=beige]"
|
||||
let sid s = Seq.findIndex ((=) s) all_ss |> sname
|
||||
let rl = function
|
||||
| Reactions.Isolated_toehold _ -> "TU"
|
||||
| Reactions.Complement_int _ -> "IB"
|
||||
| Reactions.Complement_ext _ -> "EB"
|
||||
| Reactions.Displacing _ -> "D"
|
||||
| Reactions.Nick _ -> "N"
|
||||
let rr = Reactions.get_rate toehold_map strands
|
||||
let r_to_n rid r = sprintf "r%d [label=\"%s: %.3f\"];" rid (rl r) (rr r)
|
||||
let r_to_e rid = function
|
||||
| Reactions.Isolated_toehold (r,_,ps) -> [sprintf (*"%s -> r%d%s"*)"%s -- r%d%s" (sid r) rid r_att; sprintf (*"r%d -> {%s}"*)"r%d -- {%s}" rid (ps |> Seq.map (fst >> sid) |> String.concat " ")]
|
||||
| Reactions.Complement_int (r,_,p) -> [sprintf (*"%s -> r%d%s"*)"%s -- r%d%s" (sid r) rid r_att; sprintf (*"r%d -> %s"*)"r%d -- %s" rid (p |> fst |> sid)]
|
||||
| Reactions.Complement_ext (r1,r2,_,p) -> [sprintf (*"{%s %s} -> r%d%s"*)"{%s %s} -- r%d%s" (sid r1) (sid r2) rid r_att; sprintf (*"r%d -> %s"*)"r%d -- %s" rid (p |> fst |> sid)]
|
||||
| Reactions.Displacing (r,_,ps) -> [sprintf (*"%s -> r%d%s"*)"%s -- r%d%s" (sid r) rid r_att; sprintf (*"r%d -> {%s}"*)"r%d -- {%s}" rid (ps |> Seq.map (fst >> sid) |> String.concat " ")]
|
||||
| Reactions.Nick (r,_,p) -> [sprintf (*"%s -> r%d%s"*)"%s -- r%d%s" (sid r) rid r_att; sprintf (*"r%d -> %s"*)"r%d -- %s" rid (p |> fst |> sid)]
|
||||
seq {
|
||||
yield "graph reaction_graph {"
|
||||
yield "layout=fdp"
|
||||
yield! all_ss |> Seq.mapi (fun i s -> Species.to_dot_node strands s (sprintf "subgraph %s" (sname i)) (if Set.contains s init_ss then init_style else style) (sprintf "sp_%d_str%d" i) )
|
||||
yield "node [style=filled,fillcolor=azure,color=dodgerblue4,penwidth=3.0];"
|
||||
yield "edge [color=dodgerblue4];"
|
||||
yield! rs |> Seq.mapi r_to_n
|
||||
yield! rs |> Seq.mapi r_to_e |> Seq.concat
|
||||
yield "}"
|
||||
} |> String.concat "\n"
|
||||
|
||||
#if JavaScript
|
||||
#else
|
||||
let reaction_graph_to_svgdot out_dir limit enzymes toehold_map strands ss =
|
||||
let all_ss, rs = reaction_graph limit enzymes toehold_map strands ss
|
||||
let init_ss = ss |> Set.ofList
|
||||
let sname = sprintf "species%d"
|
||||
let r_att = "[penwidth=2.0,dir=none]"
|
||||
let style = ""
|
||||
let init_style = ",penwidth=\"3.0\""
|
||||
let sid s = Seq.findIndex ((=) s) all_ss |> sname
|
||||
let rr = Reactions.get_rate toehold_map strands
|
||||
let r_to_n rid r = sprintf "r%d [label=\"%.3f\"];" rid (rr r)
|
||||
let r_to_e rid = function
|
||||
| Reactions.Isolated_toehold (r,_,ps) -> [sprintf "%s -> r%d%s" (sid r) rid r_att; sprintf "r%d -> {%s}[arrowhead=onormal]" rid (ps |> Seq.map (fst >> sid) |> String.concat " ")]
|
||||
| Reactions.Complement_int (r,_,p) -> [sprintf "%s -> r%d%s" (sid r) rid r_att; sprintf "r%d -> %s[arrowhead=onormal]" rid (p |> fst |> sid)]
|
||||
| Reactions.Complement_ext (r1,r2,_,p) -> [sprintf "{%s %s} -> r%d%s" (sid r1) (sid r2) rid r_att; sprintf "r%d -> %s[arrowhead=onormal]" rid (p |> fst |> sid)]
|
||||
| Reactions.Displacing (r,_,ps) -> [sprintf "%s -> r%d%s" (sid r) rid r_att; sprintf "r%d -> {%s}[arrowhead=onormal]" rid (ps |> Seq.map (fst >> sid) |> String.concat " ")]
|
||||
| Reactions.Nick (r,_,p) -> [sprintf "%s -> r%d%s" (sid r) rid r_att; sprintf "r%d -> %s[arrowhead=onormal]" rid (p |> fst |> sid)]
|
||||
all_ss |> Seq.iteri (fun i s -> Species.export_svg (System.IO.Path.Combine(out_dir, (sprintf "%s.svg" (sname i)))) strands s)
|
||||
( all_ss
|
||||
, rs
|
||||
, seq {
|
||||
yield "digraph reaction_graph {"
|
||||
yield! all_ss |> Seq.mapi (fun i s -> sprintf "%s [image=\"%s.png\",label=\"\",shape=\"box\",style=\"rounded\"%s];" (sname i) (sname i) (if Set.contains s init_ss then init_style else style))
|
||||
yield "node [shape=box];"
|
||||
yield! rs |> Seq.mapi r_to_n
|
||||
yield! rs |> Seq.mapi r_to_e |> Seq.concat
|
||||
yield "}"
|
||||
} |> String.concat "\n" )
|
||||
#endif
|
||||
|
||||
let state_space_to_dot strands (states, transitions) species =
|
||||
let sname = sprintf "cluster%d_%d"
|
||||
let st_name = sprintf "cluster%d"
|
||||
let r_att = "[penwidth=3.0]"
|
||||
let style = "style=\"rounded,filled\"\nfillcolor=beige\ncolor=cornsilk3\npenwidth=2.0"
|
||||
let state_seq = states |> Set.toSeq
|
||||
let st_id s = Seq.findIndex ((=) s) state_seq |> st_name
|
||||
let start_state = States.state_of_species species
|
||||
let state_to_dot i st =
|
||||
seq {
|
||||
yield sprintf "subgraph cluster%d {" i;
|
||||
if st = start_state then yield "style=filled\nfillcolor=dodgerblue4"
|
||||
yield "color=dodgerblue4"
|
||||
yield "penwidth=3.0"
|
||||
yield! st |> Map.toSeq |> Seq.mapi (fun j (s,n) -> Species.to_dot_node strands s (sprintf "subgraph %s" (sname i j)) (sprintf "label=\"%d\"\n%s" n style |> Some) (sprintf "st_%d_sp_%d_str%d" i j) )
|
||||
yield "}"
|
||||
} |> String.concat "\n"
|
||||
seq {
|
||||
yield "graph state_space {";
|
||||
yield "layout=fdp"
|
||||
yield! state_seq |> Seq.mapi state_to_dot
|
||||
yield "node [style=filled,fillcolor=azure,color=dodgerblue4,penwidth=3.0];"
|
||||
yield "edge [color=dodgerblue4];"
|
||||
yield! transitions |> Seq.mapi (fun i (_, r, _) -> sprintf "r%d [label=\"%.3f\"];" i r)
|
||||
yield! transitions |> Seq.mapi (fun i (s1, _, s2) -> seq [sprintf "%s -- r%d%s" (st_id s1) i r_att; sprintf "r%d -- %s" i (st_id s2)]) |> Seq.concat
|
||||
yield "}"
|
||||
} |> String.concat "\n"
|
||||
|
||||
#if JavaScript
|
||||
#else
|
||||
let state_space_to_svgdot strands (states, transitions) species =
|
||||
let all_species = states |> Set.toSeq |> Seq.collect (fun st -> st |> Map.toSeq |> Seq.map fst) |> Seq.distinct
|
||||
let sname = sprintf "ss_species%d"
|
||||
all_species |> Seq.iteri (fun i s -> Species.export_svg (sprintf "%s.svg" (sname i)) strands s)
|
||||
let sp_name_map = all_species |> Seq.mapi (fun i s -> s, i) |> Map.ofSeq
|
||||
let sp_name s = Map.find s sp_name_map |> sname
|
||||
let st_name = sprintf "state%d"
|
||||
let state_seq = states |> Set.toSeq
|
||||
let st_id s = Seq.findIndex ((=) s) state_seq |> st_name
|
||||
let start_state = States.state_of_species species
|
||||
let state_to_dot i st =
|
||||
seq {
|
||||
yield sprintf "%s [label=<" (st_name i);
|
||||
yield "<table border=\"0\" cellborder=\"0\" cellspacing=\"0\" cellpadding =\"0\">"
|
||||
yield! st |> Map.toSeq |> Seq.map (fun (s,n) -> sprintf "<tr>\n <td>%d</td>\n <td><img src=\"%s.png\"/></td>\n</tr>" n (sp_name s))
|
||||
yield sprintf "</table>>%s];" (if st = start_state then ",penwidth=\"3.0\"" else "")
|
||||
} |> String.concat "\n"
|
||||
seq {
|
||||
yield "digraph state_space {";
|
||||
yield "node [shape=box];"
|
||||
yield! state_seq |> Seq.mapi state_to_dot
|
||||
yield! transitions |> Seq.mapi (fun i (s1, r, s2) -> sprintf "%s -> %s [label=\" %.3f \"];" (st_id s1) (st_id s2) r)
|
||||
yield "}"
|
||||
} |> String.concat "\n"
|
||||
#endif
|
||||
|
||||
#if JavaScript
|
||||
#else
|
||||
let state_space_to_textdot strands (states, transitions) species =
|
||||
let all_species = states |> Set.toSeq |> Seq.collect (fun st -> st |> Map.toSeq |> Seq.map fst) |> Seq.distinct
|
||||
let sname i s = sprintf "ss_species%d\t%s" i (Species.to_html strands s)
|
||||
//all_species |> Seq.iteri (fun i s -> Species.export_svg (sprintf "%s.svg" (sname i)) strands s)
|
||||
let sp_name_map = all_species |> Seq.mapi (fun i s -> s, sname i s) |> Map.ofSeq
|
||||
let sp_name s = Map.find s sp_name_map
|
||||
let st_name = sprintf "state%d"
|
||||
let state_seq = states |> Set.toSeq
|
||||
let st_id s = Seq.findIndex ((=) s) state_seq |> st_name
|
||||
let start_state = States.state_of_species species
|
||||
let state_to_dot i st =
|
||||
seq {
|
||||
yield sprintf "%s [label=<" (st_name i);
|
||||
yield "<table border=\"0\" cellborder=\"0\" cellspacing=\"0\" cellpadding =\"0\">"
|
||||
yield! st |> Map.toSeq |> Seq.map (fun (s,n) -> sprintf "<tr>\n <td>%d</td>\n <td>%s</td>\n</tr>" n (sp_name s))
|
||||
yield sprintf "</table>>%s];" (if st = start_state then ",penwidth=\"3.0\"" else "")
|
||||
} |> String.concat "\n"
|
||||
seq {
|
||||
yield "digraph state_space {";
|
||||
yield "node [shape=box];"
|
||||
yield! state_seq |> Seq.mapi state_to_dot
|
||||
yield! transitions |> Seq.mapi (fun i (s1, r, s2) -> sprintf "%s -> %s [label=\" %.3f \"];" (st_id s1) (st_id s2) r)
|
||||
yield "}"
|
||||
} |> String.concat "\n"
|
||||
#endif
|
||||
|
||||
#if JavaScript
|
||||
#else
|
||||
let state_space_to_text strands (states, transitions) species =
|
||||
let all_species = states |> Set.toSeq |> Seq.collect (fun st -> st |> Map.toSeq |> Seq.map fst) |> Seq.distinct
|
||||
let sname i s = sprintf "species%-2d: %s" i (Species.to_string_i 19 strands s)
|
||||
//all_species |> Seq.iteri (fun i s -> Species.export_svg (sprintf "%s.svg" (sname i)) strands s)
|
||||
let sp_name_map = all_species |> Seq.mapi (fun i s -> s, sname i s) |> Map.ofSeq
|
||||
let sp_name s = Map.find s sp_name_map
|
||||
let st_name = sprintf "state%-2d"
|
||||
let state_seq = states |> Set.toSeq
|
||||
let st_id s = Seq.findIndex ((=) s) state_seq |> st_name
|
||||
let start_state = States.state_of_species species
|
||||
let state_to_text i st =
|
||||
seq {
|
||||
yield sprintf "%s%s:\n" (st_name i) (if st = start_state then " (Initial state)" else "")
|
||||
yield! st |> Map.toSeq |> Seq.map (fun (s,n) -> sprintf " %2d of %s" n (sp_name s))
|
||||
} |> String.concat "\n"
|
||||
seq {
|
||||
yield "State space";
|
||||
yield sprintf " species: %d" (Seq.length all_species)
|
||||
yield sprintf " states: %d" (Seq.length state_seq)
|
||||
yield sprintf " transitions: %d" (Seq.length transitions)
|
||||
yield "\nStates";
|
||||
yield! state_seq |> Seq.mapi state_to_text
|
||||
yield "\nTransitions";
|
||||
yield! transitions |> Seq.mapi (fun i (s1, r, s2) -> sprintf "%s -> %s (%.3f)" (st_id s1) (st_id s2) r)
|
||||
} |> String.concat "\n"
|
||||
#endif
|
||||
|
||||
let to_dot strands ss =
|
||||
seq {
|
||||
yield "graph g {";
|
||||
yield! ss |> Seq.mapi (fun i s -> Species.to_dot_node strands s (sprintf "subgraph cluster_species%d" i) None (sprintf "sp_%d_str%d" i) )
|
||||
yield "}"
|
||||
} |> String.concat "\n"
|
|
@ -0,0 +1,70 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 15
|
||||
VisualStudioVersion = 15.0.28307.106
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "SiteGraphReactorJS", "SiteGraphReactorJS\SiteGraphReactorJS.fsproj", "{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ParserCombinatorsJS", "..\ParserCombinators\ParserCombinatorsJS\ParserCombinatorsJS.fsproj", "{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "SiteGraphCRNJS", "SiteGraphCRNJS\SiteGraphCRNJS.fsproj", "{82903A27-E535-4D30-8449-2AD9D2A9769E}"
|
||||
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("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SiteGraphReactorTSWrapper", "SiteGraphReactorTSWrapper\SiteGraphReactorTSWrapper.csproj", "{8AC1E8EB-E9A2-45DC-9E07-15398B4362B1}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416} = {FB1F1936-AC22-41B4-AF2F-E20A486E3416}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CRNEngineTSWrapper", "..\CRNEngine\CRNEngineTSWrapper\CRNEngineTSWrapper.csproj", "{FB1F1936-AC22-41B4-AF2F-E20A486E3416}"
|
||||
EndProject
|
||||
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "ReactionDiffusionJS", "..\PDESolvers\ReactionDiffusionJS\ReactionDiffusionJS.fsproj", "{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E7457C45-ABDE-4DF5-B7A2-D396D2825B2C}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{2EED2DFA-7D94-4E12-ADC5-455FC9F85BF9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{82903A27-E535-4D30-8449-2AD9D2A9769E}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{836AF075-6448-4CD9-8020-434B963FF5E2}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4DF94589-6870-4A4C-BFAE-5825EF4634E7}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{8AC1E8EB-E9A2-45DC-9E07-15398B4362B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{8AC1E8EB-E9A2-45DC-9E07-15398B4362B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{8AC1E8EB-E9A2-45DC-9E07-15398B4362B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{8AC1E8EB-E9A2-45DC-9E07-15398B4362B1}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{FB1F1936-AC22-41B4-AF2F-E20A486E3416}.Release|Any CPU.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}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{1CF4EE5A-8217-4D9A-89DE-55F8D01ACD40}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {92A8D16D-A137-4D6C-97B6-47E7A02D9117}
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,62 @@
|
|||
#load "load-project.fsx"
|
||||
|
||||
open SiteGraphReactor
|
||||
open Parser
|
||||
|
||||
let site = Syntax.parse_site Syntax.parse_name
|
||||
let strand, gate = ExtendedSyntax.strand_gate site
|
||||
|
||||
let strands = (attempt gate <|> strand) |> Syntax.sep_by_bars
|
||||
|
||||
let complex = strands |> Syntax.bracket "[" "]" |> Syntax.counted
|
||||
let complexes = complex |> Syntax.sep_by_bars
|
||||
|
||||
let species = attempt (strands |>> fun s -> [(1,s)]) <|> complexes
|
||||
|
||||
let parse_syntax = spaces >>. sepEndBy Syntax.parse_toehold spaces1 .>>. species .>> spaces .>> eof
|
||||
|
||||
let toeholds = sepEndBy Syntax.parse_toehold spaces1
|
||||
|
||||
let prog_3i4half = " 1000 * [ <tether T2^!a X*!b T1^>
|
||||
| <A X!b T2^*!a> ]
|
||||
| 1200 * [ <T1^* X!c RA>
|
||||
| <X*!c A*!d>
|
||||
| <A!d> ]"
|
||||
|
||||
|
||||
let sites = sepBy1 site spaces1
|
||||
|
||||
let upper = sites |> Syntax.bracket "<" ">"
|
||||
let lower = sites |> Syntax.bracket "{" "}"
|
||||
let double = sites |> Syntax.bracket "[" "]"
|
||||
let left_hp = sites |> Syntax.bracket "<" "}"
|
||||
let right_hp = sites |> Syntax.bracket "{" ">"
|
||||
|
||||
run Syntax.parse_name ""
|
||||
|
||||
run ExtendedSyntax.parser_enzymes "<x t^>"
|
||||
run ExtendedSyntax.parser_enzymes ""
|
||||
|
||||
run toeholds ""
|
||||
|
||||
run species "<x t^>"
|
||||
run gate "[2]"
|
||||
run strands "{1*}<x t^>}"
|
||||
run strands "{1*}|{3}"
|
||||
run species "{1*}<x t^>"
|
||||
run parse_syntax "{1*}<x t^>"
|
||||
run parse_syntax "{1*}"
|
||||
run parse_syntax "{1*} "
|
||||
run parse_syntax "<a t^>"
|
||||
run parse_syntax "<a t^>[x]"
|
||||
|
||||
run lower "{1*}"
|
||||
run site "1*"
|
||||
run sites "1*"
|
||||
run sites "1*}"
|
||||
run (Syntax.skw "}") "}"
|
||||
run (Syntax.kw "}") "}"
|
||||
|
||||
run parse_syntax prog_3i4half
|
||||
|
||||
run pint32 "32"
|
|
@ -0,0 +1,58 @@
|
|||
<?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>
|
||||
<None Include="app.config" />
|
||||
<None Include="Scripts\scratch.fsx" />
|
||||
<Compile Include="..\SiteGraphReactor\Calculus.fs">
|
||||
<Link>Calculus.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\SiteGraphReactor\TimeSeparation.fs">
|
||||
<Link>TimeSeparation.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\SiteGraphReactor\Tiles.fs">
|
||||
<Link>Tiles.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\SiteGraphReactor\Strands.fs">
|
||||
<Link>Strands.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\SiteGraphReactor\Species.fs">
|
||||
<Link>Species.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\SiteGraphReactor\CirclesRenderer.fs">
|
||||
<Link>CirclesRenderer.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\SiteGraphReactor\Reactions.fs">
|
||||
<Link>Reactions.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\SiteGraphReactor\States.fs">
|
||||
<Link>States.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\SiteGraphReactor\ReactionGraph.fs">
|
||||
<Link>ReactionGraph.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\SiteGraphReactor\Syntax.fs">
|
||||
<Link>Syntax.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\SiteGraphReactor\ExtendedSyntax.fs">
|
||||
<Link>ExtendedSyntax.fs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\SiteGraphReactor\sitegraphs.fs">
|
||||
<Link>sitegraphs.fs</Link>
|
||||
</Compile>
|
||||
<None Include="paket.references" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\ParserCombinators\ParserCombinatorsJS\ParserCombinatorsJS.fsproj" />
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\.paket\Paket.Restore.targets" />
|
||||
</Project>
|
|
@ -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,4 @@
|
|||
group NETSTANDARD
|
||||
|
||||
WebSharper.FSharp
|
||||
FSharp.Core
|
|
@ -0,0 +1,11 @@
|
|||
Samples/**/*.d.ts
|
||||
Samples/**/*.js
|
||||
Samples/**/*.js.map
|
||||
Scripts/*.d.ts
|
||||
!Scripts/declarations.d.ts
|
||||
Scripts/*.js
|
||||
Scripts/*.wasm
|
||||
Scripts/*.js.map
|
||||
Scripts/src
|
||||
Scripts/StrandGraphs
|
||||
Scripts/CRNEngine
|
|
@ -0,0 +1,74 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import StrandGraphs from "../../Scripts/StrandGraphs";
|
||||
import * as CRNInterfaces from "../../../../CRNEngine/CRNEngineTSWrapper/Scripts/Interfaces";
|
||||
|
||||
var codeBox = <HTMLTextAreaElement>document.getElementById("codeBox");
|
||||
var parseStatus = document.getElementById("parseStatus");
|
||||
var simulateStatus = document.getElementById("simulateStatus");
|
||||
|
||||
var me = new StrandGraphs(false);
|
||||
|
||||
function appendParseStatus(text: string) {
|
||||
var p = document.createElement("p");
|
||||
p.appendChild(document.createTextNode(text));
|
||||
parseStatus.appendChild(p);
|
||||
}
|
||||
|
||||
function appendSimulateStatus(text: string) {
|
||||
var p = document.createElement("p");
|
||||
p.appendChild(document.createTextNode(text));
|
||||
simulateStatus.appendChild(p);
|
||||
}
|
||||
|
||||
function clearParseStatus() {
|
||||
while (parseStatus.firstChild)
|
||||
parseStatus.removeChild(parseStatus.firstChild);
|
||||
}
|
||||
|
||||
function clearSimulateStatus() {
|
||||
while (simulateStatus.firstChild)
|
||||
simulateStatus.removeChild(simulateStatus.firstChild);
|
||||
}
|
||||
|
||||
function onParseFail(t: string, result: CRNInterfaces.Error) {
|
||||
appendParseStatus("fail (" + t + ") (" + JSON.stringify(result));
|
||||
}
|
||||
|
||||
function onSimulateFail(t: string, result: CRNInterfaces.Error) {
|
||||
appendSimulateStatus("fail (" + t + ") (" + JSON.stringify(result) + ")");
|
||||
}
|
||||
|
||||
var currentModel: CRNInterfaces.IG = null;
|
||||
|
||||
function parseClicked() {
|
||||
clearParseStatus();
|
||||
clearSimulateStatus();
|
||||
appendParseStatus("start");
|
||||
var code = codeBox.value;
|
||||
var observables = me.UserCompile(code);
|
||||
observables.result.subscribe(result => { currentModel = result.model; appendParseStatus("progress (result): " + JSON.stringify(result)); }, error => onParseFail("result", error), () => appendParseStatus("success (result)"));
|
||||
}
|
||||
|
||||
function simulateClicked() {
|
||||
if (currentModel == null)
|
||||
return;
|
||||
clearSimulateStatus();
|
||||
appendSimulateStatus("start");
|
||||
var observables = me.UserSimulateGui(currentModel, "");
|
||||
observables.node.subscribe(node => appendSimulateStatus("progress (node): " + JSON.stringify(node)), error => onSimulateFail("node", error), () => appendSimulateStatus("completed (node)"));
|
||||
observables.exports.subscribe(exports => appendSimulateStatus("progress (exports): " + JSON.stringify(exports)), error => onSimulateFail("exports", error), () => appendSimulateStatus("completed (exports)"));
|
||||
observables.instances.subscribe(instances => appendSimulateStatus("progress (instances): " + JSON.stringify(instances)), error => onSimulateFail("instances", error), () => appendSimulateStatus("completed (instances)"));
|
||||
observables.simrun.subscribe(rundef => {
|
||||
appendSimulateStatus("progress (simrun): " + JSON.stringify(rundef));
|
||||
rundef.values.subscribe(simdata => appendSimulateStatus("progress (simdata) " + simdata.instance + " " + simdata.time + " " + simdata.values), error => onSimulateFail("simdata", error), () => appendSimulateStatus("completed (simdata)"));
|
||||
}, error => onSimulateFail("simrun", error), () => appendSimulateStatus("completed (simrun)"));
|
||||
}
|
||||
|
||||
document.getElementById("parseButton").onclick = parseClicked;
|
||||
document.getElementById("simulateButton").onclick = simulateClicked;
|
||||
|
||||
require(["text!Samples/test.txt"], (sample:string) => {
|
||||
codeBox.value = sample;
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
||||
require(["../config"], () => {
|
||||
require(["../Samples/CallCRNEngine/app"]), () => {
|
||||
}
|
||||
});
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>SiteGraphReactorTSWrapper call back into CRNEngine Sample</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../samples.css" />
|
||||
<link rel="stylesheet" href="styles.css" />
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.2.0/require.min.js" data-main="/Samples/CallCRNEngine/boot"></script>
|
||||
</head>
|
||||
<body>
|
||||
<textarea id="codeBox" class="codeBox"></textarea>
|
||||
<button id="parseButton">Parse</button>
|
||||
<div id="parseStatus" class="status"></div>
|
||||
<button id="simulateButton">Simulate</button>
|
||||
<div id="simulateStatus" class="status"/>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,2 @@
|
|||
body {
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
import StrandGraphs from "../../Scripts/StrandGraphs";
|
||||
import * as CRNInterfaces from "../../../../CRNEngine/CRNEngineTSWrapper/Scripts/Interfaces";
|
||||
|
||||
var codeBox = <HTMLTextAreaElement>document.getElementById("codeBox");
|
||||
var status = document.getElementById("status");
|
||||
|
||||
var me = new StrandGraphs(false);
|
||||
|
||||
function appendStatus(text: string) {
|
||||
var p = document.createElement("p");
|
||||
p.appendChild(document.createTextNode(text));
|
||||
status.appendChild(p);
|
||||
}
|
||||
|
||||
function clearStatus() {
|
||||
while (status.firstChild)
|
||||
status.removeChild(status.firstChild);
|
||||
}
|
||||
|
||||
function onFail(process: string, type: string, result: CRNInterfaces.Error) {
|
||||
appendStatus(process + " fail (" + type + ") (" + JSON.stringify(result));
|
||||
}
|
||||
|
||||
function parseClicked() {
|
||||
clearStatus();
|
||||
appendStatus("parse start");
|
||||
var code = codeBox.value;
|
||||
var observables = me.UserParse(code);
|
||||
observables.result.subscribe(result => appendStatus("parse progress (result): " + JSON.stringify(result)), error => onFail("parse", "result", error), () => appendStatus("parse success (result)"));
|
||||
}
|
||||
|
||||
function expandClicked() {
|
||||
appendStatus("expand start");
|
||||
var code = codeBox.value;
|
||||
var observables = me.UserExpand(code);
|
||||
observables.result.subscribe(result => appendStatus("expand progress (result): " + JSON.stringify(result)), error => onFail("expand", "result", error), () => appendStatus("expand success (result)"));
|
||||
}
|
||||
|
||||
document.getElementById("parseButton").onclick = parseClicked;
|
||||
document.getElementById("expandButton").onclick = expandClicked;
|
||||
|
||||
require(["text!Samples/test.txt"], (sample: string) => {
|
||||
codeBox.value = sample;
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
// Copyright (c) Microsoft Corporation.
|
||||
// Licensed under the MIT License.
|
||||
|
||||
|
||||
require(["../config"], () => {
|
||||
require(["../Samples/Compile/app"]), () => {
|
||||
}
|
||||
});
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче