diff --git a/rs.rkt b/rs.rkt index 37ec509..ac2d996 100644 --- a/rs.rkt +++ b/rs.rkt @@ -5,7 +5,10 @@ (provide Species (struct-out reaction) Reaction ReactionName ReactionSystem - make-reaction enabled? list-enabled union-products apply-rs) + make-reaction enabled? list-enabled union-products apply-rs + + str-triple->reaction + ) (module+ test (require typed/rackunit)) @@ -91,6 +94,18 @@ (set 't)) (check-equal? (apply-rs rs (set 'x)) (set 'z)))) + + (: str-triple->reaction (-> (List String String String) Reaction)) + (define/match (str-triple->reaction lst) + [((list str-reactants str-inhibitors str-products)) + (reaction (list->set (read-symbol-list str-reactants)) + (list->set (read-symbol-list str-inhibitors)) + (list->set (read-symbol-list str-products)))]) + + (module+ test + (test-case "str-triple->reaction" + (check-equal? (str-triple->reaction '("a b" "c d" "e f")) + (reaction (set 'b 'a) (set 'c 'd) (set 'f 'e))))) ) (require graph "utils.rkt" "generic.rkt") diff --git a/scribblings/rs.scrbl b/scribblings/rs.scrbl index 3ebaf6f..a5278eb 100644 --- a/scribblings/rs.scrbl +++ b/scribblings/rs.scrbl @@ -129,6 +129,15 @@ Applies the reaction system @racket[rs] to @racket[s]. This section contains some useful primitives for @hyperlink["https://orgmode.org/"]{Org-mode} interoperability. +@defproc[(str-triple->reaction [lst (List String String String)]) Reaction]{ + +Converts a triple of strings to a reaction. + +@ex[ +(str-triple->reaction '("a b" "c d" "e f")) +]} + + @section{Dynamics of reaction systems} The dynamics of reaction systems is typically defined as @emph{interaction