def test_degradation_bond_to_homodimer() -> None: rxncon_sys = Quick("""A_[b]_ppi_B_[a] B_[b]_ppi_B_[b] C_deg_A; ! <x> <x>; AND A@1--B@2 <x>; AND B@2--B@3""").rxncon_system boolean_model = boolean_model_from_rxncon(rxncon_sys) assert boolean_model.reaction_target_by_name( 'C_deg_A').consumed_targets == [target_from_str('A_[b]--B_[a]')] assert boolean_model.reaction_target_by_name( 'C_deg_A').produced_targets == [target_from_str('B_[a]--0')]
def test_deg_with_boolean_NOT() -> None: boolean_model = boolean_model_from_rxncon( Quick("""A_[x]_ppi+_B_[y] D_p+_A_[(r)] C_deg_A; ! <x> <x>; AND A_[x]--B_[y]; AND <NOT> <NOT>; NOT A_[(r)]-{p}""" ).rxncon_system) target_to_factor = { rule.target: rule.factor for rule in boolean_model.update_rules } expected_rules = { 'C_deg_A': '( C & A_[x]--B_[y] & ~( A_[(r)]-{p} ) & ' '( A_[x]--0 | A_[x]--B_[y] ) & ( A_[(r)]-{0} | A_[(r)]-{p} ))', 'B_[y]--0': '(( A_[x]--B_[y] & C_deg_A & ( B_[y]--0 | A_[x]--B_[y] )) | ' '( B_[y]--0 & ( B_[y]--0 | A_[x]--B_[y] ) & ~(( B_[y]--0 & A_[x]_ppi+_B_[y] & A_[x]--0 ))))', 'A_[(r)]-{p}': '(( A_[(r)]-{0} & ~( C_deg_A ) & D_p+_A_[(r)] & ( A_[x]--0 | A_[x]--B_[y] ) & ( A_[(r)]-{0} | ' 'A_[(r)]-{p} )) | ( A_[(r)]-{p} & ( A_[x]--0 | A_[x]--B_[y] ) & ( A_[(r)]-{0} | A_[(r)]-{p} )))', } for target_str, factor_str in expected_rules.items(): assert target_to_factor[target_from_str(target_str)].is_equivalent_to( venn_from_str(factor_str, target_from_str))
def test_deg_with_inhibition() -> None: boolean_model = boolean_model_from_rxncon( Quick("""B_p+_A_[(res)] D_ub+_A_[(res)] D_p+_A_[(other)] C_deg_A; x A_[(res)]-{p}""" ).rxncon_system) assert len( boolean_model.reaction_target_by_name('C_deg_A').degraded_targets) == 2 assert target_from_str( 'A_[(res)]-{0}') in boolean_model.reaction_target_by_name( 'C_deg_A').degraded_targets assert target_from_str( 'A_[(res)]-{ub}') in boolean_model.reaction_target_by_name( 'C_deg_A').degraded_targets
def test_deg_with_contingency_on_subject() -> None: boolean_model = boolean_model_from_rxncon( Quick("""A_deg_B ; ! A-{p} C_p+_A""").rxncon_system) assert len(boolean_model.update_rules) == 6 found_B, found_C = False, False for update_rule in boolean_model.update_rules: if update_rule.target == target_from_str('B'): found_B = True assert update_rule.factor.is_equivalent_to( venn_from_str('B & ~( A_deg_B )', target_from_str)) elif update_rule.target == target_from_str('C'): found_C = True assert update_rule.factor.is_equivalent_to( venn_from_str('C', target_from_str)) assert found_B and found_C
def test_deg_with_boolean_OR() -> None: """The C_deg_A reaction will be split into two ReactionTargets, one degrading A_[(r1)]-{p}, the other degrading A_[(r2)]-{p}. This choice which variant degrades which A is not deterministic, so the test splits into two branches here.""" boolean_model = boolean_model_from_rxncon( Quick("""B_p+_A_[(r1)] D_p+_A_[(r2)] C_deg_A; ! <X> <X>; OR A_[(r1)]-{p} <X>; OR A_[(r2)]-{p}""" ).rxncon_system) A = '(( A_[(r1)]-{0} | A_[(r1)]-{p} ) & ( A_[(r2)]-{0} | A_[(r2)]-{p} ))' target_to_factor = { rule.target: rule.factor for rule in boolean_model.update_rules } # C_deg_A#c0 degrades A_[(r1)]-{p}, C_deg_A#c1 degrades A_[(r2)]-{p} if target_to_factor[target_from_str('C_deg_A#c0')].is_equivalent_to( venn_from_str('( {} & C & A_[(r1)]-{{p}} )'.format(A), target_from_str)): expected_rules = { 'C_deg_A#c0': '( {} & C & A_[(r1)]-{{p}} )'.format(A), 'C_deg_A#c1': '( {} & C & A_[(r2)]-{{p}} )'.format(A), 'A_[(r1)]-{p}': '( {} & ~( C_deg_A#c0 ) & ( A_[(r1)]-{{p}} | ( B_p+_A_[(r1)] & A_[(r1)]-{{0}} )))' .format(A), 'A_[(r2)]-{p}': '( {} & ~( C_deg_A#c1 ) & ( A_[(r2)]-{{p}} | ( D_p+_A_[(r2)] & A_[(r2)]-{{0}} )))' .format(A), 'B': 'B', 'C': 'C', 'D': 'D' } for target_str, factor_str in expected_rules.items(): assert target_to_factor[target_from_str( target_str)].is_equivalent_to( venn_from_str(factor_str, target_from_str)) # C_deg_A#c0 degrades A_[(r2)]-{p}, C_deg_A#c1 degrades A_[(r1)]-{p} elif target_to_factor[target_from_str('C_deg_A#c0')].is_equivalent_to( venn_from_str('( {} & C & A_[(r2)]-{{p}} )'.format(A), target_from_str)): expected_rules = { 'C_deg_A#c0': '( {} & C & A_[(r2)]-{{p}} )'.format(A), 'C_deg_A#c1': '( {} & C & A_[(r1)]-{{p}} )'.format(A), 'A_[(r1)]-{p}': '( {} & ~( C_deg_A#c1 ) & ( A_[(r1)]-{{p}} | ( B_p+_A_[(r1)] & A_[(r1)]-{{0}} )))' .format(A), 'A_[(r2)]-{p}': '( {} & ~( C_deg_A#c0 ) & ( A_[(r2)]-{{p}} | ( D_p+_A_[(r2)] & A_[(r2)]-{{0}} )))' .format(A), 'B': 'B', 'C': 'C', 'D': 'D' } for target_str, factor_str in expected_rules.items(): assert target_to_factor[target_from_str( target_str)].is_equivalent_to( venn_from_str(factor_str, target_from_str)) else: raise AssertionError