コード例 #1
0
ファイル: avida_presets.py プロジェクト: bh0085/projects
def make_genomes(genesis):
    #Create a genome and a complementing genome
    genome = au.genesis_seqs(genesis)
    seqprime = genome
    repeats = re.search(re.compile('c{3,}'), seqprime).group()
    seqprime = seqprime.replace(repeats, repeats.replace('c', 'b'))
    org_fname2 = au.save_genome(genesis, seqprime, org_fname + '.comp')
コード例 #2
0
ファイル: avida_presets.py プロジェクト: bh0085/projects
def make_genomes(genesis):
    #Create a genome and a complementing genome
    genome = au.genesis_seqs(genesis)
    seqprime = genome
    repeats = re.search(re.compile('c{3,}'),seqprime).group()
    seqprime =seqprime.replace(repeats,repeats.replace('c','b'))
    org_fname2 = au.save_genome(genesis,  seqprime, org_fname + '.comp')
コード例 #3
0
ファイル: avida_presets.py プロジェクト: bh0085/programming
def differential_mut(name, eve_fname, org_fname, ana_fname, env_fname,  ins_fname, gen_name):
    #CONFIG PARAMETERS
    mut_rate_source = 2
    x = default_x
    y = default_y
    params_dict = {'MUT_RATE_SOURCE':2,
                   'WORLD_X':x,
                   'WORLD_Y':y,
                   'WORLD_GEOMETRY':2,
                   'ENVIRONMENT_FILE':env_fname,
                   'ANALYZE_FILE':ana_fname,
                   'EVENT_FILE':eve_fname,
                   'INST_SET':ins_fname,
                   'START_CREATURE':org_fname,
                   'DIVIDE_INS_PROB':0.0,
                   'DIVIDE_DEL_PROB':0.0,
                   'COPY_MUT_PROB':0.00}

    genesis = ca.make_gen(name,\
                          params_dict,\
                          gen_name)
    #Create a genome and a complementing genome
    genome = au.genesis_seqs(genesis)
    seqprime = genome
    repeats = re.search(re.compile('c{3,}'),seqprime).group()
    seqprime =seqprime.replace(repeats,repeats.replace('c','b'))
    org_fname2 = au.save_genome(genesis,  seqprime, org_fname + '.comp')
    n = x * y
    ntot = x*y
    nofs = ntot/2
    #STERILIZE 
    ca.alter_eve(eve_fname, 'i KillRectangle 0 0 '+str(x) + ' ' + str(y))    
    #SET MUTATION PROBS

    highmut_strings = ['i SetMutProb COPY_MUT '+str((mu0 - deltamu)*kmut) + ' 1 '+str(nofs),
                       'i SetMutProb DIVIDE_INS '+str((mu0 - deltamu)*kdiv) + ' 1 '+str(nofs),
                       'i SetMutProb DIVIDE_DEL '+str((mu0 - deltamu)*kdiv) + ' 1 '+str(nofs)]

    lowmut_strings =  ['i SetMutProb COPY_MUT '+str((mu0 + deltamu)*kmut) + ' ' + str(nofs+1) + ' ' +str(ntot),
                       'i SetMutProb DIVIDE_INS '+str((mu0 + deltamu)*kdiv) + ' ' + str(nofs+1) + ' ' +str(ntot),
                       'i SetMutProb DIVIDE_DEL '+str((mu0 + deltamu)*kdiv) + ' ' + str(nofs+1) + ' ' +str(ntot)]

    for s in highmut_strings:
        ca.alter_eve(eve_fname, s)

    for s in lowmut_strings:
        ca.alter_eve(eve_fname, s)

    #INJECT
    ca.alter_eve(eve_fname,   
                 'i InjectRange '+org_fname+' 1 '+str(nofs)+' -1 0')
    ca.alter_eve(eve_fname,   
                 'i InjectRange '+org_fname+' '+str(nofs+1)+ ' ' +str(ntot) +' -1 1')

    #get a default set of resources, tasks, rxns and corresponding  params

    task_names, res_names, resource_ropts = get_resources()
    task_names_b, res_names_b, resource_ropts_b = get_resources(distribution = 'gravity',
                                                                ygrav = default_ygrav,
                                                                outflow = biproduct_outflow,
                                                                inflow = 0, 
                                                                kind = 'byproduct')


    if enable_biproducts:
        if biproduct_last: biproducts=  shift(res_names_b, -1)
        else: biproducts = res_names_b
    else:
        biproducts = None
    rxn_names, rxn_popts, rxn_ropts = get_reactions(res_names,
                                            
        conversion = conversion,
                                                    product_names = biproducts)

    if death_chain_reaction: b_prods = res_names_b
    else:b_prods = res_names

                                   
 
    rslines = au.resource_lines(res_names, resource_ropts)
    rxlines = au.reaction_lines(rxn_names, task_names,rxn_popts,rxn_ropts)


    ca.append_lines(env_fname, rslines)
    
    

    if enable_biproducts:
        rxn_names_b, rxn_popts_b, rxn_ropts_b = get_reactions(res_names_b, 
                                                              lethal = lethal_biproduct,
                                                              min_count = lethal_dose,
                                                              product_names = b_prods,
                                                              conversion = death_chain_mag,
                                                              bonus_type = 'mult',
                                                              values = [0 for i in res_names])
        rslines_b = au.resource_lines(res_names_b, resource_ropts_b)
        rxlines_b = au.reaction_lines(rxn_names_b, task_names_b,rxn_popts_b,rxn_ropts_b)
        ca.append_lines(env_fname, rslines_b)
        ca.append_lines(env_fname, rxlines_b)
    
    ca.append_lines(env_fname, rxlines)

    #EXIT
    ca.alter_eve(eve_fname, 'g ' + str(default_gens) + ' Exit')