Пример #1
0
 def get_go_color(self, **kws):
     """Return source GO IDs and GO color, if provided."""
     ret = {'GOs': set(), 'go2color': {}}
     if 'go_color_file' in kws:
         _, go2color = ClassGetGOs.rdtxt_gos_color(kws['go_color_file'])
         self._update_ret(ret, None, go2color)
     if 'GO' in kws:
         # goids, go2color = self._goargs(ret, kws['GO'])
         goids, go2color = ClassGetGOs.get_goargs(kws['GO'], prt=sys.stdout)
         self._update_ret(ret, goids, go2color)
     if 'go_file' in kws:
         goids, go2color = ClassGetGOs.rdtxt_gos_color(kws['go_file'])
         self._update_ret(ret, goids, go2color)
     if 'draw-children' in kws:
         ret['GOs'].update(get_leaf_children(ret['GOs'], self.go2obj))
     # 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
         if len(self.go2obj) < self.max_gos:
             main_gos = set(o.id for go, o in self.go2obj.items()
                            if go != o.id)
             go_leafs = set(go for go, o in self.go2obj.items()
                            if not o.children)
             ret['GOs'] = go_leafs.difference(main_gos)
     go2obj = {go: self.go2obj[go] for go in ret['GOs']}
     ret['GOs'] = set(get_go2obj_unique(go2obj))
     return [ret['GOs'], ret['go2color']]
Пример #2
0
 def get_usrgos(self, fin_goids, prt):
     """Return source GO IDs ."""
     ret = self.get_goids(None, fin_goids, prt)
     # If there have been no GO IDs explicitly specified by the user
     if not ret:
         # If the GO-DAG is sufficiently small, print all GO IDs
         if self.max_gos is not None and len(self.go2obj) < self.max_gos:
             main_gos = set(o.id for go, o in self.go2obj.items() if go != o.id)
             go_leafs = set(go for go, o in self.go2obj.items() if not o.children)
             ret = go_leafs.difference(main_gos)
         else:
             raise RuntimeError("GO IDs NEEDED")
     go2obj = self.get_go2obj(ret)
     return get_go2obj_unique(go2obj)
Пример #3
0
 def get_usrgos(self, fin_goids, prt):
     """Return source GO IDs ."""
     ret = self.get_goids(None, fin_goids, prt)
     # If there have been no GO IDs explicitly specified by the user
     if not ret:
         # If the GO-DAG is sufficiently small, print all GO IDs
         if self.max_gos is not None and len(self.go2obj) < self.max_gos:
             main_gos = set(o.id for go, o in self.go2obj.items()
                            if go != o.id)
             go_leafs = set(go for go, o in self.go2obj.items()
                            if not o.children)
             ret = go_leafs.difference(main_gos)
         else:
             raise RuntimeError("GO IDs NEEDED")
     go2obj = self.get_go2obj(ret)
     return get_go2obj_unique(go2obj)
Пример #4
0
 def get_go_color(self, **kws):
     """Return source GO IDs ."""
     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))
     # 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
         if len(self.go2obj) < self.max_gos:
             main_gos = set(o.id for go, o in self.go2obj.items() if go != o.id)
             go_leafs = set(go for go, o in self.go2obj.items() if not o.children)
             ret['GOs'] = go_leafs.difference(main_gos)
         else:
             raise RuntimeError("GO IDs NEEDED")
     go2obj = {go:self.go2obj[go] for go in ret['GOs']}
     ret['GOs'] = set(get_go2obj_unique(go2obj))
     return [ret['GOs'], ret['go2color']]
Пример #5
0
    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:
            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
            if len(self.go2obj) < self.max_gos:
                self._add_all_leafs(ret)
            else:
                raise RuntimeError("GO IDs NEEDED")

        go2obj = {go:self.go2obj[go] for go in ret['GOs']}
        ret['GOs'] = set(get_go2obj_unique(go2obj))
        return [ret['GOs'], ret['go2color']]