Permalink
Browse files

Avoid multiple statements on one line (PEP8 E701).

  • Loading branch information...
1 parent 9f5081f commit 4d2350ae9276adb6d73af351b2094951560865b1 @cbrueffer cbrueffer committed with peterjc Dec 5, 2012
Showing with 618 additions and 298 deletions.
  1. +6 −3 Bio/AlignIO/ClustalIO.py
  2. +10 −5 Bio/AlignIO/PhylipIO.py
  3. +2 −1 Bio/AlignIO/StockholmIO.py
  4. +8 −4 Bio/Alphabet/__init__.py
  5. +4 −2 Bio/Application/__init__.py
  6. +18 −9 Bio/Blast/NCBIStandalone.py
  7. +2 −1 Bio/Blast/NCBIXML.py
  8. +34 −11 Bio/Crystal/__init__.py
  9. +3 −1 Bio/Data/IUPACData.py
  10. +4 −2 Bio/GA/Crossover/GeneralPoint.py
  11. +4 −2 Bio/GenBank/__init__.py
  12. +4 −2 Bio/Geo/__init__.py
  13. +12 −6 Bio/Graphics/GenomeDiagram/_CircularDrawer.py
  14. +12 −6 Bio/Graphics/GenomeDiagram/_LinearDrawer.py
  15. +2 −1 Bio/MarkovModel.py
  16. +2 −1 Bio/Nexus/Nexus.py
  17. +2 −1 Bio/Nexus/Trees.py
  18. +6 −3 Bio/PDB/PDBList.py
  19. +2 −1 Bio/PDB/parse_pdb_header.py
  20. +4 −2 Bio/Pathway/Rep/HashSet.py
  21. +2 −1 Bio/PopGen/FDist/Controller.py
  22. +8 −4 Bio/PopGen/GenePop/Controller.py
  23. +6 −3 Bio/Restriction/PrintFormat.py
  24. +54 −27 Bio/Restriction/Restriction.py
  25. +33 −16 Bio/Restriction/_Update/RestrictionCompiler.py
  26. +4 −2 Bio/Restriction/_Update/Update.py
  27. +2 −1 Bio/SCOP/Cla.py
  28. +2 −1 Bio/SCOP/Des.py
  29. +8 −4 Bio/SCOP/Raf.py
  30. +8 −4 Bio/SCOP/Residues.py
  31. +21 −10 Bio/SCOP/__init__.py
  32. +10 −5 Bio/SearchIO/BlastIO/blast_tab.py
  33. +6 −3 Bio/Seq.py
  34. +6 −3 Bio/SeqUtils/CheckSum.py
  35. +6 −3 Bio/SeqUtils/__init__.py
  36. +4 −2 Bio/Sequencing/Ace.py
  37. +2 −1 Bio/SubsMat/__init__.py
  38. +14 −7 BioSQL/BioSeq.py
  39. +4 −2 BioSQL/DBUtils.py
  40. +4 −2 BioSQL/Loader.py
  41. +85 −42 Doc/examples/getgene.py
  42. +37 −18 Scripts/xbbtools/nextorf.py
  43. +2 −1 Scripts/xbbtools/xbb_blast.py
  44. +2 −1 Scripts/xbbtools/xbb_blastbg.py
  45. +12 −6 Scripts/xbbtools/xbb_search.py
  46. +3 −1 Scripts/xbbtools/xbb_utils.py
  47. +12 −6 Scripts/xbbtools/xbb_widget.py
  48. +6 −3 Tests/test_GenomeDiagram.py
  49. +2 −1 Tests/test_Muscle_tool.py
  50. +6 −3 Tests/test_NCBI_BLAST_tools.py
  51. +46 −21 Tests/test_ParserSupport.py
  52. +2 −1 Tests/test_Prank_tool.py
  53. +2 −1 Tests/test_SeqIO_FastaIO.py
  54. +4 −2 Tests/test_SeqIO_convert.py
  55. +2 −1 Tests/test_SeqRecord.py
  56. +26 −13 Tests/test_Seq_objs.py
  57. +2 −1 Tests/test_Uniprot.py
  58. +2 −1 Tests/test_bgzf.py
  59. +8 −4 Tests/test_seq.py
  60. +8 −4 do2to3.py
  61. +4 −2 setup.py
View
@@ -168,7 +168,8 @@ def next(self):
#No consensus
break
line = handle.readline()
- if not line : break #end of file
+ if not line:
+ break #end of file
assert line.strip() == ""
assert seq_cols is not None
@@ -187,8 +188,10 @@ def next(self):
#previous block.
while (not line) or line.strip() == "":
line = handle.readline()
- if not line : break # end of file
- if not line : break # end of file
+ if not line:
+ break # end of file
+ if not line:
+ break # end of file
if line.split(None,1)[0] in known_headers:
#Found concatenated alignment.
View
@@ -131,10 +131,12 @@ def write_alignment(self, alignment, id_width=_PHYLIP_ID_WIDTH):
#alphabet...
#TODO - How to cope with '?' or '.' in the sequence?
handle.write(" %s" % seq_segment)
- if i+10 > length_of_seqs : break
+ if i+10 > length_of_seqs:
+ break
handle.write("\n")
block=block+1
- if block*50 > length_of_seqs : break
+ if block*50 > length_of_seqs:
+ break
handle.write("\n")
class PhylipIterator(AlignmentIterator):
@@ -228,8 +230,10 @@ def next(self):
#Skip any blank lines between blocks...
while ""==line.strip():
line = handle.readline()
- if not line : break #end of file
- if not line : break #end of file
+ if not line:
+ break #end of file
+ if not line:
+ break #end of file
if self._is_header(line):
#Looks like the start of a concatenated alignment
@@ -245,7 +249,8 @@ def next(self):
line = handle.readline()
if (not line) and i+1 < number_of_seqs:
raise ValueError("End of file mid-block")
- if not line : break #end of file
+ if not line:
+ break #end of file
records = (SeqRecord(Seq("".join(s), self.alphabet), \
id=i, name=i, description=i) \
@@ -335,7 +335,8 @@ def next(self):
passed_end_alignment = False
while 1:
line = self.handle.readline()
- if not line: break #end of file
+ if not line:
+ break #end of file
line = line.strip() #remove trailing \n
if line == '# STOCKHOLM 1.0':
self._header = line
View
@@ -357,17 +357,21 @@ def _check_type_compatible(alphabets):
if isinstance(a, DNAAlphabet):
dna = True
nucl = True
- if rna or protein : return False
+ if rna or protein:
+ return False
elif isinstance(a, RNAAlphabet):
rna = True
nucl = True
- if dna or protein : return False
+ if dna or protein:
+ return False
elif isinstance(a, NucleotideAlphabet):
nucl = True
- if protein : return False
+ if protein:
+ return False
elif isinstance(a, ProteinAlphabet):
protein = True
- if nucl : return False
+ if nucl:
+ return False
return True
def _verify_alphabet(sequence):
@@ -430,8 +430,10 @@ def __call__(self, stdin=None, stdout=True, stderr=True,
shell=(sys.platform!="win32"))
#Use .communicate as can get deadlocks with .wait(), see Bug 2804
stdout_str, stderr_str = child_process.communicate(stdin)
- if not stdout: assert not stdout_str
- if not stderr: assert not stderr_str
+ if not stdout:
+ assert not stdout_str
+ if not stderr:
+ assert not stderr_str
return_code = child_process.returncode
if return_code:
raise ApplicationError(return_code, str(self),
@@ -231,8 +231,10 @@ def _scan_header(self, uhandle, consumer):
read_and_call_until(uhandle, consumer.query_info, start='Length=')
while True:
line = uhandle.peekline()
- if not line.strip() : break
- if "Score E" in line : break
+ if not line.strip():
+ break
+ if "Score E" in line:
+ break
#It is more of the query (and its length)
read_and_call(uhandle, consumer.query_info)
read_and_call_while(uhandle, consumer.noevent, blank=1)
@@ -340,7 +342,8 @@ def _scan_descriptions(self, uhandle, consumer):
try:
read_and_call_while(uhandle, consumer.noevent, blank=1)
except ValueError, err:
- if str(err) != "Unexpected end of stream." : raise err
+ if str(err) != "Unexpected end of stream.":
+ raise err
consumer.end_descriptions()
# Stop processing.
@@ -393,7 +396,8 @@ def _scan_descriptions(self, uhandle, consumer):
consumer.end_descriptions()
def _scan_alignments(self, uhandle, consumer):
- if self._eof(uhandle) : return
+ if self._eof(uhandle):
+ return
# qblast inserts a helpful line here.
attempt_read_and_call(uhandle, consumer.noevent, start="ALIGNMENTS")
@@ -422,7 +426,8 @@ def _scan_pairwise_alignments(self, uhandle, consumer):
self._scan_one_pairwise_alignment(uhandle, consumer)
def _scan_one_pairwise_alignment(self, uhandle, consumer):
- if self._eof(uhandle) : return
+ if self._eof(uhandle):
+ return
consumer.start_alignment()
self._scan_alignment_header(uhandle, consumer)
@@ -507,7 +512,8 @@ def _scan_hsp_alignment(self, uhandle, consumer):
try:
read_and_call_while(uhandle, consumer.noevent, blank=1)
except ValueError, err:
- if str(err) != "Unexpected end of stream." : raise err
+ if str(err) != "Unexpected end of stream.":
+ raise err
# End of File (well, it looks like it with recent versions
# of BLAST for multiple queries after the Iterator class
# has broken up the whole file into chunks).
@@ -544,7 +550,8 @@ def _eof(self, uhandle):
try:
line = safe_peekline(uhandle)
except ValueError, err:
- if str(err) != "Unexpected end of stream." : raise err
+ if str(err) != "Unexpected end of stream.":
+ raise err
line = ""
return not line
@@ -575,7 +582,8 @@ def _scan_database_report(self, uhandle, consumer):
# Lambda K H
# 0.267 0.0410 0.140
- if self._eof(uhandle) : return
+ if self._eof(uhandle):
+ return
consumer.start_database_report()
@@ -617,7 +625,8 @@ def _scan_database_report(self, uhandle, consumer):
try:
read_and_call(uhandle, consumer.noevent, start='Lambda')
read_and_call(uhandle, consumer.ka_params)
- except: pass
+ except:
+ pass
#This blank line is optional:
attempt_read_and_call(uhandle, consumer.noevent, blank=1)
View
@@ -206,7 +206,8 @@ def _end_Iteration(self):
#Clear the object (a new empty one is create in _start_Iteration)
self._blast = None
- if self._debug : "NCBIXML: Added Blast record to results"
+ if self._debug:
+ "NCBIXML: Added Blast record to results"
# Header
def _end_BlastOutput_program(self):
View
@@ -61,7 +61,8 @@ def __repr__(self):
def __str__(self):
return "%s" % self.data
- def __len__(self): return len(self.data)
+ def __len__(self):
+ return len(self.data)
class Chain(object):
def __init__(self, residues = ''):
@@ -111,7 +112,8 @@ def __ne__(self, other):
"""Returns true iff self is not equal to other."""
return not self.__eq__(other)
- def __len__(self): return len(self.data)
+ def __len__(self):
+ return len(self.data)
def __getitem__(self, index):
if isinstance(index, int):
@@ -245,8 +247,12 @@ def __str__(self):
def tostring(self):
return self.data
- def __len__(self): return len(self.data)
- def __getitem__(self, key): return self.data[key]
+ def __len__(self):
+ return len(self.data)
+
+ def __getitem__(self, key):
+ return self.data[key]
+
def __setitem__(self, key, item):
if isinstance(item, Chain):
self.data[key] = item
@@ -255,20 +261,37 @@ def __setitem__(self, key, item):
else:
raise TypeError
- def __delitem__(self, key): del self.data[key]
- def clear(self): self.data.clear()
+ def __delitem__(self, key):
+ del self.data[key]
+
+ def clear(self):
+ self.data.clear()
+
def copy(self):
return copy.copy(self)
- def keys(self): return self.data.keys()
- def items(self): return self.data.items()
- def values(self): return self.data.values()
- def __contains__(self, value): return value in self.data
- def has_key(self, key): return key in self.data
+
+ def keys(self):
+ return self.data.keys()
+
+ def items(self):
+ return self.data.items()
+
+ def values(self):
+ return self.data.values()
+
+ def __contains__(self, value):
+ return value in self.data
+
+ def has_key(self, key):
+ return key in self.data
+
def get(self, key, failobj=None):
return self.data.get(key, failobj)
+
def setdefault(self, key, failobj=None):
if key not in self.data:
self.data[key] = failobj
return self.data[key]
+
def popitem(self):
return self.data.popitem()
View
@@ -141,7 +141,9 @@ def _make_ambiguous_ranges(mydict, weight_table):
avg_d = {}
for letter, values in mydict.iteritems():
#Following line is a quick hack to skip undefined weights for U and O
- if len(values)==1 and values[0] not in weight_table : continue
+ if len(values) == 1 and values[0] not in weight_table:
+ continue
+
weights = map(weight_table.get, values)
range_d[letter] = (min(weights), max(weights))
total_w = 0.0
@@ -130,8 +130,10 @@ def _crossover( self, x, no, locs ):
# _generate_locs gives us [0, +n points+, bound]
# so we can iterate: { 0:loc(1) ... loc(n):bound }
t = no[ mode ].genome[ locs[mode][n]:locs[mode][n+1] ]
- if (s): s = s + t
- else: s = t
+ if (s):
+ s = s + t
+ else:
+ s = t
return s
View
@@ -373,9 +373,11 @@ def next(self):
lines = []
while True:
line = self.handle.readline()
- if not line : return None #Premature end of file?
+ if not line:
+ return None #Premature end of file?
lines.append(line)
- if line.rstrip() == "//" : break
+ if line.rstrip() == "//":
+ break
return "".join(lines)
try:
return self._parser.parse(self.handle)
View
@@ -28,10 +28,12 @@ def parse(handle):
record = None
for line in handle:
line = line.strip('\n').strip('\r')
- if not line: continue # Ignore empty lines
+ if not line:
+ continue # Ignore empty lines
c = line[0]
if c=='^':
- if record: yield record
+ if record:
+ yield record
record = Record.Record()
record.entity_type, record.entity_id = _read_key_value(line)
elif c=='!':
@@ -504,16 +504,21 @@ def draw_cross_link(self, cross_link):
and not self.is_in_bounds(endB):
return None
- if startA < self.start: startA = self.start
- if startB < self.start: startB = self.start
- if self.end < endA: endA = self.end
- if self.end < endB: endB = self.end
+ if startA < self.start:
+ startA = self.start
+ if startB < self.start:
+ startB = self.start
+ if self.end < endA:
+ endA = self.end
+ if self.end < endB:
+ endB = self.end
trackobjA = cross_link._trackA(self._parent.tracks.values())
trackobjB = cross_link._trackB(self._parent.tracks.values())
assert trackobjA is not None
assert trackobjB is not None
- if trackobjA == trackobjB: raise NotImplementedError()
+ if trackobjA == trackobjB:
+ raise NotImplementedError()
if trackobjA.start is not None:
if endA < trackobjA.start:
@@ -538,7 +543,8 @@ def draw_cross_link(self, cross_link):
trackA = track_level
if track == trackobjB:
trackB = track_level
- if trackA == trackB: raise NotImplementedError()
+ if trackA == trackB:
+ raise NotImplementedError()
startangleA, startcosA, startsinA = self.canvas_angle(startA)
startangleB, startcosB, startsinB = self.canvas_angle(startB)
Oops, something went wrong.

0 comments on commit 4d2350a

Please sign in to comment.