Monday, March 16, 2009

Highlighting and Label items on the screen

The CLabelsTool allows labeling and highlighting (drawing circles) on objects on the screen. It also provides convenient C/Python API functions, allowing C and Python programs to label and/or highlight items on the screen. 

The C/Python functions are called displayText, displayNumber, and highlight. The C++ signals are also named the same.

Saturday, March 14, 2009

Search E.coli genetic network using RegulonDB

A python program,, loads the RegulonDB tab delimited files into hash tables. A second python program,, uses these hash tables to allow users to replace items on a model with items in the RegulonDB database. The interface makes use of the getFromList API function, which also includes the search feature.

With this python function, users can:
  • get RBS, terminator, or promoter sequences along with RegulonDB ID
  • get the list of regulatory parts for one or more selected transcription factor
  • get the list of transcription factors for one or more selected regulatory parts

Friday, March 13, 2009

Displaying List of Strings from C and Python

The C function tc_getFromList , or the equivalent python function pytc.getFromList allows C and Python programs to display either a list or a drop-down menu. When the user makes a selection, the index of the selection will be returned.

The following command generated the above dialog.

pytc.getFromList("What will you have for dinner?",("fruits and nuts", "bowl of cereal", "pasta and veggies", "sandwich", "oats and nuts"),0)

Changing the last argument will change the display to a drop-down menu (combo box), as shown below.

pytc.getFromList("What will you have for dinner?",("fruits and nuts", "bowl of cereal", "pasta and veggies", "sandwich", "oats and nuts"),1)

Flux Balanace Analaysis and generic C interfaces

It is difficult to create intricate interfaces using the C API. What is more practical is to just write a C++ plugin. So, suppose you need a relatively complicated interface for a C function, then the procedure is as follows:

  • design the interface using Qt C++
  • write the C program and make it into a dynamic library
  • make the C++ plugin call the C program using LibraryThread
  • place the C++ dynamic library in the "menu.txt" file so that it appears along with the other "functions".
The Flux Balance Analysis function is one such example. The interface is a regular plugin, but it calls the C program (lpsolve.c) when the run button is pressed. The plugin can therefore respond to selection events and other events. The plugin creates a matrix that is passed on to lpsolve.c as input.

Normal C dynamic libraries are loaded using the LibraryThread class. However, since these C++ programs are different, the LibraryThread performs a check to see whether the "loadTCTool" function exists in the library. If it does exist, then the library is loaded as a plugin on the main thread and not as a threaded C program, which is usually on a separate thread.

The diagram above shows how different libraries are loaded. Essentially, if the library contains the "run" function, it is assumed to be a C program. If it contains the "loadTCTool" function, it is assumed to be a C++ library that adds a new tool to the main window. The LibraryThread runs the C program on a separate thread and unloads the library when the program is finished. The C++ libraries represent widgets and other such tools which are only unloaded when TinkerCell exists.

Sunday, March 8, 2009

Integrated Antimony

Antimony script is now integrated into TinkerCell. The NetworkX python module is used to perform the layout, since Antimony scripts do not contain graphical information.

More importantly, the visual side and the script side (Antimony) can update one another. This allows a user to shift from script view to and from graphical view any time.

Linear Programming with LPsolve

The lpsolve library has been integrated into TinkerCell. The code is in c/lpsolve.c and the lpsolve package is included in the c/lpsolve directory. 

The generic outline of the code is as follows:

  • get selected connections (error if none)
  • get stoichiometry for all items
  • find columns of the stoichiometry corresponding to selected items
  • setup lpsolve with the selected connections as the objective 
  • setup lpsolve with the stoichiometry as the constraint
  • solve
  • get the optimal values and post them on the screen using tc_displayText

Symbols Table

Each GraphicsScene now contains a "symbols table". This table contains three hash tables:

1) handle FULL names ----> pointers to handles
2) handle FIRST names ----> list of all handles (pointer) with that name
3) data row and column name ----> list of pairs that indicates the handle and the tool (name of tool) where the row or column name comes from

The symbols tables are updates during each event (history update).
An example where the symbols tables are used is in the rate equations. When a user types a rate equation, the Stoichiometry Tool looks at the symbols table to determine whether the parameters in that rate equation already exist somewhere in the model. 

The container tool (which provides the Attributes View window) also uses the symbols table to get a list of all the handles. 

The Console Window

The console emits a signal whenever the user types a command. The plugins may then choose to respond to the command. The Python plugin in one such tool (the only one currently). The command window provides plugins with the ability to "freeze" the command window. Since Python runs on a separate thread, this is neccessary. Python "freezes" the command window when it starts executing the command and "unfreezes" the command window when it is done.

A new plugin that interprets commands at the command window may do the same...although I have not decided how the plugins will determine which command is intended for which plugin.