Пример #1
0
	def jasmine_distance(self, go_id1, go_id2, lc_ancestors):
		min_distance = 100
		for ancestor in lc_ancestors:
			distance1 = len(GraphAlgo.shortest_path(self.go_digraph, ancestor, go_id1))-1
			distance2 = len(GraphAlgo.shortest_path(self.go_digraph, ancestor, go_id2))-1
			if distance1 < min_distance:
				min_distance = distance1
			if distance2 < min_distance:
				min_distance = distance2
		return min_distance
Пример #2
0
	def submit(self):
		sys.stderr.write("Database transacting...")
		#following string operations are because of format restrictions of database array input
		string__unknown_gene_list = repr(self._unknown_gene_list)
		string__unknown_gene_list = string__unknown_gene_list.replace("'", '')
		string__unknown_gene_list = '{' + string__unknown_gene_list[1:-1] + '}'
		string_unknown_gene_list = repr(self.unknown_gene_list)
		string_unknown_gene_list = '{' + string_unknown_gene_list[1:-1] + '}'
		
		self.curs.execute("insert into go(go_id, go_no, no_of_genes, name, whole_gene_array, gene_array, depth) \
			values('%s', %d, %d, '%s', '%s', '%s', 2)"%('GO:0000004', 0, len(self._unknown_gene_list), \
			'biological_process unknown', string__unknown_gene_list, string_unknown_gene_list))
		go_dict = self.parser.parse(self.go_inf, self.vertex_dict)
		for term in go_dict:
			string_whole_gene_array = repr(go_dict[term].whole_gene_array)
			string_gene_array = repr(go_dict[term].gene_array)
			string_whole_gene_array = string_whole_gene_array.replace("'", '')
			string_whole_gene_array = '{' + string_whole_gene_array[1:-1] + '}'
			string_gene_array = '{' + string_gene_array[1:-1] + '}'
			go_dict[term].name = go_dict[term].name.replace("'",'')
			depth = len(GraphAlgo.shortest_path(self.go_graph, 'GO:0008150', term))
			self.curs.execute("insert into go(go_id, go_no, no_of_genes, name, whole_gene_array, gene_array, depth) \
				values('%s', %d, %d, '%s', '%s', '%s', %d)"%(term, go_dict[term].no, go_dict[term].no_of_genes,\
				go_dict[term].name, string_whole_gene_array, string_gene_array, depth))
		if self.needcommit:
			self.conn.commit()
		sys.stderr.write("done.\n")
Пример #3
0
	def raw_distance(self, go_id1, go_id2):
		distance = len(GraphAlgo.shortest_path(self.go_graph, go_id1, go_id2))-1
		return distance
Пример #4
0
	def depth_of_one_node(self, go_id):

		return len(GraphAlgo.shortest_path(self.go_digraph, self.root, go_id))