Commit 03dfe6ff authored by Roman Sarrazin-Gendron's avatar Roman Sarrazin-Gendron
Browse files

first summer commit

parent 176c6f88
This diff is collapsed.
import pickle
import networkx as nx
from matplotlib import pyplot as plt
g_list = pickle.load(open("one_of_each_graph.cPickle",'rb'))
print(g_list)
g = g_list[0][0]
for i in g.edges():
print (g.get_edge_data(*i))
for j in g.nodes(data=True):
print(j)
nx.draw(g)
plt.show()
import pickle
graphs = pickle.load(open('../models/one_of_each_graph.cPickle','rb'))
#print(graphs[0][0].nodes())
good = [10,22,30,32,33,62,100,147,154]
for i in good:
print(graphs[i][0].nodes())
print("BAD")
for i in range(len(graphs)):
if i not in good:
if len(graphs[i][0])>4:
print(graphs[i][0].nodes())
import pickle
import networkx as nx
from matplotlib import pyplot as plt
graphs = pickle.load(open("CATALOGUE_graphs.cPickle","rb"))
def make_align_graph(g1,g2,corr):
corr_edges = []
g0 = nx.DiGraph()
g0.add_nodes_from(g1.nodes())
g0.add_edges_from(g1.edges())
g0.add_nodes_from(g2.nodes())
g0.add_edges_from(g2.edges())
for i in corr:
corr_edges.append((i[0],i[1]))
print(corr)
g0.add_edges_from(corr_edges)
pos = nx.spring_layout(g0)
nx.draw_networkx_nodes(g0,pos,nodelist=g1.nodes(),node_color='red',node_size=500)
nx.draw_networkx_nodes(g0,pos,nodelist=g2.nodes(),node_color='green',node_size=500)
nx.draw_networkx_edges(g0,pos,edgelist=g1.edges(),edge_color='red',width=2)
nx.draw_networkx_edges(g0,pos,edgelist=g2.edges(),edge_color='green',width=2)
nx.draw_networkx_edges(g0,pos,edgelist=corr_edges,edge_color='blue',width=0.5)
labels={}
elabels = {}
for i in g0.nodes():
labels[i] = i
nx.draw_networkx_labels(g0,pos,labels)
for i in g1.edges():
elabels[i]=g1.get_edge_data(*i)['label']
for i in g2.edges():
elabels[i]=g2.get_edge_data(*i)['label']
nx.draw_networkx_edge_labels(g0,pos,elabels)
plt.show()
return g0
for i in range(10):
a = graphs[i]
for k in a[0]:
#nx.draw(k)
# plt.show()
print(k.nodes(data=True))
break
for i in k.edges():
print(i[0],i[1],k.get_edge_data(*i))
import pickle
import pandas
catalogue = pickle.load(open("CATALOGUE_graphs.cPickle","rb"))
carnaval = pickle.load(open("sorted_SRINS.cPickle","rb"))
print(carnaval[0])
print(catalogue[0])
carnaval_graphs = []
for i in carnaval :
carnaval_graphs.append((i['l_graphs'],i['names']))
print(carnaval_graphs[0])
#pickle.dump(carnaval_graphs,open("CARNAVAL_graphs.cPickle","wb"))
print(len(carnaval))
print(len(carnaval_graphs))
from matplotlib import pyplot as plt
import numpy as np
results = {1: [(34.95151239508122, 1.0, 28.843135911111354, 0.2), (31.195679785495983, 0.2, 31.083146870816744, 0.2), (36.184628404333736, 1.0, 30.128316602903546, 0.2), (36.184628404333736, 0.0, 36.184628404333736, 1.0), (36.184628404333736, 0.0, 36.184628404333736, 1.0), (36.184628404333736, 0.0, 36.184628404333736, 1.0), (36.184628404333736, 0.0, 36.184628404333736, 1.0), (36.184628404333736, 0.0, 36.184628404333736, 1.0), (36.184628404333736, 0.0, 36.184628404333736, 1.0), (31.195679785495983, 0.2, 31.083146870816744, 0.2), (36.184628404333736, 1.0, 30.128316602903546, 0.2), (26.299208018387283, 0.0, 24.569855608330947, 0.2), (36.184628404333736, 1.0, 30.18425549540535, 1.0), (36.184628404333736, 1.0, 30.18425549540535, 1.0), (34.26170930174936, 0.2, 34.26170930174936, 0.2), (36.184628404333736, 1.0, 30.128316602903546, 0.2), (36.184628404333736, 1.0, 30.128316602903546, 0.2), (31.195679785495983, 0.2, 31.083146870816744, 0.2), (31.195679785495983, 0.2, 31.083146870816744, 0.2), (31.195679785495983, 0.2, 31.083146870816744, 0.2), (31.195679785495983, 0.2, 31.083146870816744, 0.2), (31.195679785495983, 0.2, 31.083146870816744, 0.2), (36.184628404333736, 1.0, 30.18425549540535, 1.0), (36.184628404333736, 1.0, 30.18425549540535, 1.0)], 3: [(32.32498916322653, 1.0, 28.92267730898545, 0.25), (32.32498916322653, 1.0, 27.106562940444885, 0.25), (32.32498916322653, 0.25, 32.32498916322653, 0.0), (32.32498916322653, 1.0, 31.838945367404424, 0.0)], 4: [(25.689997971419448, 0.0, 22.768184324776925, 0.0), (31.753947941699852, 1.0, 27.083479327331844, 0.0), (22.820178962415188, 0.0, 21.807354922057606, 0.25), (31.753947941699852, 1.0, 28.75258971764099, 0.0), (27.57648434679685, 0.0, 27.494355603532842, 0.0)], 7: [(30.659382750512133, 1.0, 26.825753832883112, 0.0), (30.93567152496115, 0.0, 30.93567152496115, 0.0), (26.825753832883112, 0.0, 26.825753832883112, 0.0), (31.12940377319471, 1.0, 27.845490050944374, 0.0)], 9: [(38.14328355488899, 1.0, 33.409390936137704, 1.0), (34.268249571994495, 1.0, 28.409390936137704, 0.16666666666666666)], 23: [(32.06634150544502, 1.0, 28.162391328756904, 0.2), (32.06634150544502, 1.0, 30.478516847676453, 0.2), (34.40967268499923, 1.0, 29.956739145059082, 1.0)], 25: [(30.197658251195143, 1.0, 26.554828641429854, 0.0), (30.197658251195143, 0.75, 27.217957697864115, 0.75), (23.96289600533726, 0.0, 23.036173612553483, 0.0)], 29: [(26.67065624911844, 1.0, 23.56985560833095, 0.0)], 71: [(31.826747082520203, 1.0, 31.826747082520203, 0.2), (31.826747082520203, 1.0, 29.467096033905747, 0.2), (31.826747082520203, 1.0, 31.826747082520203, 0.2)], 82: [(33.14720492494223, 0.7142857142857143, 30.4757334309664, 0.42857142857142855), (34.214319120800766, 0.8571428571428571, 28.90689059560852, 0.5714285714285714), (34.214319120800766, 0.7142857142857143, 28.90689059560852, 0.42857142857142855), (34.214319120800766, 0.8571428571428571, 28.90689059560852, 0.5714285714285714)], 86: [(33.28540221886225, 1.0, -1, -100)]}
control = {1: [(22.75488750216347, 0.0, 20.321928094887365, 0.0), (34.26170930174936, 0.0, 34.26170930174936, 0.0), (19.584962500721154, 0.0, -1, -100), (22.643856189774727, 0.0, 22.459431618637296, 0.0), (30.65306897657993, 0.0, 28.916625922211235, 0.0), (28.32755264408124, 0.0, 23.4262647547021, 0.0), (27.08746284125034, 0.0, 25.055282435501194, 0.2), (30.654412268148942, 0.0, 28.23840473932508, 0.0), (26.280770770130605, 0.0, 24.339850002884624, 0.0), (27.07681559705083, 0.0, 27.014020470314936, 0.0), (19.0, 0.0, -1, -100), (-1, -100, -2, -100), (22.523561956057012, 0.0, 21.32192809488736, 0.0), (28.125413470483316, 0.0, 26.98299357469431, 0.0), (28.163649676015822, 0.0, 28.162391328756904, 0.0), (22.39231742277876, 0.2, -1, -100), (18.0, 0.2, -1, -100), (36.184628404333736, 0.0, 31.195679785495983, 0.0), (36.184628404333736, 0.0, 28.916625922211235, 0.0), (36.184628404333736, 0.0, 34.418198514554746, 0.0), (34.26170930174936, 0.0, 31.083146870816744, 0.0), (29.250298417906333, 0.0, 26.832890014164743, 0.0), (21.0, 0.0, 21.0, 0.0), (26.96000193206808, 0.0, 24.491853096329677, 0.0)], 3: [(20.807354922057606, 0.0, 20.066089190457774, 0.0), (-1, -100, -2, -100), (26.742098869778307, 0.0, 26.727707777472688, 0.0), (26.742098869778307, 0.0, 26.086467993464066, 0.0)], 4: [(23.53915881110803, 0.0, 21.044394119358454, 0.0), (28.58894882031468, 0.0, 27.01262453886506, 0.0), (20.643856189774723, 0.0, 20.523561956057012, 0.5), (22.022367813028456, 0.0, 21.857980995127573, 0.0), (27.48784003382305, 0.0, 27.48784003382305, 0.0)], 7: [(25.81538329581354, 0.0, 24.438791852578262, 0.0), (26.014020470314932, 0.0, 25.981567281903015, 0.0), (29.44475608969503, 0.0, 28.61953222757205, 0.0), (27.485326189240528, 0.0, 26.825753832883112, 0.0)], 9: [(25.584962500721158, 0.0, 25.4594316186373, 0.16666666666666666), (25.584962500721158, 0.0, 25.584962500721158, 0.0)], 23: [(26.951284714966974, 0.0, 25.53138146051631, 0.0), (-1, -100, -2, -100), (29.222794902868113, 0.0, 27.027905996569885, 0.2)], 25: [(24.422064766172813, 0.0, 24.06339508128851, 0.0), (30.197658251195143, 0.0, 27.361669679492774, 0.0), (25.587308728333547, 0.0, 24.8193807908646, 0.0)], 29: [(-1, -100, -2, -100)], 71: [(25.918863237274596, 0.0, 25.584962500721158, 0.2), (28.211888294546004, 0.0, 25.86418614465428, 0.0), (24.794415866350107, 0.2, 24.68650052718322, 0.0)], 82: [(24.0, 0.14285714285714285, -1, -100), (26.584962500721158, 0.0, 25.0, 0.0), (27.807354922057602, 0.0, 27.0, 0.0), (26.0, 0.0, 26.0, 0.0)], 86: [(-1, -100, -2, -100)]}
found_scores = []
pred_scores = []
for i in results.keys():
for k in results[i]:
if k[1]>-100:
pred_scores.append(k[0]-12)
else:
pred_scores.append(0)
if k[1]>-100:
pred_scores.append(k[2]-12)
else:
pred_scores.append(0)
if k[1]>-100:
found_scores.append(k[1])
else:
found_scores.append(0)
if k[3]>-100:
found_scores.append(k[3])
else:
found_scores.append(0)
m, b = np.polyfit(pred_scores, found_scores, 1)
plt.plot(pred_scores,found_scores,".", alpha=0.5)
plt.plot(pred_scores,[i*m for i in pred_scores] + b, "-")
plt.xlabel("BayesPairing predicted score for module")
plt.ylabel("Fraction of basepairs predicted actually observed")
plt.xlim([5,30])
plt.ylim([-0.1,1.1])
plt.title("Correlation between score predicted and base pairs found by BayesPairing in PDB sequences")
plt.show()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment