def get_response_content(fs): """ @param fs: a FieldStorage object containing the cgi arguments @return: the response """ # get the texts tikz_fiedler = get_tikz_text('\n'.join(get_fiedler_tikz_lines())) tikz_t1 = get_tikz_text('\n'.join(get_t1_tikz_lines())) tikz_t2 = get_tikz_text('\n'.join(get_t2_tikz_lines())) tikz_t3 = get_tikz_text('\n'.join(get_t3_tikz_lines())) tikz_t4 = get_tikz_text('\n'.join(get_t4_tikz_lines())) tikz_fail = get_tikz_text('\n'.join(get_fail_tikz_lines())) tikz_success = get_tikz_text('\n'.join(get_success_tikz_lines())) subfloat_pictures = [ tikz_fiedler, tikz_t1, tikz_t2, tikz_t3, tikz_t4, tikz_fail, tikz_success ] # return the response figure_body = '\n'.join(get_float_figure_lines(subfloat_pictures)) packages = ('tikz', 'subfig') preamble = '' return latexutil.get_centered_figure_response(figure_body, fs.latexformat, g_figure_caption, g_figure_label, packages, preamble)
def get_figure_response(tikzpicture, tikzformat, figure_caption, figure_label, packages=(), preamble=''): """ @param tikzpicture: a complete tikzpicture environment @param tikzformat: one of four tikz output formats @param figure_caption: figure caption @param figure_label: figure label @param packages: a collection of requested packages @param preamble: color definitions, for example @return: a response suitable to return from the get_response interface """ # check the requested format assert_tikzformat(tikzformat) # immediately return the tikzpicture if requested if tikzformat == TIKZFORMAT_TIKZ: return tikzpicture # delegate to latexutil requested_packages = set(packages) | set(['tikz']) return latexutil.get_centered_figure_response(tikzpicture, tikzformat, figure_caption, figure_label, requested_packages, preamble)
def get_latex_response(scaling_factor, latexformat): figure_body_lines = [ '\\subfloat[]{\\label{fig:without-deep-vertex}', get_tikz_text(g_tree_a, scaling_factor), '}', '\\subfloat[]{\\label{fig:with-deep-vertex}', get_tikz_text(g_tree_b, scaling_factor), '}' ] figure_body = '\n'.join(figure_body_lines) packages = ['tikz', 'subfig'] preamble = '' return latexutil.get_centered_figure_response(figure_body, latexformat, g_figure_caption, g_figure_label, packages, preamble)
def get_latex_response(scaling_factor, latexformat): figure_body_lines = [ "\\subfloat[]{\\label{fig:without-deep-vertex}", get_tikz_text(g_tree_a, scaling_factor), "}", "\\subfloat[]{\\label{fig:with-deep-vertex}", get_tikz_text(g_tree_b, scaling_factor), "}", ] figure_body = "\n".join(figure_body_lines) packages = ["tikz", "subfig"] preamble = "" return latexutil.get_centered_figure_response( figure_body, latexformat, g_figure_caption, g_figure_label, packages, preamble )
def get_response_content(fs): """ @param fs: a FieldStorage object containing the cgi arguments @return: the response """ T, B, N = FtreeIO.newick_to_TBN(fs.tree_string) # sanitize taxon labels if requested if fs.sanitization: for v in N: N[v] = latexutil.sanitize(N[v]) # scale branch lengths so the diameter is 1 diameter = np.max(Ftree.TB_to_D(T, B, Ftree.T_to_leaves(T))) # scale the branch lengths for u_edge in T: B[u_edge] /= diameter info = FigureInfo(T, B, N, fs.label_mode) # get the texts tikz_bodies = [ info.get_tikz_tree(fs.tree_layout), info.get_tikz_MDS_full(), info.get_tikz_MDS_partial(), info.get_tikz_MDS_harmonic(), ] tikz_pictures = [] for b in tikz_bodies: tikzpicture = tikz.get_picture(b, 'auto', scale=fs.scaling_factor) tikz_pictures.append(tikzpicture) figure_body = '\n'.join([ '\\subfloat[]{', tikz_pictures[0], '}', '\\subfloat[]{', tikz_pictures[1], '} \\\\', '\\subfloat[]{', tikz_pictures[2], '}', '\\subfloat[]{', tikz_pictures[3], '}', ]) packages = ['tikz', 'subfig'] preamble = '' figure_caption = None figure_label = None return latexutil.get_centered_figure_response( figure_body, fs.latexformat, figure_caption, figure_label, packages, preamble)
def get_figure_response( tikzpicture, tikzformat, figure_caption, figure_label, packages=(), preamble=''): """ @param tikzpicture: a complete tikzpicture environment @param tikzformat: one of four tikz output formats @param figure_caption: figure caption @param figure_label: figure label @param packages: a collection of requested packages @param preamble: color definitions, for example @return: a response suitable to return from the get_response interface """ # check the requested format assert_tikzformat(tikzformat) # immediately return the tikzpicture if requested if tikzformat == TIKZFORMAT_TIKZ: return tikzpicture # delegate to latexutil requested_packages = set(packages) | set(['tikz']) return latexutil.get_centered_figure_response( tikzpicture, tikzformat, figure_caption, figure_label, requested_packages, preamble)
def get_response_content(fs): """ @param fs: a FieldStorage object containing the cgi arguments @return: the response """ # get the texts tikz_fiedler = get_tikz_text('\n'.join(get_fiedler_tikz_lines())) tikz_t1 = get_tikz_text('\n'.join(get_t1_tikz_lines())) tikz_t2 = get_tikz_text('\n'.join(get_t2_tikz_lines())) tikz_t3 = get_tikz_text('\n'.join(get_t3_tikz_lines())) tikz_t4 = get_tikz_text('\n'.join(get_t4_tikz_lines())) tikz_fail = get_tikz_text('\n'.join(get_fail_tikz_lines())) tikz_success = get_tikz_text('\n'.join(get_success_tikz_lines())) subfloat_pictures = [ tikz_fiedler, tikz_t1, tikz_t2, tikz_t3, tikz_t4, tikz_fail, tikz_success] # return the response figure_body = '\n'.join(get_float_figure_lines(subfloat_pictures)) packages = ('tikz', 'subfig') preamble = '' return latexutil.get_centered_figure_response( figure_body, fs.latexformat, g_figure_caption, g_figure_label, packages, preamble)