def main():
    parser = argparse.ArgumentParser(description='Produce RNA from DNA')
    parser.add_argument('--trace', action='store_true')
    parser.add_argument('--pause', action='store_true')
    parser.add_argument('prefix_filename')
    
    args = parser.parse_args()
    prefix_filename = args.prefix_filename
    
    prefix = open(prefix_filename+'.dna').read().strip()
    
    assert all(c in 'ICFP' for c in prefix)
        
    e = Executor(prefix+endo())
    e.debug = args.trace or args.pause
    
    start = clock()
    
    #for r in e.obtain_rna():
    #    print>>rna, r
    try:
        while True:
            e.step()
            if args.pause:
                print 'press enter',
                raw_input()
    except FinishException:
        pass

    rna_file = open(prefix_filename+'.rna', 'w')
    for r in e.rna:
        print>>rna_file, r
    
    print 'it took', clock()-start
    print int(e.iteration/(clock()-start+1e-6)), 'iterations/s'
    
    rna_file.close()
def generate_trace(n_steps=10):
    e = Executor(endo())
    
    e.debug = True
    for i in range(n_steps):
        e.step()