Beispiel #1
0
def virtual_e():
    """Virtual Electrophoresis"""
    error = None
    if request.method == 'POST':
        amp_num, session_dir = request.form['amp_num'].split(':')
	filename = chilli.random_string(12) + '.png'
	pic_path = os.path.join('show_img', filename)
	#pic_path = os.path.join(session_dir, filename)
        size_list = []
        for i in range(int(amp_num)):
            amp_key = 'Amplicon_detail_name_%s' % (i+1)
            if request.form.has_key(amp_key):
                amp_seq = request.form[amp_key]
		size = len(''.join(amp_seq.splitlines()[1:]))
                size_list.append(size)

        if len(size_list) == 0:
            error = 'Please select the amplicons for Virtual Electrophresis'
	    return render_template('index.html', error=error)
        else:
	    error = ve.paint(size_list, 1, pic_path)
	    if error:
		return render_template('index.html', error=error)

	    return render_template('ve.html', filename=filename)

    return redirect(url_for('root'))
Beispiel #2
0
def virtual_electrophoresis():
    error = None
    session_dir = chilli.session(session_parent)
    if request.method == 'POST':
	size_list_str = request.form['size_list']
	size_list = []
	try:
	    for size in [size for size in re.split('[^\d]', size_list_str)]:
		if size:
		    size_list.append(size)
	except:
	    error = 'Error: Wrong size list format'
	    return render_template('elec_index.html', error=error)

	gel_conc = float(request.form['gel_conc'])
	filename = chilli.random_string(12) + '.png'
	pic_path = os.path.join('show_img', filename)

        if len(size_list) == 0:
            error = 'Please input size list for Virtual Electrophresis'
	    return render_template('elec_index.html', error=error)
        else:
	    error = ve.paint(size_list, gel_conc, pic_path)
	    if error:
		return render_template('elec_index.html', error=error)

	    return render_template('ve.html', filename=filename)

    return render_template('elec_index.html', error=error)