Skip to content

Commit

Permalink
Scripts: Some more PEP8 whitespace cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrueffer authored and peterjc committed Dec 18, 2012
1 parent d74b89a commit ae8cc5a
Show file tree
Hide file tree
Showing 18 changed files with 143 additions and 143 deletions.
2 changes: 1 addition & 1 deletion Scripts/GenBank/check_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Scripts/GenBank/check_output_simple.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down
4 changes: 2 additions & 2 deletions Scripts/GenBank/find_parser_problems.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Scripts/PDB/generate_three_to_one_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]))
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Performance/biosql_performance_load.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 2 additions & 2 deletions Scripts/Performance/biosql_performance_read.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions Scripts/Restriction/ranacompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from Bio.Restriction._Update.RestrictionCompiler import DictionaryBuilder


def standalone() :
def standalone():
parser = optparse.OptionParser()
add = parser.add_option

Expand All @@ -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()
2 changes: 1 addition & 1 deletion Scripts/Restriction/rebase_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions Scripts/query_pubmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion Scripts/scop_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
8 changes: 4 additions & 4 deletions Scripts/xbbtools/nextorf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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]

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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':
Expand Down
38 changes: 19 additions & 19 deletions Scripts/xbbtools/xbb_blast.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion Scripts/xbbtools/xbb_blastbg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 8 additions & 8 deletions Scripts/xbbtools/xbb_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
40 changes: 20 additions & 20 deletions Scripts/xbbtools/xbb_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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)
Expand Down Expand Up @@ -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()
Loading

0 comments on commit ae8cc5a

Please sign in to comment.