wiki:MussaPython

Version 1 (modified by diane, 17 years ago) ( diff )

--

Python Embedded into Mussa

There are two ways to interact with mussa via python. One is via the embedded interpreter, the other by a python extension module. The advantage to the embedded interpreter is that it is possible to launch a Mussa GUI window to view an analysis that was created via python. The advantage to the extension module is that it doesn't replace your interpreter and that its easier to run scripts from the shell. (There's also the problem that the embedded interpreter probably wont work under Microsoft Windows).

Building Python Enabled Mussa

Patches [493] and [494] currently force building the python version. Soon I'll add a CMake configuration variable to make building this optional.

The result of this is a mussa executable which has a python interpreter embedded in it.

OS X Universal Binary of Mussa with Python

Running

To run the embedded version of mussa you will need to launch mussa from the command line.

mussagl --python

Though on OS X the executable is buried deep within the mussa application folder.

./mussagl.app/Contents/MacOS/mussagl --python

The interpreter will be preloaded with the mussa and mussaqui modules.

Building Mussa Python Extension

Also the current build system produces an extension module which can be imported into a currently running python interpreter. Though I'm not currently shipping a binary that includes it.

I hope there's some way of building a python binary egg from this CMake generated module.

For this, if you have the python module, it just needs to be placed on your python path. and then

$ python
>>> import mussa

should work.

Using Mussa from Python

To actually use Mussa from python.

The following code will construct a three-way mussa analysis, and run it with a threshold of 8 base-pairs matching in 10 base-pair window.

(Sometime soon I'll try to fix .add_sequence() to also take strings)

  s1 = mussa.Sequence("A"*10)
  s2 = mussa.Sequence("GG"+"A"*8+"GG")
  s3 = mussa.Sequence("T"*10)
  m = mussa.Mussa()
  m.window = 10
  m.threshold = 8
  m.add_sequence(s1)
  m.add_sequence(s2)
  m.add_sequence(s3)
  m.analyze()
Note: See TracWiki for help on using the wiki.