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
Branches
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:
###################
table1 = RotTable()
#table1 = RotTable()
#print(table1.orta())
# print(table1.rot_table)
......@@ -65,3 +65,9 @@ class Traj3D:
ax.plot(x,y,z)
plt.show()
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"):
brin = ''.join(lineList[1:])'''
L=[]
People=Population(N)
# afficher(People)
for i in range(tmax):
print("\n \n NOUVELLE GENERATION \n \n")
print(i)
max=0
best=None
for individu in People.indiv:
individu.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
People.reproduction(p = proportion, proba_mutation= pmutation)
# for individu in People.indiv:
# individu.mutation(pmutation)
for individu in People.indiv:
individu.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
if individu.score>max:
best=individu
max=individu.score
# afficher(People)
L.append(max)
#print(L)
plt.plot([i for i in range(tmax)], L)
plt.show()
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 Traj3D import Traj3D
import numpy as np
from math import sqrt
from math import sqrt, inf
from random import random
P1 = 0.015
......@@ -10,27 +10,36 @@ class Individu():
def __init__(self, table):
self.table = table
self.score = None
self.score = self.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
def evaluate(self, brin):
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())
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]
last_nucleotide = traj_array[-1, 0:3]
distance = sqrt(sum((first_nucleotide - last_nucleotide) ** 2))
list_distance += [distance_first_nuc, distance_last_nuc]
first_name = brin[0]
last_name = brin[-1]
#rot_computed = self.table.rot_table[last_name+first_name]
#rot_traj = first_nucleotide - last_nucleotide
# print(rot_traj)
# print(rot_computed)
#diff_angle = sum(abs(rot_computed - rot_traj))
self.score = 1/max(list_distance)
self.score = 1/distance
return 1/distance
def mutation(self, proba = P1):
......@@ -58,7 +67,7 @@ class Individu():
# print(test.score)
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.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
print(qqun.score)
# 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.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
# print(qqun.score)
......@@ -64,8 +64,7 @@ class Population:
print("meilleur, individu: ", meilleur.score, individu.score)
meilleur = individu
newself = [meilleur]
# print("\n \n \nmeilleur", meilleur.table.rot_table, "\n \nscore", meilleur.score)
vu=set()
t=randrange(0,self.n)
m=randrange(0,self.n)
non_vu = [i for i in range(0, self.n)]
......@@ -155,7 +154,7 @@ class Population:
p = (self.n)//2
vieille_taille = self.n
selection(p)
newself = list(self.indiv)
newself = [element for element in self.indiv]
while len(newself)<vieille_taille:
m=randrange(0,self.n)
t=randrange(0,self.n)
......@@ -164,10 +163,12 @@ class Population:
couple_enfant = enfant(x,y)
for child in couple_enfant :
child.mutation(proba_mutation)
child.evaluate("AAAGGATCTTCTTGAGATCCTTTTTTTCTGCGCGTAATCTGCTGCCAGTAAACGAAAAAACCGCCTGGGGAGGCGGTTTAGTCGAA")
newself.append(couple_enfant[0])
newself.append(couple_enfant[1])
self = self.modifier_population(newself)
def afficher(popu):
for individu in popu.indiv :
print("\n individu \n")
......@@ -186,8 +187,6 @@ def test():
#test()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment