def on_button_melt(self): if execBash('xdotool search --name meltviewer').decode() == '': proc = subprocess.Popen( ['python3m', '/home/kablag/private/workspace/snpick/meltviewer.py'], stdout=subprocess.PIPE ) time.sleep(1) mtask = MTask(self.seqEdit.text()) mtask.execute(M_CONDS) # self.connection.send(mtask) plots = [{'action': 'add_graph', 'a': mpot.a, 'b': mpot.b, 'length': mpot.length_of_a, 'gc%': mpot.gc_of_a, 't10': mpot.t10, 't90': mpot.t90, 'mpoints': mpot.mpoints_as_XY, 'color': 'rnd', 'marker': 'rnd', } for mpot in mtask.melting_pots] messages = [yaml.dump({'plots':[plot]}) for plot in plots] self.connect_to_meltviewer() self.iface.sendPlot(messages[0])
def onLoadButtonClicked(self): filename, filter = QtGui.QFileDialog.getOpenFileName( self, 'Load project', '/home/kablag/Документы/snpick') if filename != '': with open(filename, 'r') as f: dump = yaml.load(f.read()) M_CONDS.fromYAML(dump['conditions']) self.name.setText(dump['name']) self.seqInput.setText(dump['task']) self.probeMin.setText(dump['probeMin']) self.probeMax.setText(dump['probeMax']) self.mtask = MTask(dump['task'], dump) self.add_data_to_tabs()
def onCalcProbesClicked(self): mtask = '{sequence}{min_p}->{max_p}'.format( sequence=self.seqInput.text(), min_p=self.probeMin.text(), max_p=self.probeMax.text(), ) self.mtask = MTask(mtask) self.seqInput.setText(self.mtask.task) self.mtask.meltingPotDone.connect(self.on_mpot_done) self.pd = QtGui.QProgressDialog('Melting probes', 'Cancel', 0, len(self.mtask.melting_pots)) self.pd.setWindowModality(QtCore.Qt.WindowModal) self.calcProbes.setEnabled(False) self.pd.canceled.connect(self.cancel_melting) self.mtask.execute(M_CONDS) self.calcProbes.setEnabled(True) self.add_data_to_tabs()
def onLoadButtonClicked(self): filename, filter = QtGui.QFileDialog.getOpenFileName(self, 'Load project', '/home/kablag/Документы/snpick') if filename != '': with open(filename, 'r') as f: dump = yaml.load(f.read()) M_CONDS.fromYAML(dump['conditions']) self.name.setText(dump['name']) self.seqInput.setText(dump['task']) self.probeMin.setText(dump['probeMin']) self.probeMax.setText(dump['probeMax']) self.mtask = MTask(dump['task'], dump) self.add_data_to_tabs()
class Snpick(QtGui.QWidget): def __init__(self): super(Snpick, self).__init__() self.mtask = None self.init_ui() def init_ui(self): self.name = QtGui.QLineEdit() self.name.setText('Name') self.seqInput = QtGui.QLineEdit() self.seqInput.setText( 'tcccctccaggccgtgcataaggctgtgctgaccatcgac(A>G)agaaagggactgaagctgctggggccatgtttttagaggc' ) self.probeMin = QtGui.QLineEdit() self.probeMin.setText('15') self.probeMax = QtGui.QLineEdit() self.probeMax.setText('17') self.calcProbes = QtGui.QPushButton(text='Calc') self.calcProbes.clicked.connect(self.onCalcProbesClicked) self.saveBtn = QtGui.QPushButton(text='Save') self.saveBtn.clicked.connect(self.onSaveButtonClicked) self.loadBtn = QtGui.QPushButton(text='Load') self.loadBtn.clicked.connect(self.onLoadButtonClicked) self.batchCalcBtn = QtGui.QPushButton(text='Batch Calc') self.batchCalcBtn.clicked.connect(self.onBatchButtonClicked) self.tabs = QtGui.QTabWidget() self.tab_A = FilterTab('A') self.tab_B = FilterTab('B') self.tab_Am = FilterTab('Am') self.tab_Bm = FilterTab('Bm') self.tabs.addTab(self.tab_A, 'A') self.tabs.addTab(self.tab_B, 'B') self.tabs.addTab(self.tab_Am, 'Am') self.tabs.addTab(self.tab_Bm, 'Bm') vbox = QtGui.QVBoxLayout() vbox.addWidget(self.name) vbox.addWidget(self.seqInput) # vbox.addStretch(1) hbox = QtGui.QHBoxLayout() sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) self.probeMin.setSizePolicy(sizePolicy) hbox.addWidget(self.probeMin) self.probeMax.setSizePolicy(sizePolicy) hbox.addWidget(self.probeMax) self.calcProbes.setSizePolicy(sizePolicy) hbox.addWidget(self.calcProbes) hbox.addStretch(1) hbox.addWidget(self.saveBtn) hbox.addWidget(self.loadBtn) hbox.addStretch(1) hbox.addWidget(self.batchCalcBtn) hbox.addStretch(1) rangeInputs = QtGui.QWidget() rangeInputs.setLayout(hbox) vbox.addWidget(rangeInputs) vbox.addWidget(self.tabs) self.setLayout(vbox) self.setGeometry(300, 300, 1000, 600) self.show() def resizeEvent(self, event): self.tabs.setBaseSize(self.tabs.width(), event.size().height() * 0.8) def add_data_to_tabs(self): if not self.mtask.canceled: self.tab_A.addData(self.mtask) self.tab_B.addData(self.mtask) self.tab_Am.addData(self.mtask) self.tab_Bm.addData(self.mtask) def onCalcProbesClicked(self): mtask = '{sequence}{min_p}->{max_p}'.format( sequence=self.seqInput.text(), min_p=self.probeMin.text(), max_p=self.probeMax.text(), ) self.mtask = MTask(mtask) self.seqInput.setText(self.mtask.task) self.mtask.meltingPotDone.connect(self.on_mpot_done) self.pd = QtGui.QProgressDialog('Melting probes', 'Cancel', 0, len(self.mtask.melting_pots)) self.pd.setWindowModality(QtCore.Qt.WindowModal) self.calcProbes.setEnabled(False) self.pd.canceled.connect(self.cancel_melting) self.mtask.execute(M_CONDS) self.calcProbes.setEnabled(True) self.add_data_to_tabs() def onSaveButtonClicked(self, filename=''): filename, filter = filename, '' if filename != '' else QtGui.QFileDialog.getSaveFileName( self, 'Save project', PROJECTS_FOLDER + self.name.text()) if filename != '': with open(filename, 'w') as f: # print(yaml.dump(self.mtask.melting_pots), file=f) # pickle.dump(self.mtask, f) conditions = { 'unafold_path': M_CONDS.unafold_path, 'ram_disk': M_CONDS.ram_disk, 't_min': M_CONDS.t_min, 't_max': M_CONDS.t_max, 't_increment': M_CONDS.t_increment, 'a_conc': M_CONDS.a_conc, 'Na_conc': M_CONDS.Na_conc, 'Mg_conc': M_CONDS.Mg_conc, } mpots = [{ 'A': mpot.a, 'B': mpot.b, 'Am': mpot.am, 'Bm': mpot.bm, 'position': mpot.position, 't10_AB': mpot.t10_AB, 't10_ABm': mpot.t10_ABm, 't10_AmBm': mpot.t10_AmBm, 't10_AmB': mpot.t10_AmB, 't90_AB': mpot.t90_AB, 't90_ABm': mpot.t90_ABm, 't90_AmBm': mpot.t90_AmBm, 't90_AmB': mpot.t90_AmB, } for mpot in self.mtask.melting_pots] dump = { 'name': self.name.text(), 'task': self.mtask.task, 'probeMin': self.probeMin.text(), 'probeMax': self.probeMax.text(), 'conditions': conditions, 'mpots': mpots, } print(yaml.dump(dump), file=f) def onLoadButtonClicked(self): filename, filter = QtGui.QFileDialog.getOpenFileName( self, 'Load project', '/home/kablag/Документы/snpick') if filename != '': with open(filename, 'r') as f: dump = yaml.load(f.read()) M_CONDS.fromYAML(dump['conditions']) self.name.setText(dump['name']) self.seqInput.setText(dump['task']) self.probeMin.setText(dump['probeMin']) self.probeMax.setText(dump['probeMax']) self.mtask = MTask(dump['task'], dump) self.add_data_to_tabs() def onBatchButtonClicked(self): filename, filter = QtGui.QFileDialog.getOpenFileName( self, 'Load batch', PROJECTS_FOLDER) if filename != '': with open(filename, 'r') as f: tasks = f.readlines() for task in tasks: name, sequence = task.split('\t') self.name.setText(name) self.seqInput.setText(sequence) self.onCalcProbesClicked() self.onSaveButtonClicked(PROJECTS_FOLDER + name) @QtCore.Slot() def cancel_melting(self): self.pd.close() self.mtask.cancel() @QtCore.Slot(int) def on_mpot_done(self, value): self.pd.setValue(value)
class Snpick(QtGui.QWidget): def __init__(self): super(Snpick, self).__init__() self.mtask = None self.init_ui() def init_ui(self): self.name = QtGui.QLineEdit() self.name.setText('Name') self.seqInput = QtGui.QLineEdit() self.seqInput.setText('tcccctccaggccgtgcataaggctgtgctgaccatcgac(A>G)agaaagggactgaagctgctggggccatgtttttagaggc') self.probeMin = QtGui.QLineEdit() self.probeMin.setText('15') self.probeMax = QtGui.QLineEdit() self.probeMax.setText('17') self.calcProbes = QtGui.QPushButton(text='Calc') self.calcProbes.clicked.connect(self.onCalcProbesClicked) self.saveBtn = QtGui.QPushButton(text='Save') self.saveBtn.clicked.connect(self.onSaveButtonClicked) self.loadBtn = QtGui.QPushButton(text='Load') self.loadBtn.clicked.connect(self.onLoadButtonClicked) self.batchCalcBtn = QtGui.QPushButton(text='Batch Calc') self.batchCalcBtn.clicked.connect(self.onBatchButtonClicked) self.tabs = QtGui.QTabWidget() self.tab_A = FilterTab('A') self.tab_B = FilterTab('B') self.tab_Am = FilterTab('Am') self.tab_Bm = FilterTab('Bm') self.tabs.addTab(self.tab_A, 'A') self.tabs.addTab(self.tab_B, 'B') self.tabs.addTab(self.tab_Am, 'Am') self.tabs.addTab(self.tab_Bm, 'Bm') vbox = QtGui.QVBoxLayout() vbox.addWidget(self.name) vbox.addWidget(self.seqInput) # vbox.addStretch(1) hbox = QtGui.QHBoxLayout() sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Fixed, QtGui.QSizePolicy.Minimum) self.probeMin.setSizePolicy(sizePolicy) hbox.addWidget(self.probeMin) self.probeMax.setSizePolicy(sizePolicy) hbox.addWidget(self.probeMax) self.calcProbes.setSizePolicy(sizePolicy) hbox.addWidget(self.calcProbes) hbox.addStretch(1) hbox.addWidget(self.saveBtn) hbox.addWidget(self.loadBtn) hbox.addStretch(1) hbox.addWidget(self.batchCalcBtn) hbox.addStretch(1) rangeInputs = QtGui.QWidget() rangeInputs.setLayout(hbox) vbox.addWidget(rangeInputs) vbox.addWidget(self.tabs) self.setLayout(vbox) self.setGeometry(300, 300, 1000, 600) self.show() def resizeEvent(self, event): self.tabs.setBaseSize(self.tabs.width(), event.size().height() * 0.8) def add_data_to_tabs(self): if not self.mtask.canceled: self.tab_A.addData(self.mtask) self.tab_B.addData(self.mtask) self.tab_Am.addData(self.mtask) self.tab_Bm.addData(self.mtask) def onCalcProbesClicked(self): mtask = '{sequence}{min_p}->{max_p}'.format( sequence=self.seqInput.text(), min_p=self.probeMin.text(), max_p=self.probeMax.text(), ) self.mtask = MTask(mtask) self.seqInput.setText(self.mtask.task) self.mtask.meltingPotDone.connect(self.on_mpot_done) self.pd = QtGui.QProgressDialog('Melting probes', 'Cancel', 0, len(self.mtask.melting_pots)) self.pd.setWindowModality(QtCore.Qt.WindowModal) self.calcProbes.setEnabled(False) self.pd.canceled.connect(self.cancel_melting) self.mtask.execute(M_CONDS) self.calcProbes.setEnabled(True) self.add_data_to_tabs() def onSaveButtonClicked(self, filename=''): filename, filter = filename, '' if filename != '' else QtGui.QFileDialog.getSaveFileName(self, 'Save project', PROJECTS_FOLDER+self.name.text()) if filename != '': with open(filename, 'w') as f: # print(yaml.dump(self.mtask.melting_pots), file=f) # pickle.dump(self.mtask, f) conditions = {'unafold_path': M_CONDS.unafold_path, 'ram_disk': M_CONDS.ram_disk, 't_min': M_CONDS.t_min, 't_max': M_CONDS.t_max, 't_increment': M_CONDS.t_increment, 'a_conc': M_CONDS.a_conc, 'Na_conc': M_CONDS.Na_conc, 'Mg_conc': M_CONDS.Mg_conc,} mpots = [{'A':mpot.a, 'B':mpot.b, 'Am':mpot.am, 'Bm':mpot.bm, 'position':mpot.position, 't10_AB':mpot.t10_AB, 't10_ABm':mpot.t10_ABm, 't10_AmBm':mpot.t10_AmBm, 't10_AmB':mpot.t10_AmB, 't90_AB':mpot.t90_AB, 't90_ABm':mpot.t90_ABm, 't90_AmBm':mpot.t90_AmBm, 't90_AmB':mpot.t90_AmB,} for mpot in self.mtask.melting_pots] dump = {'name':self.name.text(), 'task':self.mtask.task, 'probeMin':self.probeMin.text(), 'probeMax':self.probeMax.text(), 'conditions': conditions, 'mpots': mpots,} print(yaml.dump(dump), file=f) def onLoadButtonClicked(self): filename, filter = QtGui.QFileDialog.getOpenFileName(self, 'Load project', '/home/kablag/Документы/snpick') if filename != '': with open(filename, 'r') as f: dump = yaml.load(f.read()) M_CONDS.fromYAML(dump['conditions']) self.name.setText(dump['name']) self.seqInput.setText(dump['task']) self.probeMin.setText(dump['probeMin']) self.probeMax.setText(dump['probeMax']) self.mtask = MTask(dump['task'], dump) self.add_data_to_tabs() def onBatchButtonClicked(self): filename, filter = QtGui.QFileDialog.getOpenFileName(self, 'Load batch', PROJECTS_FOLDER) if filename != '': with open(filename, 'r') as f: tasks = f.readlines() for task in tasks: name, sequence = task.split('\t') self.name.setText(name) self.seqInput.setText(sequence) self.onCalcProbesClicked() self.onSaveButtonClicked(PROJECTS_FOLDER + name) @QtCore.Slot() def cancel_melting(self): self.pd.close() self.mtask.cancel() @QtCore.Slot(int) def on_mpot_done(self, value): self.pd.setValue(value)