diff --git a/projetsysteme/__pycache__/components.cpython-38.pyc b/projetsysteme/__pycache__/components.cpython-38.pyc index 8da2796..6e3e109 100644 Binary files a/projetsysteme/__pycache__/components.cpython-38.pyc and b/projetsysteme/__pycache__/components.cpython-38.pyc differ diff --git a/projetsysteme/__pycache__/dna.cpython-38.pyc b/projetsysteme/__pycache__/dna.cpython-38.pyc index 69ac418..a753154 100644 Binary files a/projetsysteme/__pycache__/dna.cpython-38.pyc and b/projetsysteme/__pycache__/dna.cpython-38.pyc differ diff --git a/projetsysteme/components.py b/projetsysteme/components.py index b179e56..ed4fa17 100644 --- a/projetsysteme/components.py +++ b/projetsysteme/components.py @@ -54,6 +54,7 @@ def __init__(self, *args, **kwargs): self.btn_arn_vers_proteine.clicked.connect(self.action_arn_vers_proteine) 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) def action_creer_adn(self): @@ -71,22 +72,36 @@ def action_creer_adn(self): x=msg.exec_() def action_adn_vers_arn(self): + if DNA.dna_chain == "": + return DNA.translate_to_rna() MainLayout._instance.output_rna_chain.setText(DNA.rna_chain) + def action_arn_vers_proteine(self): + if DNA.rna_chain == "": + return DNA.rna_to_prot() MainLayout._instance.output_protein_chain.setText(DNA.protein_chain) def action_comp_inv_adn(self): + if DNA.dna_chain == "": + return DNA.get_dna_complement() MainLayout._instance.output_dna_complement.setText(DNA.dna_complement) def action_taux_gc_adn(self): + if DNA.dna_chain == "": + return DNA.taux_gc() - MainLayout._instance.output_taux_gc.setText(DNA.gc_rate) - + MainLayout._instance.output_taux_gc.setText(str(DNA.gc_rate)+'%') + + def action_freq_codons_adn(self): + if DNA.dna_chain == "": + return + DNA.taux_codons() + MainLayout._instance.output_codon_frequency.setText(str(DNA.codon_frequency)) def setupButtons(self): # setup buttons list @@ -118,13 +133,14 @@ def __init__(self, *args, **kwargs): return None super().__init__(*args,**kwargs) MainLayout._instance = self - + chain_width = 50 elements = [ - ('ADN','dna_chain'), - ('ARN','rna_chain'), - ('Proteine','protein_chain'), - ('Comp Inv','dna_complement'), - ('Taux GC','taux_gc') + ('ADN','dna_chain',chain_width), + ('ARN','rna_chain',chain_width), + ('Proteine','protein_chain',chain_width), + ('Comp Inv','dna_complement',chain_width), + ('Taux GC','taux_gc',4), + ('Fréquence Codons','codon_frequency',4) ] for element in elements: label = QLabel(element[0]) @@ -134,7 +150,7 @@ def __init__(self, *args, **kwargs): textEdit.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff) textEdit.setLineWrapMode(QTextEdit.NoWrap) singleWidth = textEdit.fontMetrics().boundingRect('A').width() - textEdit.setFixedWidth(singleWidth*50) + textEdit.setFixedWidth(singleWidth*element[2]) setattr(self,'label_'+element[1], label) diff --git a/projetsysteme/dna.py b/projetsysteme/dna.py index 9f264d2..d5fb190 100644 --- a/projetsysteme/dna.py +++ b/projetsysteme/dna.py @@ -1,4 +1,3 @@ - from random import randint class DNA(): @@ -6,11 +5,12 @@ class DNA(): # and setters for these static variables - _dna_chain= "" - _rna_chain = "" - _protein_chain = "" - _dna_complement = "" - _gc_rate = 0 + dna_chain= "" + rna_chain = "" + protein_chain = "" + dna_complement = "" + gc_rate = 0 + codon_frequency=0 @@ -65,10 +65,22 @@ def taux_gc(cls): gc= int((adn.count("C")+adn.count("G")) / len(adn) * 100) cls.gc_rate=gc - # @classmethod - # def taux_codons() + @classmethod + def taux_codons(cls): + if cls.rna_chain == "": + cls.translate_to_rna() + from .rna_to_acid import RNA_to_acido_dic + rna = cls.rna_chain + freq = 0 + for index in range(0,len(rna),3): + if index+3 < len(rna) and RNA_to_acido_dic[rna[index:index+3]] != "---": + freq= freq+1 + cls.codon_frequency = freq + -# DNA.generate_dna(15) -# DNA.translate_to_rna() -# print(DNA.rna_chain) +# DNA.generate_dna(31) +# DNA.taux_codons() +# DNA.rna_to_prot() +# print(DNA.protein_chain) +# print(DNA.codon_frequency) diff --git a/projetsysteme/style.css b/projetsysteme/style.css index 19b843a..1952fa6 100644 --- a/projetsysteme/style.css +++ b/projetsysteme/style.css @@ -669,7 +669,7 @@ QTextEdit { background-color: #19232D; color: #F0F0F0; border-radius: 4px; - border: 1px solid #32414B; + border: 1px solid #5c778a; max-height: 1rem; }