From ab3f79c8af85dde254e43847cebaaf07b20c4201 Mon Sep 17 00:00:00 2001 From: Chen Tong Date: Thu, 30 Nov 2023 18:29:45 +0800 Subject: [PATCH] add customize x y for genelabelrotation 0; add --outputprefix for customized output (#612) * add ignore zero anchor parameter for skip no matches in batch search * ignore blank line in bed * set label/chr size in layout file * add genelabel rotation (customize x and y for rotation with angle 0) * add customize x y for genelabelrotation 0; add --outputprefix for customized output * Reverting some changes when I messed up the "Resolving Conflicts" step --------- Co-authored-by: Haibao Tang --- jcvi/graphics/synteny.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/jcvi/graphics/synteny.py b/jcvi/graphics/synteny.py index 671c757a..a6b49637 100644 --- a/jcvi/graphics/synteny.py +++ b/jcvi/graphics/synteny.py @@ -295,9 +295,15 @@ def __init__( ) gp.set_transform(tr) if genelabelsize and (not gene_labels or gene_name in gene_labels): + if genelabelrotation == 0: + text_x = x1 if x1 > x2 else x2 + text_y = y + else: + text_x = (x1 + x2) / 2 + text_y = y + height / 2 + genelabelsize * vpad / 3 ax.text( - (x1 + x2) / 2, - y + height / 2 + genelabelsize * vpad / 3, + text_x, + text_y, markup(gene_name), size=genelabelsize, rotation=genelabelrotation, @@ -661,6 +667,11 @@ def main(): choices=Shade.Styles, help="Style of syntenic wedges", ) + p.add_option( + "--outputprefix", + default="", + help="Prefix for the output file", + ) opts, args, iopts = p.set_image_options(figsize="8x7") if len(args) != 3: @@ -697,6 +708,9 @@ def main(): root.set_ylim(0, 1) root.set_axis_off() + outputprefix = opts.outputprefix + if outputprefix: + pf = outputprefix image_name = pf + "." + iopts.format savefig(image_name, dpi=iopts.dpi, iopts=iopts)