Return dict of GO ID as key and GO object information in namedtuple.
779970
def get_go2nt(self, goids):
        """"""
        get_nt = self.go2nt
        goids_present = set(goids).intersection(self.go2obj)
        if len(goids_present) != len(goids):
            print("GO IDs NOT FOUND IN DAG: {GOs}".format(
                GOs=" ".join(set(goids).difference(goids_present))))
        return {g:get_nt[g] for g in goids_present}
777902
def prt_goids(self, prt):
        """"""
        fmt = self.gosubdag.prt_attr['fmta']
        nts = sorted(self.gosubdag.go2nt.values(), key=lambda nt: [nt.NS, nt.depth, nt.alt])
        _get_color = self.pydotnodego.go2color.get
        for ntgo in nts:
            gostr = fmt.format(**ntgo._asdict())
            col = _get_color(ntgo.GO, "")
            prt.write("{COLOR:7} {GO}\n".format(COLOR=col, GO=gostr))
1068258
def get_relationship_dicts(self):
        """"""
        if not self.relationships:
            return None
        for goid, goobj in self.go2obj.items():
            for reltyp, relset in goobj.relationship.items():
                relfwd_goids = set(o.id for o in relset)
                # for relfwd_goid in relfwd_goids:
                #     assert relfwd_goid in self.go2obj, "{GO} {REL} NOT FOUND {GO_R}".format(
                #         GO=goid, REL=reltyp, GO_R=relfwd_goid)
                print("CountRelativesInit RELLLLS", goid, goobj.id, reltyp, relfwd_goids)
304386
def p_version_def(t):
    """"""
    global name_dict
    id = t[2]
    value = t[8]
    lineno = t.lineno(1)
    if id_unique(id, 'version', lineno):
        name_dict[id] = const_info(id, value, lineno)
16554
def as_dictionary(self):
        """"""
        values = {
            'id': self._id,
            'type': self._type
        }

        if self._owner:
            values['owner'] = self._owner
        return values
300405
def prt_ntgos(self, prt, ntgos):
        """"""
        for ntgo in ntgos:
            key2val = ntgo._asdict()
            prt.write("{GO_LINE}\n".format(GO_LINE=self.prtfmt.format(**key2val)))
869139
def get_usrgos(self, fin_goids, prt):
        """"""
        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)
1079934
def _build_named_object_ids(parameters):
    """"""
    if isinstance(parameters, str):
        return [_build_named_object_id(parameters)]
    return [_build_named_object_id(parameter) for parameter in parameters]
1219609
def _get_dict(names, ndarrays):
        """"""
        nset = set()
        for nm in names:
            if nm in nset:
                raise ValueError('Duplicate names detected, %s' % str(names))
            nset.add(nm)
        return dict(zip(names, ndarrays))
119809
def visit_DictComp(self, node: AST, dfltChaining: bool = True) -> str:
        """"""
        return f"{{{self.visit(node.key)}: {self.visit(node.value)} " \
               f"{' '.join(self.visit(gen) for gen in node.generators)}}}"
16903
def _dict_refs(obj, named):
    '''
    '''
    if named:
        for k, v in _items(obj):
            s = str(k)
            yield _NamedRef('[K] ' + s, k)
            yield _NamedRef('[V] ' + s + ': ' + _repr(v), v)
    else:
        for k, v in _items(obj):
            yield k
            yield v
819462
def get_dict_key(data, key):
    '''  '''

    if isinstance(data, Mapping):
        if key in data:
            yield data[key]
        for key_data in data.values():
            for found in get_dict_key(key_data, key):
                yield found
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
554115
def _read_info_as_dict(fid, values):
    
    output = {}
    for key, fmt in values:
        val = unpack(fmt, fid.read(calcsize(fmt)))
        if len(val) == 1:
            output[key] = val[0]
        else:
            output[key] = val
    return output
418485
def getnamedargs(*args, **kwargs):
    """"""
    adict = {}
    for arg in args:
        if isinstance(arg, dict):
            adict.update(arg)
    adict.update(kwargs)
    return adict
112053
def _get_namespace2go2term(go2terms):
        """"""
        namespace2go2term = cx.defaultdict(dict)
        for goid, goterm in go2terms.items():
            namespace2go2term[goterm.namespace][goid] = goterm
        return namespace2go2term
554819
def _init_dflt(self):
        """"""
        nts = []
        ntobj = cx.namedtuple('ntanno', self.flds)
        for itemid, gos in self.id2gos.items():
            for goid in gos:
                nts.append(ntobj(DB_ID=itemid, GO_ID=goid))
        return nts