Example #1
0
					tooBig[:,j]=0
				else:
					tooBig[i,j]=1
	print "modified",nChanged
	print map(len,tables)

def rebuild_distance_matrix():
	global dist
	dist=[(float('inf'),None)]*(N*N)
	for i in range(N):
		for j in range(i+1,N):
			d,res=table_distance(tables[i],tables[j])
			dist[i*N+j]=d,res
			dist[j*N+i]=d,res

				
def count_non_null_items_in_distance_matrix():
	c=0
	for i in geneRange:
		for j in range(i+1,N):
			if dist[i*N+j]!=(float('inf'),None):
				c+=1
	return c

def compute_sstate():
	rebuild_tables()
	trim_tables(5)
	rebuild_distance_matrix()
	sstate()
profilerun('compute_sstate()')
# compute_sstate()
Example #2
0
genes=ft.keys()
N=len(genes)
genesIndex=dict(zip(genes,range(len(genes))))
# ft=bigFocalParamsValues
ssTable=map(lambda gene:map(lambda k:k[0]+((gene,k[1]),), ft[gene].items()), genes)
#we remove all ssStates where an item has two value mapped (the case for autoactivation)
ssNodes=[[row for row in table if not hasTwoValue(row)] for table in ssTable]
# ssNodes.sort(key=len)
reducedNodes=[]
for table in ssNodes:
	rows=[]
	for state in table:
		s=["_"]*N
		for var,val in state:
			s[genesIndex[var]]=val
		rows.append(tuple(s))
	reducedNodes.append(rows)

tables=copy.copy(reducedNodes)

dist={}
for i in range(N):
	for j in range(i+1,N):
		d=table_distance(tables[i],tables[j])
		dist[(i,j)]=d
		dist[(j,i)]=d

# sstate()
# print dist
profilerun("sstate()")