From fa824dae7508c46b6ec16fc9cc71f27fd782bdd0 Mon Sep 17 00:00:00 2001 From: Quickinline Date: Wed, 17 Mar 2021 22:28:43 +0100 Subject: [PATCH] few modifications --- .vscode/settings.json | 3 +- .../__pycache__/components.cpython-38.pyc | Bin 1680 -> 1675 bytes projetsysteme/components.py | 3 +- projetsysteme/main.py | 5 + projetsysteme/test.py | 489 +++++++++++++----- 5 files changed, 375 insertions(+), 125 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index df63951..36ec34e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "python.linting.pylintEnabled": false, "python.linting.enabled": true, - "python.linting.banditEnabled": true + "python.linting.banditEnabled": false, + "python.linting.flake8Enabled": true } \ No newline at end of file diff --git a/projetsysteme/__pycache__/components.cpython-38.pyc b/projetsysteme/__pycache__/components.cpython-38.pyc index 1792658c1c8198b1b423888faa3e74885c4cd5db..3a606a77fbb7a56427b0002473ca75badac94d9e 100644 GIT binary patch delta 166 zcmbQh+s(@x%FD~e00edxK?zwKdF_~Z85c4!GSo0HU`b(0VV)epq{+hKSHw8Ei|HIA z)8t6z4o0ELkC<&4WhN`IM6rnjwH8TEZeX!w6xqCsg^Q6vFS1@005#k9Q*(P delta 152 zcmeC?oxsZ*%FD~e00b?E0unMe^4c-+GA(3cWT;_Yz>>n8!ZJC6Nt2V+uZR(-oA@0kV@Fxc~qF diff --git a/projetsysteme/components.py b/projetsysteme/components.py index ba5324f..3fa8332 100644 --- a/projetsysteme/components.py +++ b/projetsysteme/components.py @@ -15,7 +15,8 @@ def setupSidebarLayout(self,sidebarLayout, mainLayout): layout.addWidget(left) layout.addWidget(right) - layout.setStretch(0, 3) + + layout.setStretch(0, 0) layout.setStretch(1, 7) self.centralwidget = QWidget() diff --git a/projetsysteme/main.py b/projetsysteme/main.py index 33d96ae..2d4f59e 100644 --- a/projetsysteme/main.py +++ b/projetsysteme/main.py @@ -9,6 +9,11 @@ from .views import Window +# féquence codons AND +# Mutation +# ADN Consensus + profil +# Epissage ARN + def main(): """RP Contacts main function.""" # Create the application diff --git a/projetsysteme/test.py b/projetsysteme/test.py index 1bec7a6..744038a 100644 --- a/projetsysteme/test.py +++ b/projetsysteme/test.py @@ -1,123 +1,366 @@ -from PyQt5.QtWidgets import QApplication, QMainWindow, QPushButton, QBoxLayout, QVBoxLayout, QHBoxLayout, QWidget, QTabWidget, QLabel -import sys - - -class Window(QMainWindow): - def __init__(self): - super().__init__() - - # set the title of main window - self.setWindowTitle('Sidebar layout - www.luochang.ink') - - # set the size of window - self.Width = 800 - self.height = int(0.618 * self.Width) - self.resize(self.Width, self.height) - - # add all widgets - self.btn_1 = QPushButton('1', self) - self.btn_2 = QPushButton('2', self) - self.btn_3 = QPushButton('3', self) - self.btn_4 = QPushButton('4', self) - - self.btn_1.clicked.connect(self.button1) - self.btn_2.clicked.connect(self.button2) - self.btn_3.clicked.connect(self.button3) - self.btn_4.clicked.connect(self.button4) - - # add tabs - self.tab1 = self.ui1() - self.tab2 = self.ui2() - self.tab3 = self.ui3() - self.tab4 = self.ui4() - - self.initUI() - - def initUI(self): - left_layout = QVBoxLayout() - left_layout.addWidget(self.btn_1) - left_layout.addWidget(self.btn_2) - left_layout.addWidget(self.btn_3) - left_layout.addWidget(self.btn_4) - left_layout.addStretch(5) - left_layout.setSpacing(20) - left_widget = QWidget() - left_widget.setLayout(left_layout) - - self.right_widget = QTabWidget() - self.right_widget.tabBar().setObjectName("mainTab") - - self.right_widget.addTab(self.tab1, '') - self.right_widget.addTab(self.tab2, '') - self.right_widget.addTab(self.tab3, '') - self.right_widget.addTab(self.tab4, '') - - self.right_widget.setCurrentIndex(0) - self.right_widget.setStyleSheet('''QTabBar::tab{width: 0; \ - height: 0; margin: 0; padding: 0; border: none;}''') - - main_layout = QHBoxLayout() - main_layout.addWidget(left_widget) - main_layout.addWidget(self.right_widget) - main_layout.setStretch(0, 40) - main_layout.setStretch(1, 200) - main_widget = QWidget() - main_widget.setLayout(main_layout) - self.setCentralWidget(main_widget) - - # ----------------- - # buttons - - def button1(self): - self.right_widget.setCurrentIndex(0) - - def button2(self): - self.right_widget.setCurrentIndex(1) - - def button3(self): - self.right_widget.setCurrentIndex(2) - - def button4(self): - self.right_widget.setCurrentIndex(3) - - # ----------------- - # pages - - def ui1(self): - main_layout = QVBoxLayout() - main_layout.addWidget(QLabel('page 1')) - main_layout.addStretch(5) - main = QWidget() - main.setLayout(main_layout) - return main - - def ui2(self): - main_layout = QVBoxLayout() - main_layout.addWidget(QLabel('page 2')) - main_layout.addStretch(5) - main = QWidget() - main.setLayout(main_layout) - return main - - def ui3(self): - main_layout = QVBoxLayout() - main_layout.addWidget(QLabel('page 3')) - main_layout.addStretch(5) - main = QWidget() - main.setLayout(main_layout) - return main - - def ui4(self): - main_layout = QVBoxLayout() - main_layout.addWidget(QLabel('page 4')) - main_layout.addStretch(5) - main = QWidget() - main.setLayout(main_layout) - return main - - -if __name__ == '__main__': - app = QApplication(sys.argv) - ex = Window() - ex.show() - sys.exit(app.exec_()) \ No newline at end of file +# -*- 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 +N=0 +DNA='' +RNA='' +PROT='' +DNA_COMP='' +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'} + +class Ui_MainWindow(object): + def setupUi(self, MainWindow): + MainWindow.setObjectName("MainWindow") + MainWindow.resize(750, 600) + 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.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_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_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_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.verticalLayoutWidget = QtWidgets.QWidget(self.centralwidget) + self.verticalLayoutWidget.setGeometry(QtCore.QRect(10, 10, 190, 550)) + 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.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.setText(_translate("MainWindow", "ADN vers ARN")) + + self.bt_rna_to_prot.clicked.connect(lambda: self.rna_to_prot(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.setText(_translate("MainWindow", "COMP INV ADN")) + + 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.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 show_dialog(self): + n , result = QInputDialog.getInt(self.centralwidget, "Input Dialog", "Entrer la longueur:") + if result: + if n>0: + N=n + ADN='' + # beginning + for i in range(1,n+1): + ADN+='ACGT'[randint(0,3)] + # return ADN + self.textEdit.setText(ADN) + self.textEdit.setEnabled(True) + DNA=ADN + print(DNA) + print(N) + else: + msg = QMessageBox() + msg.setWindowTitle("Erreur du nombre") + msg.setText("Vous devez maitre un nombre positif") + msg.setIcon(QMessageBox.Critical) + x=msg.exec_() + + def translate_to_rna(self, dna_chain): + rna = self.textEdit.toPlainText() + # rna=dna_chain + rna = rna.replace("T", "U") + RNA=rna + # return rna + self.textEdit_2.setText(rna) + self.textEdit_2.setEnabled(True) + print(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 + # return prot + self.textEdit_3.setText(prot) + self.textEdit_3.setEnabled(True) + print(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 + # return dna_comp + self.textEdit_4.setText(dna_comp) + self.textEdit_4.setEnabled(True) + print(DNA_COMP) + + + +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_()) +