def pivot(): if 'reconstructed_structures' not in session: return redirect('/') true_structure = session['true_structure'] reconstructed_structures = session['reconstructed_structures'] coverage_image_file_name = session['coverage_image'] if reconstructed_structures is None or len(reconstructed_structures) == 0: return redirect('/') first_cycle = str(request.form['first_cycle']) first_segment = int(request.form['first_segment']) second_segment = int(request.form['second_segment']) last_structure = reconstructed_structures[-1] pivot_error = None try: g = graph_decomposition(file_content=last_structure[1]) g.pivot(first_cycle, first_segment, second_segment) new_reconstructed_structure = (last_structure[0], str(g)) reconstructed_structures.append(new_reconstructed_structure) except Exception as e: pivot_error = str(e) return draw_structures(true_structure, reconstructed_structures, coverage_image_file_name, pivot_error=pivot_error)
def merge(): print('merge function') if 'reconstructed_structures' not in session: print('redirecting to home') return redirect('/') true_structure = session['true_structure'] reconstructed_structures = session['reconstructed_structures'] coverage_image_file_name = session['coverage_image'] if reconstructed_structures is None or len(reconstructed_structures) == 0: print('redirect to home 2') return redirect('/') first_cycle = str(request.form['first_cycle']) second_cycle = str(request.form['second_cycle']) first_segment = int(request.form['first_segment']) second_segment = int(request.form['second_segment']) last_structure = reconstructed_structures[-1] merge_error = None try: g = graph_decomposition(file_content=last_structure[1]) g.merge(first_cycle, second_cycle, first_segment, second_segment) new_reconstructed_structure = (last_structure[0], str(g)) reconstructed_structures.append(new_reconstructed_structure) except Exception as e: merge_error = str(e) return draw_structures(true_structure, reconstructed_structures, coverage_image_file_name, merge_error=merge_error)