Null Symbols and CRN Parsing

Having modified the parser to fix issues addressed in the previous post, I thought it might help to make explicit the precise types of inputs accepted — in other words, the language of all valid input strings for the reactionNetwork constructor. This is a regular language, but somewhat easier to describe in Extended Backus-Naur Normal form, a notational device for context-free languages. Basically, this allows you describe your language in terms of primitive strings called “terminals” and valid production rules for making larger strings.

 

For simplicity, we’ll stipulate that a reaction network in string format should contain a single reaction; additionally, we allow for the option that this reaction is separated by a comma from another reaction network. Symbolically, this is encoded by the production rule below.


reactionNetwork = reaction ,
{ "," reactionNetwork };

Macaulay2 isn’t going to recognize ‘reaction’ as a nonterminal, so we have to go further in specifying the grammar. Here it is.

# important definitions

reaction = complex , delimiter , complex ;

complex = summand , { "+" , complex } ;

species = letter , { letter } , [ "_" ] ,
[ number ] , [ "'" ] ;

summand = nullSymbol | [coefficient] , species ;

coefficient =  digit , { coefficient } ;


# more or less obvious definitions

posDigit = "1" | "2" | "3" | "4" | "5" | "6"
| "7" | "8" | "9" ;

digit = "0" | posDigit ;

posNum = posDigit , { digit } ;

numbers = posNum | "0" ;

capLetter = "a" | "b" | "c" | "d" | "e" | "f" |
"g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" |
"o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" |
"w" | "x" | "y" | "z" ;

lowLetter = "A" | "B" | "C" | "D" | "E" | "F" |
"G" | "H" | "I" | "J" | "K" | "L" | "M" | "N" |
"O" | "P" | "Q" | "R" | "S" | "T" | "U" | "V" |
"W" | "X" | "Y" | "Z" ;

letter = capLetter | lowLetter ;

delimiter = "-->" | "<--" | "<-->" ;

nullSymbol = "" ;

This seems to roughly correspond to the format used by the Control program. The main difference seems to be that Control accepts a variety of strings for the null Symbol (eg. “”, “0”.) Currently, our package only allows one null symbol at a time, but it may be user specified.

 

In the package, objects of type ReactionNetwork now have attributes “NullSymbol” and “NullIndex”, with respective defaults of “” and -1. The function ‘laplacian’ is a prototype for constructing steady state equations. It could use some improvements, but at least generates results consistent with previous worked examples. This extension also introduced a weird error for the ‘merge’ methods in which the default method is assumed, so I renamed the method as “glue.” I’m not sure what’s wrong here.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s