def test_matching_input_output() -> None: boolean_model = boolean_model_from_rxncon( Quick("""A_p+_B_[(a)]; ! [global] [global]; ! B_[(a)]-{p}""" ).rxncon_system) # Component expressions. A = 'A' B = '( B_[(a)]-{0} | B_[(a)]-{p} )' expected_rules = { 'A_p+_B_[(a)]': '{0} & {1} & [global]'.format(A, B), '[global]': 'B_[(a)]-{p}' } rules_found = 0 for update_rule in boolean_model.update_rules: if str(update_rule.target) == 'A_p+_B_[(a)]': assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str)) rules_found += 1 elif str(update_rule.target) == '[global]': assert isinstance(update_rule.target, StateTarget) assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str)) rules_found += 1 assert rules_found == 2
def test_dnf_form() -> None: assert venn_from_str('1 & 2', int).to_dnf_set().is_equivalent_to( venn_from_str('1 & 2', int)) assert venn_from_str('1 | 2', int).to_dnf_set().is_equivalent_to( venn_from_str('1 | 2', int)) assert UniversalSet().to_dnf_set().is_equivalent_to(UniversalSet()) assert EmptySet().to_dnf_set().is_equivalent_to(EmptySet())
def test_degradation_input_required_no_output() -> None: rxncon_sys = Quick("""Decay_DEG_Ndd1mRNA; ! [Ndd1UB]""").rxncon_system boolean_model = boolean_model_from_rxncon(rxncon_sys) # Component expressions. Ndd1mRNA = 'Ndd1mRNA' Decay = 'Decay' expected_rules = { 'Decay_deg_Ndd1mRNA': '{0} & {1} & [Ndd1UB]'.format(Ndd1mRNA, Decay), '[Ndd1UB]': '[Ndd1UB]', } rules_found = 0 for update_rule in boolean_model.update_rules: if str(update_rule.target) == 'Decay_deg_Ndd1mRNA': assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str)) rules_found += 1 elif str(update_rule.target) == '[Ndd1UB]': assert isinstance(update_rule.target, StateTarget) assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str)) rules_found += 1 assert rules_found == 2
def test_calc_solutions() -> None: # Contradiction should give no solutions. assert venn_from_str('( a ) & ~( a )', str).calc_solutions() == [] # Tautology should give empty dict as solution. assert venn_from_str('( a ) | ~( a )', str).calc_solutions() == [{}] assert {'a': True, 'b': False} in venn_from_str('a | ~( b )', str).calc_solutions() assert {'a': True, 'b': True} in venn_from_str('a | ~( b )', str).calc_solutions() assert {'a': False, 'b': False} in venn_from_str('a | ~( b )', str).calc_solutions()
def test_parser() -> None: assert venn_from_str('1 & 2', int).is_equivalent_to( Intersection(ValueSet(1), ValueSet(2))) assert venn_from_str('1 & 2', str).is_equivalent_to( Intersection(ValueSet('1'), ValueSet('2'))) assert venn_from_str('( 1 | 2 ) & 3', int).is_equivalent_to( Intersection(ValueSet(3), Union(ValueSet(1), ValueSet(2)))) assert venn_from_str('~ 1', int).is_equivalent_to(Complement(ValueSet(1))) assert venn_from_str('~( 1 | 2 )', int).is_equivalent_to( Intersection(Complement(ValueSet(1)), Complement(ValueSet(2))))
def test_matching_non_matching_input_one_output() -> None: """ Testing if output reactions with one matching and one non matching input states. Returns: None Raises: Assertion error if the update rules are not as expected. """ boolean_model = boolean_model_from_rxncon( Quick("""A_p+_B_[(a)]; ! [global] A_p+_B_[(a1)]; ! [global_diff] [global]; ! B_[(a)]-{p}""" ).rxncon_system) # Component expressions. A = 'A' B = '( B_[(a)]-{0} | B_[(a)]-{p} ) & ( B_[(a1)]-{0} | B_[(a1)]-{p} )' expected_rules = { 'A_p+_B_[(a)]': '{0} & {1} & [global]'.format(A, B), 'A_p+_B_[(a1)]': '{0} & {1} & [global_diff]'.format(A, B), '[global]': 'B_[(a)]-{p}', '[global_diff]': '[global_diff]' } rules_found = 0 for update_rule in boolean_model.update_rules: if str(update_rule.target) == 'A_p+_B_[(a)]': assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str)) rules_found += 1 elif str(update_rule.target) == 'A_p+_B_[(a1)]': assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str)) rules_found += 1 elif str(update_rule.target) == '[global]': assert isinstance(update_rule.target, StateTarget) assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str)) rules_found += 1 elif str(update_rule.target) == '[global_diff]': assert isinstance(update_rule.target, StateTarget) assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str)) rules_found += 1 assert rules_found == 4
def test_nested_list_form() -> None: assert venn_from_str('1', int).to_dnf_nested_list() == [[venn_from_str('1', int)]] x = venn_from_str('1 & ( 2 | 3 )', int) assert [ValueSet(1), ValueSet(2)] in x.to_dnf_nested_list() assert [ValueSet(1), ValueSet(3)] in x.to_dnf_nested_list() assert venn_from_str('1 & 2', int).to_dnf_nested_list() == [[ValueSet(1), ValueSet(2)]] assert venn_from_str('1 | 2', int).to_dnf_nested_list() == [[ValueSet(1)], [ValueSet(2)]] assert UniversalSet().to_dnf_nested_list() == [[UniversalSet()]] assert EmptySet().to_dnf_nested_list() == [[EmptySet()]]
def test_deg_with_boolean_NOT() -> None: """ Testing degradation with NOT Boolean. Returns: None Raises: AssertionError if a rule is not equivalent to an expected rule. """ 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} & 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_smooth_production_sources() -> None: """ Testing smoothing function. Note: Only the update rule for A_[b]--0 is tested. Returns: None Raises: AssertionError: If update rule for A_[b]--0 is not as expected. """ boolean_model = boolean_model_from_rxncon( Quick("""A_[b]_ppi+_B_[a]; ! A_[(r)]-{p} A_[b]_ppi-_B_[a] C_p+_A_[(r)] D_p-_A_[(r)]"""). rxncon_system, SmoothingStrategy.smooth_production_sources) expected = '(( A_[(r)]-{p} | A_[(r)]-{0} ) & ( A_[b]--0 | A_[b]--B_[a] )) & ' \ '( A_[b]_ppi-_B_[a] & ( A_[b]--B_[a] | ( A_[b]_ppi+_B_[a] & A_[b]--0 & B_[a]--0 )) | ' \ '( A_[b]--0 & ~( A_[b]_ppi+_B_[a] & A_[b]--0 & B_[a]--0 )))' for rule in boolean_model.update_rules: if rule.target == target_from_str('A_[b]--0'): assert rule.factor.is_equivalent_to( venn_from_str(expected, target_from_str))
def test_deg_with_interaction() -> None: boolean_model = boolean_model_from_rxncon( Quick("""A_[x]_ppi+_B_[y] D_p+_A_[(r)] C_deg_A"""). rxncon_system) target_to_factor = { rule.target: rule.factor for rule in boolean_model.update_rules } A = '( ( A_[x]--B_[y] | A_[x]--0 ) & ( A_[(r)]-{p} | A_[(r)]-{0} ) )' expected_rules = { 'A_[x]--0': '( A_[x]--0 & ( A_[x]--B_[y] | A_[x]--0 ) & ( A_[(r)]-{p} | A_[(r)]-{0} ) & ' '~(( A_[x]_ppi+_B_[y] & A_[x]--0 & B_[y]--0 )) & ~( C_deg_A ))', 'B_[y]--0': '(( C_deg_A & A_[x]--B_[y] & ( B_[y]--0 | A_[x]--B_[y] )) | ( B_[y]--0 & ' '( B_[y]--0 | A_[x]--B_[y] ) & ~(( A_[x]--0 & B_[y]--0 & A_[x]_ppi+_B_[y] & ~( C_deg_A )))))', 'A_[x]--B_[y]': '{} & ~( C_deg_A ) & (( A_[x]_ppi+_B_[y] & A_[x]--0 & B_[y]--0 ) | ' '( A_[x]--B_[y] & ~( C_deg_A & A_[x]--B_[y] ) ) )'.format(A) } 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_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_of_component_without_states() -> None: """ Testing degradation of component without states. Returns: None Raises: AssertionError if the expected rule is not e """ boolean_model = boolean_model_from_rxncon( Quick("""C_deg_A""").rxncon_system) target_to_factor = { rule.target: rule.factor for rule in boolean_model.update_rules } expected_rules = { 'C_deg_A': '( C & A )', 'A': '( A & ~( C_deg_A ))', 'C': 'C' } 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_trsl_trsc_deg() -> None: boolean_model = boolean_model_from_rxncon( Quick("""PolII_trsc_TargetGene Ribo_trsl_TargetmRNA Nuclease_deg_TargetmRNA Protease_deg_Target"""). rxncon_system) expected_rules = { 'PolII_trsc_TargetGene': '( PolII & TargetGene )', 'Ribo_trsl_TargetmRNA': '( Ribo & TargetmRNA )', 'Nuclease_deg_TargetmRNA': '( Nuclease & TargetmRNA )', 'Protease_deg_Target': '( Protease & Target )', 'PolII': '( PolII )', 'TargetGene': '( TargetGene )', 'Ribo': '( Ribo )', 'TargetmRNA': '( PolII_trsc_TargetGene | ( TargetmRNA & ~( Nuclease_deg_TargetmRNA )))', 'Nuclease': '( Nuclease )', 'Protease': '( Protease )', 'Target': '( Ribo_trsl_TargetmRNA | ( Target & ~( Protease_deg_Target )))' } assert len(boolean_model.update_rules) == len(expected_rules) for update_rule in boolean_model.update_rules: assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str))
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 == 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 == venn_from_str('C', target_from_str) assert found_B and found_C
def test_list_form() -> None: assert venn_from_str('1', int).to_dnf_list() == [venn_from_str('1', int)] assert venn_from_str('1 & 2', int).to_dnf_list() == [venn_from_str('1 & 2', int)] assert set(venn_from_str('1 | 2', int).to_dnf_list()) == {ValueSet(1), ValueSet(2)} x = venn_from_str('1 & ( 2 | 3 )', int) assert any(elem.is_equivalent_to(venn_from_str('1 & 2', int)) for elem in x.to_dnf_list()) assert any(elem.is_equivalent_to(venn_from_str('1 & 3', int)) for elem in x.to_dnf_list()) assert UniversalSet().to_dnf_list() == [UniversalSet()] assert EmptySet().to_dnf_list() == [EmptySet()]
def test_eval_boolean_func_AND() -> None: f = venn_from_str('1 & 2', int) assert f.eval_boolean_func({1: True, 2: True}) is True assert f.eval_boolean_func({1: True, 2: False}) is False assert f.eval_boolean_func({1: False, 2: True}) is False assert f.eval_boolean_func({1: False, 2: False}) is False with pytest.raises(AssertionError): f.eval_boolean_func({1: True}) with pytest.raises(AssertionError): f.eval_boolean_func({1: True, 3: False})
def test_simple_system_with_input_state() -> None: boolean_model = boolean_model_from_rxncon( Quick("""A_[b]_ppi+_B_[a]; ! A_[(r)]-{p} ; ! [BLAAT] A_[b]_ppi-_B_[a] C_p+_A_[(r)] D_p-_A_[(r)]"""). rxncon_system) # Component expressions. A = '(( A_[b]--0 | A_[b]--B_[a] ) & ( A_[(r)]-{0} | A_[(r)]-{p} ))' B = '( B_[a]--0 | A_[b]--B_[a] )' C = 'C' D = 'D' expected_rules = { 'A_[b]_ppi+_B_[a]': '{0} & {1} & A_[(r)]-{{p}} & [BLAAT]'.format(A, B), 'A_[b]_ppi-_B_[a]': '{0} & {1}'.format(A, B), 'C_p+_A_[(r)]': '{0} & {1}'.format(A, C), 'D_p-_A_[(r)]': '{0} & {1}'.format(A, D), 'A_[(r)]-{p}': '{0} & (( C_p+_A_[(r)] & A_[(r)]-{{0}} ) | ' '( A_[(r)]-{{p}} & ~( D_p-_A_[(r)] & A_[(r)]-{{p}} )))'.format(A), 'A_[(r)]-{0}': '{0} & (( D_p-_A_[(r)] & A_[(r)]-{{p}} ) | ' '( A_[(r)]-{{0}} & ~( C_p+_A_[(r)] & A_[(r)]-{{0}} )))'.format(A), 'A_[b]--0': '{0} & (( A_[b]_ppi-_B_[a] & A_[b]--B_[a] ) | ' '( A_[b]--0 & ~( A_[b]_ppi+_B_[a] & A_[b]--0 & B_[a]--0 )))'.format(A), 'A_[b]--B_[a]': '{0} & {1} & (( A_[b]_ppi+_B_[a] & A_[b]--0 & B_[a]--0 ) | ' '( A_[b]--B_[a] & ~( A_[b]_ppi-_B_[a] & A_[b]--B_[a] )))'.format(A, B), 'B_[a]--0': '{0} & (( A_[b]_ppi-_B_[a] & A_[b]--B_[a] ) | ' '( B_[a]--0 & ~( A_[b]_ppi+_B_[a] & A_[b]--0 & B_[a]--0 )))'.format(B), 'C': '{0}'.format(C), 'D': '{0}'.format(D), '[BLAAT]': '[BLAAT]' } assert len(boolean_model.update_rules) == len(expected_rules) for update_rule in boolean_model.update_rules: assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str))
def test_nary_sets_constructor() -> None: assert Union() == EmptySet() assert Intersection() == UniversalSet() assert DisjunctiveUnion() == EmptySet() assert Union(venn_from_str('1', int)).is_equivalent_to(venn_from_str('1', int)) assert Intersection(venn_from_str('1', int)).is_equivalent_to(venn_from_str('1', int)) assert DisjunctiveUnion(venn_from_str('1', int)).is_equivalent_to(venn_from_str('1', int))
def test_degradation_boolean_AND_required_input_state() -> None: rxncon_sys = Quick("""APC_Ub+_Ndd1 Decay_DEG_Ndd1; ! <bool> <bool>; AND [Ndd1UB] <bool>; AND Ndd1-{ub}""").rxncon_system boolean_model = boolean_model_from_rxncon(rxncon_sys) # Component expressions. Ndd1 = '( Ndd1_[(APC)]-{0} | Ndd1_[(APC)]-{ub} )' Decay = 'Decay' expected_rules = { 'Decay_deg_Ndd1': '{0} & {1} & Ndd1_[(APC)]-{{ub}} & [Ndd1UB]'.format(Ndd1, Decay), 'Ndd1_[(APC)]-{0}': 'Ndd1_[(APC)]-{{0}} & ~( Ndd1_[(APC)]-{{0}} & APC_Ub+_Ndd1 )'.format( Ndd1), 'Ndd1_[(APC)]-{ub}': '( Ndd1_[(APC)]-{{0}} & APC_Ub+_Ndd1 ) & ~( Decay_deg_Ndd1 ) & {0} | ' 'Ndd1_[(APC)]-{{ub}} & {0} & ~( Decay_deg_Ndd1 )'.format(Ndd1), '[Ndd1UB]': '[Ndd1UB]', } rules_found = 0 for update_rule in boolean_model.update_rules: if str(update_rule.target) == 'Decay_deg_Ndd1': assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str)) rules_found += 1 elif str(update_rule.target) == '[Ndd1UB]': assert isinstance(update_rule.target, StateTarget) assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str)) rules_found += 1 assert rules_found == 2
def test_deg_with_requirement() -> None: boolean_model = boolean_model_from_rxncon( Quick("""B_p+_A_[(res)] D_ub+_A_[(res)] D_p+_A_[(other)] C_deg_A; ! A_[(res)]-{p}""" ).rxncon_system) # Component expression. A = '(( A_[(res)]-{0} | A_[(res)]-{p} | A_[(res)]-{ub} ) & ( A_[(other)]-{0} | A_[(other)]-{p} ))' expected_rules = { 'B_p+_A_[(res)]': '( B & {} )'.format(A), 'D_ub+_A_[(res)]': '( D & {} )'.format(A), 'D_p+_A_[(other)]': '( D & {} )'.format(A), 'C_deg_A': '( C & {} & A_[(res)]-{{p}} )'.format(A), 'A_[(res)]-{0}': '( {} & A_[(res)]-{{0}} & ~( B_p+_A_[(res)] & A_[(res)]-{{0}} ) & ~( D_ub+_A_[(res)] & A_[(res)]-{{0}} ))' .format(A), 'A_[(res)]-{p}': '( {} & ~( C_deg_A ) & (( B_p+_A_[(res)] & A_[(res)]-{{0}} ) | A_[(res)]-{{p}} ))' .format(A), 'A_[(res)]-{ub}': '( {} & (( D_ub+_A_[(res)] & A_[(res)]-{{0}} ) | A_[(res)]-{{ub}} ))'. format(A), 'A_[(other)]-{0}': '( {} & A_[(other)]-{{0}} & ~( D_p+_A_[(other)] & A_[(other)]-{{0}} ))' .format(A), 'A_[(other)]-{p}': '( {} & (( D_p+_A_[(other)] & A_[(other)]-{{0}} ) | A_[(other)]-{{p}} ))' .format(A), 'B': 'B', 'C': 'C', 'D': 'D' } assert len(boolean_model.update_rules) == len(expected_rules) for update_rule in boolean_model.update_rules: assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str))
def test_smooth_production_sources() -> None: """Testing Boolean model generation with smoothing function.""" boolean_model = boolean_model_from_rxncon( Quick("""A_[b]_ppi+_B_[a]; ! A_[(r)]-{p} A_[b]_ppi-_B_[a] C_p+_A_[(r)] D_p-_A_[(r)]"""). rxncon_system, SmoothingStrategy.smooth_production_sources) expected = '(( A_[(r)]-{p} | A_[(r)]-{0} ) & ( A_[b]--0 | A_[b]--B_[a] )) & ' \ '( A_[b]_ppi-_B_[a] & ( A_[b]--B_[a] | ( A_[b]_ppi+_B_[a] & A_[b]--0 & B_[a]--0 )) | ' \ '( A_[b]--0 & ~( A_[b]_ppi+_B_[a] & A_[b]--0 & B_[a]--0 )))' for rule in boolean_model.update_rules: if rule.target == target_from_str('A_[b]--0'): assert rule.factor.is_equivalent_to( venn_from_str(expected, target_from_str))
def test_deg_of_component_without_states() -> None: boolean_model = boolean_model_from_rxncon( Quick("""C_deg_A""").rxncon_system) target_to_factor = { rule.target: rule.factor for rule in boolean_model.update_rules } expected_rules = { 'C_deg_A': '( C & A )', 'A': '( A & ~( C_deg_A ))', 'C': 'C' } 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_nested_OR_NOT_boolean() -> None: cles = [ cle_from_str('<C1>', 'AND', 'A_[x]--B_[y]'), cle_from_str('<C1>', 'AND', 'A_[(r)]-{p}'), cle_from_str('<C2>', 'NOT', 'B_[(r1)]-{p}'), cle_from_str('<C1C2>', 'OR', '<C1>'), cle_from_str('<C1C2>', 'OR', '<C2>'), cle_from_str('A_[q]_ppi+_Q_[a]', '!', '<C1C2>') ] contingencies = contingencies_from_contingency_list_entries(cles) assert len(contingencies) == 1 expected = venn_from_str( '( ( A_[x]--B_[y] & A_[(r)]-{p} ) | ~( B_[(r1)]-{p} ) )', state_from_str) assert venn_from_effector( contingencies[0].effector).is_equivalent_to(expected)
def test_trsl_trsc_deg() -> None: """ Testing translation, transcription and degradation reactions. Note: The system of 4 reactions is translated into 11 rules. Returns: None Raises: AssertionError: If the number of rules differ from the expected number or if the factor of a rule is not equivalent to the expectation an error is thrown. """ boolean_model = boolean_model_from_rxncon( Quick("""PolII_trsc_TargetGene Ribo_trsl_TargetmRNA Nuclease_deg_TargetmRNA Protease_deg_Target"""). rxncon_system) expected_rules = { 'PolII_trsc_TargetGene': '( PolII & TargetGene )', 'Ribo_trsl_TargetmRNA': '( Ribo & TargetmRNA )', 'Nuclease_deg_TargetmRNA': '( Nuclease & TargetmRNA )', 'Protease_deg_Target': '( Protease & Target )', 'PolII': '( PolII )', 'TargetGene': '( TargetGene )', 'Ribo': '( Ribo )', 'TargetmRNA': '( PolII_trsc_TargetGene | ( TargetmRNA & ~( Nuclease_deg_TargetmRNA )))', 'Nuclease': '( Nuclease )', 'Protease': '( Protease )', 'Target': '( Ribo_trsl_TargetmRNA | ( Target & ~( Protease_deg_Target )))' } assert len(boolean_model.update_rules) == len(expected_rules) for update_rule in boolean_model.update_rules: assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str))
def test_deg_with_interaction() -> None: """ Testing degradation of interaction reaction. Note: A system of 2 reactions is translated to 7 rules. We have a variation of C_deg_A, because if we have the interaction state A_[x]--B_[y], B_[y]--0 can be produced otherwise not. Returns: None Raises: AssertionError if a rule is not equivalent to an expected rule. """ boolean_model = boolean_model_from_rxncon( Quick("""A_[x]_ppi+_B_[y] D_p+_A_[(r)] C_deg_A"""). rxncon_system) target_to_factor = { rule.target: rule.factor for rule in boolean_model.update_rules } A = '( ( A_[x]--B_[y] | A_[x]--0 ) & ( A_[(r)]-{p} | A_[(r)]-{0} ) )' expected_rules = { 'A_[x]--0': '( A_[x]--0 & ( A_[x]--B_[y] | A_[x]--0 ) & ( A_[(r)]-{p} | A_[(r)]-{0} ) & ~(( A_[x]_ppi+_B_[y] & A_[x]--0 & B_[y]--0 )) & ~( C_deg_A ))', 'B_[y]--0': '(( C_deg_A & A_[x]--B_[y] & ( B_[y]--0 | A_[x]--B_[y] )) | ( B_[y]--0 & ( B_[y]--0 | A_[x]--B_[y] ) & ~(( A_[x]--0 & B_[y]--0 & A_[x]_ppi+_B_[y] ))))', 'A_[x]--B_[y]': '{} & ~( C_deg_A ) & (( A_[x]_ppi+_B_[y] & A_[x]--0 & B_[y]--0 ) | ( A_[x]--B_[y] & ~( C_deg_A & A_[x]--B_[y] ) ) )' .format(A) } 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_values() -> None: assert set(venn_from_str('1 | 2 | 3 | 4 | 2', int).values) == {1, 2, 3, 4}
def test_simple_system() -> None: """ Testing a system of 4 reactions and 1 contingency. Note: The system contains 11 rules. Returns: None Raises: AssertionError: If the number of rules differ from the expected number or if the factor of a rule is not equivalent to the expectation an error is thrown. """ boolean_model = boolean_model_from_rxncon( Quick("""A_[b]_ppi+_B_[a]; ! A_[(r)]-{p} A_[b]_ppi-_B_[a] C_p+_A_[(r)] D_p-_A_[(r)]"""). rxncon_system) # Component expressions. A = '(( A_[b]--0 | A_[b]--B_[a] ) & ( A_[(r)]-{0} | A_[(r)]-{p} ))' B = '( B_[a]--0 | A_[b]--B_[a] )' C = 'C' D = 'D' expected_rules = { 'A_[b]_ppi+_B_[a]': '{0} & {1} & A_[(r)]-{{p}}'.format(A, B), 'A_[b]_ppi-_B_[a]': '{0} & {1}'.format(A, B), 'C_p+_A_[(r)]': '{0} & {1}'.format(A, C), 'D_p-_A_[(r)]': '{0} & {1}'.format(A, D), 'A_[(r)]-{p}': '{0} & (( C_p+_A_[(r)] & A_[(r)]-{{0}} ) | ( A_[(r)]-{{p}} & ~( D_p-_A_[(r)] & A_[(r)]-{{p}} )))' .format(A), 'A_[(r)]-{0}': '{0} & (( D_p-_A_[(r)] & A_[(r)]-{{p}} ) | ( A_[(r)]-{{0}} & ~( C_p+_A_[(r)] & A_[(r)]-{{0}} )))' .format(A), 'A_[b]--0': '{0} & (( A_[b]_ppi-_B_[a] & A_[b]--B_[a] ) | ( A_[b]--0 & ~( A_[b]_ppi+_B_[a] & A_[b]--0 & B_[a]--0 )))' .format(A), 'A_[b]--B_[a]': '{0} & {1} & (( A_[b]_ppi+_B_[a] & A_[b]--0 & B_[a]--0 ) | ( A_[b]--B_[a] & ~( A_[b]_ppi-_B_[a] & A_[b]--B_[a] )))' .format(A, B), 'B_[a]--0': '{0} & (( A_[b]_ppi-_B_[a] & A_[b]--B_[a] ) | ( B_[a]--0 & ~( A_[b]_ppi+_B_[a] & A_[b]--0 & B_[a]--0 )))' .format(B), 'C': '{0}'.format(C), 'D': '{0}'.format(D), } assert len(boolean_model.update_rules) == len(expected_rules) for update_rule in boolean_model.update_rules: assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str))
def test_deg_with_boolean_OR() -> None: """ Testing a degradation reaction with boolean contingencies. Note: A system of 3 reactions and one boolean contingency is translated into 7 rules. 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. Returns: None: Raises: AssertionError: If the factor is not equivalent to one of the variations of the degradation reaction and if the factor of a rule is not equivalent to the expectation an error is thrown. """ 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
def test_deg_without_contingency() -> None: """ Testing a degradation reaction without contingencies. Note: A system of 4 reactions is translated into 12 rules. Returns: None Raises: AssertionError: If the number of rules differ from the expected number or if the factor of a rule is not equivalent to the expectation an error is thrown. """ boolean_model = boolean_model_from_rxncon( Quick("""B_p+_A_[(res)] D_ub+_A_[(res)] D_p+_A_[(other)] C_deg_A"""). rxncon_system) # Component expression. A = '(( A_[(res)]-{0} | A_[(res)]-{p} | A_[(res)]-{ub} ) & ( A_[(other)]-{0} | A_[(other)]-{p} ))' expected_rules = { 'B_p+_A_[(res)]': '( B & {} )'.format(A), 'D_ub+_A_[(res)]': '( D & {} )'.format(A), 'D_p+_A_[(other)]': '( D & {} )'.format(A), 'C_deg_A': '( C & {} )'.format(A), 'A_[(res)]-{0}': '( {} & ~( C_deg_A ) & A_[(res)]-{{0}} & ~( B_p+_A_[(res)] & A_[(res)]-{{0}} ) & ~( D_ub+_A_[(res)] & A_[(res)]-{{0}} ))' .format(A), 'A_[(res)]-{p}': '( {} & ~( C_deg_A ) & (( B_p+_A_[(res)] & A_[(res)]-{{0}} ) | A_[(res)]-{{p}} ))' .format(A), 'A_[(res)]-{ub}': '( {} & ~( C_deg_A ) & (( D_ub+_A_[(res)] & A_[(res)]-{{0}} ) | A_[(res)]-{{ub}} ))' .format(A), 'A_[(other)]-{0}': '( {} & ~( C_deg_A ) & A_[(other)]-{{0}} & ~( D_p+_A_[(other)] & A_[(other)]-{{0}} ))' .format(A), 'A_[(other)]-{p}': '( {} & ~( C_deg_A ) & (( D_p+_A_[(other)] & A_[(other)]-{{0}} ) | A_[(other)]-{{p}} ))' .format(A), 'B': 'B', 'C': 'C', 'D': 'D' } assert len(boolean_model.update_rules) == len(expected_rules) for update_rule in boolean_model.update_rules: assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str))
def test_insulin_no_smoothing() -> None: boolean_model = boolean_model_from_rxncon( Quick("""IR_[IRBD]_ppi+_IR_[IRBD] IR_[IRBD]_ppi-_IR_[IRBD] IR_[lig]_i+_insulin_[IR]; ! <IR-empty> IR_[lig]_i-_insulin_[IR] IR_p+_IR_[TK(Y1158)]; ! <IR0-IR1-Insulin2> IR_p+_IR_[TK(Y1162)]; ! <IR0-IR1-Insulin2> IR_p+_IR_[TK(Y1163)]; ! <IR0-IR1-Insulin2> IR_ap+_IR_[JM(Y972)]; ! <IR-IR-active> IR_[JMY972]_ppi+_IRS_[PTB]; ! IR_[JM(Y972)]-{P}; ! IRS_[PH]--Phospholipids_[IRS] IR_[JMY972]_ppi-_IRS_[PTB] IRS_[PH]_i+_Phospholipids_[IRS] IRS_[PH]_i-_Phospholipids_[IRS] IR_p+_IRS_[(Y)]; ! IR_[JMY972]--IRS_[PTB]; ! <IR-active> Grb2_[SOS]_ppi+_SOS_[Grb2] Grb2_[SOS]_ppi-_SOS_[Grb2] Grb2_[SH2]_ppi+_IRS_[Y]; ! IRS_[(Y)]-{P} Grb2_[SH2]_ppi-_IRS_[Y] IR_[JMY972]_ppi+_Shc_[PTB]; ! IR_[JM(Y972)]-{P} IR_[JMY972]_ppi-_Shc_[PTB] IR_p+_Shc_[(YY239240)]; ! IR_[JMY972]--Shc_[PTB]; ! <IR-active> IR_p+_Shc_[(Y317)]; ! IR_[JMY972]--Shc_[PTB]; ! <IR-active> Grb2_[SH2]_ppi+_Shc_[YY]; ! Shc_[(YY239240)]-{P} Grb2_[SH2]_ppi-_Shc_[YY] Grb2_[SH2]_ppi+_Shc_[Y]; ! Shc_[(Y317)]-{P} Grb2_[SH2]_ppi-_Shc_[Y] IRS_[Y]_ppi+_PI3K_[SH2]; ! IRS_[(Y)]-{P} IRS_[Y]_ppi-_PI3K_[SH2] <IR-empty>; AND IR@0_[IRBD]--IR@2_[IRBD]; AND IR@0_[lig]--0; AND IR@2_[lig]--0 <IR-IR-active>; AND <IR-phos>; AND <IR0-IR1-Insulin2> <IR-phos>; AND IR_[TK(Y1158)]-{P}; AND IR_[TK(Y1162)]-{P}; AND IR_[TK(Y1163)]-{P} <IR0-IR1-Insulin2>; OR <IR0-insulin2>; OR <IR1-insulin2> <IR0-insulin2>; AND IR@0_[IRBD]--IR@1_[IRBD]; AND IR@0_[lig]--insulin@2_[IR] <IR1-insulin2>; AND IR@0_[IRBD]--IR@1_[IRBD]; AND IR@1_[lig]--insulin@2_[IR] <IR-active>; AND <IR-phos>; AND <IR0-IR2-Insulin3> <IR0-IR2-Insulin3>; OR <IR0-insulin3>; OR <IR2-insulin3> <IR0-insulin3>; AND IR@0_[IRBD]--IR@2_[IRBD]; AND IR@0_[lig]--insulin@3_[IR] <IR2-insulin3>; AND IR@0_[IRBD]--IR@2_[IRBD]; AND IR@2_[lig]--insulin@3_[IR] """).rxncon_system) # Component expressions IR = '(( IR_[IRBD]--0 | IR_[IRBD]--IR_[IRBD] ) & ( IR_[lig]--0 | IR_[lig]--insulin_[IR] ) & ' \ ' ( IR_[TK(Y1158)]-{0} | IR_[TK(Y1158)]-{p} ) & ( IR_[TK(Y1162)]-{0} | IR_[TK(Y1162)]-{p} ) & ' \ ' ( IR_[TK(Y1163)]-{0} | IR_[TK(Y1163)]-{p} ) & ( IR_[JM(Y972)]-{0} | IR_[JM(Y972)]-{p} ) & ' \ ' ( IR_[JMY972]--0 | IR_[JMY972]--IRS_[PTB] | IR_[JMY972]--Shc_[PTB] ))' insulin = '( insulin_[IR]--0 | IR_[lig]--insulin_[IR] )' IRS = '(( IRS_[PTB]--0 | IR_[JMY972]--IRS_[PTB] ) & ( IRS_[PH]--0 | IRS_[PH]--Phospholipids_[IRS] ) & ' \ ' ( IRS_[(Y)]-{0} | IRS_[(Y)]-{p} ) & ( IRS_[Y]--0 | Grb2_[SH2]--IRS_[Y] | IRS_[Y]--PI3K_[SH2] ))' Phospholipids = '( Phospholipids_[IRS]--0 | IRS_[PH]--Phospholipids_[IRS] )' Grb2 = '(( Grb2_[SOS]--0 | Grb2_[SOS]--SOS_[Grb2] ) & ( Grb2_[SH2]--0 | Grb2_[SH2]--IRS_[Y] | Grb2_[SH2]--Shc_[Y] | Grb2_[SH2]--Shc_[YY] ))' SOS = '( SOS_[Grb2]--0 | Grb2_[SOS]--SOS_[Grb2] )' Shc = '(( Shc_[PTB]--0 | IR_[JMY972]--Shc_[PTB] ) & ( Shc_[(YY239240)]-{0} | Shc_[(YY239240)]-{p} ) & ' \ ' ( Shc_[(Y317)]-{0} | Shc_[(Y317)]-{p} ) & ( Shc_[Y]--0 | Grb2_[SH2]--Shc_[Y] ) & ( Shc_[YY]--0 | Grb2_[SH2]--Shc_[YY] ))' PI3K = '( PI3K_[SH2]--0 | IRS_[Y]--PI3K_[SH2] )' expected_rules = { # Reaction updates 'IR_[IRBD]_ppi+_IR_[IRBD]': '{0}'.format(IR), 'IR_[IRBD]_ppi-_IR_[IRBD]': '{0}'.format(IR), 'IR_[lig]_i+_insulin_[IR]': '{0} & {1} & IR_[IRBD]--IR_[IRBD] & IR_[lig]--0'.format(IR, insulin), 'IR_[lig]_i-_insulin_[IR]': '{0} & {1}'.format(IR, insulin), 'IR_p+_IR_[TK(Y1158)]': '{0} & IR_[IRBD]--IR_[IRBD] & IR_[lig]--insulin_[IR]'.format(IR), 'IR_p+_IR_[TK(Y1162)]': '{0} & IR_[IRBD]--IR_[IRBD] & IR_[lig]--insulin_[IR]'.format(IR), 'IR_p+_IR_[TK(Y1163)]': '{0} & IR_[IRBD]--IR_[IRBD] & IR_[lig]--insulin_[IR]'.format(IR), 'IR_ap+_IR_[JM(Y972)]': '{0} & IR_[TK(Y1158)]-{{p}} & IR_[TK(Y1162)]-{{p}} & IR_[TK(Y1163)]-{{p}} & IR_[IRBD]--IR_[IRBD] & IR_[lig]--insulin_[IR]' .format(IR), 'IR_[JMY972]_ppi+_IRS_[PTB]': '{0} & {1} & IR_[JM(Y972)]-{{p}} & IRS_[PH]--Phospholipids_[IRS]'. format(IR, IRS), 'IR_[JMY972]_ppi-_IRS_[PTB]': '{0} & {1}'.format(IR, IRS), 'IRS_[PH]_i+_Phospholipids_[IRS]': '{0} & {1}'.format(IRS, Phospholipids), 'IRS_[PH]_i-_Phospholipids_[IRS]': '{0} & {1}'.format(IRS, Phospholipids), 'IR_p+_IRS_[(Y)]': '{0} & {1} & IR_[JMY972]--IRS_[PTB] & IR_[TK(Y1158)]-{{p}} & IR_[TK(Y1162)]-{{p}} & IR_[TK(Y1163)]-{{p}} & IR_[IRBD]--IR_[IRBD] & IR_[lig]--insulin_[IR]' .format(IR, IRS), 'Grb2_[SOS]_ppi+_SOS_[Grb2]': '{0} & {1}'.format(Grb2, SOS), 'Grb2_[SOS]_ppi-_SOS_[Grb2]': '{0} & {1}'.format(Grb2, SOS), 'Grb2_[SH2]_ppi+_IRS_[Y]': '{0} & {1} & IRS_[(Y)]-{{p}}'.format(Grb2, IRS), 'Grb2_[SH2]_ppi-_IRS_[Y]': '{0} & {1}'.format(Grb2, IRS), 'IR_[JMY972]_ppi+_Shc_[PTB]': '{0} & {1} & IR_[JM(Y972)]-{{p}}'.format(IR, Shc), 'IR_[JMY972]_ppi-_Shc_[PTB]': '{0} & {1}'.format(IR, Shc), 'IR_p+_Shc_[(YY239240)]': '{0} & {1} & IR_[JMY972]--Shc_[PTB] & IR_[TK(Y1158)]-{{p}} & IR_[TK(Y1162)]-{{p}} & IR_[TK(Y1163)]-{{p}} & IR_[IRBD]--IR_[IRBD] & IR_[lig]--insulin_[IR]' .format(IR, Shc), 'IR_p+_Shc_[(Y317)]': '{0} & {1} & IR_[JMY972]--Shc_[PTB] & IR_[TK(Y1158)]-{{p}} & IR_[TK(Y1162)]-{{p}} & IR_[TK(Y1163)]-{{p}} & IR_[IRBD]--IR_[IRBD] & IR_[lig]--insulin_[IR]' .format(IR, Shc), 'Grb2_[SH2]_ppi+_Shc_[YY]': '{0} & {1} & Shc_[(YY239240)]-{{p}}'.format(Grb2, Shc), 'Grb2_[SH2]_ppi-_Shc_[YY]': '{0} & {1}'.format(Grb2, Shc), 'Grb2_[SH2]_ppi+_Shc_[Y]': '{0} & {1} & Shc_[(Y317)]-{{p}}'.format(Grb2, Shc), 'Grb2_[SH2]_ppi-_Shc_[Y]': '{0} & {1}'.format(Grb2, Shc), 'IRS_[Y]_ppi+_PI3K_[SH2]': '{0} & {1} & IRS_[(Y)]-{{p}}'.format(IRS, PI3K), 'IRS_[Y]_ppi-_PI3K_[SH2]': '{0} & {1}'.format(IRS, PI3K), # State updates 'IR_[IRBD]--0': '{0} & (( IR_[IRBD]_ppi-_IR_[IRBD] & IR_[IRBD]--IR_[IRBD] ) | ( IR_[IRBD]--0 & ~( IR_[IRBD]_ppi+_IR_[IRBD] & IR_[IRBD]--0 )))' .format(IR), 'IR_[IRBD]--IR_[IRBD]': '{0} & (( IR_[IRBD]_ppi+_IR_[IRBD] & IR_[IRBD]--0 ) | ( IR_[IRBD]--IR_[IRBD] & ~( IR_[IRBD]_ppi-_IR_[IRBD] & IR_[IRBD]--IR_[IRBD] )))' .format(IR), 'IR_[lig]--0': '{0} & (( IR_[lig]_i-_insulin_[IR] & IR_[lig]--insulin_[IR] ) | ( IR_[lig]--0 & ~( IR_[lig]_i+_insulin_[IR] & IR_[lig]--0 & insulin_[IR]--0 )))' .format(IR), 'IR_[lig]--insulin_[IR]': '{0} & {1} & (( IR_[lig]_i+_insulin_[IR] & IR_[lig]--0 & insulin_[IR]--0 ) | ( IR_[lig]--insulin_[IR] & ~( IR_[lig]_i-_insulin_[IR] & IR_[lig]--insulin_[IR] )))' .format(IR, insulin), 'insulin_[IR]--0': '{0} & (( IR_[lig]_i-_insulin_[IR] & IR_[lig]--insulin_[IR] ) | ( insulin_[IR]--0 & ~( IR_[lig]_i+_insulin_[IR] & IR_[lig]--0 & insulin_[IR]--0 )))' .format(insulin), 'IR_[TK(Y1158)]-{0}': '{0} & ( IR_[TK(Y1158)]-{{0}} & ~( IR_p+_IR_[TK(Y1158)] & IR_[TK(Y1158)]-{{0}} ))' .format(IR), 'IR_[TK(Y1162)]-{0}': '{0} & ( IR_[TK(Y1162)]-{{0}} & ~( IR_p+_IR_[TK(Y1162)] & IR_[TK(Y1162)]-{{0}} ))' .format(IR), 'IR_[TK(Y1163)]-{0}': '{0} & ( IR_[TK(Y1163)]-{{0}} & ~( IR_p+_IR_[TK(Y1163)] & IR_[TK(Y1163)]-{{0}} ))' .format(IR), 'IR_[JM(Y972)]-{0}': '{0} & ( IR_[JM(Y972)]-{{0}} & ~( IR_ap+_IR_[JM(Y972)] & IR_[JM(Y972)]-{{0}} ))' .format(IR), 'IR_[TK(Y1158)]-{p}': '{0} & ( IR_[TK(Y1158)]-{{p}} | ( IR_p+_IR_[TK(Y1158)] & IR_[TK(Y1158)]-{{0}} ))' .format(IR), 'IR_[TK(Y1162)]-{p}': '{0} & ( IR_[TK(Y1162)]-{{p}} | ( IR_p+_IR_[TK(Y1162)] & IR_[TK(Y1162)]-{{0}} ))' .format(IR), 'IR_[TK(Y1163)]-{p}': '{0} & ( IR_[TK(Y1163)]-{{p}} | ( IR_p+_IR_[TK(Y1163)] & IR_[TK(Y1163)]-{{0}} ))' .format(IR), 'IR_[JM(Y972)]-{p}': '{0} & ( IR_[JM(Y972)]-{{p}} | ( IR_ap+_IR_[JM(Y972)] & IR_[JM(Y972)]-{{0}} ))' .format(IR), 'IR_[JMY972]--0': '{0} & (( IR_[JMY972]_ppi-_IRS_[PTB] & IR_[JMY972]--IRS_[PTB] ) | ( IR_[JMY972]_ppi-_Shc_[PTB] & IR_[JMY972]--Shc_[PTB] ) | ( IR_[JMY972]--0 & ~( IR_[JMY972]_ppi+_IRS_[PTB] & IR_[JMY972]--0 & IRS_[PTB]--0 ) & ~( IR_[JMY972]_ppi+_Shc_[PTB] & IR_[JMY972]--0 & Shc_[PTB]--0 )))' .format(IR), 'IRS_[PTB]--IR_[JMY972]': '{0} & {1} & (( IR_[JMY972]_ppi+_IRS_[PTB] & IR_[JMY972]--0 & IRS_[PTB]--0 ) | ( IR_[JMY972]--IRS_[PTB] & ~( IR_[JMY972]_ppi-_IRS_[PTB] & IR_[JMY972]--IRS_[PTB] )))' .format(IR, IRS), 'IRS_[PTB]--0': '{0} & (( IR_[JMY972]_ppi-_IRS_[PTB] & IR_[JMY972]--IRS_[PTB] ) | ( IRS_[PTB]--0 & ~( IR_[JMY972]_ppi+_IRS_[PTB] & IR_[JMY972]--0 & IRS_[PTB]--0 )))' .format(IRS), 'IR_[JMY972]--Shc_[PTB]': '{0} & {1} & (( IR_[JMY972]_ppi+_Shc_[PTB] & IR_[JMY972]--0 & Shc_[PTB]--0 ) | ( IR_[JMY972]--Shc_[PTB] & ~( IR_[JMY972]_ppi-_Shc_[PTB] & IR_[JMY972]--Shc_[PTB] )))' .format(IR, Shc), 'Shc_[PTB]--0': '{0} & (( IR_[JMY972]_ppi-_Shc_[PTB] & IR_[JMY972]--Shc_[PTB] ) | ( Shc_[PTB]--0 & ~( IR_[JMY972]_ppi+_Shc_[PTB] & IR_[JMY972]--0 & Shc_[PTB]--0 )))' .format(Shc), 'IRS_[PH]--0': '{0} & (( IRS_[PH]_i-_Phospholipids_[IRS] & IRS_[PH]--Phospholipids_[IRS] ) | ( IRS_[PH]--0 & ~( IRS_[PH]_i+_Phospholipids_[IRS] & IRS_[PH]--0 & Phospholipids_[IRS]--0 )))' .format(IRS), 'IRS_[PH]--Phospholipids_[IRS]': '{0} & {1} & (( IRS_[PH]_i+_Phospholipids_[IRS] & IRS_[PH]--0 & Phospholipids_[IRS]--0 ) | ( IRS_[PH]--Phospholipids_[IRS] & ~( IRS_[PH]_i-_Phospholipids_[IRS] & IRS_[PH]--Phospholipids_[IRS] )))' .format(IRS, Phospholipids), 'Phospholipids_[IRS]--0': '{0} & (( IRS_[PH]_i-_Phospholipids_[IRS] & IRS_[PH]--Phospholipids_[IRS] ) | ( Phospholipids_[IRS]--0 & ~( IRS_[PH]_i+_Phospholipids_[IRS] & IRS_[PH]--0 & Phospholipids_[IRS]--0 )))' .format(Phospholipids), 'IRS_[(Y)]-{0}': '{0} & ( IRS_[(Y)]-{{0}} & ~( IR_p+_IRS_[(Y)] & IRS_[(Y)]-{{0}} ))'. format(IRS), 'IRS_[(Y)]-{p}': '{0} & ( IRS_[(Y)]-{{p}} | ( IR_p+_IRS_[(Y)] & IRS_[(Y)]-{{0}} ))'. format(IRS), 'Grb2_[SOS]--0': '{0} & (( Grb2_[SOS]_ppi-_SOS_[Grb2] & Grb2_[SOS]--SOS_[Grb2] ) | ( Grb2_[SOS]--0 & ~( Grb2_[SOS]_ppi+_SOS_[Grb2] & Grb2_[SOS]--0 & SOS_[Grb2]--0 )))' .format(Grb2), 'Grb2_[SOS]--SOS_[Grb2]': '{0} & {1} & (( Grb2_[SOS]_ppi+_SOS_[Grb2] & Grb2_[SOS]--0 & SOS_[Grb2]--0 ) | ( Grb2_[SOS]--SOS_[Grb2] & ~( Grb2_[SOS]_ppi-_SOS_[Grb2] & Grb2_[SOS]--SOS_[Grb2] )))' .format(Grb2, SOS), 'SOS_[Grb2]--0': '{0} & (( Grb2_[SOS]_ppi-_SOS_[Grb2] & Grb2_[SOS]--SOS_[Grb2] ) | ( SOS_[Grb2]--0 & ~( Grb2_[SOS]_ppi+_SOS_[Grb2] & Grb2_[SOS]--0 & SOS_[Grb2]--0 )))' .format(SOS), 'IRS_[Y]--0': '{0} & (( IRS_[Y]_ppi-_PI3K_[SH2] & IRS_[Y]--PI3K_[SH2] ) | ( Grb2_[SH2]_ppi-_IRS_[Y] & Grb2_[SH2]--IRS_[Y] ) | ( IRS_[Y]--0 & ~( IRS_[Y]_ppi+_PI3K_[SH2] & IRS_[Y]--0 & PI3K_[SH2]--0 ) & ~( Grb2_[SH2]_ppi+_IRS_[Y] & IRS_[Y]--0 & Grb2_[SH2]--0 )))' .format(IRS), 'IRS_[Y]--PI3K_[SH2]': '{0} & {1} & (( IRS_[Y]_ppi+_PI3K_[SH2] & IRS_[Y]--0 & PI3K_[SH2]--0 ) | ( IRS_[Y]--PI3K_[SH2] & ~( IRS_[Y]_ppi-_PI3K_[SH2] & IRS_[Y]--PI3K_[SH2] )))' .format(IRS, PI3K), 'PI3K_[SH2]--0': '{0} & (( IRS_[Y]_ppi-_PI3K_[SH2] & IRS_[Y]--PI3K_[SH2] ) | ( PI3K_[SH2]--0 & ~( IRS_[Y]_ppi+_PI3K_[SH2] & IRS_[Y]--0 & PI3K_[SH2]--0 )))' .format(PI3K), 'Grb2_[SH2]--IRS_[Y]': '{0} & {1} & (( Grb2_[SH2]_ppi+_IRS_[Y] & Grb2_[SH2]--0 & IRS_[Y]--0 ) | ( Grb2_[SH2]--IRS_[Y] & ~( Grb2_[SH2]_ppi-_IRS_[Y] & Grb2_[SH2]--IRS_[Y] )))' .format(Grb2, IRS), 'Grb2_[SH2]--0': '{0} & (( Grb2_[SH2]_ppi-_IRS_[Y] & Grb2_[SH2]--IRS_[Y] ) | ( Grb2_[SH2]_ppi-_Shc_[YY] & Grb2_[SH2]--Shc_[YY] ) | ( Grb2_[SH2]_ppi-_Shc_[Y] & Grb2_[SH2]--Shc_[Y] ) | ( Grb2_[SH2]--0 & ~( Grb2_[SH2]_ppi+_IRS_[Y] & Grb2_[SH2]--0 & IRS_[Y]--0 ) & ~( Grb2_[SH2]_ppi+_Shc_[YY] & Grb2_[SH2]--0 & Shc_[YY]--0 ) & ~( Grb2_[SH2]_ppi+_Shc_[Y] & Grb2_[SH2]--0 & Shc_[Y]--0 )))' .format(Grb2), 'Grb2_[SH2]--Shc_[YY]': '{0} & {1} & (( Grb2_[SH2]_ppi+_Shc_[YY] & Grb2_[SH2]--0 & Shc_[YY]--0 ) | ( Grb2_[SH2]--Shc_[YY] & ~( Grb2_[SH2]_ppi-_Shc_[YY] & Grb2_[SH2]--Shc_[YY] )))' .format(Grb2, Shc), 'Shc_[YY]--0': '{0} & (( Grb2_[SH2]_ppi-_Shc_[YY] & Grb2_[SH2]--Shc_[YY] ) | ( Shc_[YY]--0 & ~( Grb2_[SH2]_ppi+_Shc_[YY] & Grb2_[SH2]--0 & Shc_[YY]--0 )))' .format(Shc), 'Grb2_[SH2]--Shc_[Y]': '{0} & {1} & (( Grb2_[SH2]_ppi+_Shc_[Y] & Grb2_[SH2]--0 & Shc_[Y]--0 ) | ( Grb2_[SH2]--Shc_[Y] & ~( Grb2_[SH2]_ppi-_Shc_[Y] & Grb2_[SH2]--Shc_[Y] )))' .format(Grb2, Shc), 'Shc_[Y]--0': '{0} & (( Grb2_[SH2]_ppi-_Shc_[Y] & Grb2_[SH2]--Shc_[Y] ) | ( Shc_[Y]--0 & ~( Grb2_[SH2]_ppi+_Shc_[Y] & Grb2_[SH2]--0 & Shc_[Y]--0 )))' .format(Shc), 'Shc_[(YY239240)]-{0}': '{0} & ( Shc_[(YY239240)]-{{0}} & ~( IR_p+_Shc_[(YY239240)] & Shc_[(YY239240)]-{{0}} ))' .format(Shc), 'Shc_[(YY239240)]-{p}': '{0} & ( Shc_[(YY239240)]-{{p}} | ( IR_p+_Shc_[(YY239240)] & Shc_[(YY239240)]-{{0}} ))' .format(Shc), 'Shc_[(Y317)]-{0}': '{0} & ( Shc_[(Y317)]-{{0}} & ~( IR_p+_Shc_[(Y317)] & Shc_[(Y317)]-{{0}} ))' .format(Shc), 'Shc_[(Y317)]-{p}': '{0} & ( Shc_[(Y317)]-{{p}} | ( IR_p+_Shc_[(Y317)] & Shc_[(Y317)]-{{0}} ))' .format(Shc), } assert len(boolean_model.update_rules) == len(expected_rules) for update_rule in boolean_model.update_rules: assert update_rule.factor.is_equivalent_to( venn_from_str(expected_rules[str(update_rule.target)], target_from_str))