Skip to content

Commit

Permalink
if draw-children, color leaf-level children grey.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvklopfenstein committed Jun 16, 2018
1 parent 6ca8c9e commit 3d9366f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion goatools/cli/gosubdag_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,13 +99,14 @@ def __init__(self, go2obj):

def get_go_color(self, **kws):
"""Return source GO IDs ."""
# kws: GO go_file draw-children
ret = {'GOs':set(), 'go2color':{}}
if 'GO' in kws:
self._goargs(ret, kws['GO'])
if 'go_file' in kws:
self._rdtxt_gos(ret, kws['go_file'])
if 'draw-children' in kws:
ret['GOs'].update(get_leaf_children(ret['GOs'], self.go2obj))
self._add_gochildleaf(ret)
# If there have been no GO IDs explicitly specified by the user
if not ret['GOs']:
# If the GO-DAG is sufficiently small, print all GO IDs
Expand Down Expand Up @@ -156,6 +157,17 @@ def _rdtxt_gos(self, ret, go_file):
print("IGNORING: {L}".format(L=line),)
self._update_ret(ret, goids, go2color)

def _add_gochildleaf(self, ret):
"""Add leaf-level GO children to GO list colored uniquely."""
leaf_gos = get_leaf_children(ret['GOs'], self.go2obj)
if leaf_gos:
ret['GOs'].update(leaf_gos)
leaf_go_color = Go2Color.key2col['go_leafchild']
go2color = ret['go2color']
for goid in leaf_gos:
if goid not in go2color:
go2color[goid] = leaf_go_color

@staticmethod
def _update_ret(ret, goids, go2color):
"""Update 'GOs' and 'go2color' in dict with goids and go2color."""
Expand Down
1 change: 1 addition & 0 deletions goatools/gosubdag/plot/go2color.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Go2Color(object):
key2col = {
'level_01': '#f1fbfd', # Very light blue
'go_sources': '#ffffe4', # xkcd off white
'go_leafchild': '#eae8e8', # 'Grey palette' http://www.color-hex.com/color-palette/45491
}


Expand Down

0 comments on commit 3d9366f

Please sign in to comment.