Ejemplo n.º 1
0
def make_ribostructs():
    for k, v in rutils.switch_dicts().iteritems():
        rfid = 'RF{0:05}'.format(v)
        savename = 'Riboswitch_list_{1}_{0}'.format(rfid, k)
        structs, rutils.family_clustered_suboptimals(rfid=rfid,
                                                     savename=savename,
                                                     draw=True)
Ejemplo n.º 2
0
def bsub_riboswitches(run_id):
        inp_dicts = []
        for k,v in rutils.switch_dicts().iteritems():
                rfid = 'RF{0:05}'.format(v)
                inp_dicts.append(dict(family = rfid,
                                      inp_run_id = 'RS_{0}'.format(rfid),
                                      run_id = 'RS_tree_{0}'.format(rfid)))
	eyeball = bsub.eyeball(run_id, 
			       os.path.abspath(inspect.stack()[0][1]),
			       inp_dicts,
			       func = 'run_treebuilder',
			       mem = 3)
	eyeball.launch()
	return dict(cmds=eyeball.cmds)
Ejemplo n.º 3
0
def bsub_riboswitches(run_id):
    inp_dicts = []
    for k, v in rutils.switch_dicts().iteritems():
        rfid = 'RF{0:05}'.format(v)
        savename = 'Riboswitch_list_{1}_{0}'.format(rfid, k)
        inp_dicts.append(
            dict(family=rfid, run_id='RS_{0}'.format(rfid), savename=savename))
    eyeball = bsub.eyeball(run_id,
                           os.path.abspath(inspect.stack()[0][1]),
                           inp_dicts,
                           func='run_structmaker',
                           mem=3)
    eyeball.launch()
    return dict(cmds=eyeball.cmds)
Ejemplo n.º 4
0
def bsub_riboswitches(run_id):
    inp_dicts = []
    for k, v in rutils.switch_dicts().iteritems():
        rfid = 'RF{0:05}'.format(v)
        inp_dicts.append(
            dict(family=rfid,
                 inp_run_id='RS_{0}'.format(rfid),
                 run_id='RS_tree_{0}'.format(rfid)))
    eyeball = bsub.eyeball(run_id,
                           os.path.abspath(inspect.stack()[0][1]),
                           inp_dicts,
                           func='run_treebuilder',
                           mem=3)
    eyeball.launch()
    return dict(cmds=eyeball.cmds)
Ejemplo n.º 5
0
def bsub_riboswitches(run_id):
        inp_dicts = []
        for k,v in rutils.switch_dicts().iteritems():
                rfid = 'RF{0:05}'.format(v)
                savename = 'Riboswitch_list_{1}_{0}'.format(rfid,k)
                inp_dicts.append(dict(family = rfid,
                                      run_id = 'RS_{0}'.format(rfid),
                                      savename = savename))
	eyeball = bsub.eyeball(run_id, 
			       os.path.abspath(inspect.stack()[0][1]),
			       inp_dicts,
			       func = 'run_structmaker',
			       mem = 3)
	eyeball.launch()
	return dict(cmds=eyeball.cmds)
Ejemplo n.º 6
0
def show_trees(switch_muts, switch_times, switch_structs):
    for rname,muts, times, structs in zip(switch_times.keys(),
                                          switch_muts.values(), 
                                          switch_times.values(), 
                                          switch_structs.values(),):
        if not rname[0:2] == 'RF':
            rtype = 'switch'
            rfid = 'RF{0:05}'.format(rutils.switch_dicts()[rname])
        else:
            rfid = rname
            rtype = 'all'

        print 'Showing: {0} '.format(rfid)
        #if rname != 'SAM_alpha':continue
        show_paired_v_energy(rname,rfid,muts,times,structs,rtype)
        return
Ejemplo n.º 7
0
def show_trees(switch_muts, switch_times, switch_structs):
    for rname, muts, times, structs in zip(
            switch_times.keys(),
            switch_muts.values(),
            switch_times.values(),
            switch_structs.values(),
    ):
        if not rname[0:2] == 'RF':
            rtype = 'switch'
            rfid = 'RF{0:05}'.format(rutils.switch_dicts()[rname])
        else:
            rfid = rname
            rtype = 'all'

        print 'Showing: {0} '.format(rfid)
        #if rname != 'SAM_alpha':continue
        show_paired_v_energy(rname, rfid, muts, times, structs, rtype)
        return
Ejemplo n.º 8
0
def check_trees(fam_type = 'riboswitch'):
    if fam_type == 'riboswitch':
        sdicts = rutils.switch_dicts()
        rfids = [ 'RF{0:05}'.format(n) for n in sdicts.values()]
        names = sdicts.keys()
        struct_ids = ['RS_{0}'.format(rfid) for rfid in rfids]
        tree_ids = ['RS_tree_{0}'.format(rfid) for rfid in rfids]
    elif fam_type == 'all':
        rfids = [ 'RF{0:05}'.format(n) for n in range(0,1493)]
        names = rfids
        struct_ids = ['FA_{0}'.format(rfid) for rfid in rfids]
        tree_ids = ['FA_tree_{0}'.format(rfid) for rfid in rfids]

    switch_muts = {}
    switch_times= {}
    switch_structs= {}

    for i, rname in enumerate(names):
        print 'Loading family for {0}'.format(rname)
        si, ti = zip(*[struct_ids, tree_ids])[i]
        try:
            structs = bsu.load_data(si, 'output')
            trees   = bsu.load_data(ti, 'output')
            print 'Success! Analyzing tree output'
        except Exception, e:
            print 'Failure! Did I make a booboo?'
            continue
        
            

        str_esrt = argsort(structs['energies'])[::-1]
        #SORT STRUCTURES IN DECREASING ORDER OF ENERGY (MATCH TREES)
        structs['structs'] = [structs['structs'][j] for j in str_esrt]
        structs['energies'] = [structs['energies'][j] for j in str_esrt]
        
        mc, tc, sc = {},{},{}
        sc['energies'] = structs['energies']
        sc['structs'] = structs['structs']
        sc['seq'] = structs['seq']
        for j, t in enumerate(trees):
            if t == None:continue
            mc[j] = {}
            tc[j] = {}
            for idx in range(len(t['structs'])):
                t_infos = t['structs']
                t_str = t_infos[idx]['pairs']
                s_str = structs['structs'][idx]
                e = structs['energies'][idx]
                
                t_times =t_infos[idx]['times']
                t_muts  =t_infos[idx]['muts']
                
                frac_resolved = t_times['total']  /\
                    (t_times['total_incl_unresolved'])
                frac_paired   = t_times['paired'] /\
                    (t_times['unpaired'] + t_times['paired'])

                n_2cons = t_muts['comp']
                n_1cons = t_muts['wob'] 
                n_0cons = t_muts['ucom']
                n_pluscons = t_muts['reco']
                n_nocons =   t_muts['bbad']

                frac_silent = (n_2cons+n_1cons+n_pluscons)/\
                    (n_0cons + n_nocons+\
                         n_2cons+n_1cons+n_pluscons)
                
                frac_double = (n_2cons)/\
                    (n_2cons+n_1cons)
                                          
                frac_destructive=(n_0cons)/\
                    (n_2cons+n_1cons+n_0cons)

                total_muts = (n_0cons + n_nocons+\
                                       n_2cons+n_1cons+n_pluscons)
                total_silent = (n_2cons+n_1cons)
                total_pair_mutants = (n_2cons+n_1cons+n_0cons)

                tc[j][idx] = dict(frac_resolved = frac_resolved,
                             frac_paired = frac_paired,
                             total_time = array([t_times['total_incl_unresolved']]*len(t_times['total'])),
                             total_time_res = t_times['total'])
                mc[j][idx] = dict(frac_silent = frac_silent,
                             frac_double = frac_double,
                             frac_destructive = frac_destructive,
                             total_muts = total_muts,
                             total_silent = total_silent,
                             total_pair_mutants = total_pair_mutants)

                
        print '''Done!
Results:
  {0} subtrees computed.

'''.format(len(mc))

        switch_muts[rname] = mc
        switch_times[rname] = tc
        switch_structs[rname] = sc
Ejemplo n.º 9
0
def make_ribostructs():    
    for k,v in rutils.switch_dicts().iteritems():
        rfid = 'RF{0:05}'.format(v)
        savename = 'Riboswitch_list_{1}_{0}'.format(rfid,k)
        structs, rutils.family_clustered_suboptimals(rfid =rfid,savename = savename, draw = True)
Ejemplo n.º 10
0
def check_trees(fam_type='riboswitch'):
    if fam_type == 'riboswitch':
        sdicts = rutils.switch_dicts()
        rfids = ['RF{0:05}'.format(n) for n in sdicts.values()]
        names = sdicts.keys()
        struct_ids = ['RS_{0}'.format(rfid) for rfid in rfids]
        tree_ids = ['RS_tree_{0}'.format(rfid) for rfid in rfids]
    elif fam_type == 'all':
        rfids = ['RF{0:05}'.format(n) for n in range(0, 1493)]
        names = rfids
        struct_ids = ['FA_{0}'.format(rfid) for rfid in rfids]
        tree_ids = ['FA_tree_{0}'.format(rfid) for rfid in rfids]

    switch_muts = {}
    switch_times = {}
    switch_structs = {}

    for i, rname in enumerate(names):
        print 'Loading family for {0}'.format(rname)
        si, ti = zip(*[struct_ids, tree_ids])[i]
        try:
            structs = bsu.load_data(si, 'output')
            trees = bsu.load_data(ti, 'output')
            print 'Success! Analyzing tree output'
        except Exception, e:
            print 'Failure! Did I make a booboo?'
            continue

        str_esrt = argsort(structs['energies'])[::-1]
        #SORT STRUCTURES IN DECREASING ORDER OF ENERGY (MATCH TREES)
        structs['structs'] = [structs['structs'][j] for j in str_esrt]
        structs['energies'] = [structs['energies'][j] for j in str_esrt]

        mc, tc, sc = {}, {}, {}
        sc['energies'] = structs['energies']
        sc['structs'] = structs['structs']
        sc['seq'] = structs['seq']
        for j, t in enumerate(trees):
            if t == None: continue
            mc[j] = {}
            tc[j] = {}
            for idx in range(len(t['structs'])):
                t_infos = t['structs']
                t_str = t_infos[idx]['pairs']
                s_str = structs['structs'][idx]
                e = structs['energies'][idx]

                t_times = t_infos[idx]['times']
                t_muts = t_infos[idx]['muts']

                frac_resolved = t_times['total']  /\
                    (t_times['total_incl_unresolved'])
                frac_paired   = t_times['paired'] /\
                    (t_times['unpaired'] + t_times['paired'])

                n_2cons = t_muts['comp']
                n_1cons = t_muts['wob']
                n_0cons = t_muts['ucom']
                n_pluscons = t_muts['reco']
                n_nocons = t_muts['bbad']

                frac_silent = (n_2cons+n_1cons+n_pluscons)/\
                    (n_0cons + n_nocons+\
                         n_2cons+n_1cons+n_pluscons)

                frac_double = (n_2cons)/\
                    (n_2cons+n_1cons)

                frac_destructive=(n_0cons)/\
                    (n_2cons+n_1cons+n_0cons)

                total_muts = (n_0cons + n_nocons+\
                                       n_2cons+n_1cons+n_pluscons)
                total_silent = (n_2cons + n_1cons)
                total_pair_mutants = (n_2cons + n_1cons + n_0cons)

                tc[j][idx] = dict(
                    frac_resolved=frac_resolved,
                    frac_paired=frac_paired,
                    total_time=array([t_times['total_incl_unresolved']] *
                                     len(t_times['total'])),
                    total_time_res=t_times['total'])
                mc[j][idx] = dict(frac_silent=frac_silent,
                                  frac_double=frac_double,
                                  frac_destructive=frac_destructive,
                                  total_muts=total_muts,
                                  total_silent=total_silent,
                                  total_pair_mutants=total_pair_mutants)

        print '''Done!
Results:
  {0} subtrees computed.

'''.format(len(mc))

        switch_muts[rname] = mc
        switch_times[rname] = tc
        switch_structs[rname] = sc