Permalink
Browse files

Bio/SeqUtils: PEP8 whitespace cleanup.

  • Loading branch information...
1 parent e50c1c2 commit 1bcd809ebac202e2152383224a1e5aabb580faf7 @cbrueffer cbrueffer committed with peterjc Dec 26, 2012
Showing with 36 additions and 36 deletions.
  1. +3 −3 Bio/SeqUtils/CodonUsage.py
  2. +5 −5 Bio/SeqUtils/IsoelectricPoint.py
  3. +1 −1 Bio/SeqUtils/ProtParam.py
  4. +27 −27 Bio/SeqUtils/__init__.py
@@ -85,7 +85,7 @@ def generate_index(self, fasta_file):
# synonymous codons were used all together.
for aa in SynonymousCodons:
total = 0.0
- rcsu = [] # RCSU values are CodonCount/((1/num of synonymous codons) * sum of all synonymous codons)
+ rcsu = [] # RCSU values are CodonCount/((1/num of synonymous codons) * sum of all synonymous codons)
codons = SynonymousCodons[aa]
for codon in codons:
@@ -119,10 +119,10 @@ def cai_for_gene(self, dna_sequence):
for i in range(0, len(dna_sequence), 3):
codon = dna_sequence[i:i+3]
if codon in self.index:
- if codon not in ['ATG', 'TGG']: # these two codons are always one, exclude them
+ if codon not in ['ATG', 'TGG']: # these two codons are always one, exclude them
cai_value += math.log(self.index[codon])
cai_length += 1
- elif codon not in ['TGA', 'TAA', 'TAG']: # some indices may not include stop codons
+ elif codon not in ['TGA', 'TAA', 'TAG']: # some indices may not include stop codons
raise TypeError("illegal codon in sequence: %s.\n%s" % (codon, self.index))
return math.exp(cai_value / (cai_length - 1.0))
@@ -20,10 +20,10 @@
"""
-positive_pKs = { 'Nterm': 7.5, 'K': 10.0, 'R': 12.0, 'H': 5.98 }
-negative_pKs = { 'Cterm': 3.55, 'D': 4.05, 'E': 4.45, 'C': 9.0, 'Y': 10.0 }
-pKcterminal= { 'D': 4.55, 'E': 4.75 }
-pKnterminal = { 'A': 7.59, 'M': 7.0, 'S': 6.93, 'P': 8.36, 'T': 6.82, 'V': 7.44, 'E': 7.7 }
+positive_pKs = {'Nterm': 7.5, 'K': 10.0, 'R': 12.0, 'H': 5.98}
+negative_pKs = {'Cterm': 3.55, 'D': 4.05, 'E': 4.45, 'C': 9.0, 'Y': 10.0}
+pKcterminal = {'D': 4.55, 'E': 4.75}
+pKnterminal = {'A': 7.59, 'M': 7.0, 'S': 6.93, 'P': 8.36, 'T': 6.82, 'V': 7.44, 'E': 7.7}
charged_aas = ('K', 'R', 'H', 'D', 'E', 'C', 'Y')
@@ -102,7 +102,7 @@ def pi(self):
break
# Bisection
- while pH2 - pH1 > 0.0001 and Charge!=0.0:
+ while pH2 - pH1 > 0.0001 and Charge != 0.0:
pH = (pH1 + pH2) / 2.0
Charge = self._chargeR(pH, pos_pKs, neg_pKs)
if Charge > 0.0:
@@ -106,7 +106,7 @@ def molecular_weight(self):
# remove a molecule of water from the amino acid weight
aa_weights[i] = iupac_weights[i] - water
- total_weight = water # add just one water molecule for the whole sequence
+ total_weight = water # add just one water molecule for the whole sequence
for aa in self.sequence:
total_weight += aa_weights[aa]
View
@@ -85,7 +85,7 @@ def GC123(seq):
return gcall, gc[0], gc[1], gc[2]
-def GC_skew(seq, window = 100):
+def GC_skew(seq, window=100):
"""Calculates GC skew (G-C)/(G+C) for multiple windows along the sequence.
Returns a list of ratios (floats), controlled by the length of the sequence
@@ -104,65 +104,65 @@ def GC_skew(seq, window = 100):
return values
-def xGC_skew(seq, window = 1000, zoom = 100,
- r = 300, px = 100, py = 100):
+def xGC_skew(seq, window=1000, zoom=100,
+ r=300, px=100, py=100):
"""Calculates and plots normal and accumulated GC skew (GRAPHICS !!!)."""
from Tkinter import Scrollbar, Canvas, BOTTOM, BOTH, ALL, \
VERTICAL, HORIZONTAL, RIGHT, LEFT, X, Y
- yscroll = Scrollbar(orient = VERTICAL)
- xscroll = Scrollbar(orient = HORIZONTAL)
- canvas = Canvas(yscrollcommand = yscroll.set,
- xscrollcommand = xscroll.set, background = 'white')
+ yscroll = Scrollbar(orient=VERTICAL)
+ xscroll = Scrollbar(orient=HORIZONTAL)
+ canvas = Canvas(yscrollcommand=yscroll.set,
+ xscrollcommand=xscroll.set, background='white')
win = canvas.winfo_toplevel()
win.geometry('700x700')
- yscroll.config(command = canvas.yview)
- xscroll.config(command = canvas.xview)
- yscroll.pack(side = RIGHT, fill = Y)
- xscroll.pack(side = BOTTOM, fill = X)
- canvas.pack(fill=BOTH, side = LEFT, expand = 1)
+ yscroll.config(command=canvas.yview)
+ xscroll.config(command=canvas.xview)
+ yscroll.pack(side=RIGHT, fill=Y)
+ xscroll.pack(side=BOTTOM, fill=X)
+ canvas.pack(fill=BOTH, side=LEFT, expand=1)
canvas.update()
X0, Y0 = r + px, r + py
- x1, x2, y1, y2 = X0 - r, X0 + r, Y0 -r, Y0 + r
+ x1, x2, y1, y2 = X0 - r, X0 + r, Y0 - r, Y0 + r
ty = Y0
- canvas.create_text(X0, ty, text = '%s...%s (%d nt)' % (seq[:7], seq[-7:], len(seq)))
- ty +=20
- canvas.create_text(X0, ty, text = 'GC %3.2f%%' % (GC(seq)))
- ty +=20
- canvas.create_text(X0, ty, text = 'GC Skew', fill = 'blue')
- ty +=20
- canvas.create_text(X0, ty, text = 'Accumulated GC Skew', fill = 'magenta')
- ty +=20
+ canvas.create_text(X0, ty, text='%s...%s (%d nt)' % (seq[:7], seq[-7:], len(seq)))
+ ty += 20
+ canvas.create_text(X0, ty, text='GC %3.2f%%' % (GC(seq)))
+ ty += 20
+ canvas.create_text(X0, ty, text='GC Skew', fill='blue')
+ ty += 20
+ canvas.create_text(X0, ty, text='Accumulated GC Skew', fill='magenta')
+ ty += 20
canvas.create_oval(x1, y1, x2, y2)
acc = 0
start = 0
for gc in GC_skew(seq, window):
r1 = r
- acc+=gc
+ acc += gc
# GC skew
alpha = pi - (2*pi*start)/len(seq)
r2 = r1 - gc*zoom
x1 = X0 + r1 * sin(alpha)
y1 = Y0 + r1 * cos(alpha)
x2 = X0 + r2 * sin(alpha)
y2 = Y0 + r2 * cos(alpha)
- canvas.create_line(x1, y1, x2, y2, fill = 'blue')
+ canvas.create_line(x1, y1, x2, y2, fill='blue')
# accumulated GC skew
r1 = r - 50
r2 = r1 - acc
x1 = X0 + r1 * sin(alpha)
y1 = Y0 + r1 * cos(alpha)
x2 = X0 + r2 * sin(alpha)
y2 = Y0 + r2 * cos(alpha)
- canvas.create_line(x1, y1, x2, y2, fill = 'magenta')
+ canvas.create_line(x1, y1, x2, y2, fill='magenta')
canvas.update()
start += window
- canvas.configure(scrollregion = canvas.bbox(ALL))
+ canvas.configure(scrollregion=canvas.bbox(ALL))
def molecular_weight(seq):
@@ -191,7 +191,7 @@ def nt_search(seq, subseq):
result = [pattern]
l = len(seq)
while True:
- pos+=1
+ pos += 1
s = seq[pos:]
m = re.search(pattern, s)
if not m:
@@ -313,7 +313,7 @@ def seq1(seq, custom_map={'Ter': '*'}, undef_code='X'):
# {{{
-def six_frame_translations(seq, genetic_code = 1):
+def six_frame_translations(seq, genetic_code=1):
"""Formatted string showing the 6 frame translations and GC content.
nice looking 6 frame translation with GC content - code from xbbtools

0 comments on commit 1bcd809

Please sign in to comment.