Coverage for /home/deng/Projects/ete4/hackathon/ete4/ete4/smartview/renderer/layouts/evocell_layouts.py: 24%

50 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2024-03-21 09:19 +0100

1from ..faces import RectFace, TextFace 

2from ..treelayout import TreeLayout 

3 

4__all__ = [ "LayoutHumanOGs", "LayoutUCSC", "LayoutUCSCtrans"] 

5 

6 

7class LayoutHumanOGs(TreeLayout): 

8 def __init__(self, name="Human OGs", human_orth_prop="human_orth", 

9 column=5, color="#6b92d6"): 

10 super().__init__(name) 

11 self.aligned_faces = True 

12 self.human_orth_prop = human_orth_prop 

13 self.column = column 

14 self.color = color 

15 

16 def set_node_style(self, node): 

17 if node.is_leaf: 

18 human_orth = node.props.get(self.human_orth_prop) 

19 if human_orth: 

20 human_orth = " ".join(human_orth.split('|')) 

21 human_orth_face = TextFace(human_orth, color=self.color) 

22 node.add_face(human_orth_face, column=self.column, position="aligned") 

23 

24class LayoutUCSC(TreeLayout): 

25 def __init__(self, name="UCSC", column=6, 

26 nodecolor="#800000", nodesize=5, 

27 textcolor="#c43b5d"): 

28 super().__init__(name) 

29 self.aligned_faces = True 

30 self.column = column 

31 self.nodecolor = nodecolor 

32 self.nodesize = nodesize 

33 self.textcolor = textcolor 

34 

35 def set_node_style(self, node): 

36 if node.is_leaf: 

37 if node.props.get('UCSC'): 

38 ucsc = node.props.get('UCSC') 

39 ucsc_face = TextFace(ucsc, color=self.textcolor) 

40 node.add_face(ucsc_face, column=self.column, position="aligned") 

41 node.sm_style["bgcolor"] = self.nodecolor # highligh clade 

42 while (node): 

43 node = node.up 

44 if node: 

45 node.sm_style["hz_line_width"] = self.nodesize 

46 

47class LayoutUCSCtrans(TreeLayout): 

48 def __init__(self, name="UCSC Trans", ucsc_trans_prop="ucsc_trans", 

49 column=4, color="#6b92d6"): 

50 super().__init__(name) 

51 self.aligned_faces = True 

52 self.ucsc_trans_prop = ucsc_trans_prop 

53 self.column = column 

54 self.color = color 

55 

56 def set_node_style(self, node): 

57 if node.is_leaf: 

58 ucsc_trans = node.props.get(self.ucsc_trans_prop) 

59 if ucsc_trans: 

60 ucsc_trans = " ".join(ucsc_trans.split('|')) 

61 ucsc_trans_face = TextFace(ucsc_trans, color=self.color) 

62 node.add_face(ucsc_trans_face, column=self.column, position="aligned")