示例#1
0
networks['A']['thresholds'] = {("rr","gg"):1, ("rr","bb"):2, ("bb","gg"):1, ("gg","gg"):1}

combis = [(False, False), (True, False), (False, True)] # low, medium, high
ALformulas = ["?(left: left.frozen(gg)&left.max(gg)=0)", "?(middle: middle.frozen(gg)&middle.min(gg)=1)",
              "?(right: right.frozen(gg)&right.max(gg)=0)"]

for letter in 'A': # in C, unfortunately green is the input gene
    print "===================================================================================="
    print "Considering network:", networks[letter]['name']
    interactions = networks[letter]['interactions']
    edges = interactions.keys()
    thresholds = networks[letter]['thresholds']
    IG = nx.DiGraph()
    IG.add_edges_from(edges)
                
    mc = dict_to_model(interactions, thresholds=thresholds, add_morphogene=True)
    smallmc = dict_to_model(interactions, thresholds=thresholds, add_morphogene=False)

    lpss = mc._psc._localParameterSets
    print len(mc._psc), "parameter sets."

    gpss = mc._psc.get_parameterSets()
    countaccepted = 0
    countrejected = 0
    for gps in gpss:
        #print gps
        subgps = dict((combi, encode_gps_full(subparset(gps, is_m1_in=combi[0], is_m2_in=combi[1]))) for combi in combis)
        parameter_set_IG_list = [decode_gps_full(subgps[combi]) for combi in combis]
        parameter_sets = [elem[0] for elem in parameter_set_IG_list]
        accepted = all(filter_byAL(smallmc, parameter_sets[i], ALformulas[i]) for i in range(3))*1
        if accepted:
import cPickle
from _02_regnet_generator import dict_to_model
from _03_database_functions import export_STG

if __name__=='__main__':
    net = {('rr', 'bb'):'+', ('bb', 'rr'):'+'}

    mc = dict_to_model(net, add_morphogene=True, thresholds=None)
    print "found", len(mc._psc), "parameter sets."
    gpss = mc._psc.get_parameterSets()

    for gps in gpss:
        print gps

    print "exporting example STG..."

    export_STG(mc, gps, filename="example_network_STG.gml", initialRules=None)

    print "done."
示例#3
0
 pstotal = 0
 for nwkey in networks:
     #print "===================================================================================="
     #print nwkey, networks[nwkey]
     # disable following to keep overregulated networks
     if networks[nwkey][('bb', 'rr')]!='0' and networks[nwkey][('gg', 'rr')]!='0' and networks[nwkey][('rr', 'rr')]!='0': 
         if nwkey in non:
             print "i am making a mistake at", nwkey
             sys.exit()
         print "network", nwkey, "is overregulated, skipping."
         continue # we skip if rr is overregulated (too slow)
     current += 1
     #if nwkey<start_nwkey or nwkey>=start_nwkey+tocheck: continue
     print "===================================================================================="
     print "considering nwkey:", nwkey
     mc = dict_to_model(networks[nwkey], add_morphogene)
     npsc = len(mc._psc)
     print nwkey, ":", npsc, "parameter sets."
     pstotal += npsc
     print nwkey, ":", pstotal, "parameter sets in total."
     
     gpss = mc._psc.get_parameterSets()
     count_accepted = 0
     for gps in gpss:
         # decompose gps code into 3 small gps codes
         subgps = dict((combi, encode_gps_full(subparset(gps, is_m1_in=combi[0], is_m2_in=combi[1]))) for combi in combis)
         accepted = d[subgps[combis[0]]][0] and d[subgps[combis[1]]][1] and d[subgps[combis[2]]][0] # d[][2] (the one with 'instable') is not used here
         #print accepted
         if accepted:
             count_accepted += 1
     results = [count_accepted, npsc, count_accepted*1.0/npsc]
            print net #, networks[net]['interactions']
            graph_number = lookup_graph_number(networks[net]['interactions'])
            iso_graph_number = lookup_iso_rep(graph_number) 
            print iso_graph_number 
            print crs[str(iso_graph_number)]

    print "========================================="
    print "AL model checking"
    crs = shelve.open(combined_results_shelvenames[0])
    numbers = {7747:'A', 7423:'B', 7969:'E', 9349:'D', 14284:'F'} # TODO: this should be generated by the above loop (simple)
    combis = [(False, False), (True, False), (False, True)] # low, medium, high

    ALformulas = ["?(left: left.frozen(gg)&left.max(gg)=0)", "?(middle: middle.frozen(gg)&middle.min(gg)=1)",
                  "?(right: right.frozen(gg)&right.max(gg)=0)"]
    for number in numbers:
        mc = dict_to_model(allnetworks[number], add_morphogene=True)
        smallmc = dict_to_model(allnetworks[number], add_morphogene=False)
        gpss = mc._psc.get_parameterSets()
        count_accepted = 0
        for gps in gpss:
            #print gps
            subgps = dict((combi, encode_gps_full(subparset(gps, is_m1_in=combi[0], is_m2_in=combi[1]))) for combi in combis)
            parameter_set_IG_list = [decode_gps_full(subgps[combi]) for combi in combis]
            parameter_sets = [elem[0] for elem in parameter_set_IG_list]
            #print parameter_sets
            accepted = all(filter_byAL(smallmc, parameter_sets[i], ALformulas[i]) for i in range(3))*1
            if accepted:
                print "accepting:", gps
                #export_STG(mc, gps, filename=str(number).zfill(5)+"_"+encode_gps(gps, base=10)+".gml", initialRules=None)
                export_STG(mc, gps, filename="_"+numbers[number]+"_"+encode_gps(gps, base=10)+".gml", initialRules=None)