Permalink
Browse files

Scripts: Some more PEP8 whitespace cleanup.

  • Loading branch information...
1 parent d74b89a commit ae8cc5aeb9888035038983985cc6ac2074bd3643 @cbrueffer cbrueffer committed with peterjc Dec 11, 2012
@@ -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
@@ -19,7 +19,7 @@
print "Usage ./check_output.py <GenBank file to parse>"
sys.exit()
-parser = GenBank.FeatureParser(debug_level = 2)
+parser = GenBank.FeatureParser(debug_level=2)
handle = open(sys.argv[1], 'r')
@@ -19,11 +19,11 @@
print "Usage ./find_parser_problems <GenBank file to parse>"
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
@@ -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]))
@@ -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"
@@ -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
@@ -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()
@@ -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
View
@@ -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",
View
@@ -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()
@@ -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':
@@ -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()
@@ -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
@@ -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
@@ -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()
Oops, something went wrong.

0 comments on commit ae8cc5a

Please sign in to comment.