Mercurial > repos > greg > draw_features
comparison draw_features.py @ 8:67520145696f draft default tip
Uploaded
author | greg |
---|---|
date | Thu, 23 Mar 2023 19:57:44 +0000 |
parents | c5555f1c8f49 |
children |
comparison
equal
deleted
inserted
replaced
7:c5555f1c8f49 | 8:67520145696f |
---|---|
15 FEATURE_COLORS = [AMR_COLOR, INC_GROUPS_COLOR] | 15 FEATURE_COLORS = [AMR_COLOR, INC_GROUPS_COLOR] |
16 FIGURE_WIDTH = 13 | 16 FIGURE_WIDTH = 13 |
17 | 17 |
18 | 18 |
19 def get_random_color(): | 19 def get_random_color(): |
20 number_of_colors = 16 | 20 r = lambda: random.randint(0,255) |
21 colors = ['#%s' % ' '.join([random.choice('0123456789ABCDEF') for j in range(6)]) for i in range(number_of_colors)] | 21 return '#%02X%02X%02X' % (r(),r(),r()) |
22 return random.choice(colors) | |
23 | 22 |
24 | 23 |
25 def draw_features(feature_hits_files, contigs, output_dir): | 24 def draw_features(feature_hits_files, contigs, output_dir): |
26 ofh = open('process_log', 'w') | 25 ofh = open('process_log', 'w') |
27 # Read feature_hits_files. | 26 # Read feature_hits_files. |
56 # No features. | 55 # No features. |
57 continue | 56 continue |
58 features_to_plot = [] | 57 features_to_plot = [] |
59 for i in range(contig_features.shape[0]): | 58 for i in range(contig_features.shape[0]): |
60 i = contig_features.iloc[i, :] | 59 i = contig_features.iloc[i, :] |
61 if feature_number <= len(FEATURE_COLORS): | 60 if feature_number < len(FEATURE_COLORS): |
62 color = FEATURE_COLORS[feature_number] | 61 color = FEATURE_COLORS[feature_number] |
63 else: | 62 else: |
64 color = get_random_color() | 63 color = get_random_color() |
65 features_to_plot += [GraphicFeature(start=i[1], end=i[2], label=i[3], strand=1 * i[5], color=color)] | 64 features_to_plot += [GraphicFeature(start=i[1], end=i[2], label=i[3], strand=1 * i[5], color=color)] |
66 feature_sets_to_plot[feature_name] = features_to_plot | 65 feature_sets_to_plot[feature_name] = features_to_plot |