Skip to content

Commit

Permalink
Merge pull request #52 from dengzq1234/main
Browse files Browse the repository at this point in the history
set ls layout as manual activate
  • Loading branch information
dengzq1234 authored Feb 12, 2024
2 parents ef9510a + 2f366e0 commit bf0a71f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
2 changes: 1 addition & 1 deletion treeprofiler/layouts/phylosignal_layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def __init__(self, name, ls_prop, color, legend=True):
self.ls_prop = ls_prop
self.color = color
self.legend = legend

self.active = False
def set_tree_style(self, tree, tree_style):
if self.legend:

Expand Down
1 change: 1 addition & 0 deletions treeprofiler/layouts/staple_layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ def __init__(self, name, color_dict, score_prop, internal_rep=None, \
self.color_range = color_range
self.show_score = show_score
self.line_width = 3
self.active = False

def set_tree_style(self, tree, tree_style):
if self.legend:
Expand Down
3 changes: 3 additions & 0 deletions treeprofiler/layouts/taxon_layouts.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,12 @@ def set_node_style(self, node):
lca_face = RectFace(self.rect_width, None, text = lca, color=color, padding_x=1, padding_y=1, tooltip=tooltip)
lca_face.rotate_text = True
node.sm_style["draw_descendants"] = False

node.add_face(lca_face, position='aligned', column=level)
node.add_face(lca_face, position='aligned', column=level,
collapsed_only=True)
node.add_face(TextFace(lca, color = color, padding_x=2),
column=1, position="branch_right", collapsed_only=True)

# elif node_sciname and (node_rank == self.rank):
# lca = node_sciname
Expand Down
12 changes: 7 additions & 5 deletions treeprofiler/tree_annotate.py
Original file line number Diff line number Diff line change
Expand Up @@ -1385,11 +1385,13 @@ def annot_tree_pfam_table(post_tree, pfam_table, alg_fasta, domain_prop='dom_arq
dom_start = int(info[7])
dom_end = int(info[8])
if raw2alg.get(seq_name):
trans_dom_start = raw2alg[seq_name][dom_start]
trans_dom_end = raw2alg[seq_name][dom_end]
dom_info_string = pair_delimiter.join([dom_name, str(trans_dom_start), str(trans_dom_end)])
seq2doms[seq_name].append(dom_info_string)

try:
trans_dom_start = raw2alg[seq_name][dom_start]
trans_dom_end = raw2alg[seq_name][dom_end]
dom_info_string = pair_delimiter.join([dom_name, str(trans_dom_start), str(trans_dom_end)])
seq2doms[seq_name].append(dom_info_string)
except KeyError:
raise KeyError(f"Cannot find {dom_start} or {dom_end} in {seq_name}")
for l in post_tree:
if l.name in seq2doms.keys():
domains = seq2doms[l.name]
Expand Down
16 changes: 10 additions & 6 deletions treeprofiler/tree_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,11 +494,15 @@ def run(args):
if not rank2values:
rank2values = defaultdict(list)
for n in tree.traverse():
if n.props.get('rank') and n.props.get('rank') != 'Unknown':
rank2values[n.props.get('rank')].append(n.props.get('sci_name',''))
if n.props.get('lca'):
for rank, sci_name in n.props.get('lca').items():
rank2values[rank].append(sci_name)

current_rank = n.props.get('rank')
if current_rank and current_rank != 'Unknown':
rank2values[current_rank].append(n.props.get('sci_name',''))
else:
pass


# assign color for each value of each rank
for rank, value in sorted(rank2values.items()):
Expand Down Expand Up @@ -590,9 +594,9 @@ def run(args):
taxa_layouts.append(taxa_layout)
#level += 1

if args.taxoncollapse_layout:
taxa_layout = taxon_layouts.TaxaCollapse(name = "TaxaCollapse_"+rank, rank=rank, rect_width=args.column_width, color_dict=color_dict, column=level)
taxa_layouts.append(taxa_layout)
# if args.taxoncollapse_layout:
# taxa_layout = taxon_layouts.TaxaCollapse(name = "TaxaCollapse_"+rank, rank=rank, rect_width=args.column_width, color_dict=color_dict, column=level)
# taxa_layouts.append(taxa_layout)

taxon_color_dict[rank] = color_dict

Expand Down

0 comments on commit bf0a71f

Please sign in to comment.