Get string describing counts of placed/unplaced GO IDs and count of sections.
164441
def get_summary_str(self, sec2d_nt):
        """"""
        data = self.get_summary_data(sec2d_nt)
        return "{M} GO IDs placed into {N} sections; {U} unplaced GO IDs".format(
            N=len(data['sections']), M=len(data['grouped']), U=len(data['ungrouped']))
658228
def get_summary_string(self):
        """"""
        rows = [["PLUGIN TYPE", "NAME", "DESCRIPTION", "STATUS"],
                ["-----------", "----", "-----------", "------"]]
        for plugin_type in sorted(self.get_plugin_types()):
            type_name = plugin_type.replace('_', ' ')
            for name in sorted(self.get_plugins(plugin_type)):
                module = self.get_plugin_module(plugin_type, name)
                desc = (getattr(module, "__doc__", None) or '').strip()
                rows.append((type_name, name, desc, "loaded"))
            for (name, reason) in sorted(self.get_failed_plugins(plugin_type)):
                msg = "FAILED: %s" % reason
                rows.append((type_name, name, '', msg))
        return '\n'.join(columnise(rows))
73593
def _get_fout_go(self):
        """"""
        assert self.goids, "NO VALID GO IDs WERE PROVIDED AS STARTING POINTS FOR HIERARCHY REPORT"
        base = next(iter(self.goids)).replace(':', '')
        upstr = '_up' if 'up' in self.kws else ''
        return "hier_{BASE}{UP}.{EXT}".format(BASE=base, UP=upstr, EXT='txt')
1337427
def get_html_row_count(spans):
    """"""

    if spans == []:
        return 0
    row_counts = {}
    for span in spans:
        span = sorted(span)
        try:
            row_counts[str(span[0][1])] += get_span_row_count(span)
        except KeyError:
            row_counts[str(span[0][1])] = get_span_row_count(span)

    values = list(row_counts.values())
    return max(values)
124771
def _get_wrhiercfg(self):
        """"""
        prtfmt = self.gosubdag.prt_attr['fmt']
        prtfmt = prtfmt.replace('{GO} # ', '')
        prtfmt = prtfmt.replace('{D1:5} ', '')
        return {'name2prtfmt':{'ITEM':prtfmt, 'ID':'{GO}{alt:1}'},
                'max_indent': self.usrdct.get('max_indent'),
                'include_only': self.usrdct.get('include_only'),
                'item_marks': self.usrdct.get('item_marks', {}),
                'concise_prt': 'concise' in self.usrset,
                'indent': 'no_indent' not in self.usrset,
                'dash_len': self.usrdct.get('dash_len', 6),
                'sortby': self.usrdct.get('sortby')
               }
460226
def get_section2usrnts(self):
        """"""
        sec_nts = []
        for section_name, _ in self.get_sections_2d():
            usrgos = self.get_usrgos_g_section(section_name)
            sec_nts.append((section_name, [self.go2nt.get(u) for u in usrgos]))
        return cx.OrderedDict(sec_nts)
776761
def get_nts_sections(self, sections, sortby=None):
        """"""
        goids = self.get_goids_sections(sections)
        gosubdag = GoSubDag(goids, self.go2obj)
        return [(sec, gosubdag.get_nts(gos, sortby)) for sec, gos in sections]
855128
def get_section_hdrgos(self):
        """"""
        return set([h for _, hs in self.sections for h in hs]) if self.sections else set()
829924
def getCountGT(self, item):
        """"""
        index = bisect.bisect_right(self._list, item)
        return len(self._list) - index
146717
def get_summary_data(self, sec2d_nt):
        """"""
        grouped = set()
        ungrouped = set()
        sections = set()
        secdflt = self.grprobj.hdrobj.secdflt
        for section_name, nts in sec2d_nt:
            if section_name != secdflt:
                if nts:
                    grouped.update(set(nt.GO for nt in nts))
                    sections.add(section_name)
                else:
                    ungrouped.update(set(nt.GO for nt in nts))
        return {'grouped':grouped, 'ungrouped':ungrouped, 'sections':sections}
1089353
def string_stats(strs, valid_chars='012346789', left_pad='0', right_pad='', strip=True):
    
    if left_pad is None:
        left_pad = ''.join(c for c in rex.ASCII_CHARACTERS if c not in valid_chars)
    if right_pad is None:
        right_pad = ''.join(c for c in rex.ASCII_CHARACTERS if c not in valid_chars)

    def normalize(s):
        if strip:
            s = s.strip()
        s = s.lstrip(left_pad)
        s = s.rstrip(right_pad)
        return s

    # should probably check to make sure memory not exceeded
    strs = [normalize(s) for s in strs]
    lengths = Counter(len(s) for s in strs)
    counts = {}
    max_length = max(lengths.keys())

    for i in range(max_length):
        # print i
        for s in strs:
            if i < len(s):
                counts[i] = counts.get(i, 0) + int(s[i] in valid_chars)
                counts[-i - 1] = counts.get(-i - 1, 0) + int(s[-i - 1] in valid_chars)
        long_enough_strings = float(sum(c for n, c in list(lengths.items()) if n >= i))
        counts[i] = counts[i] / long_enough_strings
        counts[-i - 1] = counts[-i - 1] / long_enough_strings

    return counts
6381
def get_usrgos_g_section(self, section=None):
        """"""
        if section is None:
            section = self.hdrobj.secdflt
        if section is True:
            return self.usrgos
        # Get dict of sections and hdrgos actually used in grouping
        section2hdrgos = cx.OrderedDict(self.get_sections_2d())
        hdrgos_lst = section2hdrgos.get(section, None)
        if hdrgos_lst is not None:
            hdrgos_set = set(hdrgos_lst)
            hdrgos_u = hdrgos_set.intersection(self.hdrgo_is_usrgo)
            hdrgos_h = hdrgos_set.intersection(self.hdrgo2usrgos.keys())
            usrgos = set([u for h in hdrgos_h for u in self.hdrgo2usrgos.get(h)])
            usrgos |= hdrgos_u
            return usrgos
        return set()
1260185
def string_position(self, id_):
        """"""
        if self.bow:
            return self.string_start[self.positions[id_]]
        else:
            return self.string_start[[self.positions[id_]]]
164336
def get_section_marks(self):
        """"""
        return [abc if s in self.sec2chr else "." for s, abc in self.datobj.sec2chr.items()]
891444
def _adj_item_marks(self):
        """"""
        if 'item_marks' in self.kws:
            # Process GO IDs specified in item_marks
            goids = self._get_goids(self.kws['item_marks'])
            # item_marks can take a list of GO IDs on cmdline or in a file.
            #     --item_marks=GO:0043473,GO:0009987
            #     --item_marks=item_marks.txt
            if goids:
                self.kws['item_marks'] = {go:'>' for go in goids}
            else:
                raise Exception("NO GO IDs FOUND IN item_marks")
103134
def _read_finish(self, goids_fin, prt):
        """"""
        # Report unused sections, if any
        if len(self.section2goids) != len(self.sections_seen):
            self._rpt_unused_sections(prt)
        # If there are no sections, then goids_fin holds all GO IDs in file
        if not self.sections_seen:
            self.goids_fin = goids_fin

        if goids_fin:
            return self.internal_get_goids_or_sections()  # {'goids':...} or {'sections':...}
        else:
            sys.stdout.write(
                "\n**WARNING: GO IDs MUST BE THE FIRST 10 CHARACTERS OF EACH LINE\n\n")
143455
def get_usrgo2sections(self):
        """"""
        usrgo2sections = cx.defaultdict(set)
        usrgo2hdrgo = self.get_usrgo2hdrgo()
        get_sections = self.hdrobj.get_sections
        for usrgo, hdrgo in usrgo2hdrgo.items():
            sections = set(get_sections(hdrgo))
            usrgo2sections[usrgo] |= sections
        assert len(usrgo2sections) >= len(self.usrgos), \
            "uGOS({U}) != uGO2sections({H}): {GOs}".format(
                U=len(self.usrgos),
                H=len(usrgo2sections),
                GOs=self.usrgos.symmetric_difference(set(usrgo2sections.keys())))
        return usrgo2sections