#!/usr/bin/env python3

"""Gibson (Isothermal) Assembly"""

def input_info(insert_number):
    """
    input
    number of inserts

    prompts for
    size = base pairs; conc = ng/ul

    returns
    fragments = {'vector': [v_size,v_conc], 'insert1': [i1_size, i1_conc], ...}

    """
    n = 1
    fragments = {}
    for numbers in range(insert_number):
        insert_bp_input = float(input(('insert' + str(n) + ' bp: ')))  #insert has to be an integer
        insert_conc_input = float(input('insert' +str(n) + ' conc: '))
        fragments['insert' + str(n)] = [insert_bp_input, insert_conc_input]
        n = n + 1

    vector_ng_input = float(input('vector bp: '))
    vector_conc_input = float(input('vector conc: '))
    fragments['vector'] = [vector_ng_input, vector_conc_input]
    return(fragments)

def gibson_calc(fragments):
    """
    Calculate ul needed for 1 vector and 1+ inserts for gibson assembly
    #suggested by protocol - indicates where protocol defaults are. These may need to be altered if troubleshooting

    input
    fragments = {'vector': [v_size,v_conc], 'insert1': [i1_size, i1_conc], ...}
    size = base pairs; conc = ng/ul

    return
    reaction = {'vector': v_ul, 'insert1': i1_ul, ...}
    """

    #vector calculations
    v_ng = 100 #suggested by protocol
    v_pmol = v_ng*(1000/(fragments['vector'][0]*650))
    v_ul = v_ng/fragments['vector'][1]
    reaction = {'vector':v_ul}

    #determine vector:insert ratio
    if len(fragments) <= 3:
        ratio = 2 #suggested by protocol
    if len(fragments) > 3:
        ratio = 1 #suggested by protocol

    #insert calculations
    for key in fragments:
        if key.startswith('insert'):
            i_pmol = v_pmol*ratio
            i_ng = i_pmol/(1000/(fragments[key][0]*650))
            i_ul = i_ng/fragments[key][1]
            reaction[key] = i_ul

    return reaction

def print_result(dictionary):
    print('') #blank row for clarity
    print('Microliters for each fragment:')
    for key in dictionary:
        print(key, round(dictionary[key],2))

def gibson():
    #running the program
    insert_number = int(input('number of inserts (not incluing vector): '))
    fragments = input_info(insert_number)
    results = gibson_calc(fragments)
    print_result(results)


if __name__ == '__main__':
    gibson()

@@ -2026,16 +2026,20 @@
 nt(key, 
+str(
 round(di
@@ -2055,16 +2055,1203 @@
 key%5D,2))
++'ul')%0A%0A#in progress writing%0Adef analyze_results(fragments,results,insert_number):%0A    #test ul are within 10ul available for standard reaction%0A    #test ul amount is reasonable%0A    sum_ul = 0%0A    for key in results:%0A        sum_ul += results%5Bkey%5D%0A        if results%5Bkey%5D %3C 1:%0A            print('ul too small for %25s. May want to dilute.' %25key)%0A    if sum_ul %3E 10:%0A        print('Total of %25sul exceeds standard 10ul for reaction.' %25round(sum_ul,2))%0A%0A    #test pmol are within range for given fragment number%0A    ratio = 2%0A    if insert_number %3E2:%0A        ratio = 1%0A    v_ng = 100 #suggested by protocol%0A    sum_pmol = v_ng*(1000/(fragments%5B'vector'%5D%5B0%5D*650)) #start equal to v_pmol%0A%0A    for key in fragments:%0A        if key.startswith('insert'):%0A            sum_pmol += v_ng*(1000/(fragments%5B'vector'%5D%5B0%5D*650))*ratio%0A    if insert_number %3C= 2:%0A        if not(sum_pmol%3E=0.03 and sum_pmol %3C=0.2):%0A            print('Total of %25spmol is outside recommended range for 2-3 total fragments' %25round(sum_pmol,2))%0A    if insert_number %3E2:%0A        if not(sum_pmol%3E=0.2 and sum_pmol %3C=0.5):%0A            print('Total of %25spmol is outside recommended range for 4-6 total fragments' %25round(sum_pmol,2))%0A
 %0A%0Adef gi
@@ -3438,16 +3438,16 @@
 gments)%0A
-
     prin
@@ -3464,16 +3464,69 @@
 esults)%0A
+    analyze_results(fragments,results,insert_number)%0A
 %0A%0Aif __n

Add analyze results function