Wednesday, May 25, 2011

Steps toward wet-lab integration

Some plans ahead include integrating wet-lab data. The diagram will be generated using semantics in order to make the integration more structured. Currently, users can draw "experiment" connections and "data" nodes. The RDF files in the TinkerCell home folder /Lab store the ontology for each. The idea is that python plugins will be used to fill in details about the experiment and the data. The long term goal is to make diagrams like these part of exchange and maybe lab automation. TinkerCell's ability to explicitly identify cells, plasmids, fluorescent proteins, and other relevant components can serve as the link between predicted results from models and experimental results.


Simple perturbation python plug-in



The plugin removes each promoter one by one and performs a simulation to see the consequence of the removal. The plugin also allows the user to perturb RBS strength and mRNA degradation by a given amount. The entire plugin is written in python and the source is available in the TinkerCell home folder.

Sunday, May 8, 2011

Ruby scripts


Users can now write Ruby scripts in TinkerCell. Unfortunately, this feature is only working properly in Linux at present. Hopefully, I will be able to fix it in Windows and Mac.

Sample Octave code for testing nonmonotonicity


target = [0 0.3 1 0.3 0]';
inputs = [0 0.1 0.3 0.5 1]';
outputs = zeros(5,1);
ic = tinkercell.tc_getInitialValues(tinkercell.tc_allItems());
k = tinkercell.tc_getRowIndex(ic, "INPUT");
for i = 1:5
    x = inputs(i);
    tinkercell.tc_setMatrixValue(ic, k, 0, x);
    tinkercell.tc_updateParameters(ic);
    ss = tinkercell.tc_getSteadyState();
    j = tinkercell.tc_getRowIndex(ss, "OUTPUT");
    if (j > -1)
        outputs(i) = tinkercell.tc_getMatrixValue(ss, j, 0);
    end
end
m = [ inputs outputs ];
m2 = toTC(m);
tinkercell.tc_plot(m2, "input-output");
score = corrcoef( target, outputs )

Friday, May 6, 2011

Dialogs with Octave or Python callback functions

#callback function
def myFunc(w,h,output):
print "width = " + str(w) + " height = " + str(h) + " output = " + output

#create the input window with 3 rows and 1 column
inputWindow = tc_createMatrix( 3, 1 )
tc_setMatrixValue(inputWindow, 0, 0, 0)
tc_setMatrixValue(inputWindow, 1, 0, 0.0)
tc_setMatrixValue(inputWindow, 2, 0, 0.0)

#given row names to display
tc_setRowName(inputWindow, 0, "Width")
tc_setRowName(inputWindow, 1, "Height")
tc_setRowName(inputWindow, 2, "Output")
tc_createInputWindowForScript(inputWindow, "Screenshot", "myFunc")

#make the last row a set of options
list = ["Wiki code","HTML code"]
tc_addInputWindowOptions("Screenshot", 2, 0, toTC(list))


Here is the screenshot. When the user clicks the ok button, the callback function is called with the arguments 55, 12, "Wiki code"


Sample python script for doing perturbation experiments

# we are just going to change all the parameters that begin with the phrase 'synthconst'

items = tc_allItems()
params = tc_getParameters(items)


p = ""   #parameter name

#just count how many there are

total = 0  
for i in range(0,params.rows):
    p = tc_getRowName(params, i)
    if p.count('synthconst') > 0:
    total += 1

#for each parameter
j = 0
for i in range(0,params.rows):
    p = tc_getRowName(params, i)
    if p.count('synthconst') > 0:   #check parameter name
        tc_showProgress("DREAM automation", int((100.0 * j)/total))  #progress meter
        j += 1
        #perturb
        s = ""
        FILE = open(p + '.perturb.txt','w+')  #save to file
        p0 = tc_getMatrixValue(params, i, 0)  #original parameter value
        for q in [100, 10, 2, 1]:        #perturbations
            tc_setMatrixValue(params, i, 0, p0/q)
            tc_setParameters(params,0)
            m = tc_getSteadyState() #steady state
            s += str(p0/q)
            for i in range(0,m.rows):  #for each output value
                if tc_getRowName(m,i).count('m') > 0: #if name starts with m
                    s += "\t"
                    s += str(tc_getMatrixValue(m, i, 0))
                    s += "\n"
            FILE.write(s)
            FILE.close()
#done
tc_showProgress("DREAM automation", 100)  #close progress meter