Write grouped and sorted GO IDs to GOs.
559311
def wr_txt_nts(self, fout_txt, desc2nts, prtfmt=None):
        """"""
        with open(fout_txt, 'w') as prt:
            summary_dct = self._prt_txt_desc2nts(prt, desc2nts, prtfmt)
            if summary_dct:
                print(self.sortobj.grprobj.fmtsum.format(
                    ACTION="WROTE:", FILE=fout_txt, **summary_dct))
            else:
                print("  WROTE: {TXT}".format(TXT=fout_txt))
637352
def write_dag(self, out=sys.stdout):
        """"""
        for rec in sorted(self.values()):
            print(rec, file=out)
236726
def read_goids(fin_txt, get_goids_only=False, exclude_ungrouped=False, prt=sys.stdout):
    """"""
    return ReadGoids().read_txt(fin_txt, get_goids_only, exclude_ungrouped, prt)
195833
def write(gmt, out_path):
    
    with open(out_path, 'w') as f:
        for _, each_dict in enumerate(gmt):
            f.write(each_dict[SET_IDENTIFIER_FIELD] + '\t')
            f.write(each_dict[SET_DESC_FIELD] + '\t')
            f.write('\t'.join([str(entry) for entry in each_dict[SET_MEMBERS_FIELD]]))
            f.write('\n')
1359881
def fmt(self):
      """"""
      lines = [ ]
      def write (line):
        lines.append(line)
      if self._defaults:
          write("[%s]\n" % DEFAULTSECT)
          for (key, value) in self._defaults.items():
              write("%s = %s\n" % (key, str(value).replace('\n', '\n\t')))
          write("\n")
      for section in self._sections:
          write("[%s]\n" % section)
          for (key, value) in self._sections[section].items():
              if key == "__name__":
                  continue
              if (value is not None) or (self._optcre == self.OPTCRE):
                  key = " = ".join((key, str(value).replace('\n', '\n\t')))
              write("%s\n" % (key))
          write("\n")
      return "".join(lines)
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))
957661
def _get_goid2dbids(associations):
        """"""
        go2ids = cx.defaultdict(set)
        for ntd in associations:
            go2ids[ntd.GO_ID].add(ntd.DB_ID)
        return dict(go2ids)
76652
def wr_xlsx(self, fout_xlsx, goids, sortby=None, **kws_usr):
        """"""
        nts = GoSubDag(goids, self.go2obj).get_nts(goids, sortby)
        kws_wr = kws_usr.copy()
        if 'fld2col_widths' not in kws_wr:
            kws_wr['fld2col_widths'] = self.fld2col_widths
        wr_xlsx_tbl(fout_xlsx, nts, **kws_wr)
552343
def _init_c2ps(self, go_sources, traverse_child):
        """"""
        if not traverse_child:
            return {}
        c2ps = defaultdict(set)
        goids_seen = set()
        go2obj = self.go2obj
        for goid_src in go_sources:
            goobj_src = go2obj[goid_src]
            if goid_src not in goids_seen:
                ##F self._traverse_child_objs(c2ps, goobj_src, go2obj, goids_seen)
                self._traverse_child_objs(c2ps, goobj_src, goids_seen)
        return c2ps
314378
def rm_gos(self, rm_goids):
        """"""
        self.edges = self._rm_gos_edges(rm_goids, self.edges)
        self.edges_rel = self._rm_gos_edges_rel(rm_goids, self.edges_rel)
679225
def write_id (self):
        """"""
        self.writeln()
        self.write(self.part('id') + self.spaces('id'))
        self.writeln(u"%d" % self.stats.number, color=self.colorinfo)
1206794
def _group(self, rdd):
        """"""
        return rdd.reduceByKey(lambda x, y: x.append(y))
264577
def get_key_goids(self, goids):
        """"""
        go2obj = self.go2obj
        return set(go2obj[go].id for go in goids)
265920
private void writeJsonForArchivedJobGroupvertex(PrintWriter wrt, RecentJobEvent jobEvent, ManagementGroupVertexID groupvertexId) {
		
		
		try {
		
		ManagementGraph jobManagementGraph = jobmanager.getManagementGraph(jobEvent.getJobID());
		
		ManagementGroupVertex groupvertex = jobManagementGraph.getGroupVertexByID(groupvertexId);
		
		// Serialize ManagementGraph to json
		wrt.write("{\"groupvertex\": "+groupvertex.toJson()+",");
		
		wrt.write("\"verticetimes\": {");
		boolean first = true;
		for(ManagementGroupVertex groupVertex : jobManagementGraph.getGroupVerticesInTopologicalOrder()) {
			
			for(int j = 0; j < groupVertex.getNumberOfGroupMembers(); j++) {
				ManagementVertex vertex = groupVertex.getGroupMember(j);
				
				if(first) {
					first = false;
				} else {
					wrt.write(","); }
				
				wrt.write("\""+vertex.getID()+"\": {");
				wrt.write("\"vertexid\": \"" + vertex.getID() + "\",");
				wrt.write("\"vertexname\": \"" + vertex + "\",");
				wrt.write("\"CREATED\": "+ jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.CREATED) + ",");
				wrt.write("\"SCHEDULED\": "+ jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.SCHEDULED) + ",");
				wrt.write("\"ASSIGNED\": "+ jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.ASSIGNED) + ",");
				wrt.write("\"READY\": "+ jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.READY) + ",");
				wrt.write("\"STARTING\": "+ jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.STARTING) + ",");
				wrt.write("\"RUNNING\": "+ jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.RUNNING) + ",");
				wrt.write("\"FINISHING\": "+ jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.FINISHING) + ",");
				wrt.write("\"FINISHED\": "+ jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.FINISHED) + ",");
				wrt.write("\"CANCELING\": "+ jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.CANCELING) + ",");
				wrt.write("\"CANCELED\": "+ jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.CANCELED) + ",");
				wrt.write("\"FAILED\": "+ jobmanager.getArchive().getVertexTime(jobEvent.getJobID(), vertex.getID(), ExecutionState.FAILED) + "");
				wrt.write("}");
			}
			
		}
		wrt.write("}}");
		
	} catch (EofException eof) { // Connection closed by client
		LOG.info("Info server for jobmanager: Connection closed by client, EofException");
	} catch (IOException ioe) { // Connection closed by client	
		LOG.info("Info server for jobmanager: Connection closed by client, IOException");
	} 
		
	}
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
957183
def get_ns2goids(self, goids):
        """"""
        ns2goids = cx.defaultdict(set)
        go2nt = self.go2nt
        for goid in goids:
            ns2goids[go2nt[goid].NS].add(goid)
        return {ns:gos for ns, gos in ns2goids.items()}
1226377
def prt_goid_cnt(self, prt=sys.stdout):
        """"""
        for section_name, hdrgos_sec in self.grprobj.get_sections_2d():
            prt.write("{NAME} {Us:5,} {Hs:5,} {SEC}\n".format(
                NAME=self.grprobj.grpname,
                Us=len(self.grprobj.get_usrgos_g_hdrgos(hdrgos_sec)),
                Hs=len(hdrgos_sec),
                SEC=section_name))