From 88238982b02efe6c9a41c1d3738c1b9934f695be Mon Sep 17 00:00:00 2001 From: aineniamh Date: Fri, 12 Apr 2024 14:37:36 +0100 Subject: [PATCH] removing text from columns optionally with --remove-site-text --- snipit/command.py | 4 +++- snipit/scripts/snp_functions.py | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/snipit/command.py b/snipit/command.py index af8c3c8..25ff9a7 100644 --- a/snipit/command.py +++ b/snipit/command.py @@ -62,6 +62,7 @@ def main(sysargs = sys.argv[1:]): f_group.add_argument("--high-to-low", action='store_false', help="If sorted by mutation number is selected, show the sequences with the fewest SNPs closest to the reference. Default: False", dest="high_to_low") + f_group.add_argument("--remove-site-text",action='store_true',help="Do not annotate text on the individual columns in the figure.",dest="remove_site_text") s_group = parser.add_argument_group('SNP options') s_group.add_argument("--show-indels",action='store_true',help="Include insertion and deletion mutations in snipit plot.",dest="show_indels") @@ -128,10 +129,11 @@ def main(sysargs = sys.argv[1:]): args.height, args.size_option, args.solid_background, + args.remove_site_text, + args.ambig_mode, args.flip_vertical, args.included_positions, args.excluded_positions, - args.ambig_mode, args.sort_by_mutation_number, args.high_to_low, args.sort_by_id, diff --git a/snipit/scripts/snp_functions.py b/snipit/scripts/snp_functions.py index bc8eef0..2fcae8a 100644 --- a/snipit/scripts/snp_functions.py +++ b/snipit/scripts/snp_functions.py @@ -376,6 +376,7 @@ def make_graph(num_seqs, height, size_option, solid_background, + remove_site_text, ambig_mode, flip_vertical=False, included_positions=None, @@ -543,7 +544,7 @@ def make_graph(num_seqs, fig, ax = plt.subplots(1,1, figsize=(width,height), dpi=250) y_level = 0 - + print(remove_site_text) for record in record_order: # y position increments, with a gap after the two recombi_refs @@ -570,7 +571,8 @@ def make_graph(num_seqs, # write text adjacent to the SNPs shown with the numeric position # the text alignment is toggled right/left (top/bottom considering 90-deg rotation) if the plot is flipped - ax.text(position, y_level+(0.55*y_inc), snp, size=9, ha="center", va="bottom" if not flip_vertical else "top", rotation=90) + if not remove_site_text: + ax.text(position, y_level+(0.55*y_inc), snp, size=9, ha="center", va="bottom" if not flip_vertical else "top", rotation=90) # snp position labels left_of_box = position-(0.4*spacing) @@ -594,11 +596,12 @@ def make_graph(num_seqs, ax.add_patch(rect) # sequence variant text - ax.text(position, y_pos*y_inc, var, size=9, ha="center", va="center") + if not remove_site_text: + ax.text(position, y_pos*y_inc, var, size=9, ha="center", va="center") # reference variant text - - ax.text(position, y_inc * -0.2, ref, size=9, ha="center", va="center") + if not remove_site_text: + ax.text(position, y_inc * -0.2, ref, size=9, ha="center", va="center") #polygon showing mapping from genome to spaced out snps x = [snp-0.5,snp+0.5,right_of_box,left_of_box,snp-0.5]