def test_main(): text = """ A = True B = Random C = Random D = Random B* = A or C C* = A and not D D* = B and C """ repeat = 5000 coll = util.Collector() for i in range(repeat): update_progress(i, repeat) model = boolean2.Model(text, mode='async') model.initialize() model.iterate(steps=15) # in this case we take all nodes # one could just list a few nodes such as [ 'A', 'B', 'C' ] nodes = model.nodes # this collects states for each run coll.collect(states=model.states, nodes=nodes) # this step averages the values for each node # returns a dictionary keyed by nodes and a list of values # with the average state for in each timestep avgs = coll.get_averages(normalize=True) # make some shortcut to data to for easier plotting valueB = avgs["B"] valueC = avgs["C"] valueD = avgs["D"] # # plot the state of the nodes # p1, = plt.plot(valueB, 'ob-') p2, = plt.plot(valueC, 'sr-') p3, = plt.plot(valueD, '^g-') plt.legend([p1, p2, p3], ["B", "C", "D"]) plt.show() plt.savefig('t-05_figure.png')
import pandas as pd from pyhet.dataset import ccle from pyhet import util # Bring data from filelist mutcna = ccle.mutcna() therapy = ccle.therapy() mutcna_col = mutcna.filter(regex='LARGE_INTESTINE') therapy_col = therapy[therapy['CCLE Cell Line Name'].str.contains( "LARGE_INTESTINE")] gene = pd.read_csv('node_name.csv') # Select data that has 'LARGE INTESTINE' and same gene name with network i = 0 for i in gene.index: util.update_progress(i, gene.shape[0]) gene_index = gene.loc[i, 'node_name'] data_mut = mutcna_col[mutcna_col.index.str.contains(gene_index)] data_therapy = therapy_col[therapy_col['Target'].str.contains(gene_index)] if i == 0: total_mut = data_mut total_therapy = data_therapy else: if gene_index == 'AMP': j = 0 for j in range(len(data_mut.index)): gene_name = data_mut.index[j] if gene_name.find(gene_index) < gene_name.find('_'): temp = data_mut.ix[[j], :] if j == 0: data_mut_cor = temp