Beispiel #1
0
def test_translation() -> None:
    rxncon_sys = Quick('''A_trsl_BmRNA
                          C_p+_B_[(r1)]
                          D_p+_B_[(r2)] ; ! B@1_[(r1)]-{p}
                          D_[x]_ppi+_B_[y]
                          E_ub+_B_[(r1)]''').rxncon_system

    expected_rxns = {
        'A_trsl_BmRNA': ReactionTestCase(
            [
                state_from_str('B_[(r1)]-{0}'),
                state_from_str('B_[(r2)]-{0}'),
                state_from_str('B_[y]--0')
            ],
            [],
            []
        ),
        'C_p+_B_[(r1)]': ReactionTestCase(
            [],
            [state_from_str('B_[(r1)]-{p}')],
            [state_from_str('B_[(r1)]-{0}')]
        ),
        'D_p+_B_[(r2)]': ReactionTestCase(
            [],
            [state_from_str('B_[(r2)]-{p}')],
            [state_from_str('B_[(r2)]-{0}')]
        ),
        'D_[x]_ppi+_B_[y]': ReactionTestCase(
            [],
            [state_from_str('D_[x]--B_[y]')],
            [state_from_str('D_[x]--0'), state_from_str('B_[y]--0')]
        ),
        'E_ub+_B_[(r1)]': ReactionTestCase(
            [],
            [state_from_str('B_[(r1)]-{ub}')],
            [state_from_str('B_[(r1)]-{0}')]
        )
    }

    for rxn in rxncon_sys.reactions:
        assert elems_eq(rxn.synthesised_states, expected_rxns[str(rxn)].synthesised_states)
        assert elems_eq(rxn.produced_states, expected_rxns[str(rxn)].produced_states)
        assert elems_eq(rxn.consumed_states, expected_rxns[str(rxn)].consumed_states)

    assert rxncon_sys.states_for_component_grouped(spec_from_str('A')) == {}
    assert rxncon_sys.states_for_component_grouped(spec_from_str('C')) == {}
    assert rxncon_sys.states_for_component_grouped(spec_from_str('E')) == {}

    assert elems_eq(list(rxncon_sys.states_for_component_grouped(spec_from_str('B')).values()), [
        [state_from_str('B_[y]--0'), state_from_str('B_[y]--D_[x]')],
        [state_from_str('B_[(r1)]-{0}'), state_from_str('B_[(r1)]-{p}'), state_from_str('B_[(r1)]-{ub}')],
        [state_from_str('B_[(r2)]-{0}'), state_from_str('B_[(r2)]-{p}')]
    ])
    assert elems_eq(list(rxncon_sys.states_for_component_grouped(spec_from_str('D')).values()), [
        [state_from_str('D_[x]--0'), state_from_str('B_[y]--D_[x]')]
    ])
Beispiel #2
0
def test_ppi_props() -> None:
    # Elemental state, free binding domain.
    state = state_from_str('A_[m]--0')
    assert state.is_elemental
    assert elems_eq(state.components, [spec_from_str('A')])
    assert state.is_neutral
    assert elems_eq(state.neutral_states, [state])

    # Elemental state, bond.
    state = state_from_str('A_[m]--B_[n]')
    assert state.is_elemental
    assert elems_eq(state.components, [spec_from_str('A'), spec_from_str('B')])
    assert not state.is_neutral
    assert elems_eq(state.neutral_states,
                    [state_from_str('A_[m]--0'),
                     state_from_str('B_[n]--0')])

    # Non-elemental state, free binding domain.
    state = state_from_str('A--0')
    assert not state.is_elemental
    assert elems_eq(state.components, [spec_from_str('A')])
    assert state.is_neutral
    assert elems_eq(state.neutral_states, [state])

    # Non-elemental state, bond.
    state = state_from_str('A--B_[n]')
    assert not state.is_elemental
    assert elems_eq(state.components, [spec_from_str('A'), spec_from_str('B')])
    assert not state.is_neutral
    assert elems_eq(state.neutral_states,
                    [state_from_str('A--0'),
                     state_from_str('B_[n]--0')])
Beispiel #3
0
def test_modification_props() -> None:
    # Elemental state, neutral.
    state = state_from_str('A_[(res)]-{0}')
    assert state.is_elemental
    assert elems_eq(state.components, [spec_from_str('A')])
    assert state.is_neutral
    assert elems_eq(state.neutral_states, [state])

    # Elemental state, non-neutral.
    state = state_from_str('A_[(res)]-{p}')
    assert state.is_elemental
    assert elems_eq(state.components, [spec_from_str('A')])
    assert not state.is_neutral
    assert elems_eq(state.neutral_states, [state_from_str('A_[(res)]-{0}')])

    # Non-elemental state, neutral.
    state = state_from_str('A_[dom]-{0}')
    assert not state.is_elemental
    assert elems_eq(state.components, [spec_from_str('A')])
    assert state.is_neutral
    assert elems_eq(state.neutral_states, [state])

    # Non-elemental state, non-neutral.
    state = state_from_str('A_[dom]-{p}')
    assert not state.is_elemental
    assert elems_eq(state.components, [spec_from_str('A')])
    assert not state.is_neutral
    assert elems_eq(state.neutral_states, [state_from_str('A_[dom]-{0}')])
Beispiel #4
0
def test_ipi_props() -> None:
    # Elemental state, bond.
    state = state_from_str('A_[m]--[n]')
    assert state.is_elemental
    assert state.components == [spec_from_str('A')]
    assert not state.is_neutral
    assert elems_eq(state.neutral_states, [state_from_str('A_[m]--0'), state_from_str('A_[n]--0')])
Beispiel #5
0
def test_elems_eq_not_nested() -> None:
    assert elems_eq([1, 2, 3], [3, 1, 2])
    assert not elems_eq([1, 2], [1, 2, 3])

    assert elems_eq([], [])  # type: ignore
    assert not elems_eq([1], [])  # type: ignore
Beispiel #6
0
def test_elems_eq_nested() -> None:
    assert elems_eq([[1, 2, 3], [4, 5]], [[2, 1, 3], [5, 4]])
    assert elems_eq([[4, 5], [3, 2, 1]], [[2, 1, 3], [5, 4]])

    assert elems_eq([[], [1, 2, 3]], [[3, 2, 1], []])  # type: ignore
    assert elems_eq([[], []], [[], []])  # type: ignore