Skip to content

Commit

Permalink
added codon frequency functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
adelbke committed Mar 18, 2021
1 parent ef632d6 commit 23ecf22
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 21 deletions.
Binary file modified projetsysteme/__pycache__/components.cpython-38.pyc
Binary file not shown.
Binary file modified projetsysteme/__pycache__/dna.cpython-38.pyc
Binary file not shown.
34 changes: 25 additions & 9 deletions projetsysteme/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand Down Expand Up @@ -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])
Expand All @@ -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)
Expand Down
34 changes: 23 additions & 11 deletions projetsysteme/dna.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@

from random import randint
class DNA():

# this metaclass is here to implement getters
# 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



Expand Down Expand Up @@ -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)
2 changes: 1 addition & 1 deletion projetsysteme/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ QTextEdit {
background-color: #19232D;
color: #F0F0F0;
border-radius: 4px;
border: 1px solid #32414B;
border: 1px solid #5c778a;
max-height: 1rem;
}

Expand Down

0 comments on commit 23ecf22

Please sign in to comment.