From c757dd7337d272dbc3880a0d8cf435deca751a61 Mon Sep 17 00:00:00 2001 From: Quickinline Date: Fri, 19 Mar 2021 06:27:59 +0100 Subject: [PATCH] merged protein_mass calculation. the integration caused a keyerror issue --- .../__pycache__/__init__.cpython-38.pyc | Bin 240 -> 240 bytes .../__pycache__/acid_mass.cpython-38.pyc | Bin 0 -> 830 bytes .../__pycache__/components.cpython-38.pyc | Bin 6290 -> 6619 bytes projetsysteme/__pycache__/dna.cpython-38.pyc | Bin 2142 -> 2613 bytes projetsysteme/__pycache__/main.cpython-38.pyc | Bin 535 -> 535 bytes .../__pycache__/rna_to_acid.cpython-38.pyc | Bin 862 -> 862 bytes .../__pycache__/settings.cpython-38.pyc | Bin 234 -> 234 bytes .../__pycache__/views.cpython-38.pyc | Bin 1203 -> 1203 bytes projetsysteme/acid_mass.py | 42 ++ projetsysteme/components.py | 9 +- projetsysteme/dna.py | 24 +- projetsysteme/test.py | 223 ++++++--- test.txt | 0 test2.py | 469 ------------------ 14 files changed, 227 insertions(+), 540 deletions(-) create mode 100644 projetsysteme/__pycache__/acid_mass.cpython-38.pyc create mode 100644 projetsysteme/acid_mass.py delete mode 100644 test.txt delete mode 100644 test2.py diff --git a/projetsysteme/__pycache__/__init__.cpython-38.pyc b/projetsysteme/__pycache__/__init__.cpython-38.pyc index 8c30a8e039e7d1cc09c9b090f967c566e50fb9b3..c6976f931f33163df393b04a91f313eaa8622bad 100644 GIT binary patch delta 19 Zcmeys_<@l-l$V!_0SH93LMC!Q1pqEV1bYAg delta 19 Zcmeys_<@l-l$V!_0SIR622bRE3IH*11p@#8 diff --git a/projetsysteme/__pycache__/acid_mass.cpython-38.pyc b/projetsysteme/__pycache__/acid_mass.cpython-38.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cbb9c985bb94e1ec6059723dea945392afb0bb93 GIT binary patch literal 830 zcma)(OH31C5XX1AP$*E|Eh;`h@lmi;;z@&MOGO|Q0#d3Fq}_Hl%cG^uwm>?8RH}2U{GS>MGq#P#uyWc2NI5+JUJ6h^vL&RfBDbMKl4p?#=YJOjnB`n zSaPLQ({?2I|M)pD_;Zkf8Ungd#}X_>HJdawd3u?oFdjWt+{by$xL*oeMIzDW)J z*n|i0ARfYIJd8*1C?3NWY{lbv0^9H;p2E|31_RiR9qb1@JEjGK_A~#wE4e*t*q^2z zKX~|N!m#UK-%D-2oigl1+lwDltx3Z!ZR(gimr5D7$G>uZYdOjydtvQ+t7+J;HoGpF zy=;E|@&2wyXLEaDI=$Az8Q;aH&jwA-G~d2;b8DG1(;G|k$;b`EMtA$pH{jChu4l0O zPTH{N*H_7!{rI&&hXe{#w@Z@@|i9*r_iYAKWQ4cKPpU0Utq_AVP43 zpqJn(K_5Xs!2rP^L6l&KV3=TpV3gn*!5Be|AWm?dV1i&$xwwnc1tkJrh^E|vGC{e( zBaoe`N%p&O{GnS|#>HV`@ z7|3uK6-(6O>X20s^8))+PJFDw$|ilxQl!Ub7;!VhN^!qfQ7!4gU~o9#qMEGfI0-X5 zyO2wm=~<-ee>!2N)DukwWi-LBaA+o%wL&IZnNVKk=B#wV38{QKw@@%yCjRFB)Cx|~ nDOh6Xwh4KrGhd|g?raVhGuCC`hEAN}f_>gSw{M?LaP9pD1G?i9 literal 0 HcmV?d00001 diff --git a/projetsysteme/__pycache__/components.cpython-38.pyc b/projetsysteme/__pycache__/components.cpython-38.pyc index 6e3e109fac73ab1a21fc6a9a823ccb4d9ff7dc36..8f91783d41bd98041f99951a734fa7c600729d90 100644 GIT binary patch delta 1238 zcmZWoO>7%g5Pr|zpO@^9?cI&-2uzbele%gPDXmBdNo=KnN}Dv~M=BOzyIxb0(zWxv zhBjI&AR`reDjmexR!`xEazg3_apA&+8>!TL@4d9*z`TtUtg=r#@69(e-@Koh`;(8} zG}jGdkl=Ug+*;|U)Gy|YLO+Hdk|`)FQt#3&|yF(;W&{s*;h6hTP-i1Gv+rt6b zOl(RW8E30YDRIdv*`-Tad+&<+GCf_eulZi_X1UR*7VEs`S2wnr)%|3-;&0Uchri;fmzrd1eym^OJ?R!=kq8E@mkZbH~k{_%Eij(;NQcf|IZJ^?vHqARehe`EBs<>9fO zRt^~8AN?hogS2r%ehZUa#ncn+7?dHXmDTIgA+xizoR$CK>wgofg0yo#6YRc`YfGVx`2YG&nWTvlN$ zwg8@K?2Mr1lMd|?O8m%XRJ^3G_+(RU)5F)~ljzjD!-5<>WnW7Bg^LsRUOo)l*AFi= z#7`o`M~}o9lr+hD8}%FbHxv|vGU~u&EFF8HX7;Ye+=zS@J?ijV;$6$&r*O?r3vot> zA;?%6O&pI4Mt&A%tnsv{CPsCWnM`F04k2a!2Aond@S`r<9=2p(3S`$9CT-eMe7Q|pYM^!$*M!UV`JGsob`o9EVu)D*L(ljyafrAx-wueI zK*Sm*DH15{Xb-cGFjZgy={WvSzi&Gd>PLRs)|%+4th4k)oW2mvUs&SPqLOgA zvUE_@Y&q;LugWi@VVf<~Zq`RGdSCKIRI|}-bq#B7@2`|de2=V#B$Zgt+_uoC>e zGGfb5{O{F4M(1FhOK3(;Np!XDRX1OXZixr=E_1BD}{)9Mmxs#3*V z{G)uPau1ea_-KX3+nB{&I!|V{){=TEp=T33ljLE9`4DW{{4@g3ZI|U62#mv#&1f0L zETnL^V2oji+fX2M8$7F5h12$W6h5%G$-PLKf!Fr^(euL6XKT|bJ)xm^CA+?{mRe6` zs(NAT%Wmr%+y4+i8QMW4ZqxR;TnzsHWVNF#loEliQCH>6J=H!cna_ zR!<@@p|;9>c(epN>Rx%Wa~^S9iMf*1vYD;wWI<;Gi=c!@VbB?p`!UsE)j3>z>RK?# z-B{j-liItzcHSXa*F@+P!6$;acrNaei+kZ>3@#er!iRUmlBd-#9!sHihoUMLh2b9~ z?}8522p>FcGz`By7pNEhdL~=aEGHS#2w6JL$+~37nmtJJG{v(fU(DATwrsntx1k0WPS8O8-@8q4hP2`oeA zUCSIkUeo9>pM-?3nN1WwG~L9`=Abf5L@S=l zf*^SC=1sxkAK;(i9`ZMc|A4-?)zlr{hwr>!`(}1$!MB?Kpj7f0KEdYpPNQ(>@4~CY z=M5=&#|^!(AdL?og)|SuYv>e1Pg>GGV5m!|9qH!UNA1Z%uFI&4vXtupwJ*!LUO*kl zgHwbmYS;8VBD?U}@NjMmFsa?}mbVvVXpQr5-qT^5^ zy;)tLt)P6hLgC^ZB~+P7k?LRUqd(+ ajWu5;hrr@h@C*)Kfaas2(<`KP=k6b7Wt|uR delta 314 zcmdlga!-ISl$V!_0SIcUgA?pICh}!57EP>F4oT%qp%oxR;%9+BJ z!rsCFWb**o94VY&HZPFPmBI~X^8wjBDZF4dKakCr!VhK(qzD8vXbMhZG+;EEY{;n3 zQp1qNG&zZJrjQWO=3=n@Oe~Cij3SI|o4J|pF)~I?e#LxHKmjOQ#1A5rK!oDt-7KHj zpv=vzhKwqkpR%?yGW%%?PS)Zyu~r5t(gG2>K;jm6a!z7#ac*i!Mt(|>21u9>L)~ju>cVB0Ws_351g(5*Tg)= diff --git a/projetsysteme/__pycache__/main.cpython-38.pyc b/projetsysteme/__pycache__/main.cpython-38.pyc index 07b743fbb7c0c9a1b9fc2203dc14812a76cbf85d..de526d799fb9304c83c292dc7d4c3dce88cc0de3 100644 GIT binary patch delta 20 acmbQvGM$Axl$V!_0SH93LN;>qFaZE0!UGrp delta 20 acmbQvGM$Axl$V!_0SHzZ1#jf$VFCat00XoD diff --git a/projetsysteme/__pycache__/rna_to_acid.cpython-38.pyc b/projetsysteme/__pycache__/rna_to_acid.cpython-38.pyc index 34968b1c4b04c6fa52b84a2a3d446cdcd1876463..ae0016e1c339758038faf7bf399279bc87b5e1b4 100644 GIT binary patch delta 20 acmcb|c8`ral$V!_0SH93LN;;-GXnrHBLngP delta 20 acmcb|c8`ral$V!_0SIR625;mJW(EK=+5~z4 diff --git a/projetsysteme/__pycache__/settings.cpython-38.pyc b/projetsysteme/__pycache__/settings.cpython-38.pyc index ea46070c01b7a768863007fe53456253a2afe161..d1214fbaf8fd61eeafdc08a12796b5edec0c4f5b 100644 GIT binary patch delta 19 ZcmaFG_==G`l$V!_0SH93LMC$G2LLT&1Ze;O delta 19 ZcmaFG_==G`l$V!_0SIR622bR^4*)Qd1n~d> diff --git a/projetsysteme/__pycache__/views.cpython-38.pyc b/projetsysteme/__pycache__/views.cpython-38.pyc index 6a1a43e92d678729bc6b1ec37445a41f0aff8cd2..bc23c37bf7fe37b305a627ae62281a0255d2865a 100644 GIT binary patch delta 20 acmdnYxtWtYl$V!_0SH93LN;=*U;zLs*aP?g delta 20 acmdnYxtWtYl$V!_0SIR625;nE!2$p-j|6}K diff --git a/projetsysteme/acid_mass.py b/projetsysteme/acid_mass.py new file mode 100644 index 0000000..d1aadf1 --- /dev/null +++ b/projetsysteme/acid_mass.py @@ -0,0 +1,42 @@ +mass_amino_acid = {'A': 71.03711, + 'C': 103.00919, + 'D': 115.02694, + 'E': 129.04259, + 'F': 147.06841, + 'G': 57.02146, + 'H': 137.05891, + 'I': 113.08406, + 'K': 128.09496, + 'L': 113.04049, + 'M': 131.04049, + 'N': 114.04293, + 'P': 97.05276, + 'Q': 128.05858, + 'R': 156.10111, + 'S': 87.03203, + 'T': 101.04768, + 'V': 99.06841, + 'W': 186.07931, + 'Y': 163.06333, + 'Z': 0} +amino_acid_abr = {'Ala': 'A', + 'Cys': 'C', + 'Asp': 'D', + 'Glu': 'E', + 'Phe': 'F', + 'Gly': 'G', + 'His': 'H', + 'Ile': 'I', + 'Lys': 'K', + 'Leu': 'L', + 'Met': 'M', + 'Asn': 'N', + 'Pro': 'P', + 'Gln': 'Q', + 'Arg': 'R', + 'Ser': 'S', + 'Thr': 'T', + 'Val': 'V', + 'Trp': 'W', + 'Tyr': 'Y', + '---': 'Z'} diff --git a/projetsysteme/components.py b/projetsysteme/components.py index ed4fa17..5f36327 100644 --- a/projetsysteme/components.py +++ b/projetsysteme/components.py @@ -55,6 +55,7 @@ def __init__(self, *args, **kwargs): self.btn_comp_inv_adn.clicked.connect(self.action_comp_inv_adn) self.btn_taux_gc_adn.clicked.connect(self.action_taux_gc_adn) self.btn_freq_codons_adn.clicked.connect(self.action_freq_codons_adn) + self.btn_masse_proteique.clicked.connect(self.action_masse_proteique) def action_creer_adn(self): @@ -103,6 +104,11 @@ def action_freq_codons_adn(self): DNA.taux_codons() MainLayout._instance.output_codon_frequency.setText(str(DNA.codon_frequency)) + def action_masse_proteique(self): + DNA.masse() + MainLayout._instance.output_protein_mass.setText(str(DNA.protein_mass)) + pass + def setupButtons(self): # setup buttons list self.buttons = [ @@ -140,7 +146,8 @@ def __init__(self, *args, **kwargs): ('Proteine','protein_chain',chain_width), ('Comp Inv','dna_complement',chain_width), ('Taux GC','taux_gc',4), - ('Fréquence Codons','codon_frequency',4) + ('Fréquence Codons','codon_frequency',40), + ('Masse Protéique','protein_mass',10) ] for element in elements: label = QLabel(element[0]) diff --git a/projetsysteme/dna.py b/projetsysteme/dna.py index d5fb190..497b3cc 100644 --- a/projetsysteme/dna.py +++ b/projetsysteme/dna.py @@ -11,6 +11,7 @@ class DNA(): dna_complement = "" gc_rate = 0 codon_frequency=0 + protein_mass = 0 @@ -21,7 +22,6 @@ def generate_dna(cls,length: int): for i in range(0,length): ADN+='ACGT'[randint(0,3)] cls.dna_chain = ADN - return cls.dna_chain @classmethod def translate_to_rna(cls): @@ -76,6 +76,28 @@ def taux_codons(cls): if index+3 < len(rna) and RNA_to_acido_dic[rna[index:index+3]] != "---": freq= freq+1 cls.codon_frequency = freq + + @classmethod + def masse(cls): + from .acid_mass import amino_acid_abr, mass_amino_acid + if (len(cls.protein_chain)>0): + index = 0 + l = [] + while index <= len(cls.protein_chain)-1: + if(len(cls.protein_chain[index:index+3]) == 3): + l.append(amino_acid_abr[cls.protein_chain[index:index+3]]) + + index += 3 + prot_abr = "" + for ele in l: + prot_abr += ele + mass = 0 + for x in prot_abr: + mass+=mass_amino_acid[x] + cls.protein_mass = mass + # print(cls.MASSE) + # else: + # cls.show_popup("vous devez creer le Proteine") diff --git a/projetsysteme/test.py b/projetsysteme/test.py index 42c86ff..54f85e8 100644 --- a/projetsysteme/test.py +++ b/projetsysteme/test.py @@ -12,12 +12,8 @@ from PyQt5 import QtCore, QtGui, QtWidgets from PyQt5.QtWidgets import QMessageBox,QInputDialog, QLineEdit ,QPushButton from random import randint -N=0 -DNA='' -RNA='' -PROT='' -DNA_COMP='' -GC=0 + + RNA_to_acido_dic = {'UUU': 'Phe', 'UCU': 'Ser', 'UAU': 'Tyr', @@ -82,8 +78,60 @@ 'GCG': 'Ala', 'GAG': 'Glu', 'GGG': 'Gly'} +mass_amino_acid = {'A': 71.03711, + 'C': 103.00919, + 'D': 115.02694, + 'E': 129.04259, + 'F': 147.06841, + 'G': 57.02146, + 'H': 137.05891, + 'I': 113.08406, + 'K': 128.09496, + 'L': 113.04049, + 'M': 131.04049, + 'N': 114.04293, + 'P': 97.05276, + 'Q': 128.05858, + 'R': 156.10111, + 'S': 87.03203, + 'T': 101.04768, + 'V': 99.06841, + 'W': 186.07931, + 'Y': 163.06333, + 'Z': 0} +amino_acid_abr = {'Ala': 'A', + 'Cys': 'C', + 'Asp': 'D', + 'Glu': 'E', + 'Phe': 'F', + 'Gly': 'G', + 'His': 'H', + 'Ile': 'I', + 'Lys': 'K', + 'Leu': 'L', + 'Met': 'M', + 'Asn': 'N', + 'Pro': 'P', + 'Gln': 'Q', + 'Arg': 'R', + 'Ser': 'S', + 'Thr': 'T', + 'Val': 'V', + 'Trp': 'W', + 'Tyr': 'Y', + '---': 'Z'} class Ui_MainWindow(object): + + N=0 + GC=0 + MASSE=0 + DNA='' + RNA='' + PROT='' + PROT_abr='' + DNA_COMP='' + def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(750, 700) @@ -119,6 +167,11 @@ def setupUi(self, MainWindow): self.gc_label.setObjectName("gc_label") self.gc_label.setFont(font) + self.masse_label = QtWidgets.QLabel(self.centralwidget) + self.masse_label.setGeometry(QtCore.QRect(210, 290, 500, 41)) + self.masse_label.setObjectName("masse_label") + self.masse_label.setFont(font) + self.textEdit = QtWidgets.QTextEdit(self.centralwidget) self.textEdit.setEnabled(False) self.textEdit.setGeometry(QtCore.QRect(280, 10, 450, 41)) @@ -240,8 +293,6 @@ def setupUi(self, MainWindow): self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) - - def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) @@ -251,27 +302,31 @@ def retranslateUi(self, MainWindow): self.prot_label.setText(_translate("MainWindow", "Protein")) self.dna_comp_label.setText(_translate("MainWindow", "Comp inv")) self.gc_label.setText(_translate("MainWindow","")) + self.masse_label.setText(_translate("MainWindow","")) self.bt_dna.clicked.connect(self.show_dialog) self.bt_dna.setText(_translate("MainWindow", "Créer ADN")) - self.bt_dna_to_rna.clicked.connect(lambda: self.translate_to_rna(DNA)) + self.bt_dna_to_rna.clicked.connect(lambda: self.translate_to_rna(self.DNA)) self.bt_dna_to_rna.setText(_translate("MainWindow", "ADN vers ARN")) - self.bt_rna_to_prot.clicked.connect(lambda: self.rna_to_prot(RNA)) + self.bt_rna_to_prot.clicked.connect(lambda: self.rna_to_prot(self.RNA)) self.bt_rna_to_prot.setText(_translate("MainWindow", "ARN vers PROTEIN")) - self.bt_comp_inv_adn.clicked.connect(lambda: self.dna_complement(DNA)) + self.bt_comp_inv_adn.clicked.connect(lambda: self.dna_complement(self.DNA)) self.bt_comp_inv_adn.setText(_translate("MainWindow", "COMP INV ADN")) - self.bt_taux_gc_adn.clicked.connect(lambda: self.gc_taux(DNA)) + self.bt_taux_gc_adn.clicked.connect(lambda: self.gc_taux(self.DNA)) self.bt_taux_gc_adn.setText(_translate("MainWindow", "Taux GC ADN")) self.bt_freq_codons_adn.setText(_translate("MainWindow", "Fréq codons ADN")) self.bt_mutation.setText(_translate("MainWindow", "Mutation")) self.bt_motif_adn.setText(_translate("MainWindow", "Chercher motif ADN")) self.bt_adn_cons_profil.setText(_translate("MainWindow", "ADN consensus + profil")) + + self.bt_masse_prot.clicked.connect(lambda: self.masse(self.PROT)) self.bt_masse_prot.setText(_translate("MainWindow", "Masse protéique")) + self.bt_epis_arn.setText(_translate("MainWindow", "Epissage d\'ARN")) self.textEdit.setLineWrapColumnOrWidth(214748) @@ -295,83 +350,113 @@ def retranslateUi(self, MainWindow): self.actionNew.setShortcut(_translate("MainWindow", "Ctrl+N")) def create_dna(self,n): - ADN='' + self.DNA='' for i in range(1,n+1): - ADN+='ACGT'[randint(0,3)] - self.textEdit.setText(ADN) + self.DNA+='ACGT'[randint(0,3)] + self.textEdit.setText(self.DNA) self.textEdit.setEnabled(True) - DNA=ADN - print(DNA) + print(self.DNA) - def show_popup(self): + def show_popup(self,str): msg = QMessageBox() - msg.setWindowTitle("create dna") - msg.setText("Vous devez donner un nombre positif") + msg.setWindowTitle("Error") + msg.setText(str) msg.setIcon(QMessageBox.Critical) x=msg.exec_() def show_dialog(self): - n , result = QInputDialog.getInt(self.centralwidget, "Input Dialog", "Entrer la longueur:") + n , result = QInputDialog.getInt(self.centralwidget, "Input Dialog", "Entrer la longueur:",min=1) if result: if n>0: - N=n + self.N=n self.create_dna(n) - print(DNA) - print(N) + print(self.DNA) + print(self.N) else: - self.show_popup() + self.show_popup("Vous devez donner un nombre positif") def translate_to_rna(self, dna_chain): - rna = self.textEdit.toPlainText() - # rna=dna_chain - rna = rna.replace("T", "U") - RNA=rna - self.textEdit_2.setText(rna) - self.textEdit_2.setEnabled(True) - print(RNA) + self.RNA = self.textEdit.toPlainText() + # self.RNA=dna_chain + if (len(self.RNA)==0): + self.show_popup("vous devez creer la chaine adn") + else: + self.RNA = self.RNA.replace("T", "U") + self.RNA=self.RNA + self.textEdit_2.setText(self.RNA) + self.textEdit_2.setEnabled(True) + print(self.RNA) def rna_to_prot(self,rna): - rna = self.textEdit_2.toPlainText() - index = 0 - l = [] - while index <= len(rna)-1: - if(len(rna[index:index+3]) == 3): - l.append(RNA_to_acido_dic[rna[index:index+3]]) - - index += 3 - prot='' - print(l) - for ele in l: - prot += ele+' ' - PROT=prot - self.textEdit_3.setText(prot) - self.textEdit_3.setEnabled(True) - print(PROT) + self.RNA = self.textEdit_2.toPlainText() + if (len(self.RNA)==0): + self.show_popup("vous devez creer la chaine arn") + else: + index = 0 + l = [] + while index <= len(self.RNA)-1: + if(len(self.RNA[index:index+3]) == 3): + l.append(RNA_to_acido_dic[self.RNA[index:index+3]]) + + index += 3 + prot='' + print(l) + for ele in l: + prot += ele+' ' + for ele in l: + self.PROT += ele + self.textEdit_3.setText(prot) + self.textEdit_3.setEnabled(True) + print(self.PROT) def dna_complement(self, adn): - adn = self.textEdit.toPlainText() - dna_comp='' - for i in range(len(adn)): - if adn[i] == 'A': - dna_comp += 'T' - elif adn[i] == 'T': - dna_comp += 'A' - elif adn[i] == 'C': - dna_comp += 'G' - elif adn[i] == 'G': - dna_comp += 'C' - dna_comp=dna_comp[::-1] - DNA_COMP=dna_comp - self.textEdit_4.setText(dna_comp) - self.textEdit_4.setEnabled(True) - print(DNA_COMP) + self.DNA = self.textEdit.toPlainText() + if (len(self.DNA)==0): + self.show_popup("vous devez creer la chaine ADN") + else: + for i in range(len(self.DNA)): + if self.DNA[i] == 'A': + self.DNA_COMP += 'T' + elif self.DNA[i] == 'T': + self.DNA_COMP += 'A' + elif self.DNA[i] == 'C': + self.DNA_COMP += 'G' + elif self.DNA[i] == 'G': + self.DNA_COMP += 'C' + self.DNA_COMP=self.DNA_COMP[::-1] + self.textEdit_4.setText(self.DNA_COMP) + self.textEdit_4.setEnabled(True) + print(self.DNA_COMP) def gc_taux(self,adn): - adn = self.textEdit.toPlainText() - gc= int((adn.count("C")+adn.count("G")) / len(adn) * 100) - self.gc_label.setText("le taux de GC est: "+str(gc)+"%") - GC=gc - print(GC) + self.DNA = self.textEdit.toPlainText() + if (len(self.DNA)==0): + self.show_popup("vous devez creer la chaine ADN") + else: + gc= int((self.DNA.count("C")+self.DNA.count("G")) / len(self.DNA) * 100) + self.gc_label.setText("le taux de GC est: "+str(gc)+"%") + self.GC=gc + print(self.GC) + + def masse(self,prot): + if (len(self.PROT)>0): + index = 0 + l = [] + while index <= len(self.PROT)-1: + if(len(self.PROT[index:index+3]) == 3): + l.append(amino_acid_abr[self.PROT[index:index+3]]) + + index += 3 + print(l) + for ele in l: + self.PROT_abr += ele + print(self.PROT_abr) + for x in self.PROT_abr: + self.MASSE+=mass_amino_acid[x] + self.masse_label.setText("La masse proteique est : "+str(self.MASSE)) + print(self.MASSE) + else: + self.show_popup("vous devez creer le Proteine") if __name__ == "__main__": import sys diff --git a/test.txt b/test.txt deleted file mode 100644 index e69de29..0000000 diff --git a/test2.py b/test2.py deleted file mode 100644 index 54f85e8..0000000 --- a/test2.py +++ /dev/null @@ -1,469 +0,0 @@ -# -*- coding: utf-8 -*- - -# Form implementation generated from reading ui file 'first.ui' -# -# Created by: PyQt5 UI code generator 5.15.2 -# -# WARNING: Any manual changes made to this file will be lost when pyuic5 is -# run again. Do not edit this file unless you know what you are doing. - - -from main import dna_complement -from PyQt5 import QtCore, QtGui, QtWidgets -from PyQt5.QtWidgets import QMessageBox,QInputDialog, QLineEdit ,QPushButton -from random import randint - - -RNA_to_acido_dic = {'UUU': 'Phe', - 'UCU': 'Ser', - 'UAU': 'Tyr', - 'UGU': 'Cys', - 'UUC': 'Phe', - 'UCC': 'Ser', - 'UAC': 'Tyr', - 'UGC': 'Cys', - 'UUA': 'Leu', - 'UCA': 'Ser', - 'UAA': '---', - 'UGA': '---', - 'UUG': 'Leu', - 'UCG': 'Ser', - 'UAG': '---', - 'UGG': 'Trp', - 'CUU': 'Leu', - 'CCU': 'Pro', - 'CAU': 'His', - 'CGU': 'Arg', - 'CUC': 'Leu', - 'CCC': 'Pro', - 'CAC': 'His', - 'CGC': 'Arg', - 'CUA': 'Leu', - 'CCA': 'Pro', - 'CAA': 'Gln', - 'CGA': 'Arg', - 'CUG': 'Leu', - 'CCG': 'Pro', - 'CAG': 'Gln', - 'CGG': 'Arg', - 'AUU': 'Ile', - 'ACU': 'Thr', - 'AAU': 'Asn', - 'AGU': 'Ser', - 'AUC': 'Ile', - 'ACC': 'Thr', - 'AAC': 'Asn', - 'AGC': 'Ser', - 'AUA': 'Ile', - 'ACA': 'Thr', - 'AAA': 'Lys', - 'AGA': 'Arg', - 'AUG': 'Met', - 'ACG': 'Thr', - 'AAG': 'Lys', - 'AGG': 'Arg', - 'GUU': 'Val', - 'GCU': 'Ala', - 'GAU': 'Asp', - 'GGU': 'Gly', - 'GUC': 'Val', - 'GCC': 'Ala', - 'GAC': 'Asp', - 'GGC': 'Gly', - 'GUA': 'Val', - 'GCA': 'Ala', - 'GAA': 'Glu', - 'GGA': 'Gly', - 'GUG': 'Val', - 'GCG': 'Ala', - 'GAG': 'Glu', - 'GGG': 'Gly'} -mass_amino_acid = {'A': 71.03711, - 'C': 103.00919, - 'D': 115.02694, - 'E': 129.04259, - 'F': 147.06841, - 'G': 57.02146, - 'H': 137.05891, - 'I': 113.08406, - 'K': 128.09496, - 'L': 113.04049, - 'M': 131.04049, - 'N': 114.04293, - 'P': 97.05276, - 'Q': 128.05858, - 'R': 156.10111, - 'S': 87.03203, - 'T': 101.04768, - 'V': 99.06841, - 'W': 186.07931, - 'Y': 163.06333, - 'Z': 0} -amino_acid_abr = {'Ala': 'A', - 'Cys': 'C', - 'Asp': 'D', - 'Glu': 'E', - 'Phe': 'F', - 'Gly': 'G', - 'His': 'H', - 'Ile': 'I', - 'Lys': 'K', - 'Leu': 'L', - 'Met': 'M', - 'Asn': 'N', - 'Pro': 'P', - 'Gln': 'Q', - 'Arg': 'R', - 'Ser': 'S', - 'Thr': 'T', - 'Val': 'V', - 'Trp': 'W', - 'Tyr': 'Y', - '---': 'Z'} - -class Ui_MainWindow(object): - - N=0 - GC=0 - MASSE=0 - DNA='' - RNA='' - PROT='' - PROT_abr='' - DNA_COMP='' - - def setupUi(self, MainWindow): - MainWindow.setObjectName("MainWindow") - MainWindow.resize(750, 700) - self.centralwidget = QtWidgets.QWidget(MainWindow) - self.centralwidget.setObjectName("centralwidget") - - font = QtGui.QFont() - font.setFamily("Andalus") - font.setPointSize(12) - - self.dna_label = QtWidgets.QLabel(self.centralwidget) - self.dna_label.setGeometry(QtCore.QRect(210, 10, 70, 41)) - self.dna_label.setObjectName("dna_label") - self.dna_label.setFont(font) - - self.rna_label = QtWidgets.QLabel(self.centralwidget) - self.rna_label.setGeometry(QtCore.QRect(210, 65, 70, 41)) - self.rna_label.setObjectName("rna_label") - self.rna_label.setFont(font) - - self.prot_label = QtWidgets.QLabel(self.centralwidget) - self.prot_label.setGeometry(QtCore.QRect(210, 120, 70, 41)) - self.prot_label.setObjectName("prot_label") - self.prot_label.setFont(font) - - self.dna_comp_label = QtWidgets.QLabel(self.centralwidget) - self.dna_comp_label.setGeometry(QtCore.QRect(210, 180, 70, 41)) - self.dna_comp_label.setObjectName("dna_comp_label") - self.dna_comp_label.setFont(font) - - self.gc_label = QtWidgets.QLabel(self.centralwidget) - self.gc_label.setGeometry(QtCore.QRect(210, 240, 500, 41)) - self.gc_label.setObjectName("gc_label") - self.gc_label.setFont(font) - - self.masse_label = QtWidgets.QLabel(self.centralwidget) - self.masse_label.setGeometry(QtCore.QRect(210, 290, 500, 41)) - self.masse_label.setObjectName("masse_label") - self.masse_label.setFont(font) - - self.textEdit = QtWidgets.QTextEdit(self.centralwidget) - self.textEdit.setEnabled(False) - self.textEdit.setGeometry(QtCore.QRect(280, 10, 450, 41)) - self.textEdit.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.textEdit.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded) - self.textEdit.setObjectName("textEdit") - self.textEdit.setReadOnly(True) - - self.textEdit_2 = QtWidgets.QTextEdit(self.centralwidget) - self.textEdit_2.setEnabled(False) - self.textEdit_2.setGeometry(QtCore.QRect(280, 60, 450, 41)) - self.textEdit_2.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.textEdit_2.setObjectName("textEdit_2") - self.textEdit_2.setReadOnly(True) - - self.textEdit_3 = QtWidgets.QTextEdit(self.centralwidget) - self.textEdit_3.setEnabled(False) - self.textEdit_3.setGeometry(QtCore.QRect(280, 120, 450, 41)) - self.textEdit_3.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.textEdit_3.setObjectName("textEdit_3") - self.textEdit_3.setReadOnly(True) - - self.textEdit_4 = QtWidgets.QTextEdit(self.centralwidget) - self.textEdit_4.setEnabled(False) - self.textEdit_4.setGeometry(QtCore.QRect(280, 180, 450, 41)) - self.textEdit_4.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) - self.textEdit_4.setObjectName("textEdit_4") - self.textEdit_4.setReadOnly(True) - - self.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget) - self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 0, 190, 650)) - self.verticalLayoutWidget.setObjectName("verticalLayoutWidget") - self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget) - self.verticalLayout.setContentsMargins(0, 0, 0, 0) - self.verticalLayout.setObjectName("verticalLayout") - - self.bt_dna = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.bt_dna.setObjectName("bt_dna") - self.bt_dna.setFont(font) - self.verticalLayout.addWidget(self.bt_dna) - - self.bt_dna_to_rna = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.bt_dna_to_rna.setObjectName("bt_dna_to_rna") - self.bt_dna_to_rna.setFont(font) - self.verticalLayout.addWidget(self.bt_dna_to_rna) - - self.bt_rna_to_prot = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.bt_rna_to_prot.setObjectName("bt_rna_to_prot") - self.bt_rna_to_prot.setFont(font) - self.verticalLayout.addWidget(self.bt_rna_to_prot) - - self.bt_comp_inv_adn = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.bt_comp_inv_adn.setObjectName("bt_comp_inv_adn") - self.bt_comp_inv_adn.setFont(font) - self.verticalLayout.addWidget(self.bt_comp_inv_adn) - - self.bt_taux_gc_adn = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.bt_taux_gc_adn.setObjectName("bt_taux_gc_adn") - self.bt_taux_gc_adn.setFont(font) - self.verticalLayout.addWidget(self.bt_taux_gc_adn) - - self.bt_freq_codons_adn = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.bt_freq_codons_adn.setObjectName("bt_freq_codons_adn") - self.bt_freq_codons_adn.setFont(font) - self.verticalLayout.addWidget(self.bt_freq_codons_adn) - - self.bt_mutation = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.bt_mutation.setObjectName("bt_mutation") - self.bt_mutation.setFont(font) - self.verticalLayout.addWidget(self.bt_mutation) - - self.bt_motif_adn = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.bt_motif_adn.setObjectName("bt_motif_adn") - self.bt_motif_adn.setFont(font) - self.verticalLayout.addWidget(self.bt_motif_adn) - - self.bt_adn_cons_profil = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.bt_adn_cons_profil.setObjectName("bt_adn_cons_profil") - self.bt_adn_cons_profil.setFont(font) - self.verticalLayout.addWidget(self.bt_adn_cons_profil) - - self.bt_masse_prot = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.bt_masse_prot.setObjectName("bt_masse_prot") - self.bt_masse_prot.setFont(font) - self.verticalLayout.addWidget(self.bt_masse_prot) - - self.bt_epis_arn = QtWidgets.QPushButton(self.verticalLayoutWidget) - self.bt_epis_arn.setObjectName("bt_epis_arn") - self.bt_epis_arn.setFont(font) - self.verticalLayout.addWidget(self.bt_epis_arn) - - MainWindow.setCentralWidget(self.centralwidget) - self.menubar = QtWidgets.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 575, 21)) - self.menubar.setObjectName("menubar") - self.menuFile = QtWidgets.QMenu(self.menubar) - self.menuFile.setObjectName("menuFile") - self.menuEdit = QtWidgets.QMenu(self.menubar) - self.menuEdit.setObjectName("menuEdit") - MainWindow.setMenuBar(self.menubar) - self.statusbar = QtWidgets.QStatusBar(MainWindow) - self.statusbar.setObjectName("statusbar") - MainWindow.setStatusBar(self.statusbar) - self.actionImport_fasta_file = QtWidgets.QAction(MainWindow) - self.actionImport_fasta_file.setObjectName("actionImport_fasta_file") - self.actionSave = QtWidgets.QAction(MainWindow) - self.actionSave.setObjectName("actionSave") - self.actionCopier = QtWidgets.QAction(MainWindow) - self.actionCopier.setObjectName("actionCopier") - self.actionNew = QtWidgets.QAction(MainWindow) - self.actionNew.setObjectName("actionNew") - self.menuFile.addAction(self.actionNew) - self.menuFile.addAction(self.actionImport_fasta_file) - self.menuFile.addAction(self.actionSave) - self.menuEdit.addAction(self.actionCopier) - self.menubar.addAction(self.menuFile.menuAction()) - self.menubar.addAction(self.menuEdit.menuAction()) - - self.retranslateUi(MainWindow) - QtCore.QMetaObject.connectSlotsByName(MainWindow) - - def retranslateUi(self, MainWindow): - _translate = QtCore.QCoreApplication.translate - MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) - - self.dna_label.setText(_translate("MainWindow", "ADN")) - self.rna_label.setText(_translate("MainWindow", "ARN")) - self.prot_label.setText(_translate("MainWindow", "Protein")) - self.dna_comp_label.setText(_translate("MainWindow", "Comp inv")) - self.gc_label.setText(_translate("MainWindow","")) - self.masse_label.setText(_translate("MainWindow","")) - - self.bt_dna.clicked.connect(self.show_dialog) - self.bt_dna.setText(_translate("MainWindow", "Créer ADN")) - - self.bt_dna_to_rna.clicked.connect(lambda: self.translate_to_rna(self.DNA)) - self.bt_dna_to_rna.setText(_translate("MainWindow", "ADN vers ARN")) - - self.bt_rna_to_prot.clicked.connect(lambda: self.rna_to_prot(self.RNA)) - self.bt_rna_to_prot.setText(_translate("MainWindow", "ARN vers PROTEIN")) - - self.bt_comp_inv_adn.clicked.connect(lambda: self.dna_complement(self.DNA)) - self.bt_comp_inv_adn.setText(_translate("MainWindow", "COMP INV ADN")) - - self.bt_taux_gc_adn.clicked.connect(lambda: self.gc_taux(self.DNA)) - self.bt_taux_gc_adn.setText(_translate("MainWindow", "Taux GC ADN")) - - self.bt_freq_codons_adn.setText(_translate("MainWindow", "Fréq codons ADN")) - self.bt_mutation.setText(_translate("MainWindow", "Mutation")) - self.bt_motif_adn.setText(_translate("MainWindow", "Chercher motif ADN")) - self.bt_adn_cons_profil.setText(_translate("MainWindow", "ADN consensus + profil")) - - self.bt_masse_prot.clicked.connect(lambda: self.masse(self.PROT)) - self.bt_masse_prot.setText(_translate("MainWindow", "Masse protéique")) - - self.bt_epis_arn.setText(_translate("MainWindow", "Epissage d\'ARN")) - - self.textEdit.setLineWrapColumnOrWidth(214748) - self.textEdit.setLineWrapMode(self.textEdit.FixedPixelWidth) - self.textEdit_2.setLineWrapColumnOrWidth(214748) - self.textEdit_2.setLineWrapMode(self.textEdit.FixedPixelWidth) - self.textEdit_3.setLineWrapColumnOrWidth(214748) - self.textEdit_3.setLineWrapMode(self.textEdit.FixedPixelWidth) - self.textEdit_4.setLineWrapColumnOrWidth(214748) - self.textEdit_4.setLineWrapMode(self.textEdit.FixedPixelWidth) - - self.menuFile.setTitle(_translate("MainWindow", "File")) - self.menuEdit.setTitle(_translate("MainWindow", "Editer")) - self.actionImport_fasta_file.setText(_translate("MainWindow", "Import fasta file")) - self.actionImport_fasta_file.setShortcut(_translate("MainWindow", "Ctrl+I")) - self.actionSave.setText(_translate("MainWindow", "Save")) - self.actionSave.setShortcut(_translate("MainWindow", "Ctrl+S")) - self.actionCopier.setText(_translate("MainWindow", "Copier")) - self.actionCopier.setShortcut(_translate("MainWindow", "Ctrl+C")) - self.actionNew.setText(_translate("MainWindow", "New")) - self.actionNew.setShortcut(_translate("MainWindow", "Ctrl+N")) - - def create_dna(self,n): - self.DNA='' - for i in range(1,n+1): - self.DNA+='ACGT'[randint(0,3)] - self.textEdit.setText(self.DNA) - self.textEdit.setEnabled(True) - print(self.DNA) - - def show_popup(self,str): - msg = QMessageBox() - msg.setWindowTitle("Error") - msg.setText(str) - msg.setIcon(QMessageBox.Critical) - x=msg.exec_() - - def show_dialog(self): - n , result = QInputDialog.getInt(self.centralwidget, "Input Dialog", "Entrer la longueur:",min=1) - if result: - if n>0: - self.N=n - self.create_dna(n) - print(self.DNA) - print(self.N) - else: - self.show_popup("Vous devez donner un nombre positif") - - def translate_to_rna(self, dna_chain): - self.RNA = self.textEdit.toPlainText() - # self.RNA=dna_chain - if (len(self.RNA)==0): - self.show_popup("vous devez creer la chaine adn") - else: - self.RNA = self.RNA.replace("T", "U") - self.RNA=self.RNA - self.textEdit_2.setText(self.RNA) - self.textEdit_2.setEnabled(True) - print(self.RNA) - - def rna_to_prot(self,rna): - self.RNA = self.textEdit_2.toPlainText() - if (len(self.RNA)==0): - self.show_popup("vous devez creer la chaine arn") - else: - index = 0 - l = [] - while index <= len(self.RNA)-1: - if(len(self.RNA[index:index+3]) == 3): - l.append(RNA_to_acido_dic[self.RNA[index:index+3]]) - - index += 3 - prot='' - print(l) - for ele in l: - prot += ele+' ' - for ele in l: - self.PROT += ele - self.textEdit_3.setText(prot) - self.textEdit_3.setEnabled(True) - print(self.PROT) - - def dna_complement(self, adn): - self.DNA = self.textEdit.toPlainText() - if (len(self.DNA)==0): - self.show_popup("vous devez creer la chaine ADN") - else: - for i in range(len(self.DNA)): - if self.DNA[i] == 'A': - self.DNA_COMP += 'T' - elif self.DNA[i] == 'T': - self.DNA_COMP += 'A' - elif self.DNA[i] == 'C': - self.DNA_COMP += 'G' - elif self.DNA[i] == 'G': - self.DNA_COMP += 'C' - self.DNA_COMP=self.DNA_COMP[::-1] - self.textEdit_4.setText(self.DNA_COMP) - self.textEdit_4.setEnabled(True) - print(self.DNA_COMP) - - def gc_taux(self,adn): - self.DNA = self.textEdit.toPlainText() - if (len(self.DNA)==0): - self.show_popup("vous devez creer la chaine ADN") - else: - gc= int((self.DNA.count("C")+self.DNA.count("G")) / len(self.DNA) * 100) - self.gc_label.setText("le taux de GC est: "+str(gc)+"%") - self.GC=gc - print(self.GC) - - def masse(self,prot): - if (len(self.PROT)>0): - index = 0 - l = [] - while index <= len(self.PROT)-1: - if(len(self.PROT[index:index+3]) == 3): - l.append(amino_acid_abr[self.PROT[index:index+3]]) - - index += 3 - print(l) - for ele in l: - self.PROT_abr += ele - print(self.PROT_abr) - for x in self.PROT_abr: - self.MASSE+=mass_amino_acid[x] - self.masse_label.setText("La masse proteique est : "+str(self.MASSE)) - print(self.MASSE) - else: - self.show_popup("vous devez creer le Proteine") - -if __name__ == "__main__": - import sys - app = QtWidgets.QApplication(sys.argv) - MainWindow = QtWidgets.QMainWindow() - ui = Ui_MainWindow() - ui.setupUi(MainWindow) - MainWindow.show() - sys.exit(app.exec_()) -