File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -829,7 +829,7 @@ def run(args):
829829 level += 1
830830 layouts .append (matrix_layout )
831831
832- if layout == "taxoncollapse-layout" or layout == "taxonrectangle-layout" or layout == "taxonclade-layout" :
832+ if layout in [ "taxoncollapse-layout" , "taxonrectangle-layout" , "taxonclade-layout" ] :
833833 # Taxa layouts
834834 taxon_color_dict = {}
835835 taxa_layouts = []
@@ -838,11 +838,18 @@ def run(args):
838838 if not rank2values :
839839 rank2values = defaultdict (list )
840840 for n in tree .traverse ():
841- if n .props .get ('lca' ):
842- lca_dict = utils .string_to_dict (n .props .get ('lca' ))
843- for rank , sci_name in lca_dict .items ():
844- rank2values [rank ].append (sci_name )
845-
841+ lca_raw = n .props .get ('lca' )
842+ if isinstance (lca_raw , str ):
843+ try :
844+ lca_dict = utils .string_to_dict (lca_raw )
845+ for rank , sci_name in lca_dict .items ():
846+ rank2values [rank ].append (sci_name )
847+ except Exception as e :
848+ #print(f"[Warning] Invalid LCA format on node {n.name}: {lca_raw}")
849+ continue # skip this node
850+ else :
851+ pass # lca is None or not a string
852+
846853 current_rank = n .props .get ('rank' )
847854 if current_rank and current_rank != 'Unknown' :
848855 rank2values [current_rank ].append (n .props .get ('sci_name' ,'' ))
You can’t perform that action at this time.
0 commit comments