diff --git a/Scripts/GenBank/check_output.py b/Scripts/GenBank/check_output.py index d2f62af3cf3..3560d773e09 100644 --- a/Scripts/GenBank/check_output.py +++ b/Scripts/GenBank/check_output.py @@ -48,7 +48,7 @@ def do_comparison(good_record, test_record): def write_format(file): - record_parser = GenBank.RecordParser(debug_level = 2) + record_parser = GenBank.RecordParser(debug_level=2) print "Testing GenBank writing for %s..." % os.path.basename(file) # be able to handle gzipped files diff --git a/Scripts/GenBank/check_output_simple.py b/Scripts/GenBank/check_output_simple.py index dd5a3066b56..dbc93edeaef 100644 --- a/Scripts/GenBank/check_output_simple.py +++ b/Scripts/GenBank/check_output_simple.py @@ -19,7 +19,7 @@ print "Usage ./check_output.py " sys.exit() -parser = GenBank.FeatureParser(debug_level = 2) +parser = GenBank.FeatureParser(debug_level=2) handle = open(sys.argv[1], 'r') diff --git a/Scripts/GenBank/find_parser_problems.py b/Scripts/GenBank/find_parser_problems.py index 66c3df6fc2e..3a40e136b2b 100644 --- a/Scripts/GenBank/find_parser_problems.py +++ b/Scripts/GenBank/find_parser_problems.py @@ -19,11 +19,11 @@ print "Usage ./find_parser_problems " sys.exit() -feature_parser = GenBank.FeatureParser(debug_level = 0) +feature_parser = GenBank.FeatureParser(debug_level=0) parser = GenBank.ErrorParser(feature_parser) handle = open(sys.argv[1], 'r') -iterator = GenBank.Iterator(handle, parser, has_header = 1) +iterator = GenBank.Iterator(handle, parser, has_header=1) while 1: have_record = 0 diff --git a/Scripts/PDB/generate_three_to_one_dict.py b/Scripts/PDB/generate_three_to_one_dict.py index 2f1edb725f4..a70a34f53ef 100644 --- a/Scripts/PDB/generate_three_to_one_dict.py +++ b/Scripts/PDB/generate_three_to_one_dict.py @@ -71,7 +71,7 @@ one = line.strip().split()[-1] found_one = True if line.startswith('_chem_comp.three_letter_code'): - three = '%-3s' % (line.strip().split()[-1],) # make it three-letter + three = '%-3s' % (line.strip().split()[-1],) # make it three-letter found_three = True if found_one and found_three: @@ -96,7 +96,7 @@ line = fh.readline() if len(current_line) < 5: - three_to_one_buf[-1] = three_to_one_buf[:-1] # remove the last comma + three_to_one_buf[-1] = three_to_one_buf[:-1] # remove the last comma three_to_one_buf.append('}') else: three_to_one_buf.append('%s }' % (current_line[:-1])) diff --git a/Scripts/Performance/biosql_performance_load.py b/Scripts/Performance/biosql_performance_load.py index b6bfb4ba5a4..97f6179df5c 100644 --- a/Scripts/Performance/biosql_performance_load.py +++ b/Scripts/Performance/biosql_performance_load.py @@ -5,8 +5,8 @@ # set up the connection from Bio import GenBank from BioSQL import BioSeqDatabase -server = BioSeqDatabase.open_database(host = "192.168.0.192", user = "root", - passwd = "", db = "pythonloadtest") +server = BioSeqDatabase.open_database(host="192.168.0.192", user="root", + passwd="", db="pythonloadtest") # remove the database if it already exists db_name = "testload" diff --git a/Scripts/Performance/biosql_performance_read.py b/Scripts/Performance/biosql_performance_read.py index ad1bd3fd800..ac7947621af 100644 --- a/Scripts/Performance/biosql_performance_read.py +++ b/Scripts/Performance/biosql_performance_read.py @@ -4,8 +4,8 @@ import time # set up the connection from BioSQL import BioSeqDatabase -server = BioSeqDatabase.open_database(host = "192.168.0.192", user = "root", - passwd = "", db = "test_biosql") +server = BioSeqDatabase.open_database(host="192.168.0.192", user="root", + passwd="", db="test_biosql") db = server["embl_rod"] # -- do the fasta-only timing part diff --git a/Scripts/Restriction/ranacompiler.py b/Scripts/Restriction/ranacompiler.py index dcb901d9b35..690e632e29d 100755 --- a/Scripts/Restriction/ranacompiler.py +++ b/Scripts/Restriction/ranacompiler.py @@ -12,7 +12,7 @@ from Bio.Restriction._Update.RestrictionCompiler import DictionaryBuilder -def standalone() : +def standalone(): parser = optparse.OptionParser() add = parser.add_option @@ -37,12 +37,12 @@ def standalone() : options, args = parser.parse_args() return options, args -if __name__ == '__main__' : +if __name__ == '__main__': options, args = standalone() Builder = DictionaryBuilder(options.rebase_password, options.ftp_proxy) Builder.build_dict() - if options.i : + if options.i: Builder.install_dict() - else : + else: Builder.no_install() sys.exit() diff --git a/Scripts/Restriction/rebase_update.py b/Scripts/Restriction/rebase_update.py index 4c646eecb1c..b81b170736b 100755 --- a/Scripts/Restriction/rebase_update.py +++ b/Scripts/Restriction/rebase_update.py @@ -11,7 +11,7 @@ import optparse from Bio.Restriction._Update.Update import * -if __name__ == '__main__' : +if __name__ == '__main__': parser = optparse.OptionParser() add = parser.add_option diff --git a/Scripts/query_pubmed.py b/Scripts/query_pubmed.py index 40eaa2b5e7b..752825855dd 100755 --- a/Scripts/query_pubmed.py +++ b/Scripts/query_pubmed.py @@ -52,7 +52,7 @@ def print_usage(): if count_only: handle = Entrez.esearch(db="pubmed", term=query) - else : + else: handle = Entrez.esearch(db="pubmed", term=query, usehistory="Y") search_results = Entrez.read(handle) ids = search_results["IdList"] @@ -65,7 +65,7 @@ def print_usage(): webenv = search_results["WebEnv"] query_key = search_results["QueryKey"] batch_size = 3 - for start in range(0, count, batch_size) : + for start in range(0, count, batch_size): end = min(count, start + batch_size) #print "Going to download record %i to %i" % (start+1, end) fetch_handle = Entrez.efetch(db="pubmed", rettype="medline", diff --git a/Scripts/scop_pdb.py b/Scripts/scop_pdb.py index 905d0e47c3a..42081c8c0e2 100755 --- a/Scripts/scop_pdb.py +++ b/Scripts/scop_pdb.py @@ -113,7 +113,7 @@ def main(): sids = args[2:] elif input == '-': sids = sys.stdin.xreadlines() - else : + else: in_handle = open(input) sids = in_handle.xreadlines() diff --git a/Scripts/xbbtools/nextorf.py b/Scripts/xbbtools/nextorf.py index a4f8a9954fb..d1dd7d1cb00 100755 --- a/Scripts/xbbtools/nextorf.py +++ b/Scripts/xbbtools/nextorf.py @@ -80,7 +80,7 @@ def ReadFile(self): CDS.extend(self.GetCDS(self.seq)) if minus: self.rseq = self.seq.reverse_complement() - CDS.extend(self.GetCDS(self.rseq, strand = -1)) + CDS.extend(self.GetCDS(self.rseq, strand=-1)) self.Output(CDS) def ToFasta(self, header, seq): @@ -98,7 +98,7 @@ def Gc(self, seq): def Gc2(self, seq): l = len(seq) - d= {} + d = {} for nt in ['A', 'T', 'G', 'C']: d[nt] = [0, 0, 0] @@ -150,7 +150,7 @@ def GetOrfCoordinates(self, seq): frame_coordinates.append(coordinates) return frame_coordinates - def GetCDS(self, seq, strand = 1): + def GetCDS(self, seq, strand=1): frame_coordinates = self.GetOrfCoordinates(seq) START, STOP = 1, 0 so = self.options @@ -180,7 +180,7 @@ def GetCDS(self, seq, strand = 1): start_site = start_site + f - 1 if codon == 'XXX': stop = start_site + 3*((int((stop-1)-start_site)/3)) - s = seq[start_site -1 : stop] + s = seq[start_site-1:stop] CDS.append((start_site, stop, length, s, strand*f)) start_site = 0 if nostart == '1': diff --git a/Scripts/xbbtools/xbb_blast.py b/Scripts/xbbtools/xbb_blast.py index bf1773754f5..4d63a52eb2c 100644 --- a/Scripts/xbbtools/xbb_blast.py +++ b/Scripts/xbbtools/xbb_blast.py @@ -18,7 +18,7 @@ class BlastIt: - def __init__(self, seq, parent = None): + def __init__(self, seq, parent=None): self.seq = seq self.parent = parent self.toplevel = Toplevel(parent) @@ -46,29 +46,29 @@ def GetBlasts(self): def Choices(self): self.GetBlasts() self.cf = Frame(self.toplevel) - self.cf.pack(side = TOP, expand = 1, fill = X) + self.cf.pack(side=TOP, expand=1, fill=X) self.dbs = Pmw.ComboBox(self.cf, - label_text = 'Blast Databases:', - labelpos = 'nw', - scrolledlist_items = self.nin + self.pin, - selectioncommand = self.Validate + label_text='Blast Databases:', + labelpos='nw', + scrolledlist_items=self.nin + self.pin, + selectioncommand=self.Validate ) self.blasts = Pmw.ComboBox(self.cf, - label_text = 'Blast Programs:', - labelpos = 'nw', - scrolledlist_items = ['blastn', 'blastp', 'blastx', 'tblastn', 'tblastx'], - selectioncommand = self.Validate + label_text='Blast Programs:', + labelpos='nw', + scrolledlist_items=['blastn', 'blastp', 'blastx', 'tblastn', 'tblastx'], + selectioncommand=self.Validate ) - self.dbs.pack(side = LEFT, expand = 1, fill = X) - self.blasts.pack(side = LEFT, expand = 1, fill = X) + self.dbs.pack(side=LEFT, expand=1, fill=X) + self.blasts.pack(side=LEFT, expand=1, fill=X) self.alternative_f = Frame(self.cf) self.alternative = Entry(self.alternative_f) - self.alternative_f.pack(side = TOP, fill = X, expand = 1) - self.alternative.pack(side = LEFT, fill = X, expand = 1) - self.ok = Button(self.alternative_f, text = 'Run', - command = self._Run) - self.ok.pack(side = RIGHT) + self.alternative_f.pack(side=TOP, fill=X, expand=1) + self.alternative.pack(side=LEFT, fill=X, expand=1) + self.ok = Button(self.alternative_f, text='Run', + command=self._Run) + self.ok.pack(side=RIGHT) self.dbs.selectitem(0) self.blasts.selectitem(0) @@ -83,8 +83,8 @@ def Validate(self, *args): elif (prog in ['blastp', 'blastx']) == (db in self.pin): color = 'green' - self.dbs.component('entry').configure(bg = color) - self.blasts.component('entry').configure(bg = color) + self.dbs.component('entry').configure(bg=color) + self.blasts.component('entry').configure(bg=color) def _Run(self): alternative_command = self.alternative.get() diff --git a/Scripts/xbbtools/xbb_blastbg.py b/Scripts/xbbtools/xbb_blastbg.py index 6149245e1e5..0e633fb103e 100644 --- a/Scripts/xbbtools/xbb_blastbg.py +++ b/Scripts/xbbtools/xbb_blastbg.py @@ -18,7 +18,7 @@ class BlastDisplayer: - def __init__(self, command, text_id = None): + def __init__(self, command, text_id=None): self.command = command self.tid = text_id diff --git a/Scripts/xbbtools/xbb_help.py b/Scripts/xbbtools/xbb_help.py index c19529511e3..e22b0feead5 100644 --- a/Scripts/xbbtools/xbb_help.py +++ b/Scripts/xbbtools/xbb_help.py @@ -12,20 +12,20 @@ class xbbtools_help(Toplevel): def __init__(self, *args): Toplevel.__init__(self) self.tid = ScrolledText(self) - self.tid.pack(fill = BOTH, expand = 1) + self.tid.pack(fill=BOTH, expand=1) self.Styles() self.Show() def Styles(self): for c in ['red', 'blue', 'magenta', 'yellow', 'green', 'red4', 'green4', 'blue4']: - self.tid.tag_configure(c, foreground = c) + self.tid.tag_configure(c, foreground=c) - self.tid.tag_config('underline', underline =1) - self.tid.tag_config('italic', font = ('Courier', 6, 'italic')) - self.tid.tag_config('bold', font = ('Courier', 8, 'bold')) - self.tid.tag_config('title', font = ('Courier', 12, 'bold')) - self.tid.tag_config('small', font = ('Courier', 6, '')) - self.tid.tag_config('highlight', background = 'gray') + self.tid.tag_config('underline', underline=1) + self.tid.tag_config('italic', font=('Courier', 6, 'italic')) + self.tid.tag_config('bold', font=('Courier', 8, 'bold')) + self.tid.tag_config('title', font=('Courier', 12, 'bold')) + self.tid.tag_config('small', font=('Courier', 6, '')) + self.tid.tag_config('highlight', background='gray') def Show(self): t = self.tid diff --git a/Scripts/xbbtools/xbb_search.py b/Scripts/xbbtools/xbb_search.py index 1560bfd3da8..bf7dda0d81e 100644 --- a/Scripts/xbbtools/xbb_search.py +++ b/Scripts/xbbtools/xbb_search.py @@ -51,11 +51,11 @@ def IUPAC2regex(self, s): rx += r return rx - def _Search(self, start = 0): + def _Search(self, start=0): pos = self.rx.search(self.sequence, start) return pos - def Search(self, start = 0): + def Search(self, start=0): pos = self.rx.search(self.sequence, start) if pos: return pos.start() @@ -78,7 +78,7 @@ def SearchAll(self): class XDNAsearch(Toplevel, DNAsearch): - def __init__(self, seq= '', master= None, highlight = 0): + def __init__(self, seq='', master=None, highlight=0): DNAsearch.__init__(self) self.master = master self.highlight = highlight @@ -90,28 +90,28 @@ def __init__(self, seq= '', master= None, highlight = 0): def init_graphics(self): Toplevel.__init__(self, self.master) self.frame = Frame(self) - self.frame.pack(fill = BOTH, expand = 1) + self.frame.pack(fill=BOTH, expand=1) self.search_entry = Entry(self.frame) - self.search_entry.pack(fill = BOTH, expand = 1) + self.search_entry.pack(fill=BOTH, expand=1) f2 = Frame(self.frame) - f2.pack(side = TOP, fill = BOTH, expand = 1) + f2.pack(side=TOP, fill=BOTH, expand=1) f = f2 - self.forward = Button(f, text = 'Search +', command = self.do_search) - self.forward.pack(side = LEFT) - self.forward = Button(f, text = 'Search -', - command = lambda x=self.do_search: x(other_strand=1)) - self.forward.pack(side = LEFT) - self.cancel = Button(f, text = 'Cancel', command = self.exit) - self.cancel.pack(side = LEFT) + self.forward = Button(f, text='Search +', command=self.do_search) + self.forward.pack(side=LEFT) + self.forward = Button(f, text='Search -', + command=lambda x=self.do_search: x(other_strand=1)) + self.forward.pack(side=LEFT) + self.cancel = Button(f, text='Cancel', command=self.exit) + self.cancel.pack(side=LEFT) self.current_color = 'cyan' - self.colorb = Button(f, text = 'Color', command = self.change_color, foreground = self.current_color) - self.colorb.pack(side = LEFT) + self.colorb = Button(f, text='Color', command=self.change_color, foreground=self.current_color) + self.colorb.pack(side=LEFT) self.config_color(self.current_color) - def config_color(self, color = None): + def config_color(self, color=None): if not self.highlight: return if not color: @@ -122,19 +122,19 @@ def config_color(self, color = None): self.current_color = color self.current_tag = 'searched_%s' % self.current_color self.master.tag_config(self.current_tag, background=self.current_color) - self.master.tag_config(self.current_tag + 'R', background=self.current_color, underline = 1) + self.master.tag_config(self.current_tag + 'R', background=self.current_color, underline=1) self.colors.append(color) def change_color(self): self.config_color() - self.colorb.configure(foreground = self.current_color) + self.colorb.configure(foreground=self.current_color) self.colorb.update() def get_pattern(self): pattern = self.search_entry.get() return pattern - def do_search(self, other_strand = 0): + def do_search(self, other_strand=0): pattern = self.get_pattern() if other_strand: pattern = reverse_complement(pattern) @@ -165,6 +165,6 @@ def showcolor(self): if __name__ == '__main__': seq = 'ATGGTGTGTGTGTACGATCGCCCCCCCCAGTCGATCGATGCATCGTA' win = Tk() - xtest = XDNAsearch(seq = seq, master = win) + xtest = XDNAsearch(seq=seq, master=win) win.mainloop() diff --git a/Scripts/xbbtools/xbb_translations.py b/Scripts/xbbtools/xbb_translations.py index 6e2ad4714ff..7785933c17f 100644 --- a/Scripts/xbbtools/xbb_translations.py +++ b/Scripts/xbbtools/xbb_translations.py @@ -18,7 +18,7 @@ class xbb_translations: def __init__(self): "" - def frame1(self, seq, translation_table = 1): + def frame1(self, seq, translation_table=1): return translate(seq, table=translation_table) def complement(self, seq): @@ -31,7 +31,7 @@ def reverse(self, seq): def antiparallel(self, seq): return reverse_complement(seq) - def frame(self, seq, frame, translation_table = 1): + def frame(self, seq, frame, translation_table=1): if not ((-3 <= frame <= -1) or (1 <= frame <= 3)): frame = 1 if frame != 1: @@ -59,7 +59,7 @@ def header_nice(self, txt, seq): res += '\n\n' return res - def frame_nice(self, seq, frame, translation_table = 1): + def frame_nice(self, seq, frame, translation_table=1): length = len(seq) protein = self.frame(seq, frame, translation_table) res = self.header_nice('Plus one frame translation', seq) @@ -77,7 +77,7 @@ def gc(self, seq): """Returns a float between 0 and 100.""" return GC(seq) - def gcframe(self, seq, translation_table = 1): + def gcframe(self, seq, translation_table=1): # always use uppercase nt-sequence !! comp = self.complement(seq) anti = self.reverse(comp) diff --git a/Scripts/xbbtools/xbb_utils.py b/Scripts/xbbtools/xbb_utils.py index 0ec8a1d4980..596027a4166 100644 --- a/Scripts/xbbtools/xbb_utils.py +++ b/Scripts/xbbtools/xbb_utils.py @@ -11,21 +11,21 @@ class NotePad(Toplevel): - def __init__(self, master= None): + def __init__(self, master=None): Toplevel.__init__(self, master) self.menubar = Menu(self) self.filemenu = Menu(self.menubar) - self.filemenu.add_command(label = "Save", command = self.save) + self.filemenu.add_command(label="Save", command=self.save) self.filemenu.add_separator() - self.filemenu.add_command(label = "Dismiss", command = self.destroy) + self.filemenu.add_command(label="Dismiss", command=self.destroy) self.menubar.add_cascade(label="File", menu=self.filemenu) - self.configure(menu = self.menubar) + self.configure(menu=self.menubar) self.yscroll = Scrollbar(self, orient=VERTICAL) - self.tid = Text(self, yscrollcommand = self.yscroll.set) - self.yscroll.configure(command = self.tid.yview) - self.tid.pack(side = LEFT, fill = BOTH, expand = 1) - self.yscroll.pack(side = RIGHT, fill = Y) + self.tid = Text(self, yscrollcommand=self.yscroll.set) + self.yscroll.configure(command=self.tid.yview) + self.tid.pack(side=LEFT, fill=BOTH, expand=1) + self.yscroll.pack(side=RIGHT, fill=Y) def text_id(self): return self.tid diff --git a/Scripts/xbbtools/xbb_widget.py b/Scripts/xbbtools/xbb_widget.py index d9801e66abd..419914fc537 100644 --- a/Scripts/xbbtools/xbb_widget.py +++ b/Scripts/xbbtools/xbb_widget.py @@ -27,7 +27,7 @@ class xbb_widget: - def __init__(self, parent = None): + def __init__(self, parent=None): self.is_a_master = (parent is None) self.parent = parent @@ -39,18 +39,18 @@ def __init__(self, parent = None): self.init_optionsdb() self.parent = self.main_frame.master - self.main_frame.pack(fill = BOTH, expand = 1) + self.main_frame.pack(fill=BOTH, expand=1) # sequence info (GC%, positins etc.) self.info_frame = Frame(self.main_frame) - self.info_frame.pack(fill = BOTH, expand = 1) + self.info_frame.pack(fill=BOTH, expand=1) self.create_menu(self.info_frame) self.create_seqinfo(self.info_frame) # sequence field and fast buttons self.seq_frame = Frame(self.main_frame) - self.seq_frame.pack(fill = BOTH, expand = 1) + self.seq_frame.pack(fill=BOTH, expand=1) self.create_buttons(self.seq_frame) self.create_seqfield(self.seq_frame) @@ -126,25 +126,25 @@ def create_menu(self, parent): # File menu self.file_menu = Menu(self.menubar) menu = self.file_menu - menu.add_command(label='Exit', command = self.exit) + menu.add_command(label='Exit', command=self.exit) self.menubar.add_cascade(label="File", menu=self.file_menu) # Edit menu self.edit_menu = Menu(self.menubar) menu = self.edit_menu - menu.add_command(label='Complement', command = self.complement) - menu.add_command(label='Antiparallel', command = self.antiparallel) - menu.add_command(label='Reverse', command = self.reverse) - menu.add_command(label='Fix sequence', command = self.fix_sequence) - menu.add_command(label='Search', command = self.search) + menu.add_command(label='Complement', command=self.complement) + menu.add_command(label='Antiparallel', command=self.antiparallel) + menu.add_command(label='Reverse', command=self.reverse) + menu.add_command(label='Fix sequence', command=self.fix_sequence) + menu.add_command(label='Search', command=self.search) self.menubar.add_cascade(label="Edit", menu=self.edit_menu) # Translation menu self.translation_menu = Menu(self.menubar) menu = self.translation_menu - menu.add_command(label='+1 Frame', command = self.translate) - menu.add_command(label='6 Frames', command = self.gcframe) - menu.add_command(label='Extract to FASTA', command = self.extract) + menu.add_command(label='+1 Frame', command=self.translate) + menu.add_command(label='6 Frames', command=self.gcframe) + menu.add_command(label='Extract to FASTA', command=self.extract) self.current_codon_table = StringVar() self.current_codon_table.set('Standard') @@ -158,7 +158,7 @@ def create_menu(self, parent): self.gencode_menu = Menu(self.translation_menu) menu = self.gencode_menu for table in keys: - menu.add_radiobutton(label=table, command = self.set_codon_table, variable = self.current_codon_table) + menu.add_radiobutton(label=table, command=self.set_codon_table, variable=self.current_codon_table) self.translation_menu.add_cascade(label="Genetic Codes", menu=self.gencode_menu) self.menubar.add_cascade(label="Translations", menu=self.translation_menu) @@ -166,17 +166,17 @@ def create_menu(self, parent): # Tools menu self.tools_menu = Menu(self.menubar) menu = self.tools_menu - menu.add_command(label='Blast', command = self.blast) - menu.add_command(label='Stats', command = self.statistics) + menu.add_command(label='Blast', command=self.blast) + menu.add_command(label='Stats', command=self.statistics) self.menubar.add_cascade(label="Tools", menu=self.tools_menu) # Help menu - self.help_menu = Menu(self.menubar, name = 'help') + self.help_menu = Menu(self.menubar, name='help') menu = self.help_menu - menu.add_command(label='Help', command = xbbtools_help) + menu.add_command(label='Help', command=xbbtools_help) self.menubar.add_cascade(label="Help", menu=self.help_menu) - self.parent.config(menu = self.menubar) + self.parent.config(menu=self.menubar) def set_codon_table(self): self.current_codon_table_id = self.translation_tables[self.current_codon_table.get()] @@ -190,64 +190,64 @@ def exit(self, *args): def create_seqinfo(self, parent): # all the sequence information in the top labels - self.seq_info1 = Frame(parent, relief = RIDGE, - borderwidth = 5, height = 30) - self.seq_info1.pack(fill = BOTH, expand = 1, side = TOP) + self.seq_info1 = Frame(parent, relief=RIDGE, + borderwidth=5, height=30) + self.seq_info1.pack(fill=BOTH, expand=1, side=TOP) self.position_ids = {} d = self.position_ids - d['id'] = Label(self.seq_info1, width = 10) - d['from_id'] = Label(self.seq_info1, width = 10) - d['to_id'] = Label(self.seq_info1, width = 10) - d['length_id'] = Label(self.seq_info1, width = 10) - d['label'] = Label(self.seq_info1, width = 10) + d['id'] = Label(self.seq_info1, width=10) + d['from_id'] = Label(self.seq_info1, width=10) + d['to_id'] = Label(self.seq_info1, width=10) + d['length_id'] = Label(self.seq_info1, width=10) + d['label'] = Label(self.seq_info1, width=10) for i in ['id', 'from_id', 'to_id', 'length_id', 'label']: - d[i].pack(side = LEFT, fill = BOTH, expand = 1) + d[i].pack(side=LEFT, fill=BOTH, expand=1) - self.seq_info2 = Frame(parent, relief = RIDGE, - borderwidth = 5, height = 30) - self.seq_info2.pack(fill = BOTH, expand = 1, side = TOP) + self.seq_info2 = Frame(parent, relief=RIDGE, + borderwidth=5, height=30) + self.seq_info2.pack(fill=BOTH, expand=1, side=TOP) self.statistics_ids = {} d = self.statistics_ids - d['length_id'] = Label(self.seq_info2, width = 10) - d['length_id'].pack(side = LEFT, fill = BOTH, expand = 1) + d['length_id'] = Label(self.seq_info2, width=10) + d['length_id'].pack(side=LEFT, fill=BOTH, expand=1) for nt in ['A', 'C', 'G', 'T']: - d[nt] = Label(self.seq_info2, width = 10, fg = self.colorsNT[nt]) - d[nt].pack(side = LEFT, fill = BOTH, expand = 1) + d[nt] = Label(self.seq_info2, width=10, fg=self.colorsNT[nt]) + d[nt].pack(side=LEFT, fill=BOTH, expand=1) def create_buttons(self, parent): self.button_frame = Frame(parent) - self.button_frame.pack(fill = Y, side = LEFT) + self.button_frame.pack(fill=Y, side=LEFT) self.buttons = {} for text, func in [('Open', self.open), ('Export', self.export), ('GC Frame', self.gcframe), ('Blast', self.blast), ('Exit', self.exit)]: - b_id = Button(self.button_frame, text = text, - command = func, width = 7) - b_id.pack(side = TOP, pady = 5, padx = 10) + b_id = Button(self.button_frame, text=text, + command=func, width=7) + b_id.pack(side=TOP, pady=5, padx=10) self.buttons[text] = b_id f = Frame(self.button_frame) - l = Label(f, text = 'Goto:', bg = self.colorsbg['frame'], fg = self.colorsfg['button']) - l.pack(side = LEFT) + l = Label(f, text='Goto:', bg=self.colorsbg['frame'], fg=self.colorsfg['button']) + l.pack(side=LEFT) l.bind('', self.goto) - self.goto_entry = Entry(f, width = 5) - self.goto_entry.pack(side = RIGHT, pady = 5, padx = 4) + self.goto_entry = Entry(f, width=5) + self.goto_entry.pack(side=RIGHT, pady=5, padx=4) self.goto_entry.bind('', self.goto) - f.pack(side = BOTTOM) + f.pack(side=BOTTOM) def create_seqfield(self, parent): - self.sequence_id = Text(parent, wrap = 'char', - width = self.seqwidth) - self.sequence_id.pack(fill = BOTH, expand = 1, side = RIGHT) + self.sequence_id = Text(parent, wrap='char', + width=self.seqwidth) + self.sequence_id.pack(fill=BOTH, expand=1, side=RIGHT) def create_bindings(self): self.sequence_id.bind('', self.position) - self.sequence_id.bind('', lambda x, s = self: - s.position_ids['id'].configure(text = '')) + self.sequence_id.bind('', lambda x, s=self: + s.position_ids['id'].configure(text='')) self.sequence_id.bind('<1>', self.zero) self.sequence_id.bind('', self.count_selection) self.sequence_id.bind('', self.select_all) @@ -255,7 +255,7 @@ def create_bindings(self): def zero(self, event): p = self.position_ids for i in ['from_id', 'to_id', 'length_id']: - self.position_ids[i].configure(text = '') + self.position_ids[i].configure(text='') def get_length(self): self.sequence_length = len(self.sequence_id.get(1.0, END)) @@ -308,15 +308,15 @@ def count_selection(self, event): b = int(w.index('sel.last').split('.')[1]) length = b - a + 1 - self.position_ids['from_id'].configure(text = 'Start:%d' % a) - self.position_ids['to_id'].configure(text = 'Stop:%d' % b) - self.position_ids['length_id'].configure(text = '%d nt' % length) + self.position_ids['from_id'].configure(text='Start:%d' % a) + self.position_ids['to_id'].configure(text='Stop:%d' % b) + self.position_ids['length_id'].configure(text='%d nt' % length) - self.statistics_ids['length_id'].configure(text = 'Length=%d' % length) + self.statistics_ids['length_id'].configure(text='Length=%d' % length) seq = self.get_self_selection() for nt in ['A', 'C', 'G', 'T']: n = seq.count(nt) - self.statistics_ids[nt].configure(text = '%s=%d' % (nt, n)) + self.statistics_ids[nt].configure(text='%s=%d' % (nt, n)) except: pass @@ -325,9 +325,9 @@ def position(self, event): y = event.y pos = self.sequence_id.index('@%d,%d' % (x, y)).split('.') pos = int(pos[1]) + 1 - self.position_ids['id'].configure(text = str(pos)) + self.position_ids['id'].configure(text=str(pos)) - def open(self, file = None): + def open(self, file=None): if not file: file = askopenfilename() if not file: @@ -351,7 +351,7 @@ def fix_sequence(self): def update_label(self, header): name = header.split(' ')[0] name = name.split(',')[0] - self.position_ids['label'].configure(text = name) + self.position_ids['label'].configure(text=name) def export(self): seq = self.get_self_selection() @@ -365,7 +365,7 @@ def gcframe(self): tid = np.text_id() tid.insert(END, self.translator.gcframe(seq, self.current_codon_table_id)) - def translate(self, frame = 1): + def translate(self, frame=1): seq = self.get_selection_or_sequence() if not seq: return @@ -373,7 +373,7 @@ def translate(self, frame = 1): tid = np.text_id() tid.insert(END, self.translator.frame_nice(seq, frame, self.current_codon_table_id)) - def extract(self, frame = 1): + def extract(self, frame=1): seq = self.get_selection_or_sequence() if not seq: return @@ -472,7 +472,7 @@ def antiparallel(self): def search(self): seq = self.get_selection_or_sequence() - searcher = XDNAsearch(seq, master = self.sequence_id, highlight = 1) + searcher = XDNAsearch(seq, master=self.sequence_id, highlight=1) def goto(self, *args): pos = self.goto_entry.get()