def assemble_cx(stmts_with_counts):
    for channel, (stmts, ev_counts,
                  source_counts) in stmts_with_counts.items():
        cxa = CxAssembler(stmts, network_name='%s INDRA interactome' % channel)
        cxa.make_model()
        add_semantic_hub_layout(cxa.cx, channel)
        model_id = cxa.upload_model()
Exemple #2
0
def upload_ndex_network(kinase, stmts):
    network_set_id = '9d9d4f66-e3da-11eb-b666-0ac135e8bacf'
    name = '%s INDRA network' % kinase
    cxa = CxAssembler(stmts, name)
    cxa.make_model()
    add_semantic_hub_layout(cxa.cx, kinase)
    network_id = cxa.upload_model(private=False)
    # Style setting already done as part of upload
    # ndex_client.set_style(network_id)
    ndex_client.add_to_network_set(network_id, network_set_id)
    return network_id
def test_hub_layout():
    stmts = [st_phos, st_dephos, st_act]
    cxa = CxAssembler(stmts)
    cxa.make_model()
    graph = hub_layout.cx_to_networkx(cxa.cx)
    erk = hub_layout.get_node_by_name(graph, 'MAPK1')
    hub_layout.add_semantic_hub_layout(cxa.cx, 'MAPK1')
    assert cxa.cx['cartesianLayout']
    for node in cxa.cx['cartesianLayout']:
        if node['node'] == erk:
            assert node['x'] == 0.0
            assert node['y'] == 0.0
        else:
            assert node['x'] != 0
            assert node['y'] != 0

    node_classes = hub_layout.classify_nodes(graph, erk)
    assert node_classes[hub_layout.get_node_by_name(graph, 'DUSP4')] == \
        (1, 'modification', 'other')
    assert node_classes[hub_layout.get_node_by_name(graph, 'MAP2K1')] in \
        {(1, 'activity', 'protein'), (1, 'modification', 'protein')}
import sys
import pickle
from indra.databases import ndex_client
from indra.assemblers.cx import CxAssembler
from indra.assemblers.cx.hub_layout import add_semantic_hub_layout

if __name__ == '__main__':
    kinase = sys.argv[1]
    with open('dark_kinase_statements_assembled.pkl', 'rb') as fh:
        stmts = pickle.load(fh)
    cxa = CxAssembler(stmts[kinase])
    cxa.make_model()
    add_semantic_hub_layout(cxa.cx, kinase)
    model_id = cxa.upload_model()
    ndex_client.set_style(model_id)