Below is my code for a barcode generator for dna sequencing. When I enter nothing for the mingc and max gc, the interpreter does not give any results. Did I use the correct format, ex. if mincg ='': etc.
import random
nucl_list = ['A', 'C', 'G', 'T']
length = 10
print '\nEnter desired GC content range in percentages (i.e. 50 ->50%)'
# ask for desired GC content range
mingc = raw_input("Minimum GC content (default is 40):")
if mingc == '':
mingc = 40
else:
mingc = float(mingc) / 100
maxgc = raw_input("Maximum GC content (default is 60):")
if maxgc == '':
maxgc = 60
else:
maxgc = float(maxgc) / 100
def gc_cont(barcode):
gc = 0.0
for base in range(length):
if barcode[base] == 'C' or barcode[base] == 'G':
gc += 1
else:
gc += 0
cont = gc / length
return cont
barcode = ''
while barcode == '':
for i in range(length):
barcode += random.choice(nucl_list)
#print barcode
if maxgc >= gc_cont(barcode) >= mingc:
bar_code = barcode
print bar_code
else:
barcode = ''`enter code here`
print repr(mingc)aftermingc = raw_input(...)?ifstatement, what'smingcwhen you enter 40, and what's in it when you leave it blank? Just keep looking for places to addprintstatements (or, better, use the debugger) to figure out where it first goes wrong. Then, instead of having to look at your whole program and guess what might be wrong, you can look at the one line where things go wrong and figure it out.mingc = 40gets executed; if you enter 40,mingc = 40 / 100gets executed.