converting Mx 1.0 algebras

1 reply [Last post]
mspiegel's picture
Offline
Joined: 07/31/2009

I've written a python script that converts Mx 1.0 algebra expressions into OpenMx. The script is located in the subversion repository at trunk/inst/tools/mxAlgebraParser.py (in the next binary release 0.1.6 you will find this file in your OpenMx installation in the directory tools/mxAlgebraParser.py). You will need python installed on your machine, and the PLY library (Python Lex-Yacc library). If you have easy_install on your machine, run "sudo easy_install ply" for painless install. You can get easy_install over here: http://pypi.python.org/pypi/setuptools, although I recall some kind of dark magic is needed to get it for Python 2.6 on Windows (try this? http://stackoverflow.com/questions/309412/how-to-setup-setuptools-for-py...)

The script expects an expression on standard input and it prints the resulting translation on standard output. So you can either run: ./mxAlgebraParser.py < input > output if you love files. Or you can just run ./mxAlgebraParser and start typing your Mx 1.0 algebra. Use ctrl-D at the beginning of a line on OS X and unix to terminate input, and ctrl-Z at the beginning of a line on Windows. Input expression can span multiple lines, the parser ignores spaces, tabs, and newlines. The next step is to combine the algebra parser with the rudimentary Mx 1.0 script parser in the repository.

Steve's picture
Offline
Joined: 07/30/2009
Very cool!

Very cool!