In [32]:
%matplotlib inline
import os, sys
import ntpath
from eden.util import display
# -----------------------------------------------------------------------------

In [25]:
from GraphFinder import graphFinder

Divide Sto files based on their classes:


In [58]:
#reload(divid_sto_files)
from GraphFinder import divid_sto_files

In [59]:
files_dir = "StoExamples/StoExmapleSmall"
partition_dir = "StoExamples/partitionsFiles"

pos_class_0_path = "StoExamples/StoClasses/pos_class_0"
pos_class_1_path = "StoExamples/StoClasses/pos_class_1"
neg_class_0_path = "StoExamples/StoClasses/neg_class_0"
neg_class_1_path = "StoExamples/StoClasses/neg_class_1"

files_abs_path = os.path.abspath(files_dir)
partition_abs_path = os.path.abspath(partition_dir)
pos_class_0_abs_path = os.path.abspath(pos_class_0_path)
pos_class_1_abs_path = os.path.abspath(pos_class_1_path)
neg_class_0_abs_path = os.path.abspath(neg_class_0_path)
neg_class_1_abs_path = os.path.abspath(neg_class_1_path)


Class_to_folder = divid_sto_files.classesToFolders(files_abs_path, partition_abs_path, pos_class_0_abs_path, pos_class_1_abs_path, neg_class_0_abs_path, neg_class_1_abs_path)

Experiments:

read a single '.sto' file and converted to a graph


In [11]:
file_path = "StoExamples/StoExmapleSmall/positives-sto/550-53949-1-0.sto"
abs_path = os.path.abspath(file_path)
gf = graphFinder.GraphFinder()
Graph = gf.file_to_graph(file_path)


{'graph_title': '550-53949-1-0'}

display the created graph


In [12]:
display.draw_graph(Graph, size=40, node_size=400, font_size=20, node_border=True, prog='neato')


transform the created graph to have the desired type of info(end user specification)


In [14]:
graph_transform = gf.transform(Graph, use_seq= False, use_cov = False, use_cor = False, use_ent = True)
display.draw_graph(Graph, size=40, node_size=400, font_size=20, node_border=True, prog='neato')


read a directory of '.sto' files and create their graphs


In [6]:
pos_class_0_path = "StoExamples/StoClasses/pos_class_0"
pos_class_1_path = "StoExamples/StoClasses/pos_class_1"
neg_class_0_path = "StoExamples/StoClasses/neg_class_0"
neg_class_1_path = "StoExamples/StoClasses/neg_class_1"

pos_class_0_abs_path = os.path.abspath(pos_class_0_path)
pos_class_1_abs_path = os.path.abspath(pos_class_1_path)
neg_class_0_abs_path = os.path.abspath(neg_class_0_path)
neg_class_1_abs_path = os.path.abspath(neg_class_1_path)

convert files to graphs


In [8]:
gf = graphFinder.GraphFinder()
pos_0_Graphs = gf.convert(pos_class_0_abs_path)
pos_1_Graphs = gf.convert(pos_class_1_abs_path)
neg_0_Graphs = gf.convert(neg_class_0_abs_path)
neg_1_Graphs = gf.convert(neg_class_1_abs_path)


{'graph_title': '550-70730-0-0'}
{'graph_title': '550-70852-0-0'}
{'graph_title': '550-53949-1-0'}
{'graph_title': '550-69275-0-0'}
{'graph_title': '550-69410-0-0'}
{'graph_title': '550-751-0-0'}
{'graph_title': '550-1137-0-0'}
{'graph_title': '550-904-1-0'}
{'graph_title': '550-1143-1-0'}
{'graph_title': '550-1153-0-0'}

transform the created graph to have the desired type of info(end user specification)


In [9]:
for graph in pos_0_Graphs:
    transform_pos_0_Graphs = gf.transform(graph, use_seq=True, use_cov = False)
for graph in pos_1_Graphs:
    transform_pos_1_Graphs = gf.transform(graph, use_seq=True, use_cov = False)

for graph in neg_0_Graphs:
    transform_neg_0_Graphs = gf.transform(graph, use_seq=True, use_cov = False)
for graph in neg_1_Graphs:
    transform_neg_1_Graphs = gf.transform(graph, use_seq=True, use_cov = False)

draw the transformed graphs


In [10]:
for G in pos_0_Graphs:
    display.draw_graph(G, size=40, node_size=400, font_size=20, node_border=True, prog='neato')
for G in pos_1_Graphs:
    display.draw_graph(G, size=40, node_size=400, font_size=20, node_border=True, prog='neato')

for G in neg_0_Graphs:
    display.draw_graph(G, size=40, node_size=400, font_size=20, node_border=True, prog='neato')
for G in neg_1_Graphs:
    display.draw_graph(G, size=40, node_size=400, font_size=20, node_border=True, prog='neato')