def recursive_pk(pk_core_dic, seq, array_traceback, array_traceback_positive): """ Function: recursive_pk() Purpose: Given core pseudoknot dictionary and secondary structure dictionaries, calculate set of recursive elements in the three loops with MWIS calculation. Input: Core pseudoknot dictionary and secondary structure dictionaries. Return: Recursive pseudoknot dictionary. """ for pk in pk_core_dic: result1, result2, result3 = [], [], [] loop1_start = pk[2] + pk[4] loop1_end = pk[5] - 1 l1 = loop1_end - loop1_start + 1 loop2_start = pk[5] + pk[7] loop2_end = pk[3] - pk[4] l2 = loop2_end - loop2_start + 1 loop3_start = pk[3] + 1 loop3_end = pk[6] - pk[7] l3 = loop3_end - loop3_start + 1 L1_key = loop1_start, loop1_end L2_key = loop2_start, loop2_end L3_key = loop3_start, loop3_end energy_l1, result1, effective_l1 = array_traceback[L1_key[0]][L1_key[1]] energy_l2, result2, effective_l2 = array_traceback[L2_key[0]][L2_key[1]] energy_l3, result3, effective_l3 = array_traceback[L3_key[0]][L3_key[1]] # Check for sterically infeasible configurations in loops L1 and L3 if l1 >= 9 and result1: energy_l1, result1, effective_l1 = functions.steric_constraints(result1, L1_key, array_traceback) if l3 >= 9 and result3: energy_l3, result3, effective_l3 = functions.steric_constraints(result3, L3_key, array_traceback) if not result1 and l1 >= 9: energy_l1, result1, effective_l1 = array_traceback_positive[L1_key[0]][L1_key[1]] if result1: energy_l1, result1, effective_l1 = functions.steric_constraints(result1, L1_key, array_traceback_positive) if not result2 and l2 >= 9: energy_l2, result2, effective_l2 = array_traceback_positive[L2_key[0]][L2_key[1]] if not result3 and l3 >= 9: energy_l3, result3, effective_l3 = array_traceback_positive[L3_key[0]][L3_key[1]] if result3: energy_l3, result3, effective_l3 = functions.steric_constraints(result3, L3_key, array_traceback_positive) pseudoknot_energy = pk_core_dic[pk] pk_core_dic[pk] = pseudoknot_energy, result1, result2, result3 return pk_core_dic
def recursive_pk(pk_core_dic, seq, array_traceback, array_traceback_positive): for pk in pk_core_dic: result1, result2, result3 = [], [], [] loop1_start = pk[2] + pk[4] loop1_end = pk[5] - 1 l1 = loop1_end - loop1_start + 1 loop2_start = pk[5] + pk[7] loop2_end = pk[3] - pk[4] l2 = loop2_end - loop2_start + 1 loop3_start = pk[3] + 1 loop3_end = pk[6] - pk[7] l3 = loop3_end - loop3_start + 1 L1_key = loop1_start, loop1_end L2_key = loop2_start, loop2_end L3_key = loop3_start, loop3_end energy_l1, result1, effective_l1 = array_traceback[L1_key[0]][L1_key[1]] energy_l2, result2, effective_l2 = array_traceback[L2_key[0]][L2_key[1]] energy_l3, result3, effective_l3 = array_traceback[L3_key[0]][L3_key[1]] # Check for sterically infeasible configurations in loops L1 and L3 if l1 >= 9 and result1: energy_l1, result1, effective_l1 = functions.steric_constraints(result1, L1_key, array_traceback) if l3 >= 9 and result3: energy_l3, result3, effective_l3 = functions.steric_constraints(result3, L3_key, array_traceback) if not result1 and l1 >= 9: energy_l1, result1, effective_l1 = array_traceback_positive[L1_key[0]][L1_key[1]] if result1: energy_l1, result1, effective_l1 = functions.steric_constraints( result1, L1_key, array_traceback_positive ) if not result2 and l2 >= 9: energy_l2, result2, effective_l2 = array_traceback_positive[L2_key[0]][L2_key[1]] if not result3 and l3 >= 9: energy_l3, result3, effective_l3 = array_traceback_positive[L3_key[0]][L3_key[1]] if result3: energy_l3, result3, effective_l3 = functions.steric_constraints( result3, L3_key, array_traceback_positive ) pseudoknot_energy = pk_core_dic[pk] pk_core_dic[pk] = pseudoknot_energy, result1, result2, result3 return pk_core_dic
def recursive_pk(pk_core_dic, seq, array_traceback, array_traceback_positive): for pk in pk_core_dic: result1, result2, result3 = [], [], [] loop1_start = pk[2] + pk[4] loop1_end = pk[5] - 1 l1 = loop1_end - loop1_start + 1 loop2_start = pk[5] + pk[7] loop2_end = pk[3] - pk[4] l2 = loop2_end - loop2_start + 1 loop3_start = pk[3] + 1 loop3_end = pk[6] - pk[7] l3 = loop3_end - loop3_start + 1 L1_key = loop1_start, loop1_end L2_key = loop2_start, loop2_end L3_key = loop3_start, loop3_end energy_l1, result1, effective_l1 = array_traceback[L1_key[0]][L1_key[1]] energy_l2, result2, effective_l2 = array_traceback[L2_key[0]][L2_key[1]] energy_l3, result3, effective_l3 = array_traceback[L3_key[0]][L3_key[1]] # Check for sterically infeasible configurations in loops L1 and L3 if l1 >= 9 and result1: energy_l1, result1, effective_l1 = functions.steric_constraints(result1, L1_key, array_traceback) if l3 >= 9 and result3: energy_l3, result3, effective_l3 = functions.steric_constraints(result3, L3_key, array_traceback) if not result1 and l1 >= 9: energy_l1, result1, effective_l1 = array_traceback_positive[L1_key[0]][L1_key[1]] if result1: energy_l1, result1, effective_l1 = functions.steric_constraints(result1, L1_key, array_traceback_positive) if not result2 and l2 >= 9: energy_l2, result2, effective_l2 = array_traceback_positive[L2_key[0]][L2_key[1]] if not result3 and l3 >= 9: energy_l3, result3, effective_l3 = array_traceback_positive[L3_key[0]][L3_key[1]] if result3: energy_l3, result3, effective_l3 = functions.steric_constraints(result3, L3_key, array_traceback_positive) pseudoknot_energy = pk_core_dic[pk] pk_core_dic[pk] = pseudoknot_energy, result1, result2, result3 return pk_core_dic
def recursive_pk(pk_dic_ib, array_traceback, array_traceback_positive): """ Function: recursive_pk() Purpose: Given core pseudoknot dictionary where one of the stems is interrupted and secondary structure dictionaries, calculate set of recursive elements in the three loops with MWIS calculation. Input: Core pseudoknot dictionary and secondary structure dictionaries. Return: Recursive pseudoknot dictionary. """ for pk, values_pk in pk_dic_ib.items(): result1, result2, result3 = [], [], [] l1, l2, l3 = values_pk[1], values_pk[2], values_pk[3] left, right = values_pk[5], values_pk[6] marker = pk[8] if marker == 'iS1': # First Case, combine s_ib with normal stem s # (((...((((.xxx...))))...)))........xxx loop1_start = pk[0] + left + 1 loop1_end = pk[5] - 1 loop2_start = pk[5] + pk[7] loop2_end = pk[0] + right - 1 loop3_start = pk[3] + 1 loop3_end = pk[6] - pk[7] if marker == 'iS2': # Second Case, combine normal stem s with s_ib # xxx........(((...((((.xxx...))))...))) loop1_start = pk[2] + pk[4] loop1_end = pk[5] - 1 loop2_start = pk[5] + left + 1 loop2_end = pk[3] - pk[4] loop3_start = pk[3] + 1 loop3_end = pk[5] + right - 1 L1_key = loop1_start, loop1_end L2_key = loop2_start, loop2_end L3_key = loop3_start, loop3_end energy_l1, result1, effective_l1 = array_traceback[L1_key[0]][ L1_key[1]] energy_l2, result2, effective_l2 = array_traceback[L2_key[0]][ L2_key[1]] energy_l3, result3, effective_l3 = array_traceback[L3_key[0]][ L3_key[1]] # Check for sterically infeasible configurations in loops L1 and L3 if l1 >= 9 and result1: energy_l1, result1, effective_l1 = functions.steric_constraints( result1, L1_key, array_traceback) if l3 >= 9 and result3: energy_l3, result3, effective_l3 = functions.steric_constraints( result3, L3_key, array_traceback) if not result1 and l1 >= 9: energy_l1, result1, effective_l1 = array_traceback_positive[ L1_key[0]][L1_key[1]] if result1: energy_l1, result1, effective_l1 = functions.steric_constraints( result1, L1_key, array_traceback_positive) if not result3 and l3 >= 9: energy_l3, result3, effective_l3 = array_traceback_positive[ L3_key[0]][L3_key[1]] if result3: energy_l3, result3, effective_l3 = functions.steric_constraints( result3, L3_key, array_traceback_positive) pseudoknot_energy = pk_dic_ib[pk] pk_dic_ib[pk] = pseudoknot_energy, result1, result2, result3 return pk_dic_ib
def recursive_pk(pk_core_dic, seq, array_traceback, array_traceback_positive): """ Function: recursive_pk() Purpose: Given core pseudoknot dictionary and secondary structure dictionaries, calculate set of recursive elements in the three loops with MWIS calculation. Input: Core pseudoknot dictionary and secondary structure dictionaries. Return: Recursive pseudoknot dictionary. """ for pk in pk_core_dic: result1, result2, result3 = [], [], [] loop1_start = pk[2] + pk[4] loop1_end = pk[5] - 1 l1 = loop1_end - loop1_start + 1 loop2_start = pk[5] + pk[7] loop2_end = pk[3] - pk[4] l2 = loop2_end - loop2_start + 1 loop3_start = pk[3] + 1 loop3_end = pk[6] - pk[7] l3 = loop3_end - loop3_start + 1 L1_key = loop1_start, loop1_end L2_key = loop2_start, loop2_end L3_key = loop3_start, loop3_end energy_l1, result1, effective_l1 = array_traceback[L1_key[0]][ L1_key[1]] energy_l2, result2, effective_l2 = array_traceback[L2_key[0]][ L2_key[1]] energy_l3, result3, effective_l3 = array_traceback[L3_key[0]][ L3_key[1]] # Check for sterically infeasible configurations in loops L1 and L3 if l1 >= 9 and result1: energy_l1, result1, effective_l1 = functions.steric_constraints( result1, L1_key, array_traceback) if l3 >= 9 and result3: energy_l3, result3, effective_l3 = functions.steric_constraints( result3, L3_key, array_traceback) if not result1 and l1 >= 9: energy_l1, result1, effective_l1 = array_traceback_positive[ L1_key[0]][L1_key[1]] if result1: energy_l1, result1, effective_l1 = functions.steric_constraints( result1, L1_key, array_traceback_positive) if not result2 and l2 >= 9: energy_l2, result2, effective_l2 = array_traceback_positive[ L2_key[0]][L2_key[1]] if not result3 and l3 >= 9: energy_l3, result3, effective_l3 = array_traceback_positive[ L3_key[0]][L3_key[1]] if result3: energy_l3, result3, effective_l3 = functions.steric_constraints( result3, L3_key, array_traceback_positive) pseudoknot_energy = pk_core_dic[pk] pk_core_dic[pk] = pseudoknot_energy, result1, result2, result3 return pk_core_dic
def recursive_pk(pk_dic_ib, array_traceback, array_traceback_positive): """ Function: recursive_pk() Purpose: Given core pseudoknot dictionary where one of the stems is interrupted and secondary structure dictionaries, calculate set of recursive elements in the three loops with MWIS calculation. Input: Core pseudoknot dictionary and secondary structure dictionaries. Return: Recursive pseudoknot dictionary. """ for pk, values_pk in pk_dic_ib.items(): result1, result2, result3 = [], [], [] l1, l2, l3 = values_pk[1], values_pk[2], values_pk[3] left, right = values_pk[5], values_pk[6] marker = pk[8] if marker == 'iS1': # First Case, combine s_ib with normal stem s # (((...((((.xxx...))))...)))........xxx loop1_start = pk[0] + left + 1 loop1_end = pk[5] - 1 loop2_start = pk[5] + pk[7] loop2_end = pk[0] + right - 1 loop3_start = pk[3] + 1 loop3_end = pk[6] - pk[7] if marker == 'iS2': # Second Case, combine normal stem s with s_ib # xxx........(((...((((.xxx...))))...))) loop1_start = pk[2] + pk[4] loop1_end = pk[5] - 1 loop2_start = pk[5] + left + 1 loop2_end = pk[3] - pk[4] loop3_start = pk[3] + 1 loop3_end = pk[5] + right -1 L1_key = loop1_start, loop1_end L2_key = loop2_start, loop2_end L3_key = loop3_start, loop3_end energy_l1, result1, effective_l1 = array_traceback[L1_key[0]][L1_key[1]] energy_l2, result2, effective_l2 = array_traceback[L2_key[0]][L2_key[1]] energy_l3, result3, effective_l3 = array_traceback[L3_key[0]][L3_key[1]] # Check for sterically infeasible configurations in loops L1 and L3 if l1 >= 9 and result1: energy_l1, result1, effective_l1 = functions.steric_constraints(result1, L1_key, array_traceback) if l3 >= 9 and result3: energy_l3, result3, effective_l3 = functions.steric_constraints(result3, L3_key, array_traceback) if not result1 and l1 >= 9: energy_l1, result1, effective_l1 = array_traceback_positive[L1_key[0]][L1_key[1]] if result1: energy_l1, result1, effective_l1 = functions.steric_constraints(result1, L1_key, array_traceback_positive) if not result3 and l3 >= 9: energy_l3, result3, effective_l3 = array_traceback_positive[L3_key[0]][L3_key[1]] if result3: energy_l3, result3, effective_l3 = functions.steric_constraints(result3, L3_key, array_traceback_positive) pseudoknot_energy = pk_dic_ib[pk] pk_dic_ib[pk] = pseudoknot_energy, result1, result2, result3 return pk_dic_ib