Skip to content

Commit 7ef0f6d

Browse files
cbruefferpeterjc
authored andcommitted
Fixes for PEP8 W2 whitespace warnings.
1 parent 2c191ff commit 7ef0f6d

33 files changed

+258
-268
lines changed

Bio/CodonAlign/CodonAlignment.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __str__(self):
6262
lines = ["%s CodonAlignment with %i rows and %i columns (%i codons)"
6363
% (str(self._alphabet), rows, \
6464
self.get_alignment_length(), self.get_aln_length())]
65-
65+
6666
if rows <= 60:
6767
lines.extend([self._str_line(rec, length=60) \
6868
for rec in self._records])

Bio/CodonAlign/CodonSeq.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ def __init__(self, data='', alphabet=default_codon_alphabet,
103103
"from alphabet "
104104
"({0})!".format(seq_ungapped[i:i+3]))
105105
self.rf_table = rf_table
106-
106+
107107
def __getitem__(self, index):
108108
# TODO: handle alphabet elegantly
109109
return Seq(self._data[index], alphabet=generic_dna)
@@ -238,7 +238,7 @@ def full_translate(self, codon_table=default_codon_table, stop_symbol="*"):
238238
full_rf_table = self.get_full_rf_table()
239239
return self.translate(codon_table=codon_table, stop_symbol=stop_symbol,
240240
rf_table=full_rf_table, ungap_seq=False)
241-
241+
242242
def ungap(self, gap=None):
243243
if hasattr(self.alphabet, "gap_char"):
244244
if not gap:
@@ -533,7 +533,7 @@ def compare_codon(codon1, codon2, codon_table=default_codon_table,
533533
weight=0.5/3))
534534
]
535535
return SN
536-
536+
537537

538538
#################################################################
539539
# private functions for LWL85 method
@@ -818,7 +818,7 @@ def _get_kappa_t(pi, TV, t=False):
818818
t = (4*pi['T']*pi['C']*(1+kappaF84/pi['Y'])+\
819819
4*pi['A']*pi['G']*(1+kappaF84/pi['R'])+4*pi['Y']*pi['R'])*b
820820
return t
821-
821+
822822

823823
def _count_site_YN00(codon_lst1, codon_lst2, pi, k,
824824
codon_table=default_codon_table):

Bio/Graphics/KGML_vis.py

+29-29
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
""" This module provides classes and functions to visualise a KGML Pathway Map
22
3-
The KGML definition is as of release KGML v0.7.1
3+
The KGML definition is as of release KGML v0.7.1
44
(http://www.kegg.jp/kegg/xml/docs/)
55
66
Classes:
@@ -28,14 +28,14 @@
2828
def hexdarken(hexcolor, factor=0.7):
2929
"""Returns darkened hex color as a ReportLab RGB color.
3030
31-
Take a passed hex color and return an RGB color that is
31+
Take a passed hex color and return an RGB color that is
3232
slightly darker (if possible).
3333
"""
3434
c = colors.HexColor(hexcolor)
3535
for a in ['red', 'green', 'blue']:
3636
setattr(c, a, factor * getattr(c, a))
3737
return c
38-
38+
3939
def get_temp_imagefilename(url):
4040
"""Returns filename of temporary file containing downloaded image.
4141
@@ -50,7 +50,7 @@ def get_temp_imagefilename(url):
5050
f.close()
5151
im.save(fname, 'PNG')
5252
return fname
53-
53+
5454

5555
class KGMLCanvas(object):
5656
"""Reportlab Canvas-based representation of a KGML pathway map."""
@@ -75,7 +75,7 @@ def __init__(self, pathway, import_imagemap=False, label_compounds=True,
7575
self.draw_relations = draw_relations
7676
self.non_reactant_transparency = 0.3
7777
self.import_imagemap = import_imagemap # Import the map .png from URL
78-
# percentage of canvas that will be margin in on either side in the
78+
# percentage of canvas that will be margin in on either side in the
7979
# X and Y directions
8080
self.margins = margins
8181

@@ -99,9 +99,9 @@ def draw(self, filename):
9999
self.pathway.bounds[1][1])
100100
# Instantiate canvas
101101
self.drawing = \
102-
canvas.Canvas(filename, bottomup=0,
102+
canvas.Canvas(filename, bottomup=0,
103103
pagesize=(cwidth * \
104-
(1 + 2 * self.margins[0]),
104+
(1 + 2 * self.margins[0]),
105105
cheight * \
106106
(1 + 2 * self.margins[1])))
107107
self.drawing.setFont(self.fontname, self.fontsize)
@@ -116,7 +116,7 @@ def draw(self, filename):
116116
self.drawing.drawImage(imfilename, 0, 0)
117117
self.drawing.restoreState()
118118
# Add the reactions, compounds and maps
119-
# Maps go on first, to be overlaid by more information.
119+
# Maps go on first, to be overlaid by more information.
120120
# By default, they're slightly transparent.
121121
if self.show_maps:
122122
self.__add_maps()
@@ -136,10 +136,10 @@ def draw(self, filename):
136136
def __add_maps(self):
137137
"""Adds maps to the drawing of the map.
138138
139-
We do this first, as they're regional labels to be overlaid by
139+
We do this first, as they're regional labels to be overlaid by
140140
information. Also, we want to set the color to something subtle.
141141
142-
We're using Hex colors because that's what KGML uses, and
142+
We're using Hex colors because that's what KGML uses, and
143143
Reportlab doesn't mind.
144144
"""
145145
for m in self.pathway.maps:
@@ -177,13 +177,13 @@ def __add_graphics(self, graphics):
177177
self.drawing.circle(graphics.x, graphics.y, graphics.width*0.5,
178178
stroke=1, fill=1)
179179
elif graphics.type == 'roundrectangle':
180-
self.drawing.roundRect(graphics.x - graphics.width * 0.5,
180+
self.drawing.roundRect(graphics.x - graphics.width * 0.5,
181181
graphics.y - graphics.height * 0.5,
182182
graphics.width, graphics.height,
183183
min(graphics.width, graphics.height) * 0.1,
184184
stroke=1, fill=1)
185185
elif graphics.type == 'rectangle':
186-
self.drawing.rect(graphics.x - graphics.width * 0.5,
186+
self.drawing.rect(graphics.x - graphics.width * 0.5,
187187
graphics.y - graphics.height * 0.5,
188188
graphics.width, graphics.height,
189189
stroke=1, fill=1)
@@ -196,9 +196,9 @@ def __add_labels(self, graphics):
196196
"""
197197
if graphics.type == 'line':
198198
# We use the midpoint of the line - sort of - we take the median
199-
# line segment (list-wise, not in terms of length), and use the
200-
# midpoint of that line. We could have other options here,
201-
# maybe even parameterising it to a proportion of the total line
199+
# line segment (list-wise, not in terms of length), and use the
200+
# midpoint of that line. We could have other options here,
201+
# maybe even parameterising it to a proportion of the total line
202202
# length.
203203
mid_idx = len(graphics.coords) * 0.5
204204
if not int(mid_idx) == mid_idx:
@@ -222,7 +222,7 @@ def __add_labels(self, graphics):
222222
text = graphics.name[:12] + '...'
223223
self.drawing.drawCentredString(x, y, text)
224224
self.drawing.setFont(self.fontname, self.fontsize)
225-
225+
226226
def __add_orthologs(self):
227227
"""Adds 'ortholog' Entry elements to the drawing of the map (PRIVATE).
228228
@@ -272,7 +272,7 @@ def __add_compounds(self):
272272
if self.label_compounds:
273273
if not compound.is_reactant:
274274
t = 0.3
275-
else:
275+
else:
276276
t = 1
277277
self.drawing.setFillColor(colors.Color(0.2, 0.2, 0.2, t))
278278
self.__add_labels(g)
@@ -288,20 +288,20 @@ def __add_genes(self):
288288
if self.label_compounds:
289289
self.drawing.setFillColor(hexdarken(g.fgcolor))
290290
self.__add_labels(g)
291-
291+
292292

293293
def __add_relations(self):
294294
"""Adds relations to the map (PRIVATE).
295295
296-
This is tricky. There is no defined graphic in KGML for a
296+
This is tricky. There is no defined graphic in KGML for a
297297
relation, and the corresponding entries are typically defined
298298
as objects 'to be connected somehow'. KEGG uses KegSketch, which
299299
is not public, and most third-party software draws straight line
300300
arrows, with heads to indicate the appropriate direction
301-
(at both ends for reversible reactions), using solid lines for
301+
(at both ends for reversible reactions), using solid lines for
302302
ECrel relation types, and dashed lines for maplink relation types.
303303
304-
The relation has:
304+
The relation has:
305305
- entry1: 'from' node
306306
- entry2: 'to' node
307307
- subtype: what the relation refers to
@@ -346,7 +346,7 @@ def __draw_arrow(self, g_from, g_to):
346346
p.moveTo(centre_from[0], bounds_from[1][1])
347347
p.lineTo(centre_from[0], bounds_to[0][1])
348348
# Draw arrow point - TODO
349-
else: # to below from
349+
else: # to below from
350350
p.moveTo(centre_from[0], bounds_from[0][1])
351351
p.lineTo(centre_from[0], bounds_to[1][1])
352352
# Draw arrow point - TODO
@@ -356,10 +356,10 @@ def __draw_arrow(self, g_from, g_to):
356356
p.moveTo(centre_to[0], bounds_from[1][1])
357357
p.lineTo(centre_to[0], bounds_to[0][1])
358358
# Draw arrow point - TODO
359-
else: # to below from
359+
else: # to below from
360360
p.moveTo(centre_to[0], bounds_from[0][1])
361361
p.lineTo(centre_to[0], bounds_to[1][1])
362-
# Draw arrow point - TODO
362+
# Draw arrow point - TODO
363363
self.drawing.drawPath(p) # Draw arrow shaft
364364
#print(g_from)
365365
#print(bounds_from)
@@ -371,7 +371,7 @@ def __draw_arrow(self, g_from, g_to):
371371

372372
if __name__ == '__main__':
373373
# Test production of Reportlab Canvas PDF visualisation
374-
# Try a default KO metabolic map with ortholog lines given
374+
# Try a default KO metabolic map with ortholog lines given
375375
pathway = KGML_parser.read(open('ko01100.xml', 'rU'))
376376
print(pathway)
377377
kgml_map = KGMLCanvas(pathway)
@@ -388,7 +388,7 @@ def __draw_arrow(self, g_from, g_to):
388388
g.width = 3
389389
kgml_map.draw('KGML_canvas_ddc_test.pdf')
390390

391-
# Try a KO metabolic map with no ortholog lines, using a local .png
391+
# Try a KO metabolic map with no ortholog lines, using a local .png
392392
pathway = KGML_parser.read(open('ko_metabolic/ko00910.xml', 'rU'))
393393
pathway.image = 'map/map00910.png'
394394
print(pathway)
@@ -397,15 +397,15 @@ def __draw_arrow(self, g_from, g_to):
397397
kgml_map.show_maps = False
398398
kgml_map.draw('KGML_canvas_map_local_test.pdf')
399399

400-
# Try a KO metabolic map with no ortholog lines, using the KEGG .png
400+
# Try a KO metabolic map with no ortholog lines, using the KEGG .png
401401
pathway = KGML_parser.read(open('ko_metabolic/ko00253.xml', 'rU'))
402402
print(pathway)
403403
kgml_map = KGMLCanvas(pathway)
404404
kgml_map.import_imagemap = True
405405
kgml_map.show_maps = False
406406
kgml_map.draw('KGML_canvas_map_test.pdf')
407407

408-
# Try a KO metabolic map with no ortholog lines using the KEGG .png,
408+
# Try a KO metabolic map with no ortholog lines using the KEGG .png,
409409
# but this time using a Dickeya XML file
410410
pathway = KGML_parser.read(open('dda00190.xml', 'rU'))
411411
print(pathway)
@@ -414,7 +414,7 @@ def __draw_arrow(self, g_from, g_to):
414414
kgml_map.show_maps = True
415415
kgml_map.draw('KGML_canvas_dda_map_test.pdf')
416416

417-
# Try a KO metabolic map with no ortholog lines using the KEGG .png,
417+
# Try a KO metabolic map with no ortholog lines using the KEGG .png,
418418
# but this time using a Dickeya XML file
419419
pathway = KGML_parser.read(open('test_retrieve_ddc00190.kgml', 'rU'))
420420
print(pathway)

Bio/KEGG/KGML/KGML_parser.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def parse(handle, debug=0):
5757
Arguments:
5858
- handle - file handle to a KGML file for parsing
5959
- debug - integer for amount of debug information to print
60-
60+
6161
This is a generator for the return of multiple Pathway objects.
6262
"""
6363
# Check handle
@@ -155,7 +155,7 @@ def _parse_relation(element):
155155
warnings.warn("Warning: tag %s not implemented in parser" % element.tag,
156156
BiopythonParserWarning)
157157
return self.pathway
158-
158+
159159

160160
if __name__ == '__main__':
161161
# Check large metabolism

Bio/KEGG/KGML/KGML_pathway.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def get_KGML(self):
7777
rough_xml = header + _as_string(ET.tostring(self.element, 'utf-8'))
7878
reparsed = minidom.parseString(rough_xml)
7979
return reparsed.toprettyxml(indent=" ")
80-
80+
8181

8282
def add_entry(self, entry):
8383
"""Add an Entry element to the pathway."""
@@ -290,15 +290,15 @@ def add_component(self, element):
290290
assert element.id in self._pathway.entries, \
291291
"Component %s is not an entry in the pathway" % value
292292
self.components.add(element)
293-
293+
294294
def remove_component(self, value):
295295
"""Remove the entry with the passed ID from the group."""
296296
self.components.remove(value)
297297

298298
def add_graphics(self, entry):
299299
"""Add the Graphics entry."""
300300
self.graphics.append(entry)
301-
301+
302302
def remove_graphics(self, entry):
303303
"""Remove the Graphics entry with the passed ID from the group."""
304304
self.graphics.remove(entry)
@@ -449,7 +449,7 @@ def __init__(self, parent):
449449
self.fgcolor = ''
450450
self.bgcolor = ''
451451
self._parent = parent
452-
452+
453453
# We make sure that the XY coordinates, width and height are numbers
454454
def _getx(self):
455455
return self._x

Bio/Motif/Parsers/MAST.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
class Record(object):
1212
"""The class for holding the results from a MAST run.
13-
13+
1414
A MAST.Record holds data about matches between motifs and sequences.
1515
The motifs held by the Record are objects of the class MEMEMotif.
16-
16+
1717
Methods:
1818
get_motif_by_name (motif_name): returns a MEMEMotif with the given
1919
name.
@@ -26,7 +26,7 @@ def __init__ (self):
2626
self.diagrams = {}
2727
self.alphabet = None
2828
self.motifs = []
29-
29+
3030
def get_motif_by_name (self, name):
3131
for m in self.motifs:
3232
if m.name == name:

0 commit comments

Comments
 (0)