Initialize go2obj in small dag for source gos.
420485
def _init_go2obj(self, **kws):
        """"""
        if 'goids' in kws and 'obodag' in kws:
            self.godag.go_sources = kws['goids']
            obo = kws['obodag']
            for goid in self.godag.go_sources:
                self.godag.go2obj[goid] = obo[goid]
        elif 'goid2goobj' in kws:
            goid2goobj = kws['goid2goobj']
            self.godag.go_sources = goid2goobj.keys()
            for goid, goobj in goid2goobj.items():
                self.godag.go2obj[goid] = goobj
        elif 'goea_results' in kws:
            goea_results = kws['goea_results']
            self.godag.go_sources = [rec.GO for rec in goea_results]
            self.godag.go2obj = {rec.GO:rec.goterm for rec in goea_results}
140586
def initialize(g, app):
    
    if 'DATABASES' in app.config and 'POSTGRESQL' in app.config['DATABASES']:
        # Database connection established for console commands
        for k, v in app.config['DATABASES']['POSTGRESQL'].items():
            init_db_conn(k, v)

        if 'test' not in sys.argv:
            # Establish a new connection every request
            @app.before_request
            def before_request():
                """
                Assign postgresql connection pool to the global
                flask object at the beginning of every request
                """
                # inject stack context if not testing
                from flask import _app_ctx_stack
                for k, v in app.config['DATABASES']['POSTGRESQL'].items():
                    init_db_conn(k, v, scopefunc=_app_ctx_stack)
                g.postgresql_pool = pool

            # avoid to close connections if testing
            @app.teardown_request
            def teardown_request(exception):
                """
                Releasing connection after finish request, not required in unit
                testing
                """
                pool = getattr(g, 'postgresql_pool', None)
                if pool is not None:
                    for k, v in pool.connections.items():
                        v.session.remove()
        else:
            @app.before_request
            def before_request():
                """
                Assign postgresql connection pool to the global
                flask object at the beginning of every request
                """
                for k, v in app.config['DATABASES']['POSTGRESQL'].items():
                    init_db_conn(k, v)
                g.postgresql_pool = pool
457395
def initialize_from_bucket(self):
    """"""
    # In order to support Colab, we use the HTTP GCS API to access the metadata
    # files. They are copied locally and then loaded.
    tmp_dir = tempfile.mkdtemp("tfds")
    data_files = gcs_utils.gcs_dataset_info_files(self.full_name)
    if not data_files:
      return
    logging.info("Loading info from GCS for %s", self.full_name)
    for fname in data_files:
      out_fname = os.path.join(tmp_dir, os.path.basename(fname))
      gcs_utils.download_gcs_file(fname, out_fname)
    self.read_from_directory(tmp_dir)
1108379
def sg_init(sess):
     
    """
    # initialize variables
    sess.run(tf.group(tf.global_variables_initializer(),
                      tf.local_variables_initializer()))
168738
function DDInit(){

    ll('');
    ll('DrillExp.js');
    ll('DDInit start...');

    var gconf = new bbop.golr.conf(amigo.data.golr);
    var gm = new bbop.golr.manager.jquery(server_meta.golr_base(), gconf);
    //gm.set_personality('bbop_ont'); // profile in gconf
    gm.add_query_filter('document_category', 'ontology_class', ['*']);
    
    // Let's limit ourselves to 100 rows returned so we don't overload
    // while (dumb) browsing.
    gm.set('rows', 100);

    // Let's capture an initial url (one that gets the roots), then
    // reset.
    gm.set_query('id:"GO:0008150" or id:"GO:0005575" or id:"GO:0003674"');
    var reset_url = gm.get_query_url();
    gm.reset_query();

    // Ready tree with response.
    var did = '#drilldown';
    jQuery(did).jstree(
	{
	    "json_data" : {
	        "ajax" : {
		    "type": 'GET',
		    "dataType": 'jsonp',
		    "jsonp": 'json.wrf',
	            "url" : function (n) {
			var retval = reset_url;
			if( !n || ! n.attr || ! n.attr("id") ){
			    ll('url: initial');
			}else{
			    ll('url: open');

			    // Get id.
			    var attr_id = n.attr("id");

			    if( n.attr('kid_query') ){
				gm.set('parent', n.attr('id'));
				gm.set('q', n.attr('kid_query'));
				retval = gm.get_query_url();
			    }else{
				retval = null;
			    }
			}
			ll('try url: ' + retval);
	                return retval;
	            },
	            "error" : function(e) {
			ll('ERROR: ' + e);
			//throw new Error('...');
		    },
	            "success" : function(json_data) {

			//ll('SUCCESS on data');

			// Figure out if there was a parent and
			// capture the id if there was.
			var parent_id = null;
			if( json_data &&
			    json_data.responseHeader &&
			    json_data.responseHeader.params &&
			    json_data.responseHeader.params.parent ){
				parent_id = json_data.responseHeader.params.parent;
			}

			// Gather the documents found.
			var resp = new bbop.golr.response(json_data);
			var docs = resp.documents();
			var json_nodes = [];
			var each = bbop.core.each;
			each(docs,
			     function(doc){
				 json_nodes.push(_doc_to_tree_node(doc,
								   parent_id));
			     });
			
			// Alpha sort, but get GO stuff first.
			json_nodes.sort(
			    function(a, b){

				// First id suffix-ish compare (dirty)
				// for GO.
				var foo = 0;
				var a_id = a['attr']["id"].substr(0, 2);
				var b_id = b['attr']["id"].substr(0, 2);
				if (a_id == 'GO' && b_id != 'GO' ){
				    foo = -1;
				}else if (a_id != 'GO' && b_id == 'GO' ){
				    foo = 1;
				}else{
				    // Then a general suffix compare.
				    foo = a_id.localeCompare(b_id);

				    if( foo == 0 ){
					// And finally an alpha label
					// comparison.
					var a_t = a['data']['title'];
					var b_t = b['data']['title'];
					foo = a_t.localeCompare(b_t);
				    }
				}
				return foo;
			    });
			
	                return json_nodes;
	            }
	        }
	    },
	    "plugins" : ["json_data", "themeroller"]});
    // Revoved the bits that override the normal HTML click
    // functionality. Nice to know it's there though.
    //     "plugins" : ["json_data", "themeroller", "ui"]
    // }).bind("select_node.jstree",
    // 	// TODO: Probably want a callback to the server here
    // 	// to get more detailed information; just a
    // 	// placeholder linker for now.
    // 	function(e, data){
    // 	    var attr_id = data.rslt.obj[0].id;
    // 	    var linky = api.link.term({acc: attr_id});
    // 	    window.location.href = linky;
    // 	    // Or perhaps a pop-up info window?
    // 	    // var dia = '<div>' +
    // 	    // 	api.html.term_link(attr_id,
    // 	    // 			     'Link to ' + attr_id + '.') +
    // 	    // 	'</div>';
    // 	    // jQuery(dia).dialog({closeOnEscape: true,
    // 	    // 			modal: true,
    // 	    // 			title: 'Quick info about: ' + attr_id});
    // 	});

    ll('DDInit done.');
}
687908
def _initialize(self):
        """"""

        payload = {
            'apikey': self.session.cookies.get('apikey'),
            'source': self.session.cookies.get('source')
            }

        if self.fm_user.logged_in:
            payload['logintoken'] = self.session.cookies.get('logintoken')

        payload.update(self.transfer_info)

        method, url = get_URL('init')

        res = getattr(self.session, method)(url, params=payload)

        if res.status_code == 200:
            for key in ['transferid', 'transferkey', 'transferurl']:
                self.transfer_info[key] = res.json().get(key)

        else:
            hellraiser(res)
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}
426521
def init_goid2color(self):
        """"""
        goid2color = {}
        # 1. User-specified colors for each GO term
        if 'go2color' in self.kws:
            for goid, color in self.kws['go2color'].items():
                goid2color[goid] = color
        # 2. colors based on p-value override colors based on source GO
        if self.objgoea is not None:
            self.objgoea.set_goid2color_pval(goid2color)
        key2color = self.kws.get('key2col')
        if key2color is not None:
            # 3. Default GO source color
            if 'go_sources' in key2color:
                color = key2color['go_sources']
                go2obj = self.gosubdag.go2obj
                for goid in self.gosubdag.go_sources:
                    if goid not in goid2color:
                        goobj = go2obj[goid]
                        goid2color[goobj.id] = color
                        goid2color[goid] = color
            # 4. Level-01 GO color
            if 'level_01' in key2color:
                color = key2color['level_01']
                for goid, goobj in self.gosubdag.go2obj.items():
                    if goobj.level == 1:
                        if goid not in goid2color:
                            goid2color[goid] = color
        return goid2color
978024
def _init_objcolor(self, node_opts, **kwu):
        """"""
        objgoea = node_opts.kws['dict'].get('objgoea', None)
        # kwu: go2color go2bordercolor dflt_bordercolor key2col
        return Go2Color(self.gosubdag, objgoea, **kwu)
532701
def _init(self):
        """"""
        for goid in self.godag.go_sources:
            goobj = self.godag.go2obj[goid]
            self.godag.go2obj[goid] = goobj
            # Traverse up parents
            if self.traverse_parent and goid not in self.seen_cids:
                self._traverse_parent_objs(goobj)
            # Traverse down children
            if self.traverse_child and goid not in self.seen_pids:
                self._traverse_child_objs(goobj)
445184
def _init_ns2nt(rcntobj):
        """"""
        go2dcnt = rcntobj.go2dcnt
        ntobj = cx.namedtuple("NtD1", "D1 dcnt goobj")
        d0s = rcntobj.depth2goobjs[0]
        ns_nt = [(o.namespace, ntobj(D1="", dcnt=go2dcnt[o.id], goobj=o)) for o in d0s]
        return cx.OrderedDict(ns_nt)
1079462
def _init_gos(self, go_sources_arg, relationships_arg):
        """"""
        # No GO sources provided
        if not go_sources_arg:
            assert self.go2obj_orig, "go2obj MUST BE PRESENT IF go_sources IS NOT"
            self.go_sources = set(self.go2obj_orig)
            self.go2obj = self.go2obj_orig
            sys.stdout.write("**NOTE: {N:,} SOURCE GO IDS\n".format(N=len(self.go_sources)))
            return
        # GO sources provided
        go_sources = self._init_go_sources(go_sources_arg, self.go2obj_orig)
        # Create new go2obj_user subset matching GO sources
        # Fill with source and parent GO IDs and alternate GO IDs
        go2obj_user = {}
        objrel = CurNHigher(relationships_arg, self.go2obj_orig)
        objrel.get_id2obj_cur_n_high(go2obj_user, go_sources)
        # Add additional GOTerm information, if needed for user task
        kws_gos = {k:v for k, v in self.kws.items() if k in self.kws_aux_gos}
        if kws_gos:
            self._add_goterms_kws(go2obj_user, kws_gos)
        self.go_sources = go_sources
        self.go2obj = go2obj_user
1221234
def _add_goterms_kws(self, go2obj_user, kws_gos):
        """"""
        if 'go2color' in kws_gos:
            for goid in kws_gos['go2color'].keys():
                self._add_goterms(go2obj_user, goid)
923208
def _go_install(self, target, gopath, build_flags):
    """"""
    args = build_flags + [target.import_path]
    result, go_cmd = self.go_dist.execute_go_cmd(
      'install', gopath=gopath, args=args,
      workunit_factory=self.context.new_workunit,
      workunit_name='install {}'.format(target.import_path),
      workunit_labels=[WorkUnitLabel.COMPILER])
    if result != 0:
      raise TaskError('{} failed with exit code {}'.format(go_cmd, result))
1068506
def initialize():
    """"""
    try:
        requests.get('http://localhost:4242/poll')
        state['connected_to_bot'] = True
    except requests.exceptions.ConnectionError:
        state['connected_to_bot'] = False

    # set up turtle
    state['window'] = turtle.Screen()
    state['window'].setup(width=AXI_WIDTH, height=AXI_HEIGHT)
    state['turtle'] = turtle.Turtle()
    state['turtle'].width(2)
    state['turtle'].speed(0)
    point_in_direction(0)

    pen_up()
745077
def create_initialize(repo, atts)
      @repo = repo
      atts.each do |k, v|
        instance_variable_set("@#{k}".to_sym, v)
      end
      self
    end
19822
def __init_go2nt_dflt(self, gos_all, prt_flds_all):
        """"""
        go2nts = [self.gosubdag.go2nt, self._get_go2nthdridx(gos_all)]
        go2nt = get_dict_w_id2nts(gos_all, go2nts, prt_flds_all)
        return self._init_go2nt_aug(go2nt)