def test_basic_network_where_neighbor_of_citations_merges_enabled(self):
        net = NiceCXNetwork()
        adjud = RedundantEdgeAdjudicator()
        edge_map = {}
        nid = net.create_edge(edge_source=0,
                              edge_target=1,
                              edge_interaction='neighbor-of')
        net.set_edge_attribute(nid,
                               RedundantEdgeAdjudicator.CITATION, ['pubmed:5'],
                               type='list_of_string')

        cid = net.create_edge(edge_source=0,
                              edge_target=1,
                              edge_interaction='controls-state-change-of')
        net.set_edge_attribute(cid,
                               RedundantEdgeAdjudicator.CITATION, ['pubmed:6'],
                               type='list_of_string')

        neighbor_of_map = {}
        controls_state_change_map = {}
        other_edge_exists = {}
        for k, v in net.get_edges():
            s = v['s']
            t = v['t']
            i = v['i']

            if i == 'neighbor-of':
                if not s in neighbor_of_map:
                    neighbor_of_map[s] = {}
                if not t in neighbor_of_map:
                    neighbor_of_map[t] = {}
                neighbor_of_map[s][t] = k
                neighbor_of_map[t][s] = k
            elif i == 'controls-state-change-of':
                adjud._add_to_edge_map(controls_state_change_map, k, s, t)
            else:
                adjud._add_to_edge_map(other_edge_exists, k, s, t)

        adjud.remove_and_merge_neighbor_of(net, neighbor_of_map, edge_map)

        net.print_summary()
Exemple #2
0
    cx_network.add_node_attribute(property_of=cx_node,
                                  name="HEIGHT",
                                  values=height)

# TODO: need to handle defaults. The following doesn't appear to work.
# node_properties = [
#    {"properties_of": "nodes:default", "properties": {"NODE_SHAPE": "RECTANGLE"}}
# ]
# set_visual_properties_aspect(cx_network, node_properties)

style_network = ndex2.create_nice_cx_from_file("./WP4571.cx.json")
cx_network.apply_style_from_network(style_network)

set_cartesian_layout_aspect(cx_network, cartesianLayout)

cx_network.print_summary()

mycx = cx_network.to_cx()
# print(mycx)
pprint.pprint(mycx, depth=4)

# result = cx_network.upload_to(
#    server="http://test.ndexbio.org", username=NDEX_USER, password=NDEX_PWD
# )

result = cx_network.update_to(
    server="http://test.ndexbio.org",
    username=NDEX_USER,
    password=NDEX_PWD,
    uuid="99698d91-9155-11e9-b7e4-0660b7976219",
)