def __connection_in_extra_genes_step_1(self, control, connected_nodes): """ calculate c[1]: whether 'extra-gene' is directly connected to the LGN connected_nodes = list[set()] ==> remember to 'flatten' them first """ # use set() since we do not pay attention to how many times # extra genes connect with LGN nodes = set(helper.list_of_sets_to_list(connected_nodes)) for gene in nodes: if gene in control: control[gene][1] += 1 else: # In the same block, this thing should never happen!!! print "Problem!!! internal validation 1" return control
def __connection_in_extra_genes_step_2(self, control, connected_nodes): """ calculate c[2] ... c[n+1]: number of times it's connected to SLGN(0), ..., whether 'extra-gene' is connected to SLGN(i), ... , whether 'extra-gene' is connected to SLGN(n-1)) connected_nodes_in_subLGN = list[] """ number_of_LGN_genes = len(self.genes_in_lgn) list_of_connected_nodes = helper.list_of_sets_to_list(connected_nodes) calculated_node = set() set_of_connected_nodes = set(list_of_connected_nodes) for (index, set_of_genes) in enumerate(connected_nodes): for gene in set_of_genes: if gene in control: for k in range(0, number_of_LGN_genes): control[gene][k + 2] = 1 if gene not in calculated_node: control[gene][index + 2] = 0 else: # In the same block, this thing should never happen!!! print "Problem!!! internal validation 2" return control