Beispiel #1
0
 def prt_hier_up(self, goids, prt=sys.stdout):
     """Write hierarchy for all GO IDs below GO ID in arg, goid."""
     go2goterm_all = {go: self.gosubdag.go2obj[go] for go in goids}
     objp = GoPaths()
     items_list = []
     for namespace, go2term_ns in self._get_namespace2go2term(
             go2goterm_all).items():
         goids_all = set()  # GO IDs from user-specfied GO to root
         for goid_usr, goterm in go2term_ns.items():
             goids_all.add(goid_usr)
             paths = objp.get_paths_from_to(goterm,
                                            goid_end=None,
                                            dn0_up1=True)
             goids_all.update(set(o.id for p in paths for o in p))
         # Only include GO IDs from user-specified GO to the root
         if 'include_only' not in self.usrdct:
             self.usrdct['include_only'] = set()
         self.usrdct['include_only'].update(goids_all)
         # Mark the user-specfied GO term
         if 'item_marks' not in self.usrdct:
             self.usrdct['item_marks'] = {}
         for goid_usr in go2term_ns.keys():
             if goid_usr not in self.usrdct['item_marks']:
                 self.usrdct['item_marks'][goid_usr] = '*'
         # Write the hierarchy
         wrhiercfg = self._get_wrhiercfg()
         obj = WrHierPrt(self.gosubdag.go2obj, self.gosubdag.go2nt,
                         wrhiercfg, prt)
         go_root = self._get_goroot(goids_all, namespace)
         obj.prt_hier_rec(go_root)
         items_list.extend(obj.items_list)
     return items_list
Beispiel #2
0
 def prt_hier_up(self, goids, prt=sys.stdout):
     """Write hierarchy for all GO IDs below GO ID in arg, goid."""
     go2goterm_all = {go: self.gosubdag.go2obj[go] for go in goids}
     objp = GoPaths()
     gos_printed = set()
     for namespace, go2term_ns in self._get_namespace2go2term(
             go2goterm_all).items():
         go_root = self.consts.NAMESPACE2GO[namespace]
         goids_all = set()  # GO IDs from user-specfied GO to root
         for goid, goterm in go2term_ns.items():
             goids_all.add(goid)
             paths = objp.get_paths_from_to(goterm,
                                            goid_end=None,
                                            dn0_up1=True)
             goids_all.update(set(o.id for p in paths for o in p))
         # Only include GO IDs from user-specified GO to the root
         if 'include_only' not in self.usrdct:
             self.usrdct['include_only'] = set()
         self.usrdct['include_only'].update(goids_all)
         # Mark the user-specfied GO term
         if 'go_marks' not in self.usrdct:
             self.usrdct['go_marks'] = set()
         self.usrdct['go_marks'].update(go2term_ns.keys())
         obj = _WrHierPrt(self, prt)  # , goids_all, set(go2term_ns.keys()))
         gos_printed.update(obj.gos_printed)
         obj.prt_hier_rec(go_root)
     return gos_printed
Beispiel #3
0
 def prt_hier_up(self, goids, prt=sys.stdout):
     """Write hierarchy for all GO IDs below GO ID in arg, goid."""
     go2goterm_all = {go:self.gosubdag.go2obj[go] for go in goids}
     objp = GoPaths()
     items_list = []
     for namespace, go2term_ns in self._get_namespace2go2term(go2goterm_all).items():
         goids_all = set()  # GO IDs from user-specfied GO to root
         for goid_usr, goterm in go2term_ns.items():
             goids_all.add(goid_usr)
             paths = objp.get_paths_from_to(goterm, goid_end=None, dn0_up1=True)
             goids_all.update(set(o.id for p in paths for o in p))
         # Only include GO IDs from user-specified GO to the root
         if 'include_only' not in self.usrdct:
             self.usrdct['include_only'] = set()
         self.usrdct['include_only'].update(goids_all)
         # Mark the user-specfied GO term
         if 'item_marks' not in self.usrdct:
             self.usrdct['item_marks'] = {}
         for goid_usr in go2term_ns.keys():
             if goid_usr not in self.usrdct['item_marks']:
                 self.usrdct['item_marks'][goid_usr] = '*'
         # Write the hierarchy
         wrhiercfg = self._get_wrhiercfg()
         obj = WrHierPrt(self.gosubdag.go2obj, self.gosubdag.go2nt, wrhiercfg, prt)
         go_root = self._get_goroot(goids_all, namespace)
         obj.prt_hier_rec(go_root)
         items_list.extend(obj.items_list)
     return items_list
Beispiel #4
0
 def get_goids_all(go2term_ns):
     """GO IDs from user-specfied GO to root"""
     goids_all = set()  # GO IDs from user-specfied GO to root
     objp = GoPaths()
     for goid_usr, goterm in go2term_ns.items():
         goids_all.add(goid_usr)
         paths = objp.get_paths_from_to(goterm, goid_end=None, dn0_up1=True)
         goids_all.update(set(o.id for p in paths for o in p))
     return goids_all
 def prt_hier_up(self, goids, prt=sys.stdout):
     """Write hierarchy for all GO IDs below GO ID in arg, goid."""
     go2goterm_all = {go: self.gosubdag.go2obj[go] for go in goids}
     objp = GoPaths()
     for namespace, go2term_ns in self._get_namespace2go2term(
             go2goterm_all).items():
         go_root = self.consts.NAMESPACE2GO[namespace]
         goids_all = set()
         for goid, goterm in go2term_ns.items():
             goids_all.add(goid)
             paths = objp.get_paths_from_to(goterm,
                                            goid_end=None,
                                            dn0_up1=True)
             goids_all.update(set(o.id for p in paths for o in p))
         obj = _WrHierPrt(self, prt, goids_all, set(go2term_ns.keys()))
         obj.prt_hier_rec(go_root)