Commit 3e6571b9 authored by VIGNET Pierre's avatar VIGNET Pierre
Browse files

build_interactions: update doc; Fix typos

parent c99a495a
......@@ -179,7 +179,7 @@ def filter_trajectories(trajectories, molecules_of_interest):
def entity_is_in_trajectory(sol, trajectory_places):
"""Search interactions between molecules of interest and entities
involved in the given trajectory.
involved in the given trajectory, and pre-build binary interactions.
We assume that the molecules of interest **are** in the trajectories.
We associate with each entity the trajectories containing them.
......@@ -215,11 +215,9 @@ def filter_trajectories(trajectories, molecules_of_interest):
def build_interactions(filtered_macs, binary_interactions):
filtered_macs = list of tuples of macs
binary_interactions = list of tuples (searched place, place)
"""Make binary interactions used by the graph as edges
PS: genes and stimulis are frontier places
PS: genes and stimulis are frontier places.
:param filtered_macs: All solutions related to the molecules of interest.
......@@ -249,8 +247,9 @@ def build_interactions(filtered_macs, binary_interactions):
* stimulis_interactions: Interactions between stimuli in the same solution
* genes_stimuli_interactions: Interactions between genes and stimulis in
the same solution
* filtered_binary_interactions: Counter interactions between molecules of
interest and frontier places that are not genes in trajectories
* molecule_stimuli_interactions: Counter interactions between molecules
of interest and frontier places that are not genes (stimuli)
in trajectories (i.e.: ``(molecule, stimulus)``).
:rtype: <set>, <set>, <Counter>, <Counter>, <Counter>, <Counter>
......@@ -274,7 +273,6 @@ def build_interactions(filtered_macs, binary_interactions):
#print("genes, stimulis:", genes, stimuli)
# For every solution composed of frontier places,
# compute binary interactions between:
......@@ -288,15 +286,31 @@ def build_interactions(filtered_macs, binary_interactions):
# print("genes/stimulis interactions:", genes_stimuli_interactions)
# print("genes interactions:", genes_interactions)
# print("stimulis interactions:", stimulis_interactions)
# print("all stimuli:", all_stimuli)
# print("all genes:", all_genes)
LOGGER.debug("build_interactions:: all genes:\n%s", all_genes)
LOGGER.debug("build_interactions:: all stimuli:\n%s", all_stimuli)
def filter_interactions(molecule_of_interest, places_occurrences):
"""Remove all interactions that do not contain almost 1 frontier place (gene or stimulus)
def make_molec_stimuli_interactions(molecule_of_interest, places_occurrences):
"""Make binary interactions between a molecule of interest and
the stimuli in their solutions.
We also add to each generated tuple, its number of occurences.
We avoid all interactions that contain genes, and do not contain
Counter: clé: interaction binaire/tuple, valeur occurences
.. warning:: Will not work if the molecule of interest is only in conditions
and not in trajectories. In this case the molecule is a frontier
place (an input of the model); so it seems useless to search this
kind of entity.
:param molecule_of_interest: A searched molecule (user input).
:param places_occurrences: Counter with frontier placs as keys,
and their occurences as values.
:type molecule_of_interest: <str>
:type places_occurrences: <Counter <str>: <int>>
frontier_places = set(places_occurrences.keys())
......@@ -320,27 +334,23 @@ def build_interactions(filtered_macs, binary_interactions):
for molec_place in it.product([molecule_of_interest], frontier_places)}
# filtered_binary_interactions = set(it.chain(*[filter_interactions(*data) for data in binary_interactions.iteritems()]))
g = (filter_interactions(*data) for data in binary_interactions.iteritems())
# TODO: marchera pas si la molec of interest est dans les conditions et non dans les places des trajectoires...
filtered_binary_interactions = Counter(next(g))
[filtered_binary_interactions.update(f_bin) for f_bin in g]
# print("filtered_binary_interactions:", filtered_binary_interactions)
# print(len(filtered_binary_interactions))
# raw_input("PAUSE")
g = (make_molec_stimuli_interactions(*data)
for data in binary_interactions.iteritems())
# warning: marchera pas si la molec of interest est dans les conditions
# et non dans les places des trajectoires...
molecule_stimuli_interactions = Counter(next(g))
[molecule_stimuli_interactions.update(f_bin) for f_bin in g]
return all_genes, all_stimuli, genes_interactions, \
stimulis_interactions, \
genes_stimuli_interactions, \
def build_graph(all_genes, all_stimuli, unique_genes_interactions,
......@@ -348,7 +358,7 @@ def build_graph(all_genes, all_stimuli, unique_genes_interactions,
nodes_count = Counter(it.chain(*unique_genes_interactions.keys()))
import networkx as nx
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment