Exemplo n.º 1
0
    def run(self):
        """
		03-01-05
			initial
		
		--db_connect()
		--get_go_no2term_id()		#for get_distance(), needs self.go_no2term_id
		--data_fetch()
			--gene_no2p_gene_setup()
		--p_gene_id_map()
			--_p_gene_map()  or --_p_gene_map_network_topology()
				--get_distance()		#touches self.go_no2distance
		--submit()		
		"""
        (conn, curs) = db_connect(self.hostname, self.dbname, self.schema)
        curs.execute("begin")  # because of cursor usage
        self.go_no2term_id = get_go_no2term_id(curs, self.schema, self.term_table)
        self.data_fetch(curs, self.p_gene_table, self.gene_p_table)
        if self.type == 2 and self.pattern_table == None:
            sys.stderr.write("\n type=2 needs pattern_table.\n")
            sys.exit(3)
        self.p_gene_map(
            self.gene_no2p_gene,
            self.p_gene_id_map,
            curs,
            self.distance_table,
            self.go_no2distance,
            self.go_no2term_id,
            self.type,
        )
        if self.needcommit:
            self.submit(curs, self.gene_p_table, self.p_gene_id_map)
            curs.execute("end")
Exemplo n.º 2
0
	def dstruc_loadin(self, curs):
		"""
		03-14-05
			remove the distance loading part
		"""
		sys.stderr.write("Loading Data STructure...\n")
		from codense.common import get_known_genes_dict, get_go_no2go_id,\
			get_go_no2term_id, get_go_no2depth, get_go_term_id2go_no, \
			get_go_term_id2depth
		
		self.known_genes_dict = get_known_genes_dict(curs)
		self.go_no2go_id = get_go_no2go_id(curs)
		self.go_no2term_id = get_go_no2term_id(curs)
		self.go_no2depth = get_go_no2depth(curs)
		self.go_term_id2go_no = get_go_term_id2go_no(curs)
		self.go_term_id2depth = get_go_term_id2depth(curs)
		
		sys.stderr.write("Done\n")
Exemplo n.º 3
0
	def return_go_no_map(self, go_no_list, curs, distance_table):
		"""
		03-06-05
			input: a list of go_nos, curs
			output: a map showing which go_no corresponds to which
			
			curs is used to get the go_no2term_id and nodes pairwise distance
		"""
		sys.stderr.write("Mapping go_nos...")
		from gene_p_map_redundancy import gene_p_map_redundancy
		from codense.common import get_go_no2term_id
		borrowed_instance = gene_p_map_redundancy()
		go_no_map = {}
		go_no2term_id = get_go_no2term_id(curs)
		go_no2distance = {}
		
		for i in range(len(go_no_list)):
			go_no = go_no_list[i]
			if go_no not in go_no_map:
				#not flagged, map
				go_no_map[go_no] = go_no
				for j in range(i+1, len(go_no_list)):
					go_no2 = go_no_list[j]
					if go_no < go_no2:
						key= (go_no, go_no2)
					else:
						key = (go_no2, go_no)
					if key in go_no2distance:
						jasmine_distance = go_no2distance[key][2]
					else:
						jasmine_distance = borrowed_instance.get_distance(curs, go_no, go_no2, distance_table, go_no2distance, go_no2term_id)
					if jasmine_distance == 0:
						#jasmine_distance=0 means they are parent-child
						go_no_map[go_no2] = go_no
		sys.stderr.write("done.\n")
		return go_no_map