コード例 #1
0
def main(nb_input, f, directory_name):

    # number of input in integer
    nb_input=int(nb_input)

    # generate the STT using the following function
    function=STT_from_output_string(f, nb_input)
    
    # copy of the STT
    STT=copy.deepcopy(function)
    
    # check the len of the directory name and complete with zero if lower than 6
    while len(directory_name)<6:
        directory_name='0'+directory_name
    
    # directory path to store the output files    
    mypath='../results/'+directory_name
    os.makedirs(mypath)
    
    name_output_file=mypath+'/'+directory_name+'_output.txt'
    of=open(name_output_file, 'w')

    # From the STT, extraction of the caracteristic for the required devices
    imp, max_output=extraction_of_constructions(nb_input, function)
    
    strain=0
    
    for construction in imp:
        strain+=1
        
        list_integrase=lineage_to_order_inputs(nb_input, construction[0])

        title='Strain'+str(strain)
        gsm.computational_device(nb_input, list_integrase, construction[1], title, mypath, directory_name)
        gsm.legend(nb_input, mypath, directory_name)
        
        if max_output<5:
            DNAseq.design_DNAsequence(nb_input, list_integrase, construction[1], str(strain), '', mypath, directory_name)
   
    if nb_input==5:
        if f[325]=='1':
            strain+=1
            gcm.computation_device('50', str(strain), ['1','2','3','4','5'], 'Strain'+str(strain), mypath, directory_name)
            
            if max_output<5:
                DNAcomb.design_DNAsequence('50', str(strain), '', mypath, directory_name)
            
    #of.write('For the following sequential program:\n'+str(STT)+'\n\n')
    #of.write(str(strain)+' strains are needed.\n\n')
    #of.close()
    
    of.write("This "+str(nb_input)+'-input history-dependent function, \n'+str(STT)+', \nis implemented with '+str(strain)+' strain(s).\n\n')
    
    if max_output<5:
        of.write('The DNA sequence is generated using <i>E. coli</i> promoters, terminators and GOI sequences.\n')
        name_int=['Bxb1', 'Tp901', 'Int5', 'Int7', 'Int3', 'Int4']
        name_output=['GFP', 'RFP', 'BFP', 'LacZ']
               
        texte_int=''
        texte_int1=''
        texte_int2=''
        texte_out1=''
        texte_out2=''
    
        for name in range(0, nb_input):
            if name==nb_input-1:
	        texte_int1+=(str(name+1))
	        texte_int2+=(name_int[name]+'.')
	    else:
	        texte_int1+=(str(name+1)+', ')
	        texte_int2+=(name_int[name]+', ')
	        
        if nb_input==1:
            texte_int=('The integrase '+texte_int1+' corresponds to '+texte_int2)
        else:
            texte_int=('The integrases '+texte_int1+' correspond respectively to '+texte_int2) 
            
        for name in range(0, max_output):
            if name==max_output-1:
	        texte_out1+=(str(name+1))
	        texte_out2+=(name_output[name]+' ')
	    else:
	        texte_out1+=(str(name+1)+', ')
	        texte_out2+=(name_output[name]+', ')
	        
        if nb_input==1:
            texte_out=('For the output '+texte_out1+', the '+texte_out2+'gene is used')
        else:
            texte_out=('For the outputs '+texte_out1+', the '+texte_out2+'genes are used.') 
        
        of.write(texte_int+'\n')    
        of.write(texte_out+'\n\n')
            
    else:
        of.write('Generation of DNA sequence file of computational device is not possible using CALIN website as IDs of output gene are biggest than 4. Please refer to <a href="https://github.com/sguiz/calin" target="_blank" class="nav">github</a> for custom DNA generation.\n\n')



    of.close()
    strain=0
    
    return
コード例 #2
0
def design(output, nb_input, path, directory_name):

    # convert the output integer in a binary number
    #output=bin(output)[2:]
    name_output_file = path + '/' + directory_name + '_output.txt'
    of = open(name_output_file, 'w')
    # if len of the output does not correspond to the number of input, add 0 to the number
    if len(output) < (2**(nb_input)):
        for w in range(2**(nb_input) - len(output)):
            output = '0' + output

    # initialize the on_sate which will be a list of state equal to 1. The states are identifiy by an integer.
    on_state = []
    off_state = []
    # index for input state
    x = 0

    # screen all output state (all bit), from the lowest bit to the highest one
    for c in reversed(output):

        # if output is equal to 1
        if c == '1':
            # add X to the on_state list
            on_state.append(x)
        else:
            off_state.append(x)

        x += 1

    # obtain the simplification from Cain McKluskey algorithm of the on_state
    # pos_imp correspond to a list of string. Number of string correspond to the nb of sub_function
    # Each string is composed of X for whatever, 1 for A or 0 for not(A) and the position of the term correspond to the variable.
    pos_imp = function_simplification(on_state, off_state)

    #print pos_imp

    # bioloigcal_implementation is to obtain the explicit biological implement
    # inputs are pos_imp (result from QM algo) and the number of inputs
    # outputs are the number of inputs, the number of strains needed, the list of computation devices
    # and the list of the connection between integrases and variables.
    [nb_strain, list_component,
     list_int_var] = biological_implementation(pos_imp, nb_input)

    of.write("This " + str(nb_input) + '-input Boolean function ' + output +
             ' is implemented using ' + str(nb_strain) + ' strain(s).\n\n')
    of.write(
        'DNA sequences are generated using <i>E. coli</i> promoters, terminators and GOI sequences.\n'
    )

    name_int = ['Bxb1', 'Tp901', 'Int5', 'Int7', 'Int3', 'Int4']

    texte_int1 = ''
    texte_int2 = ''

    for name in range(0, nb_input):
        if name == nb_input - 1:
            texte_int1 += (str(name + 1))
            texte_int2 += (name_int[name] + '.')
        else:
            texte_int1 += (str(name + 1) + ', ')
            texte_int2 += (name_int[name] + ', ')

    if nb_input == 1:
        texte_int = ('Integrase ' + texte_int1 + ' corresponds to ' +
                     texte_int2)
    else:
        texte_int = ('Integrases ' + texte_int1 +
                     ' correspond respectively to ' + texte_int2)

    of.write(texte_int + '\n\n')
    of.close()
    strain = 0

    # for each strain, loop in the list of component and list of integrase variable connections
    for COMP, X in zip(list_component, list_int_var):

        strain += 1

        # To represent the computation device with the information of the strain number and of var/int connections
        gcm.computation_device(COMP, str(strain), X, 'Strain' + str(strain),
                               path, directory_name)
        # Generation of the DNA sequence
        dns.design_DNAsequence(COMP, str(strain), output, path, directory_name)

    gcm.legend(nb_input, path, directory_name)