def test_plot_glycans(self): for name, structure in glycans.items(): for layout in ['balanced', 'topological']: for symbol_nomenclature in ['cfg']: # ['cfg', 'iupac']: plot.plot( structure, label=True, orientation='h', symbol_nomenclature=symbol_nomenclature, layout=layout) path = "%s\%s_%s_%s.png" % (plot_dir, name, layout, symbol_nomenclature) plt.savefig(path) plt.clf() plt.close('all') #os.remove(plot_dir + os.sep + name + '.png') plt.figure() plot.enumerate_tree(*plot.plot(glycan_structure)) plt.savefig(plot_dir + os.sep + "enum_tree" + '.png')
def cfg_plot(record): if "svg_plot" in record.report_data: return base64.decodestring(record.report_data["svg_plot"]) s = record.structure.clone() composition_transform.strip_derivatization(s) dtree, ax = plot.plot(s, orientation='h', squeeze=1.4, scale=.135) fmap = {f.name: f for f in record.fragments} for match in record.matches: match_key = match.match_key.split(":")[0] order = len(match_key.split("-")) if order == 1: dtree.draw_cleavage(ax=ax, fragment=fmap[match_key], color='red', label=True) else: for key in match_key.split("-"): dtree.draw_cleavage(fragment=fmap[key], ax=ax, color='orange', label=True) ax.axis('off') fig = ax.get_figure() fig.tight_layout(pad=0.2) img_buffer = StringIO() fig.savefig(img_buffer, format="svg") plt.close(fig) root, ids = ET.XMLID(img_buffer.getvalue()) root.set("id", dtree.uuid) svg = ET.tostring(root) record.report_data["svg_plot"] = base64.encodestring(svg) record.update() return svg
def simple_plot(record): dtree, ax = plot.plot(record, orientation='h', squeeze=1.4, scale=.135) ax.axis('off') fig = ax.get_figure() fig.tight_layout(pad=0.2) img_buffer = StringIO() fig.savefig(img_buffer, format="svg") plt.close(fig) root, ids = ET.XMLID(img_buffer.getvalue()) root.set("id", dtree.uuid) svg = ET.tostring(root) return svg
def parsePlot(linear_code_expression): ''' Abbreviation for `plot(glypy.io.linear_code.parse_linear_code(linear_code_expression))` ''' plot(glypy.io.linear_code.parse_linear_code(linear_code_expression))
def test_plot_monosaccharide(self): for name, residue in monosaccharides.items(): plot.plot(residue) #plt.savefig(plot_dir + os.sep + name + '.png') plt.clf() plt.close('all')