def test_st_layout_full():
    G = NdexGraph()
    toolbox.load(G, 'st_layout_network2.txt', header=True)
    toolbox.annotate(G, 'st_layout_annotate2.txt')
    toolbox.apply_source_target_layout(G)
    template_id = 'd1856d17-4937-11e6-a5c7-06603eb7f303'
    toolbox.apply_template(G, template_id, 'http://public.ndexbio.org', 'scratch', 'scratch')
    G.set_name('test_st_layout_wtf1')
    # G.write_to('temp.cx')
    G.upload_to('http://dev2.ndexbio.org', 'scratch', 'scratch')
Exemple #2
0
def test_st_layout_full():
    G = NdexGraph()
    toolbox.load(G, 'st_layout_network2.txt', header=True)
    toolbox.annotate(G, 'st_layout_annotate2.txt')
    toolbox.apply_source_target_layout(G)
    template_id = 'd1856d17-4937-11e6-a5c7-06603eb7f303'
    toolbox.apply_template(G, template_id, 'http://public.ndexbio.org',
                           'scratch', 'scratch')
    G.set_name('test_st_layout_wtf1')
    # G.write_to('temp.cx')
    G.upload_to('http://dev2.ndexbio.org', 'scratch', 'scratch')
def test_complex_layout():
    G = NdexGraph()
    s1 = G.add_new_node('S1', st_layout='Source')
    s2 = G.add_new_node('S2', st_layout='Source')
    s3 = G.add_new_node('S3', st_layout='Source')
    t1 = G.add_new_node('T1', st_layout='Target')
    t2 = G.add_new_node('T2', st_layout='Target')
    f1 = G.add_new_node('F1', st_layout='Forward')
    f2 = G.add_new_node('F2', st_layout='Forward')
    f3 = G.add_new_node('F3', st_layout='Forward')
    f4 = G.add_new_node('F4', st_layout='Forward')
    f5 = G.add_new_node('F5', st_layout='Forward')
    r1 = G.add_new_node('R1', st_layout='Reverse')
    r2 = G.add_new_node('R2', st_layout='Reverse')
    r3 = G.add_new_node('R3', st_layout='Reverse')
    b = G.add_new_node('B1', st_layout='Both')


    G.add_edge_between(r3,r2)
    G.add_edge_between(r2,r1)
    G.add_edge_between(r1,s1)
    G.add_edge_between(r3,b)

    G.add_edge_between(s2, f3)
    G.add_edge_between(s3, f1)
    G.add_edge_between(f1, f2)
    G.add_edge_between(f2, t1)
    G.add_edge_between(f1, b)
    G.add_edge_between(f3, f4)
    G.add_edge_between(f4, f5)
    G.add_edge_between(f5, t2)

    G.add_edge_between(b, t1)
    G.add_edge_between(b, s2)
    G.add_edge_between(b, r1)

    G.add_edge_between(t1,r3)

    toolbox.apply_source_target_layout(G)

    template_id = 'd1856d17-4937-11e6-a5c7-06603eb7f303'
    toolbox.apply_template(G, template_id)
    G.set_name('experiment1')
    G.upload_to('http://public.ndexbio.org', 'scratch', 'scratch')
Exemple #4
0
def test_complex_layout():
    G = NdexGraph()
    s1 = G.add_new_node('S1', st_layout='Source')
    s2 = G.add_new_node('S2', st_layout='Source')
    s3 = G.add_new_node('S3', st_layout='Source')
    t1 = G.add_new_node('T1', st_layout='Target')
    t2 = G.add_new_node('T2', st_layout='Target')
    f1 = G.add_new_node('F1', st_layout='Forward')
    f2 = G.add_new_node('F2', st_layout='Forward')
    f3 = G.add_new_node('F3', st_layout='Forward')
    f4 = G.add_new_node('F4', st_layout='Forward')
    f5 = G.add_new_node('F5', st_layout='Forward')
    r1 = G.add_new_node('R1', st_layout='Reverse')
    r2 = G.add_new_node('R2', st_layout='Reverse')
    r3 = G.add_new_node('R3', st_layout='Reverse')
    b = G.add_new_node('B1', st_layout='Both')

    G.add_edge_between(r3, r2)
    G.add_edge_between(r2, r1)
    G.add_edge_between(r1, s1)
    G.add_edge_between(r3, b)

    G.add_edge_between(s2, f3)
    G.add_edge_between(s3, f1)
    G.add_edge_between(f1, f2)
    G.add_edge_between(f2, t1)
    G.add_edge_between(f1, b)
    G.add_edge_between(f3, f4)
    G.add_edge_between(f4, f5)
    G.add_edge_between(f5, t2)

    G.add_edge_between(b, t1)
    G.add_edge_between(b, s2)
    G.add_edge_between(b, r1)

    G.add_edge_between(t1, r3)

    toolbox.apply_source_target_layout(G)

    template_id = 'd1856d17-4937-11e6-a5c7-06603eb7f303'
    toolbox.apply_template(G, template_id)
    G.set_name('experiment1')
    G.upload_to('http://public.ndexbio.org', 'scratch', 'scratch')
def test_template():
    template_id = 'f35fbfd3-4918-11e6-a5c7-06603eb7f303'

    G = NdexGraph()
    G.add_new_node('1', color='green')
    G.add_new_node('2', color='red')
    G.add_new_node('3', color='green')
    G.add_new_node('4', color='green')
    G.add_new_node('5', color='green')
    G.add_new_node('6', color='red')
    G.add_edge_between(1, 2)
    G.add_edge_between(2, 3)
    G.add_edge_between(3, 4)
    G.add_edge_between(4, 5)
    G.add_edge_between(5, 6)

    toolbox.apply_template(G, template_id)

    G.set_name('template apply')
    G.upload_to('http://public.ndexbio.org', 'scratch', 'scratch')
Exemple #6
0
def test_template():
    template_id = 'f35fbfd3-4918-11e6-a5c7-06603eb7f303'

    G = NdexGraph()
    G.add_new_node('1', color='green')
    G.add_new_node('2', color='red')
    G.add_new_node('3', color='green')
    G.add_new_node('4', color='green')
    G.add_new_node('5', color='green')
    G.add_new_node('6', color='red')
    G.add_edge_between(1, 2)
    G.add_edge_between(2, 3)
    G.add_edge_between(3, 4)
    G.add_edge_between(4, 5)
    G.add_edge_between(5, 6)

    toolbox.apply_template(G, template_id)

    G.set_name('template apply')
    G.upload_to('http://public.ndexbio.org', 'scratch', 'scratch')
Exemple #7
0
def set_style(network_id, ndex_cred):
    # Update network style
    import ndex.beta.toolbox as toolbox
    template_uuid = "ea4ea3b7-6903-11e7-961c-0ac135e8bacf"

    server = 'http://public.ndexbio.org'
    username = ndex_cred.get('user')
    password = ndex_cred.get('password')

    source_network = ndex.networkn.NdexGraph(server=server,
                                             username=username,
                                             password=password,
                                             uuid=network_id)

    toolbox.apply_template(source_network,
                           template_uuid,
                           server=server,
                           username=username,
                           password=password)

    source_network.update_to(network_id,
                             server=server,
                             username=username,
                             password=password)
Exemple #8
0
    else:
        (r1, g1, b1), (r2, g2, b2) = colors[i], colors[i+1]
        return int(r1 + f*(r2-r1)), int(g1 + f*(g2-g1)), int(b1 + f*(b2-b1))

def convert_to_rgb_string(minval, maxval, val, colors):
    r, g, b = convert_to_rgb(minval, maxval, val, colors)
    return 'rbg(' + str(r) + ',' + str(g) + ', ' + str(b) + ')'


#with open(path.join(path.abspath(path.dirname(__file__)),'nci_pid_preview.cx'), 'r') as file_handler:
#    network_in_cx_from_file = file_handler.read().replace('\n', '')
#    G = NdexGraph(cx=json.loads(network_in_cx_from_file))
#    print G.to_cx()

source_network = networkn.NdexGraph(server="http://dev.ndexbio.org", username="******", password="******", uuid="49eb81d9-665a-11e7-8e93-06832d634f41")
toolbox.apply_template(source_network, "4a78a6ab-665a-11e7-8e93-06832d634f41", server="http://dev.ndexbio.org", username="******", password="******")
source_network.upload_to(server="http://dev.ndexbio.org", username="******", password="******")

if False:
    elastic_search_uri = 'http://ec2-107-21-1-214.compute-1.amazonaws.com/'
    es = Elasticsearch([elastic_search_uri],send_get_body_as='POST',timeout=300) # Prod Clustered Server

    search_body = {
        'sort' : [
            '_score'
        ],
       'query': {
            'bool': {
                'must': [
                   {'match': {
                      '_id': '2020037526'
Exemple #9
0
                    )  # ndexebs.get('edge_table')[0].get('PATHWAY_NAMES')

                network_summary = current_netpath_metadata.get(
                    sif_pathway_name)
                # {'node_table': [], 'edge_table': []}
                if len(ebs.get('node_table')) > 0:
                    network = ebs2cx.ebs_to_network(ebs, name=sif_pathway_name)
                    #network = trim_edges(network)
                    ebs2cx.ndex_edge_filter(network)

                    layouts.apply_directed_flow_layout(network)
                    #toolbox.apply_template(network, "c51cda49-6192-11e5-8ac5-06603eb7f303", server="http://dev2.ndexbio.org", username="******", password="******")
                    toolbox.apply_template(
                        network,
                        config_data.get('network_style').get('uuid'),
                        server=config_data.get('network_style').get('server'),
                        username=config_data.get('network_style').get('user'),
                        password=config_data.get('network_style').get(
                            'pass'))  # NCI PID
                    #toolbox.apply_template(network, "4b63be4e-4716-11e7-96f7-06832d634f41", server="http://dev.ndexbio.org", username="******", password="******") # Lipid Maps
                    #toolbox.apply_template(network, "23aa48fe-4fb0-11e7-a8b5-06832d634f41", server="http://dev.ndexbio.org", username="******", password="******") # Lipid Maps
                    #toolbox.apply_template(network, "71f237da-4704-11e7-a6ff-0660b7976219", server="http://dev2.ndexbio.org", username="******", password="******") # Netpath

                    #if network.pos:
                    #    if network.view_id is None:
                    #        network.view_id = 1
                    #    if network.subnetwork_id is None:
                    #        network.subnetwork_id = 1

                    # SET NETWORK METADATA FROM CURRENT NETWORK IN NDEx
                    current_netpath_metadata_tmp = current_netpath_metadata.get(
Exemple #10
0
            print ebs

            sif_pathway_name = sif.replace('.sif', '')
            #if ndexebs.get('edge_table') and len(ndexebs.get('edge_table')) > 0:
            #sif_pathway_name = file_title_mapping.get(sif_pathway_name) # ndexebs.get('edge_table')[0].get('PATHWAY_NAMES')

            network_summary = current_netpath_metadata.get(sif_pathway_name)
            # {'node_table': [], 'edge_table': []}
            if len(ebs.get('node_table')) > 0:
                network = ebs2cx.ebs_to_network(ebs, name=sif_pathway_name)
                ebs2cx.ndex_edge_filter(network)

                layouts.apply_directed_flow_layout(network)
                toolbox.apply_template(network,
                                       "2328cb9f-4d39-11e7-9a21-06832d634f41",
                                       server="http://dev.ndexbio.org",
                                       username="******",
                                       password="******")  # NCI PID

                # SET NETWORK METADATA FROM CURRENT NETWORK IN NDEx
                current_netpath_metadata_tmp = current_netpath_metadata.get(
                    sif_pathway_name)
                network.set_name(sif_pathway_name)
                network.namespaces = {
                    "KEGG Pathway": "http://identifiers.org/kegg.pathway/",
                    "Mouse Genome Database":
                    "http://www.informatics.jax.org/accession/",
                    "KEGG Compound": "http://identifiers.org/kegg.compound/",
                    "LIPID MAPS":
                    "http://www.lipidmaps.org/data/LMSDRecord.php?LMID=",
                    "cas": "http://identifiers.org/cas/",