예제 #1
0
def test_grouping_block_targeting_block():
    st1 = Phosphorylation(Agent('A'), Agent('B'))
    st2 = Phosphorylation(Agent('A'), Agent('C'))
    st3 = Phosphorylation(Agent('D'), Agent('B'))
    st4 = Phosphorylation(Agent('D'), Agent('C'))
    cja = CyJSAssembler()
    cja.add_statements([st1, st2, st3, st4])
    cja.make_model(grouping=True)
    for node in cja._nodes:
        if node['data']['name'] == 'A':
            parent_a = node['data']['parent']
        if node['data']['name'] == 'B':
            parent_b = node['data']['parent']
        if node['data']['name'] == 'C':
            parent_c = node['data']['parent']
        if node['data']['name'] == 'D':
            parent_d = node['data']['parent']
    assert_element_properties(cja)
    assert parent_b == parent_c
    assert parent_a == parent_d
    parent_b_name = [x['data']['name'] for x in cja._nodes if
                     x['data']['id']==parent_b][0]
    parent_a_name = [x['data']['name'] for x in cja._nodes if
                     x['data']['id']==parent_a][0]
    assert parent_b_name.startswith('Group')
    assert parent_a_name.startswith('Group')
    assert len(cja._edges) == 5
    virtual_edges = [x for x in cja._edges if
                     x['data']['i'] == 'Virtual']
    assert len(virtual_edges) == 4
    real_edges = [x for x in cja._edges if
                  x['data']['i'] != 'Virtual']
    assert len(real_edges) == 1
예제 #2
0
def test_selfmod():
    cja = CyJSAssembler()
    cja.add_statements([st_selfmod])
    cja.make_model()
    assert len(cja._nodes) == 1
    assert len(cja._edges) == 1
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(polarities) == 1
    assert polarities[0] == 'positive'
예제 #3
0
def test_complex():
    cja = CyJSAssembler()
    cja.add_statements([st_complex])
    cja.make_model()
    assert len(cja._nodes) == 3
    assert len(cja._edges) == 3
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities))==1
    assert 'none' in polarities
예제 #4
0
def test_no_grouping():
    st1 = Phosphorylation(Agent('A'), Agent('B'))
    st2 = Phosphorylation(Agent('A'), Agent('C'))
    st3 = Phosphorylation(Agent('C'), Agent('B'))
    cja = CyJSAssembler()
    cja.add_statements([st1, st2, st3])
    cja.make_model(grouping=True)
    parents = [node['data']['parent'] for node in cja._nodes]
    for parent in parents:
        assert parent == ''
예제 #5
0
def test_ras():
    cja = CyJSAssembler()
    cja.add_statements([st_gef, st_gap])
    cja.make_model()
    assert len(cja._nodes) == 3
    assert len(cja._edges) == 2
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities))==2
    assert 'positive' in polarities
    assert 'negative' in polarities
예제 #6
0
def test_print_cyjs_graph():
    cja = CyJSAssembler()
    cja.add_statements([st_act, st_act2])
    cja.make_model()
    cyjs_str = cja.print_cyjs_graph()
    # assert output is not empty
    assert len(cyjs_str) > len('{\n "edges": [],\n "nodes": []\n}')
예제 #7
0
def test_edge_aggregation_between_nongroup_nodes():
    cja = CyJSAssembler()
    cja.add_statements([st_phos_Y, st_phos_T])
    cja.make_model(grouping=False)
    assert len(cja._nodes) == 2
    assert len(cja._edges) == 1
    for edge in cja._edges:
        assert len(edge['data']['uuid_list']) == 2
    for node in cja._nodes:
        assert len(node['data']['uuid_list']) == 2
    cja = CyJSAssembler()
    cja.add_statements([st_phos_Y, st_phos_T])
    cja.make_model(grouping=True)
    assert len(cja._nodes) == 2
    assert len(cja._edges) == 1
    for edge in cja._edges:
        assert len(edge['data']['uuid_list']) == 2
    for node in cja._nodes:
        assert len(node['data']['uuid_list']) == 2
예제 #8
0
def test_act():
    cja = CyJSAssembler()
    cja.add_statements([st_act, st_act2])
    cja.make_model()
    assert len(cja._nodes) == 3
    assert len(cja._edges) == 2
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities))==2
    assert 'positive' in polarities
    assert 'negative' in polarities
    db_refs = [node['data']['db_refs'] for node in cja._nodes]
    for node, refs in zip(cja._nodes, db_refs):
        if node['data']['name'] == 'MAP2K1':
            assert refs.get('HGNC') == \
                'http://identifiers.org/hgnc/HGNC:6840', refs
            assert refs.get('TEXT') == 'mek1', refs
        if node['data']['name'] == 'MAPK1':
            assert refs.get('UniProt')
        if node['data']['name'] == 'DUSP4':
            assert not refs
예제 #9
0
파일: api.py 프로젝트: steppi/indra
    def post(self):
        """Assemble INDRA Statements and return Cytoscape JS network.

        Parameters
        ----------
        statements : list[indra.statements.Statement.to_json()]
            A list of INDRA Statements to assemble.

        Returns
        -------
        json_model : dict
            Json dictionary containing graph information.
        """
        args = request.json
        stmts_json = args.get('statements')
        stmts = stmts_from_json(stmts_json)
        cja = CyJSAssembler(stmts)
        cja.make_model(grouping=True)
        model_str = cja.print_cyjs_graph()
        return json.loads(model_str)
예제 #10
0
def test_print_cyjs_graph():
    cja = CyJSAssembler()
    cja.add_statements([st_act, st_act2])
    cja.make_model()
    cyjs_str = cja.print_cyjs_graph()
    # assert output is not empty
    assert len(cyjs_str) > len('{\n "edges": [],\n "nodes": []\n}')
예제 #11
0
def test_grouping_block_targeting_block():
    st1 = Phosphorylation(Agent('A'), Agent('B'))
    st2 = Phosphorylation(Agent('A'), Agent('C'))
    st3 = Phosphorylation(Agent('D'), Agent('B'))
    st4 = Phosphorylation(Agent('D'), Agent('C'))
    cja = CyJSAssembler()
    cja.add_statements([st1, st2, st3, st4])
    cja.make_model(grouping=True)
    for node in cja._nodes:
        if node['data']['name'] == 'A':
            parent_a = node['data']['parent']
        if node['data']['name'] == 'B':
            parent_b = node['data']['parent']
        if node['data']['name'] == 'C':
            parent_c = node['data']['parent']
        if node['data']['name'] == 'D':
            parent_d = node['data']['parent']
    assert_element_properties(cja)
    assert parent_b == parent_c
    assert parent_a == parent_d
    parent_b_name = [
        x['data']['name'] for x in cja._nodes if x['data']['id'] == parent_b
    ][0]
    parent_a_name = [
        x['data']['name'] for x in cja._nodes if x['data']['id'] == parent_a
    ][0]
    assert parent_b_name.startswith('Group')
    assert parent_a_name.startswith('Group')
    assert len(cja._edges) == 5
    virtual_edges = [x for x in cja._edges if x['data']['i'] == 'Virtual']
    assert len(virtual_edges) == 4
    real_edges = [x for x in cja._edges if x['data']['i'] != 'Virtual']
    assert len(real_edges) == 1
예제 #12
0
def test_selfmod():
    cja = CyJSAssembler()
    cja.add_statements([st_selfmod])
    cja.make_model()
    assert len(cja._nodes) == 1
    assert len(cja._edges) == 1
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(polarities) == 1
    assert polarities[0] == 'positive'
예제 #13
0
def test_complex():
    cja = CyJSAssembler()
    cja.add_statements([st_complex])
    cja.make_model()
    assert len(cja._nodes) == 3
    assert len(cja._edges) == 3
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities)) == 1
    assert 'none' in polarities
예제 #14
0
def assemble_cyjs():
    """Assemble INDRA Statements and return Cytoscape JS network."""
    if request.method == 'OPTIONS':
        return {}
    response = request.body.read().decode('utf-8')
    body = json.loads(response)
    stmts_json = body.get('statements')
    stmts = stmts_from_json(stmts_json)
    cja = CyJSAssembler()
    cja.add_statements(stmts)
    cja.make_model(grouping=True)
    model_str = cja.print_cyjs_graph()
    return model_str
예제 #15
0
def test_no_grouping():
    st1 = Phosphorylation(Agent('A'), Agent('B'))
    st2 = Phosphorylation(Agent('A'), Agent('C'))
    st3 = Phosphorylation(Agent('C'), Agent('B'))
    cja = CyJSAssembler()
    cja.add_statements([st1, st2, st3])
    cja.make_model(grouping=True)
    parents = [node['data']['parent'] for node in cja._nodes]
    for parent in parents:
        assert parent == ''
예제 #16
0
def test_ras():
    cja = CyJSAssembler()
    cja.add_statements([st_gef, st_gap])
    cja.make_model()
    assert len(cja._nodes) == 3
    assert len(cja._edges) == 2
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities)) == 2
    assert 'positive' in polarities
    assert 'negative' in polarities
예제 #17
0
def make_cyjs_network(results, model, stmts):
    path_stmts = get_path_stmts(results, model, stmts)
    path_genes = get_path_genes(path_stmts)
    # Get UUIDs to use as filter
    path_uuids = [list(path.keys()) for path in path_stmts]
    all_path_uuids = []
    for p in path_uuids:
        all_path_uuids += p
    #filtered_stmts = ac.filter_gene_list(stmts, path_genes, 'one')
    filtered_stmts = ac.filter_uuid_list(stmts, all_path_uuids)
    ac.dump_statements(filtered_stmts, 'output/korkut_cyjs_model.pkl')
    ca = CyJSAssembler(filtered_stmts)
    cm = ca.make_model()
    ca.set_CCLE_context(['SKMEL28_SKIN'])
    ca.save_json('output/korkut_model')
예제 #18
0
파일: api.py 프로젝트: johnbachman/indra
def assemble_cyjs():
    """Assemble INDRA Statements and return Cytoscape JS network."""
    if request.method == 'OPTIONS':
        return {}
    response = request.body.read().decode('utf-8')
    body = json.loads(response)
    stmts_json = body.get('statements')
    stmts = stmts_from_json(stmts_json)
    cja = CyJSAssembler()
    cja.add_statements(stmts)
    cja.make_model(grouping=True)
    model_str = cja.print_cyjs_graph()
    return model_str
예제 #19
0
def test_act():
    cja = CyJSAssembler()
    cja.add_statements([st_act, st_act2])
    cja.make_model()
    assert len(cja._nodes) == 3
    assert len(cja._edges) == 2
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities)) == 2
    assert 'positive' in polarities
    assert 'negative' in polarities
    db_refs = [node['data']['db_refs'] for node in cja._nodes]
    for node in cja._nodes:
        if node['data']['name'] == 'MAP2K1':
            assert node['data']['db_refs'].get('HGNC')
        if node['data']['name'] == 'MAPK1':
            assert node['data']['db_refs'].get('UniProt')
        if node['data']['name'] == 'DUSP4':
            assert not node['data']['db_refs']
예제 #20
0
def test_act():
    cja = CyJSAssembler()
    cja.add_statements([st_act, st_act2])
    cja.make_model()
    assert len(cja._nodes) == 3
    assert len(cja._edges) == 2
    polarities = [edge['data']['polarity'] for edge in cja._edges]
    assert len(set(polarities)) == 2
    assert 'positive' in polarities
    assert 'negative' in polarities
    db_refs = [node['data']['db_refs'] for node in cja._nodes]
    for node, refs in zip(cja._nodes, db_refs):
        if node['data']['name'] == 'MAP2K1':
            assert refs.get('HGNC') == \
                'http://identifiers.org/hgnc/HGNC:6840', refs
            assert refs.get('TEXT') == 'mek1', refs
        if node['data']['name'] == 'MAPK1':
            assert refs.get('UniProt')
        if node['data']['name'] == 'DUSP4':
            assert not refs
예제 #21
0
def test_edge_aggregation_between_nongroup_nodes():
    cja = CyJSAssembler()
    cja.add_statements([st_phos_Y, st_phos_T])
    cja.make_model(grouping=False)
    assert len(cja._nodes) == 2
    assert len(cja._edges) == 1
    for edge in cja._edges:
        assert len(edge['data']['uuid_list']) == 2
    for node in cja._nodes:
        assert len(node['data']['uuid_list']) == 2
    cja = CyJSAssembler()
    cja.add_statements([st_phos_Y, st_phos_T])
    cja.make_model(grouping=True)
    assert len(cja._nodes) == 2
    assert len(cja._edges) == 1
    for edge in cja._edges:
        assert len(edge['data']['uuid_list']) == 2
    for node in cja._nodes:
        assert len(node['data']['uuid_list']) == 2