Print all GO IDs in the plot, plus their color.
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))
677059
def _get_goids(gostr):
        """"""
        if 'GO:' in gostr:
            return gostr.split(',')
        elif os.path.exists(gostr):
            return GetGOs().get_goids(None, gostr, sys.stdout)
96238
def plot_lines(it):
    
    data = [go.Scatter(mode='lines', **d) for d in it]
    return py.iplot(data, filename='scatter-mode')
1360473
def colorful_print(raw):
    ''''''

    lines = raw.split('\n')
    colorful = True
    detail = False
    for line in lines:
        if line:
            if colorful:
                colorful = False
                print(colored(line, 'white', 'on_green') + '\n')
                continue
            elif line.startswith('例'):
                print(line + '\n')
                continue
            elif line.startswith('【'):
                print(colored(line, 'white', 'on_green') + '\n')
                detail = True
                continue

            if not detail:
                print(colored(line + '\n', 'yellow'))
            else:
                print(colored(line, 'cyan') + '\n')
447694
def just_log(*texts, sep = ""):
	""""""
	if config.silent:
		return

	text = _color_sep + "default" + _color_sep2 + sep.join(texts)
	array = text.split(_color_sep)

	for part in array:
		parts = part.split(_color_sep2, 1)
		if len(parts) != 2 or not parts[1]:
			continue

		if not config.color:
			print(parts[1], end='')
		else:
			colors.foreground(parts[0])
			print(parts[1], end='', flush=colors.is_win32)

	if config.color:
		colors.foreground("default")
	print()
763735
function makeRowIds(numRows, maxLines) {
  var printVec = jd.seq(numRows)._toTruncatedPrintVector(maxLines);
  return printVec.map(function(str) {
    return str === _SKIP_MARKER ? str : str + _ROW_ID_SUFFIX;
  });
}
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")
901603
def pretty_print(self):
        
        print colored.blue("-" * 40)
        print colored.red("datacats: problem was encountered:")
        print self.message
        print colored.blue("-" * 40)
730306
def print_table(lines, separate_head=True):
	""""""
	#Count the column width
	widths = []
	for line in lines:
			for i,size in enumerate([len(x) for x in line]):
					while i >= len(widths):
							widths.append(0)
					if size > widths[i]:
							widths[i] = size
	   
	#Generate the format string to pad the columns
	print_string = ""
	for i,width in enumerate(widths):
			print_string += "{" + str(i) + ":" + str(width) + "} | "
	if (len(print_string) == 0):
			return
	print_string = print_string[:-3]
	   
	#Print the actual data
	for i,line in enumerate(lines):
			print(print_string.format(*line))
			if (i == 0 and separate_head):
					print("-"*(sum(widths)+3*(len(widths)-1)))
78532
def plot_gos(fout_png, goids, obo_dag, *args, **kws):
    """"""
    engine = kws['engine'] if 'engine' in kws else 'pydot'
    godagsmall = OboToGoDagSmall(goids=goids, obodag=obo_dag).godag
    godagplot = GODagSmallPlot(godagsmall, *args, **kws)
    godagplot.plt(fout_png, engine)
967212
def print_all_signals(self):
        
        for o in dir(self):
            obj= getattr(self, o)
            #print o, type(obj)
            div = False
            for c in dir(obj):
                cobj = getattr(obj, c)
                if isinstance(cobj, Signal):
                    print('def _on_{}__{}(self):'.format(o, c))
                    div = True

            if div: print('-'*30)
1295230
def _print(self, text, color=None, **kwargs):
        
        COLORS = {
            'red': '\033[91m{}\033[00m',
            'green': '\033[92m{}\033[00m',
            'yellow': '\033[93m{}\033[00m',
            'cyan': '\033[96m{}\033[00m'
        }
        _ = COLORS[color]
        six.print_(_.format(text), **kwargs)
17664
def output(*args, **kwargs):
    '''
    '''
    indent = kwargs.pop('indent', 0)
    sep = kwargs.pop('sep', None)
    kwargs['sep'] = u''  # Sanity
    if sep is None:
        sep = u' '
    indent_str = u' ' * (indent * tab_width)
    text = sep.join(map(str_, args))
    color = kwargs.pop('color', None)
    if color:
        color.bright = kwargs.pop('bright', None)
        text = ColorText(text, color)
    print(indent_str + text, **kwargs)
735893
def printDot(self):
        """"""
        print("digraph ModuleDependencies {")
        print("  node[shape=box];")
        allNames = set()
        nameDict = {}
        for n, module in enumerate(self.listModules()):
            module._dot_name = "mod%d" % n
            nameDict[module.modname] = module._dot_name
            print("  %s[label=\"%s\"];" % (module._dot_name,
                                           quote(module.label)))
            allNames |= module.imports
        print("  node[style=dotted];")
        if self.external_dependencies:
            myNames = set(self.modules)
            extNames = list(allNames - myNames)
            extNames.sort()
            for n, name in enumerate(extNames):
                nameDict[name] = id = "extmod%d" % n
                print("  %s[label=\"%s\"];" % (id, name))
        for modname, module in sorted(self.modules.items()):
            for other in sorted(module.imports):
                if other in nameDict:
                    print("  %s -> %s;" % (nameDict[module.modname],
                                           nameDict[other]))
        print("}")
571120
def rdtxt_gos(go_file, prt):
        """"""
        goids_all = set()
        if not os.path.exists(go_file):
            raise RuntimeError("CAN NOT READ GO FILE: {FILE}\n".format(FILE=go_file))
        re_go = re.compile(r'(GO:\d{7})+?')
        re_com = re.compile(r'^\s*#')  # Lines starting with a '#' are comment lines and ignored
        with open(go_file) as ifstrm:
            for line in ifstrm:
                # Skip lines that are comments
                if re_com.search(line):
                    continue
                # Search for GO IDs on the line
                goids_found = re_go.findall(line)
                if goids_found:
                    goids_all.update(goids_found)
            if prt:
                prt.write("  {N} GO IDs READ: {TXT}\n".format(N=len(goids_all), TXT=go_file))
        return goids_all
873152
def main():
    
    allowed_format = ("emf", "eps", "pdf", "png", "ps", \
                      "raw", "rgba", "svg", "svgz")
    p = OptionParser(main.__doc__)
    p.add_option("--skip", default=0, type="int",
            help="skip the first several lines [default: %default]")
    p.add_option("--col", default=0, type="int", help="Get the n-th column")
    p.set_histogram()
    p.add_option("--tags", dest="tags", default=None,
            help="tags for data if multiple input files, comma sep")
    p.add_option("--ascii", default=False, action="store_true",
            help="print ASCII text stem-leaf plot [default: %default]")
    p.add_option("--base", default="0", choices=("0", "2", "10"),
            help="use logarithm axis with base, 0 to disable [default: %default]")
    p.add_option("--facet", default=False, action="store_true",
            help="place multiple histograms side-by-side [default: %default]")
    p.add_option("--fill", default="white",
            help="color of the bin [default: %default]")
    p.add_option("--format", default="pdf", choices=allowed_format,
            help="Generate image of format [default: %default]")
    p.add_option("--quick", default=False, action="store_true",
            help="Use quick plot, assuming bins are already counted")
    p.add_option("--noprintstats", default=False, action="store_true",
            help="Write basic stats when using --quick")
    opts, args = p.parse_args()

    if len(args) < 1:
        sys.exit(not p.print_help())

    skip = opts.skip
    vmin, vmax = opts.vmin, opts.vmax
    bins = opts.bins
    xlabel, title = opts.xlabel, opts.title
    title = title or args[0]
    base = int(opts.base)
    fileno = len(args)

    if opts.quick:
        assert fileno == 1, "Single input file expected using --quick"
        filename = args[0]
        figname = filename.rsplit(".", 1)[0] + ".pdf"
        data = DictFile(filename, keycast=int, cast=int)
        quickplot(data, vmin, vmax, xlabel, title, figname=figname,
                  print_stats=(not opts.noprintstats))
        return

    if fileno == 1:
        histogram(args[0], vmin, vmax, xlabel, title, outfmt=opts.format,
                bins=bins, skip=skip, ascii=opts.ascii,
                base=base, fill=opts.fill, col=opts.col)
    else:
        histogram_multiple(args, vmin, vmax, xlabel, title, outfmt=opts.format,
                tags=opts.tags, bins=bins, skip=skip, ascii=opts.ascii,
                facet=opts.facet, fill=opts.fill)
463960
def color_lines(ax, labels, colors):
    
    assert len(labels) == len(colors), \
        "Equal no. of colors and lables must be given"
    lines = ax.findobj(mpl.lines.Line2D)
    line_labels = [i + "_line" for i in lineid_plot.unique_labels(labels)]
    for line in lines:
        l = line.get_label()
        try:
            loc = line_labels.index(l)
        except ValueError:
            continue  # No changes for this line
        line.set_color(colors[loc])

    ax.figure.canvas.draw()