Get the top GO for the set of goids_all.
432698
def _get_goroot(self, goids_all, namespace):
        """"""
        root_goid = self.consts.NAMESPACE2GO[namespace]
        if root_goid in goids_all:
            return root_goid
        root_goids = set()
        for goid in goids_all:
            goterm = self.gosubdag.go2obj[goid]
            if goterm.depth == 0:
                root_goids.add(goterm.id)
        if len(root_goids) == 1:
            return next(iter(root_goids))
        raise RuntimeError("UNEXPECTED NUMBER OF ROOTS: {R}".format(R=root_goids))
109916
def _get_all_slots(self):
        """"""
        all_slots = (getattr(cls, '__slots__', [])
                         for cls in self.__class__.__mro__)
        return set(slot for slots in all_slots for slot in slots)
957661
def _get_goid2dbids(associations):
        """"""
        go2ids = cx.defaultdict(set)
        for ntd in associations:
            go2ids[ntd.GO_ID].add(ntd.DB_ID)
        return dict(go2ids)
1353796
def _get_top_states(saltenv='base'):
    '''
    
    '''
    alt_states = []
    try:
        returned = __salt__['state.show_top']()
        for i in returned[saltenv]:
            alt_states.append(i)
    except Exception:
        raise
    # log.info("top states: %s", alt_states)
    return alt_states
780433
def get_most_specific_tinfo_dcnt(goids, go2nt):
    """"""
    # go2nt_usr = {go:go2nt[go] for go in goids}
    # return max(go2nt_usr.items(), key=lambda t: [t[1].tinfo, t[1].dcnt])[0]
    return max(_get_go2nt(goids, go2nt), key=lambda t: [t[1].tinfo, t[1].dcnt])[0]
1264513
def get_top(self):
        '''
        
        '''
        try:
            tops = self.get_tops()
        except SaltRenderError as err:
            log.error('Unable to render top file: %s', err.error)
            return {}
        return self.merge_tops(tops)
1103982
def top(self) -> "InstanceNode":
        """"""
        inst = self
        while inst.parinst:
            inst = inst.up()
        return inst
980435
def get_items(self, gos):
        """"""
        items = []
        for go_id in gos:
            items.extend(self.go2items.get(go_id, []))
        return set(items)
992091
public function getTops(): Collection
    {
        $this->repo->makeModel();
        return $this->repo->pushCriteria(new GetTops())->all([
            'id',
            'pid',
            'root_id',
            'deep',
            'name',
            'sort',
        ]);
    }
1365690
def prt_hier_up(self, goids, prt=sys.stdout):
        """"""
        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
585248
def get_nts(self, goids=None, sortby=None):
        """"""
        nts = []
        # User GO IDs
        if goids is None:
            goids = self.go_sources
        else:
            chk_goids(goids, "GoSubDag::get_nts")
        if goids:
            ntobj = cx.namedtuple("NtGo", " ".join(self.prt_attr['flds']))
            go2nt = self.get_go2nt(goids)
            for goid, ntgo in self._get_sorted_go2nt(go2nt, sortby):
                assert ntgo is not None, "{GO} NOT IN go2nt".format(GO=goid)
                if goid == ntgo.GO:
                    nts.append(ntgo)
                else:
                    fld2vals = ntgo._asdict()
                    fld2vals['GO'] = goid
                    nts.append(ntobj(**fld2vals))
        return nts
435695
def get_top(self):
        '''
        
        '''
        tops, errors = self.get_tops()
        try:
            merged_tops = self.merge_tops(tops)
        except TypeError as err:
            merged_tops = OrderedDict()
            errors.append('Error encountered while rendering pillar top file.')
        return merged_tops, errors
351548
def get_goids_sections(sections):
        """"""
        goids_all = set()
        for _, goids_sec in sections:
            goids_all |= set(goids_sec)
        return goids_all
138568
def _get_gosrcs_upper(self, goids, max_upper, go2parentids):
        """"""
        gosrcs_upper = set()
        get_nt = self.gosubdag.go2nt.get
        go2nt = {g:get_nt(g) for g in goids}
        # Sort by descending order of descendant counts to find potential new hdrgos
        go_nt = sorted(go2nt.items(), key=lambda t: -1*t[1].dcnt)
        goids_upper = set()
        for goid, _ in go_nt: # Loop through GO ID, GO nt
            goids_upper.add(goid)
            if goid in go2parentids:
                goids_upper |= go2parentids[goid]
            #print "{} {:3} {}".format(goid, len(goids_upper), gont.GO_name)
            if len(goids_upper) < max_upper:
                gosrcs_upper.add(goid)
            else:
                break
        return gosrcs_upper
1306727
def items_top_get(self, keyword, nick=None):
        ''''''
        request = TOPRequest('xxxxx.xxxxx.tools.items.top.get')
        request['keyword'] = keyword
        if nick!=None: request['nick'] = nick
        self.create(self.execute(request), models={'result':RankedItem})
        return self.result
865124
def get_depth2goobjs(go2obj, max_depth=2):
        """"""
        depth2goobjs = {d:list() for d in range(max_depth+1)}
        goid_seen = set()
        for _, goobj in sorted(go2obj.items(), key=lambda t: t[1].depth):
            # Save depth-00, depth-01, depth-02
            if goobj.depth > max_depth:
                break
            goid = goobj.id
            if not goobj.is_obsolete and goid not in goid_seen:
                depth2goobjs[goobj.depth].append(goobj)
                goid_seen.add(goid)
        return depth2goobjs
194410
def get_top_paths(self):
        
        headers, data = self._requester.requestJsonAndCheck(
            "GET",
            self.url + "/traffic/popular/paths"
        )
        if isinstance(data, list):
            return [
                github.Path.Path(self._requester, headers, item, completed=True)
                for item in data
            ]