Beispiel #1
0
 def test_triadic_census(self):
     cens = triadic_census.triadic_census(self.random_graph)
     f = open("unit_test_data/random_triadic_census.pickle", "r")
     shouldBe = cPickle.load(f)
     f.close()
     self.assertEqual(cens, shouldBe)
Beispiel #2
0
	def test_triadic_census(self):
		cens = triadic_census.triadic_census(self.random_graph)
		f = open("unit_test_data/random_triadic_census.pickle","r")
		shouldBe = cPickle.load(f)
		f.close()
		self.assertEqual(cens,shouldBe)
    triadGraph.add_edge(nodes[id(neuron2)], nodes[id(neuron1)])
for innervation in network.innervations():
    triadGraph.add_edge(nodes[id(innervation.neurite.rootObject())], nodes[id(innervation.muscle)])
for pathway in network.pathways():
    if pathway.region1Projects:
        triadGraph.add_edge(nodes[id(pathway.region1)], nodes[id(pathway.region2)])
    if pathway.region2Projects:
        triadGraph.add_edge(nodes[id(pathway.region2)], nodes[id(pathway.region1)])
for stimulus in network.stimuli():
    triadGraph.add_edge(nodes[id(stimulus)], nodes[id(stimulus.target.rootObject())])
for synapse in network.synapses():
    for postPartner in synapse.postSynapticPartners:
        triadGraph.add_edge(nodes[id(synapse.preSynapticNeurite.rootObject())], nodes[id(postPartner.rootObject())])

updateProgress(gettext('Finding motifs...'))
counts = triadic_census.triadic_census(triadGraph)

# Report the results in the console in case the user wants to copy/paste
print('Triad motif occurences:')
print('Motif\tCount')
for triad in triadOrder:
    print(triad + '\t' + str(counts[triad]))

# Open a new display that shows the results graphically
network = createNetwork()
display = displayNetwork(network)
display.setDefaultFlowSpacing(0.15)
edgeLength = 0.5
xDiff = edgeLength / 2.0
yDiff = sqrt(edgeLength ** 2 - xDiff ** 2) / 2.0
nodeSize = edgeLength / 5.0