def time_series_all(net, nodes_list, Nbr_Initial_States, Nbr_States, MAX_TimeStep=20): ''' Description: -- compute TE for every pair of nodes using distribution from all possible initial conditions or an arbitrary set of initial conditions Arguments: -- 1. net -- 2. nodes_list -- 3. Initial_States_List -- 4. Nbr_States -- 5. MAX_TimeStep Return: -- 1. timeSeriesData ''' #Nbr_Nodes = len(net.nodes()) #Nbr_All_Initial_States = np.power(Nbr_States, Nbr_Nodes) timeSeriesData = {} for n in net.nodes(): timeSeriesData[n] = {} for initState in range(Nbr_Initial_States): timeSeriesData[n][initState] = [] for initDecState in range(Nbr_Initial_States): currBiState = decimal_to_binary(nodes_list, initDecState, Nbr_States) for step in range(MAX_TimeStep): prevBiState = currBiState.copy() for n in nodes_list: timeSeriesData[n][initDecState].append(prevBiState[n]) currBiState = ur.sigmoid_updating(net, prevBiState) return timeSeriesData
def time_series_one(net, nodes_list, Initial_State, Nbr_States, MAX_TimeStep=20): ''' Description: -- compute TE for every pair of nodes using distribution from all initial conditions that converge to the primary or biological attractor Arguments: -- 1. net -- 2. nodes_list -- 3. Initial_States_List -- 4. Nbr_States -- 5. MAX_TimeStep Return: -- 1. timeSeriesData (only for primary attractor) ''' timeSeriesData = {} for n in net.nodes(): timeSeriesData[n] = {} timeSeriesData[n][0] = [] currBiState = Initial_State for step in range(MAX_TimeStep): prevBiState = currBiState.copy() for n in nodes_list: timeSeriesData[n][0].append(prevBiState[n]) currBiState = ur.sigmoid_updating(net, prevBiState) return timeSeriesData
def biological_sequence(net, nodes_list, bio_initStates, fileName, Nbr_States=2): bioSeq = [] currBiStates = bio_initStates finished = False while(not finished): oneDiff = 0 prevBiStates = currBiStates.copy() bioSeq.append(prevBiStates) currBiStates = ur.sigmoid_updating(net, prevBiStates) for u in nodes_list: if abs(prevBiStates[u] - currBiStates[u]) > 0: oneDiff = 1 break finished = (oneDiff < 1) OUTPUT_FILE = open(fileName, 'w') OUTPUT_FILE.write('time step') for u in nodes_list: OUTPUT_FILE.write('\t%s'%(u)) OUTPUT_FILE.write('\n') for i in range(len(bioSeq)): OUTPUT_FILE.write('%d'%i) for u in nodes_list: OUTPUT_FILE.write('\t%d'%(bioSeq[i][u])) OUTPUT_FILE.write('\n')
def net_state_transition(net, nodes_list, Nbr_States=2): ''' Arguments: 1. net 2. Nbr_States Return: 1. decStateTransMap ''' Nbr_Nodes = len(net.nodes()) Nbr_All_Initial_States = np.power(Nbr_States, Nbr_Nodes) decStateTransMap = nx.DiGraph() for prevDecState in range(Nbr_All_Initial_States): prevBiState = decimal_to_binary(nodes_list, prevDecState, Nbr_States) currBiState = ur.sigmoid_updating(net, prevBiState) currDecState = binary_to_decimal(nodes_list, currBiState, Nbr_States) decStateTransMap.add_edge(prevDecState, currDecState) return decStateTransMap