Skip to content

Commit

Permalink
complete remodeling of the Application with dna generation working on…
Browse files Browse the repository at this point in the history
… the UI all

all other features working under the hood
  • Loading branch information
adelbke committed Mar 18, 2021
1 parent fa824da commit 0cea9f8
Show file tree
Hide file tree
Showing 9 changed files with 298 additions and 62 deletions.
Binary file modified projetsysteme/__pycache__/components.cpython-38.pyc
Binary file not shown.
Binary file added projetsysteme/__pycache__/dna.cpython-38.pyc
Binary file not shown.
Binary file modified projetsysteme/__pycache__/main.cpython-38.pyc
Binary file not shown.
Binary file modified projetsysteme/__pycache__/views.cpython-38.pyc
Binary file not shown.
83 changes: 75 additions & 8 deletions projetsysteme/components.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from PyQt5.QtWidgets import QMainWindow, QHBoxLayout, QWidget, QToolBar, QPushButton
from PyQt5.QtWidgets import QFormLayout, QInputDialog, QLabel, QMainWindow, QHBoxLayout, QMessageBox, QTextEdit, QVBoxLayout, QWidget, QToolBar, QPushButton
# from PyQt5.QtCore import Qt

from .dna import DNA

class AbstractWindow(QMainWindow):
def __init__(self, parent=None):
"""Initializer."""
super().__init__()
# self.setMinimumWidth(1500)

def setupSidebarLayout(self,sidebarLayout, mainLayout):
def setupMainLayout(self,sidebarLayout, mainLayout):
layout = QHBoxLayout()
left = QWidget()
left.setLayout(sidebarLayout)
Expand All @@ -23,15 +27,78 @@ def setupSidebarLayout(self,sidebarLayout, mainLayout):
self.setCentralWidget(self.centralwidget)
self.centralwidget.setLayout(layout)

def setMenuItems(self):
self.menu_fichier = self.menuBar().addMenu("Fichier")
self.menu_edit = self.menuBar().addMenu("Edit")


class SidebarLayout(QVBoxLayout):
def __init__(self, *args, **kwargs):
super().__init__(*args,**kwargs)
self.setupButtons()


self.btn_creer_adn.clicked.connect(self.action_creer_adn)

def action_creer_adn(self):
n,result = QInputDialog.getInt(QWidget(), "Input Dialog", "Entrer la longueur:",0,0)
if result:
if n>0:
N=n
DNA.generate_dna(N)
print(self.parentWidget().window().mainLayout.output_ADN.setText(DNA.dna_chain))
else:
msg = QMessageBox()
msg.setWindowTitle("create dna")
msg.setText("Vous devez donner un nombre positif")
msg.setIcon(QMessageBox.Critical)
x=msg.exec_()

def setupButtons(self):
# setup buttons list
self.buttons = [
('Créer ADN','creer_adn'),
('ADN vers ARN','adn_vers_arn'),
('ARN vers Proteine','arn_vers_proteine'),
('Comp INV ADN','comp_inv_adn'),
('taux GC ADN','taux_gc_adn'),
('fréq codons ADN','freq_codons_adn'),
('Mutation','mutation'),
('Chercher Motif ADN','chercher_motif_adn'),
('ADN Consensus + profil','adn_consensus_profil'),
('Masse Proteïque','masse_proteique'),
('Epissage d\'ADN','epissage_adn'),
]
# create and assign buttons
for btn in self.buttons:
setattr(self,'btn_' + btn[1],QPushButton(btn[0]))
self.addWidget(getattr(self,'btn_' + btn[1]))
self.addStretch()

# automatizing setting the ToolBar for the app
def setToolBar(self, menuItems):
tools = QToolBar()
self.addToolBar(tools)
for item in menuItems :
tools.addWidget(item)


class MainLayout(QFormLayout):
def __init__(self, *args, **kwargs):
super().__init__(*args,**kwargs)

elements = [
('ADN','dna_chain'),
('ARN','rna_chain'),
('Proteine','protein_chain'),
('Comp Inv','dna_complement')
]
for element in elements:
label = QLabel(element[0])
textEdit = QTextEdit()
textEdit.setReadOnly(True)

setattr(self,'label_'+element[0], label)
setattr(self,'output_'+element[0],textEdit)
self.addRow(getattr(self,'label_'+element[0]),getattr(self,'output_'+element[0]))




class QPrimaryButton(QPushButton):
def __init__(self, *args, **kwargs):
super().__init__(*args,**kwargs)
Expand Down
117 changes: 109 additions & 8 deletions projetsysteme/dna.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,113 @@


from random import randint
class DNA():
chain= ""

# read from fasta file
def __init__(self, path: str):
pass

# this metaclass is here to implement getters
# and setters for these static variables

class __metaclass__():
@property
def dna_chain(cls):
return cls._dna_chain

@dna_chain.setter
def dna_chain(cls, value):
cls._dna_chain = value

@property
def rna_chain(cls):
return cls._rna_chain

@rna_chain.setter
def rna_chain(cls, value):
cls._rna_chain = value

@property
def protein_chain(cls):
return cls._protein_chain

@protein_chain.setter
def protein_chain(cls, value):
cls._protein_chain = value

@property
def dna_complement(cls):
return cls._dna_complement

@dna_complement.setter
def dna_complement(cls, value):
cls._dna_complement = value

@property
def gc_rate(cls):
return cls._gc_rate

@gc_rate.setter
def gc_rate(cls, value):
cls._gc_rate = value

_dna_chain= ""
_rna_chain = ""
_protein_chain = ""
_dna_complement = ""
_gc_rate = 0



# generate DNA Sequence from length
def __init__(slef, length: int):
pass
@classmethod
def generate_dna(cls,length: int):
ADN = ''
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):
cls.rna_chain = cls.dna_chain.replace("T", "U")

@classmethod
def rna_to_prot(cls):
from .rna_to_acid import RNA_to_acido_dic
rna = cls.rna_chain
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+' '
cls.protein_chain = prot

@classmethod
def get_dna_complement(cls):
adn = cls.dna_chain
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]

cls.dna_complement = dna_comp

@classmethod
def taux_gc(cls):
adn = cls.dna_chain
gc= int((adn.count("C")+adn.count("G")) / len(adn) * 100)
cls.gc_rate=gc


DNA.generate_dna(15)
DNA.translate_to_rna()
print(DNA.rna_chain)
65 changes: 65 additions & 0 deletions projetsysteme/rna_to_acid.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@

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'}
Loading

0 comments on commit 0cea9f8

Please sign in to comment.