Skip to content
Snippets Groups Projects
Commit e1b707ec authored by Santos Garcia Carlos's avatar Santos Garcia Carlos
Browse files

Merge branch 'master' of...

parents b87ec9ce 90976419
No related branches found
No related tags found
No related merge requests found
{ {
"python.pythonPath": "D:\\Programmes\\Anaconda3\\python.exe" "python.pythonPath": "/Users/gauthierroy/anaconda3/bin/python"
} }
\ No newline at end of file
...@@ -99,6 +99,7 @@ class RotTable: ...@@ -99,6 +99,7 @@ class RotTable:
################### ###################
table1 = RotTable() #table1 = RotTable()
#print(table1.orta())
# print(table1.rot_table) # print(table1.rot_table)
...@@ -65,3 +65,9 @@ class Traj3D: ...@@ -65,3 +65,9 @@ class Traj3D:
ax.plot(x,y,z) ax.plot(x,y,z)
plt.show() plt.show()
plt.savefig(filename) plt.savefig(filename)
# from RotTable import RotTable
# table = RotTable()
# test = Traj3D()
# test.compute("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA", table)
# test.draw("first_plot")
\ No newline at end of file
File added
No preview for this file type
File added
No preview for this file type
File deleted
...@@ -16,30 +16,23 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"): ...@@ -16,30 +16,23 @@ def main(N,tmax,pmutation, proportion,brin="plasmid_8k.fasta"):
brin = ''.join(lineList[1:])''' brin = ''.join(lineList[1:])'''
L=[] L=[]
People=Population(N) People=Population(N)
# afficher(People)
for i in range(tmax): for i in range(tmax):
print("\n \n NOUVELLE GENERATION \n \n") print(i)
max=0 max=0
best=None best=None
for individu in People.indiv:
individu.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
People.reproduction(p = proportion, proba_mutation= pmutation) People.reproduction(p = proportion, proba_mutation= pmutation)
# for individu in People.indiv:
# individu.mutation(pmutation)
for individu in People.indiv: for individu in People.indiv:
individu.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
if individu.score>max: if individu.score>max:
best=individu best=individu
max=individu.score max=individu.score
# afficher(People)
L.append(max) L.append(max)
#print(L)
plt.plot([i for i in range(tmax)], L) plt.plot([i for i in range(tmax)], L)
plt.show() plt.show()
return(best) return(best)
main(6,8,0.01,2) main(100,100,0.1,50)
sample.png

2.35 KiB | W: | H:

first_plot.png

2.36 KiB | W: | H:

sample.png
first_plot.png
sample.png
first_plot.png
  • 2-up
  • Swipe
  • Onion skin
from RotTable import RotTable from RotTable import RotTable
from Traj3D import Traj3D from Traj3D import Traj3D
import numpy as np import numpy as np
from math import sqrt from math import sqrt, inf
from random import random from random import random
P1 = 0.015 P1 = 0.015
...@@ -10,27 +10,36 @@ class Individu(): ...@@ -10,27 +10,36 @@ class Individu():
def __init__(self, table): def __init__(self, table):
self.table = table self.table = table
self.score = None self.score = self.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
def evaluate(self, brin): def evaluate(self, brin):
traj = Traj3D() traj = Traj3D()
traj.compute(brin, self.table)
numb_ajout = 3
fisrt_seq = brin[0:numb_ajout]
last_seq = brin[-numb_ajout:]
traj.compute(last_seq + brin + fisrt_seq, self.table)
traj_array = np.array(traj.getTraj()) traj_array = np.array(traj.getTraj())
list_distance = []
for i in range(numb_ajout):
first_nuc_coordonate = traj_array[numb_ajout+i, 0:3]
first_nuc_coordonate_compute = traj_array[-(numb_ajout-i), 0:3]
last_nuc_coordonate = traj_array[-(2*numb_ajout-i), 0:3]
last_nuc_coordonate_compute = traj_array[i, 0:3]
distance_first_nuc = np.linalg.norm(first_nuc_coordonate - first_nuc_coordonate_compute, ord=2)
distance_last_nuc = np.linalg.norm(last_nuc_coordonate - last_nuc_coordonate_compute, ord=2)
first_nucleotide = traj_array[0, 0:3] list_distance += [distance_first_nuc, distance_last_nuc]
last_nucleotide = traj_array[-1, 0:3]
distance = sqrt(sum((first_nucleotide - last_nucleotide) ** 2))
first_name = brin[0]
last_name = brin[-1]
#rot_computed = self.table.rot_table[last_name+first_name] self.score = 1/max(list_distance)
#rot_traj = first_nucleotide - last_nucleotide
# print(rot_traj)
# print(rot_computed)
#diff_angle = sum(abs(rot_computed - rot_traj))
self.score = 1/distance return 1/distance
def mutation(self, proba = P1): def mutation(self, proba = P1):
...@@ -58,7 +67,7 @@ class Individu(): ...@@ -58,7 +67,7 @@ class Individu():
# print(test.score) # print(test.score)
qqun=Individu(RotTable()) # qqun=Individu(RotTable())
qqun.table.rot_table={'AA': [35.576558502141, 7.433901511509349, -154], 'AC': [33.22048222654215, 5.25191751302917, 143], 'AG': [26.446029097301288, 6.052240462237622, -2], 'AT': [30.47045254036881, 1.333716025628036, 0], 'CA': [34.00734209585039, 33.70710613604862, -64], 'CC': [33.61019622767888, 3.713127032109607, -57], 'CG': [29.664061041382677, 6.725155507162601, 0], 'CT': [26.446029097301288, 6.052240462237622, 2], 'GA': [36.655773481637176, 10.45337581740701, 120], 'GC': [42.26984493493484, 3.5310453395352823, 180], 'GG': [33.61019622767888, 3.713127032109607, -57], 'GT': [33.22048222654215, 5.25191751302917, 143], 'TA': [36.951508786388914, -2.5174751178033303, 0], 'TC': [36.655773481637176, 10.45337581740701, -120], 'TG': [34.00734209585039, 33.70710613604862, -64], 'TT': [35.576558502141, 7.433901511509349, -154]} # qqun.table.rot_table={'AA': [35.576558502141, 7.433901511509349, -154], 'AC': [33.22048222654215, 5.25191751302917, 143], 'AG': [26.446029097301288, 6.052240462237622, -2], 'AT': [30.47045254036881, 1.333716025628036, 0], 'CA': [34.00734209585039, 33.70710613604862, -64], 'CC': [33.61019622767888, 3.713127032109607, -57], 'CG': [29.664061041382677, 6.725155507162601, 0], 'CT': [26.446029097301288, 6.052240462237622, 2], 'GA': [36.655773481637176, 10.45337581740701, 120], 'GC': [42.26984493493484, 3.5310453395352823, 180], 'GG': [33.61019622767888, 3.713127032109607, -57], 'GT': [33.22048222654215, 5.25191751302917, 143], 'TA': [36.951508786388914, -2.5174751178033303, 0], 'TC': [36.655773481637176, 10.45337581740701, -120], 'TG': [34.00734209585039, 33.70710613604862, -64], 'TT': [35.576558502141, 7.433901511509349, -154]}
qqun.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA") # qqun.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
print(qqun.score) # print(qqun.score)
...@@ -64,8 +64,7 @@ class Population: ...@@ -64,8 +64,7 @@ class Population:
print("meilleur, individu: ", meilleur.score, individu.score) print("meilleur, individu: ", meilleur.score, individu.score)
meilleur = individu meilleur = individu
newself = [meilleur] newself = [meilleur]
# print("\n \n \nmeilleur", meilleur.table.rot_table, "\n \nscore", meilleur.score) vu=set()
t=randrange(0,self.n) t=randrange(0,self.n)
m=randrange(0,self.n) m=randrange(0,self.n)
non_vu = [i for i in range(0, self.n)] non_vu = [i for i in range(0, self.n)]
...@@ -155,7 +154,7 @@ class Population: ...@@ -155,7 +154,7 @@ class Population:
p = (self.n)//2 p = (self.n)//2
vieille_taille = self.n vieille_taille = self.n
selection(p) selection(p)
newself = list(self.indiv) newself = [element for element in self.indiv]
while len(newself)<vieille_taille: while len(newself)<vieille_taille:
m=randrange(0,self.n) m=randrange(0,self.n)
t=randrange(0,self.n) t=randrange(0,self.n)
...@@ -164,10 +163,12 @@ class Population: ...@@ -164,10 +163,12 @@ class Population:
couple_enfant = enfant(x,y) couple_enfant = enfant(x,y)
for child in couple_enfant : for child in couple_enfant :
child.mutation(proba_mutation) child.mutation(proba_mutation)
child.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
newself.append(couple_enfant[0]) newself.append(couple_enfant[0])
newself.append(couple_enfant[1]) newself.append(couple_enfant[1])
self = self.modifier_population(newself) self = self.modifier_population(newself)
def afficher(popu): def afficher(popu):
for individu in popu.indiv : for individu in popu.indiv :
print("\n individu \n") print("\n individu \n")
...@@ -186,8 +187,6 @@ def test(): ...@@ -186,8 +187,6 @@ def test():
#test() #test()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment