""" Copyright (C) 2010-2012 Victor Khangulov - Johns Hopkins University
This file is part of Primer Design Tool.
Primer Design Tool is a free software: you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>
Title: Primer Design Tool GUI
File: dialog.py
Description:
This file is the GUI for the Primer Design Tool.
This file contains the following classes:
MutEntry - Object for user added mutation.
BaseDialog - Class for the base dialog. The constructor allows
user to specify a variable number of section (or frames)
StdDialog - This is a class for the dialog with Quit, Next and
Back button. It inherits from the BaseDialog
SeqDialog - This is a sequence dialog (window #1). In this
dialog, the user is required to enter their initials,
date and select background ID. If the background is not
available, the user can add a new background by loading
a new DNA sequence. Next, user is able to add current
mutations and new mutations.
PrimerDialog- Primer dialog (Window #2). Display starting primer
with new mutations and an overhang. Display DNA
sequence 30 bp up and downstream of the starting primer.
Do some simple calculations about Tm, #bp, GC content,
residues covered. Allow user to choose alternate codons
for the mutations that were specified, and allow them to
enter additional bp on either side of the primer.
Usage: execute PrimerDesigner.py file to run program
Website: https://sourceforge.net/apps/mediawiki/primer-design/index.php?title=Main_Page
Created: 2010.Nov.04 VK
Repository path: $HeadURL$
Last committed: $Revision$
Last changed by: $Author$
Last changed date: $Date$
ID: $Id$
"""
# Import python standard modules
import sys, os
# Import modules
try:
from Tkinter import *
import FileDialog, tkMessageBox, Dialog, tkFileDialog
except ImportError:
print "TK required!"
sys.exit()
from tkModule import *
from utils import *
from PrimerDesigner import Mutation
from datetime import datetime
from string import *
from math import ceil
class AutoScrollbar(Scrollbar):
# a scrollbar that hides itself if it's not needed. only
# works if you use the grid geometry manager.
def set(self, lo, hi):
if float(lo) <= 0.0 and float(hi) >= 1.0:
# grid_remove is currently missing from Tkinter!
self.tk.call("grid", "remove", self)
else:
self.grid()
Scrollbar.set(self, lo, hi)
def pack(self, **kw):
raise TclError, "cannot use pack with this widget"
def place(self, **kw):
raise TclError, "cannot use place with this widget"
class MutEntry:
""" Class to create object each time the user adds another mutation. """
def __init__(self, master, mut_id):
""" Initialize mutation entry. This will create a separate frame
for each mutation and the required entry boxes."""
# Create the entry box for the mutation
self.frame = Frame(master)
self.label = StandardLabel(self.frame, \
label_text="Mutation #%d:"%mut_id)
self.res1 = EntryBox(self.frame,entry_type=str, tag="res1-%d"%mut_id,\
entry_width=1, allow_blank=True)
self.res1.config(width=2)
self.pos = EntryBox(self.frame, entry_type=int,tag="res_pos-%d"%mut_id,\
entry_width=3, allow_blank=True)
self.pos.config(width=4)
self.res2 = EntryBox(self.frame, entry_type=str, tag="res2-%d"%mut_id,\
entry_width=1,allow_blank=True)
self.res2.config(width=2)
self.label.grid(row=0,column=0,sticky=W)
self.res1.grid(row=0,column=1,sticky=W)
self.pos.grid(row=0,column=2,sticky=W)
self.res2.grid(row=0,column=3,sticky=W)
self.frame.pack()
def get_mutation(self):
""" Return a list containing the mutation. For now, just add a place-
holder 'XXX' for the new codon and for the old codon """
# If index had not been entered, then set it to some arbitrary number
if self.pos.get() == None: index = None
else: index = int(self.pos.get())
return [str(self.res1.get()).upper(),index,\
str(self.res2.get()).upper(), "XXX", "XXX"]
class BaseDialog(object):
""" Class for the base dialog. The constructor allows user to specify a
variable number of section (or frames) """
def __init__(self, master, nframes=1):
"""
Constructor. User can set the optional nframes argumet to set
the number of frames to be pre-created.
"""
self.master = master
vscrollbar = AutoScrollbar(master)
vscrollbar.grid(row=0, column=1, sticky=N+S)
hscrollbar = AutoScrollbar(master, orient=HORIZONTAL)
hscrollbar.grid(row=1, column=0, sticky=E+W)
self.canvas = Canvas(master,
yscrollcommand=vscrollbar.set,
xscrollcommand=hscrollbar.set)
self.canvas.grid(row=0, column=0, sticky=N+S+E+W)
vscrollbar.config(command=self.canvas.yview)
hscrollbar.config(command=self.canvas.xview)
# make the canvas expandable
master.grid_rowconfigure(0, weight=1)
master.grid_columnconfigure(0, weight=1)
#
# create canvas contents
self.mframe = Frame(self.canvas, border=5)
self.mframe.grid(row=0, column=0)
self.mframe.rowconfigure(0, weight=1)
self.mframe.columnconfigure(0, weight=1)
self.frames = []
# Create frames
j = 0
for i in range(nframes):
self.frames.append(Frame(self.mframe, border=5))
self.frames[i].grid(row=j,column=0,sticky=EW)
self.frames[i].columnconfigure(0, weight=1)
j += 1
self.div = Divider(self.mframe,arrangement="h")
self.div.grid(row=j,column=0,sticky=EW)
j += 1
# Bottom button pane
self.bpane = Frame(self.mframe, border=5)
self.bpane.grid(row=j,column=0,sticky=EW)
self.bpane.columnconfigure(0, weight=1)
self.bpane.columnconfigure(1, weight=1)
self.bpane.columnconfigure(2, weight=1)
#rows = 5
#for i in range(0,rows):
# for j in range(0,10):
# button = Button(self.bpane, padx=7, pady=7, text="[%d,%d]" % (i,j))
# button.grid(row=i, column=j, sticky='news')
def update_canvas(self):
Primer Design Tool:引物PCR设计-开源
68 浏览量
2021-04-28
22:35:33
上传
评论
收藏 43KB GZ 举报
Mika.w
- 粉丝: 32
- 资源: 4591
最新资源
- c语言对对碰游戏源码.zip
- 新录音.m4a
- shufflenet模型-基于人工智能的卷积网络训练识别中药饮片-不含数据集图片-含逐行注释和说明文档.zip
- resnet模型-基于图像分类算法对7种水果识别-不含数据集图片-含逐行注释和说明文档.zip
- JMeter使用教程.md
- JMeter使用教程.md
- mobilenet模型-基于图像分类算法对农作物病害部位识别-不含数据集图片-含逐行注释和说明文档.zip
- 【资源免费分享】MP4文件自动分轨工具(内附使用录像介绍)
- densenet模型-基于人工智能的卷积网络训练识别人行为-不含数据集图片-含逐行注释和说明文档.zip
- JMeter使用教程.md
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
评论0