Permalink
Browse files

Various whitespace fixes, mostly around commas and colons.

  • Loading branch information...
cbrueffer authored and peterjc committed Dec 7, 2012
1 parent 9c220e5 commit 83f9b75384d81bb7c8a4b351a5eae81baf271822
View
@@ -39,27 +39,27 @@ def read(handle):
for line in handle:
if not line.strip():
continue
- if line[:8]=="[HEADER]":
+ if line[:8] == "[HEADER]":
section = "HEADER"
- elif line[:11]=="[INTENSITY]":
+ elif line[:11] == "[INTENSITY]":
section = "INTENSITY"
record.intensities = numpy.zeros((record.nrows, record.ncols))
record.stdevs = numpy.zeros((record.nrows, record.ncols))
record.npix = numpy.zeros((record.nrows, record.ncols), int)
- elif line[0]=="[":
+ elif line[0] == "[":
section = ""
- elif section=="HEADER":
+ elif section == "HEADER":
keyword, value = line.split("=", 1)
- if keyword=="Cols":
+ if keyword == "Cols":
record.ncols = int(value)
- elif keyword=="Rows":
+ elif keyword == "Rows":
record.nrows = int(value)
- elif section=="INTENSITY":
+ elif section == "INTENSITY":
if "=" in line:
continue
words = line.split()
y, x = map(int, words[:2])
- record.intensities[x,y] = float(words[2])
- record.stdevs[x,y] = float(words[3])
- record.npix[x,y] = int(words[4])
+ record.intensities[x, y] = float(words[2])
+ record.stdevs[x, y] = float(words[3])
+ record.npix[x, y] = int(words[4])
return record
@@ -73,7 +73,7 @@ def __init__(self, returncode, cmd, stdout="", stderr=""):
def __str__(self):
#get first line of any stderr message
try:
- msg = self.stderr.lstrip().split("\n",1)[0].rstrip()
+ msg = self.stderr.lstrip().split("\n", 1)[0].rstrip()
except:
msg = ""
if msg:
@@ -195,13 +195,13 @@ def __init__(self, cmd, **kwargs):
#Beware of binding-versus-assignment confusion issues
def getter(name):
- return lambda x : x._get_parameter(name)
+ return lambda x: x._get_parameter(name)
def setter(name):
- return lambda x, value : x.set_parameter(name, value)
+ return lambda x, value: x.set_parameter(name, value)
def deleter(name):
- return lambda x : x._clear_parameter(name)
+ return lambda x: x._clear_parameter(name)
doc = p.description
if isinstance(p, _Switch):
@@ -334,7 +334,7 @@ def _check_value(self, value, name, check_function):
"""
if check_function is not None:
is_good = check_function(value) # May raise an exception
- assert is_good in [0,1,True,False]
+ assert is_good in [0, 1, True, False]
if not is_good:
raise ValueError("Invalid parameter value %r for parameter %s"
% (value, name))
View
@@ -83,7 +83,7 @@ def _savetree(jobname, tree, order, transpose):
order1 = nodeorder[index1]
counts1 = nodecounts[index1]
outputfile.write(nodeID[index1]+"\t")
- nodedist[nodeindex] = max(nodedist[nodeindex],nodedist[index1])
+ nodedist[nodeindex] = max(nodedist[nodeindex], nodedist[index1])
else:
order1 = order[min1]
counts1 = 1
@@ -93,7 +93,7 @@ def _savetree(jobname, tree, order, transpose):
order2 = nodeorder[index2]
counts2 = nodecounts[index2]
outputfile.write(nodeID[index2]+"\t")
- nodedist[nodeindex] = max(nodedist[nodeindex],nodedist[index2])
+ nodedist[nodeindex] = max(nodedist[nodeindex], nodedist[index2])
else:
order2 = order[min2]
counts2 = 1
@@ -493,7 +493,7 @@ def save(self, jobname, geneclusters=None, expclusters=None):
calculated by kcluster.
"""
- (ngenes,nexps) = numpy.shape(self.data)
+ (ngenes, nexps) = numpy.shape(self.data)
if self.gorder is None:
gorder = numpy.arange(ngenes)
else:
@@ -538,7 +538,7 @@ def save(self, jobname, geneclusters=None, expclusters=None):
else:
expindex = numpy.argsort(eorder)
filename = filename + postfix
- self._savedata(filename,gid,aid,geneindex,expindex)
+ self._savedata(filename, gid, aid, geneindex, expindex)
def _savekmeans(self, filename, clusterids, order, transpose):
# Save a k-means clustering solution
@@ -582,7 +582,7 @@ def _savedata(self, jobname, gid, aid, geneindex, expindex):
if self.mask is not None:
mask = self.mask
else:
- mask = numpy.ones((ngenes,nexps), int)
+ mask = numpy.ones((ngenes, nexps), int)
if self.gweight is not None:
gweight = self.gweight
else:
@@ -621,8 +621,8 @@ def _savedata(self, jobname, gid, aid, geneindex, expindex):
(self.geneid[i], genename[i], gweight[i]))
for j in expindex:
outputfile.write('\t')
- if mask[i,j]:
- outputfile.write(str(self.data[i,j]))
+ if mask[i, j]:
+ outputfile.write(str(self.data[i, j]))
outputfile.write('\n')
outputfile.close()
View
@@ -157,7 +157,7 @@ def __read_names(record, line):
record.hit = m.group(2)
-def __read_threshold(record,line):
+def __read_threshold(record, line):
if not line.startswith("Threshold"):
raise ValueError("Line does not start with 'Threshold':\n%s" % line)
m = __regex["threshold"].search(line)
View
@@ -94,8 +94,8 @@ def epost(db, **keywds):
Raises an IOError exception if there's a network error.
"""
- cgi='http://eutils.ncbi.nlm.nih.gov/entrez/eutils/epost.fcgi'
- variables = {'db' : db}
+ cgi = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/epost.fcgi'
+ variables = {'db': db}
variables.update(keywds)
return _open(cgi, variables, post=True)
@@ -125,8 +125,8 @@ def efetch(db, **keywds):
Warning: The NCBI changed the default retmode in Feb 2012, so many
databases which previously returned text output now give XML.
"""
- cgi='http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi'
- variables = {'db' : db}
+ cgi = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi'
+ variables = {'db': db}
keywords = keywds
if "id" in keywds and isinstance(keywds["id"], list):
#Fix for NCBI change (probably part of EFetch 2,0, Feb 2012) where
@@ -168,9 +168,9 @@ def esearch(db, term, **keywds):
True
"""
- cgi='http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi'
- variables = {'db' : db,
- 'term' : term}
+ cgi = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esearch.fcgi'
+ variables = {'db': db,
+ 'term': term}
variables.update(keywds)
return _open(cgi, variables)
@@ -208,7 +208,7 @@ def elink(**keywds):
This is explained in much more detail in the Biopython Tutorial.
"""
- cgi='http://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi'
+ cgi = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/elink.fcgi'
variables = {}
variables.update(keywds)
return _open(cgi, variables)
@@ -236,7 +236,7 @@ def einfo(**keywds):
True
"""
- cgi='http://eutils.ncbi.nlm.nih.gov/entrez/eutils/einfo.fcgi'
+ cgi = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/einfo.fcgi'
variables = {}
variables.update(keywds)
return _open(cgi, variables)
@@ -268,7 +268,7 @@ def esummary(**keywds):
Computational biology and chemistry
"""
- cgi='http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi'
+ cgi = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/esummary.fcgi'
variables = {}
variables.update(keywds)
return _open(cgi, variables)
@@ -302,7 +302,7 @@ def egquery(**keywds):
True
"""
- cgi='http://eutils.ncbi.nlm.nih.gov/entrez/eutils/egquery.fcgi'
+ cgi = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/egquery.fcgi'
variables = {}
variables.update(keywds)
return _open(cgi, variables)
@@ -331,7 +331,7 @@ def espell(**keywds):
biopython
"""
- cgi='http://eutils.ncbi.nlm.nih.gov/entrez/eutils/espell.fcgi'
+ cgi = 'http://eutils.ncbi.nlm.nih.gov/entrez/eutils/espell.fcgi'
variables = {}
variables.update(keywds)
return _open(cgi, variables)
View
@@ -80,7 +80,7 @@ def sprot_search_ful(text, make_wild=None, swissprot=1, trembl=None,
Search SwissProt by full text.
"""
- variables = {'SEARCH' : text}
+ variables = {'SEARCH': text}
if make_wild:
variables['makeWild'] = 'on'
if swissprot:
@@ -102,7 +102,7 @@ def sprot_search_de(text, swissprot=1, trembl=None,
organelle.
"""
- variables = {'SEARCH' : text}
+ variables = {'SEARCH': text}
if swissprot:
variables['S'] = 'on'
if trembl:
View
@@ -17,13 +17,13 @@ def __init__(self):
self.data = {}
-def mult_align(sum_dict,align_dict):
+def mult_align(sum_dict, align_dict):
"""Returns a biopython multiple alignment instance (Bio.Align.Generic)"""
mult_align_dict = {}
for j in align_dict.abs(1).pos_align_dict:
mult_align_dict[j] = ''
- for i in range(1,len(align_dict)+1):
+ for i in range(1, len(align_dict)+1):
# loop on positions
for j in align_dict.abs(i).pos_align_dict:
# loop within a position
@@ -53,7 +53,7 @@ def mult_align(sum_dict,align_dict):
# Took me ~160 seconds for the largest FSSP file (1reqA.fssp)
#
-def filter(sum_dict,align_dict,filter_attribute,low_bound, high_bound):
+def filter(sum_dict, align_dict, filter_attribute, low_bound, high_bound):
"""filters a passed summary section and alignment section according to a numeric
attribute in the summary section. Returns new summary and alignment sections"""
new_sum_dict = FSSP.FSSPSumDict()
@@ -62,7 +62,7 @@ def filter(sum_dict,align_dict,filter_attribute,low_bound, high_bound):
# new_align_dict[i] = copy.copy(align_dict[i])
# new_align_dict = copy.copy(align_dict)
for prot_num in sum_dict:
- attr_value = getattr(sum_dict[prot_num],filter_attribute)
+ attr_value = getattr(sum_dict[prot_num], filter_attribute)
if attr_value >= low_bound and attr_value <= high_bound:
new_sum_dict[prot_num] = sum_dict[prot_num]
prot_numbers = new_sum_dict.keys()
View
@@ -16,7 +16,7 @@
from Bio import Alphabet
fff_rec = fssp_rec.fff_rec
header_records = {
- 'database' : re.compile('^DATABASE'),
+ 'database': re.compile('^DATABASE'),
'pdbid': re.compile('^PDBID'),
'header': re.compile('^HEADER'),
'compnd': re.compile('^COMPND'),
@@ -44,24 +44,24 @@ def __init__(self):
self.seqlength = 0
self.nalign = 0
- def fill_header(self,inline):
+ def fill_header(self, inline):
for i in header_records:
if header_records[i].match(inline):
if i == 'database' or i == 'seqlength' or i == 'nalign':
- setattr(self,i,int(inline.split()[1]))
+ setattr(self, i, int(inline.split()[1]))
elif i == 'compnd' or i == 'author':
- setattr(self,i,inline.split()[1:])
+ setattr(self, i, inline.split()[1:])
elif i == 'source' or i == 'header':
attr = inline[inline.find(' ')+1:].strip()
- setattr(self,i,attr)
+ setattr(self, i, attr)
else:
- setattr(self,i,inline.split()[1])
+ setattr(self, i, inline.split()[1])
class PosAlign(object):
- def __init__(self,inStr):
+ def __init__(self, inStr):
inStr = inStr.strip()
- if len(inStr) != 1 and len(inStr)!= 2:
+ if len(inStr) != 1 and len(inStr) != 2:
raise ValueError('PosAlign: length not 2 chars' + inStr)
if inStr == '..':
self.aa = '-'
@@ -88,7 +88,7 @@ def __repr__(self):
class FSSPSumRec(object):
""" Contains info from an FSSP summary record"""
- def __init__(self,in_str):
+ def __init__(self, in_str):
self.raw = in_str
in_rec = in_str.strip().split()
# print in_rec
@@ -127,7 +127,7 @@ def __repr__(self):
class FSSPAlignRec(object):
- def __init__(self,in_fff_rec):
+ def __init__(self, in_fff_rec):
# print in_fff_rec
self.abs_res_num = int(in_fff_rec[fssp_rec.align.abs_res_num])
self.pdb_res_num = in_fff_rec[fssp_rec.align.pdb_res_num].strip()
@@ -144,7 +144,7 @@ def __init__(self,in_fff_rec):
self.pos_align_dict = {}
self.PosAlignList = []
- def add_align_list(self,align_list):
+ def add_align_list(self, align_list):
for i in align_list:
self.PosAlignList.append(PosAlign(i))
@@ -171,16 +171,16 @@ def build_resnum_list(self):
# Given an absolute residue number & chain, returns the relevant fssp
# record
- def abs(self,num):
+ def abs(self, num):
return self[self.abs_res_dict[num]]
# Given an PDB residue number & chain, returns the relevant fssp
# record
- def pdb(self,num):
+ def pdb(self, num):
return self[self.pdb_res_dict[num]]
# Returns a sequence string
- def sequence(self,num):
+ def sequence(self, num):
s = ''
sorted_pos_nums = self.abs_res_dict.keys()
sorted_pos_nums.sort()
@@ -259,7 +259,7 @@ def read_fssp(fssp_handle):
curline = fssp_handle.readline() # Read the next line
while alignments_rec.match(curline):
align_rec = FSSPAlignRec(fff_rec(curline))
- key = align_rec.chain_id+align_rec.res_name+str(align_rec.pdb_res_num)
+ key = align_rec.chain_id + align_rec.res_name + str(align_rec.pdb_res_num)
align_list = curline[fssp_rec.align.start_aa_list:].strip().split()
if key not in align_dict:
align_dict[key] = align_rec
Oops, something went wrong.

0 comments on commit 83f9b75

Please sign in to comment.