d2_graph.py 1.08 KB
Newer Older
Yoann Dufresne's avatar
Yoann Dufresne committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import networkx as nx
import d_graph as dgm


class D2Graph(object):
    """D2Graph (read it (d-graph)²)"""
    def __init__(self, graph):
        super(D2Graph, self).__init__()
        self.graph = graph

        # Compute all the d-graphs
        self.d_graphs = dgm.compute_all_max_d_graphs(self.graph)
        
        # Index all the d-graphes
        self.index = self.create_index()


    def create_index(self):
        index = {}
        return index


    def save_to_file(self, filename):
        next_idx = 0
        nodes = {}
        G = nx.Graph()

        # for dmer in self.dmers:
        #     for d_idx, dg in enumerate(self.dmers[dmer]):
        #         # Create a node name
        #         if not dg in nodes:
        #             nodes[dg] = next_idx
        #             next_idx += 1
                
        #         # Add the node
        #         G.add_node(nodes[dg])

        #         # Add the edges
        #         for prev_node in self.dmers[dmer][:d_idx]:
        #             G.add_edge(nodes[dg], nodes[prev_node])

        nx.write_gexf(G,filename)