File: parsing_human_readable.m2

package info (click to toggle)
macaulay2 1.21%2Bds-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 133,096 kB
  • sloc: cpp: 110,377; ansic: 16,306; javascript: 4,193; makefile: 3,821; sh: 3,580; lisp: 764; yacc: 590; xml: 177; python: 140; perl: 114; lex: 65; awk: 3
file content (40 lines) | stat: -rw-r--r-- 940 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
restart
-- errorDepth = 0 
needs "ReactionNetworks.m2"
needsPackage "Graphs"
-- string in "human-readable format"
string = "A_0 <--> 2b, A + C <--> D, B_6 + E_9 --> A + C, D --> B + E"
reactions = separateRegexp(",", string)
CRN = reactionNetwork reactions
peek CRN 
 
-- now build the hash table
CRN = new ReactionNetwork from {
    Species => {"A","B","C","D","E"}, 
    Complexes => {matrix {{1,0,0,0,0}}, matrix {{0,2,0,0,0}}, matrix {{1,0,1,0,0}}, 
	          matrix {{0,0,0,1,0}}, matrix {{0,1,0,0,1}}},
    ReactionGraph => digraph({{0,1}, {1,0}, {2,3}, {3,2}, {4,2}, {3,4}}, EntryMode => "edges")
    }

S = "222S_0"
CRN.Species
addSpecies(s,CRN)
c = "2S_0 + A + 55B_3 + d"
separateRegexp("", S)
delete("", separateRegexp("[^(((A-Z)|(a-z))_?(0-9)*)]", c))
s

s = toString "222S_2"
stripCoef(s)
while i=1 do print "hello";
  i=0



length(S)

addSpecies("D_3", CRN)
Rn = CRN
ts = apply(separateRegexp("\\+", c), removeWhitespace)

c