def test_bidirectional_reactions() -> None: rxncon_sys = Quick('''A_[x]_ppi_B_[y]; ! A_[(x)]-{p} C_p+_A_[(x)]''').rxncon_system # Forward direction contingencies = rxncon_sys.contingencies_for_reaction(reaction_from_str('A_[x]_ppi+_B_[y]')) assert len(contingencies) == 1 assert contingencies[0].effector.states == [state_from_str('A@0_[(x)]-{p}')] assert contingencies[0].contingency_type == ContingencyType.requirement # Reverse direction contingencies = rxncon_sys.contingencies_for_reaction(reaction_from_str('A_[x]_ppi-_B_[y]')) assert len(contingencies) == 0
def test_output_reactions() -> None: rxncon_sys = Quick("""A_p+_B_[(x)] [output]; ! B_[(x)]-{p}""").rxncon_system contingencies = rxncon_sys.contingencies_for_reaction(reaction_from_str('[output]')) assert len(contingencies) == 1 assert isinstance(contingencies[0].effector, StateEffector) assert [state_from_str('B@2_[(x)]-{p}')] == contingencies[0].effector.states
def test_non_elemental_contingency_single_state() -> None: rxncon_sys = Quick('''A_trsl_BmRNA C_p+_B_[(r1)] D_[x]_ppi_B_[y] ; ! B-{p}''').rxncon_system contingencies = rxncon_sys.contingencies_for_reaction(reaction_from_str('D_[x]_ppi+_B_[y]')) assert len(contingencies) == 1 print(contingencies[0].effector) assert contingencies[0].effector.name == 'B-{p}'
def test_single_contingency() -> None: rxncon_sys = Quick('''A_p+_B_[(r)]; ! A_[(x)]-{p} C_p+_A_[(x)]''').rxncon_system assert state_from_str('A_[(x)]-{0}') in rxncon_sys.consumed_states assert state_from_str('B_[(r)]-{0}') in rxncon_sys.consumed_states assert state_from_str('A_[(x)]-{p}') in rxncon_sys.produced_states assert state_from_str('B_[(r)]-{p}') in rxncon_sys.produced_states assert state_from_str('A_[(x)]-{0}') in rxncon_sys.states_for_component(spec_from_str('A')) assert state_from_str('B_[(r)]-{0}') in rxncon_sys.states_for_component(spec_from_str('B')) assert state_from_str('A_[(x)]-{p}') in rxncon_sys.states_for_component(spec_from_str('A')) assert state_from_str('B_[(r)]-{p}') in rxncon_sys.states_for_component(spec_from_str('B')) contingencies = rxncon_sys.contingencies_for_reaction(reaction_from_str('A_p+_B_[(r)]')) assert len(contingencies) == 1 assert contingencies[0].effector.states == [state_from_str('A@0_[(x)]-{p}')] assert contingencies[0].contingency_type == ContingencyType.requirement