mirror of
https://codeberg.org/JasterV/sarscov-hierarchy.git
synced 2026-04-27 02:15:45 +00:00
tree with ete3
This commit is contained in:
parent
bfb7c58342
commit
0627ef71c7
2 changed files with 7 additions and 12 deletions
|
|
@ -67,7 +67,7 @@ class FastaMap:
|
|||
sequences = filter(None, fasta.read().split('>'))
|
||||
for seq in sequences:
|
||||
rna_id, rna = self._get_rna(seq)
|
||||
data[rna_id] = rna if len(rna) < 1000 else rna[:1000]
|
||||
data[rna_id] = rna
|
||||
return data
|
||||
|
||||
def _compare_all_samples(self):
|
||||
|
|
|
|||
|
|
@ -17,20 +17,15 @@ class HierarchyTree:
|
|||
self._show_tree(str(closest_pair))
|
||||
|
||||
def _show_tree(self, tuple_repr):
|
||||
for key in self.__labels:
|
||||
tuple_repr = tuple_repr.replace(key, self.__labels[key])
|
||||
t = Tree(tuple_repr + ";")
|
||||
ts = TreeStyle()
|
||||
ts.show_leaf_name = True
|
||||
ts.mode = "c"
|
||||
ts.arc_start = -180 # 0 degrees = 3 o'clock
|
||||
ts.arc_span = 180
|
||||
t.render("hierarchy.png", tree_style=ts)
|
||||
ts.branch_vertical_margin = 10
|
||||
ts.scale = 120
|
||||
t.show(tree_style=ts)
|
||||
|
||||
def __transform(self, value):
|
||||
value = str(value).translate(
|
||||
str.maketrans({'(': '', ')': '', "'": ''}))
|
||||
if self.__labels is None:
|
||||
return value
|
||||
return ','.join(map(lambda x: self.__labels[x.strip()], value.split(',')))
|
||||
|
||||
@staticmethod
|
||||
def find_closest_pair(table):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue