diff cwpair2_util.py @ 2:abc464ca7260 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/cwpair2 commit 0e7c1b37cf73425c6637b4e196fdeb290e042bc1
author iuc
date Tue, 26 Jul 2016 06:06:17 -0400
parents 8600bfe7ed52
children 436dc65bd902
line wrap: on
line diff
--- a/cwpair2_util.py	Wed Dec 23 09:26:01 2015 -0500
+++ b/cwpair2_util.py	Tue Jul 26 06:06:17 2016 -0400
@@ -3,9 +3,10 @@
 import os
 import sys
 import traceback
+
 import matplotlib
 matplotlib.use('Agg')
-from matplotlib import pyplot
+from matplotlib import pyplot  # noqa: E402
 
 # Data outputs
 DETAILS = 'D'
@@ -47,7 +48,7 @@
         """
         Returns the bin in which a data point falls
         """
-        return self.start + (x-self.start) // self.binsize * self.binsize + self.binsize/2.0
+        return self.start + (x - self.start) // self.binsize * self.binsize + self.binsize / 2.0
 
     def add(self, x):
         x = self.get_bin(x)
@@ -75,7 +76,7 @@
 
 
 def distance(peak1, peak2):
-    return (peak2[1]+peak2[2])/2 - (peak1[1]+peak1[2])/2
+    return (peak2[1] + peak2[2]) / 2 - (peak1[1] + peak1[2]) / 2
 
 
 def gff_row(cname, start, end, score, source, type='.', strand='.', phase='.', attrs={}):
@@ -114,7 +115,7 @@
             values.append(peak[3])
     values.sort()
     # Get 95% value
-    return values[int(len(values)*0.95)]
+    return values[int(len(values) * 0.95)]
 
 
 def filter(chromosomes, threshold=0.05):
@@ -149,7 +150,7 @@
 
 
 def make_keys(crick):
-    return [(data[1] + data[2])//2 for data in crick]
+    return [(data[1] + data[2]) // 2 for data in crick]
 
 
 def get_window(crick, peak, up_distance, down_distance, keys=None):
@@ -190,7 +191,7 @@
 def match_mode(window, peak, mode):
     if not window:
         return None
-    return min(window, key=lambda cpeak: abs(distance(peak, cpeak)-mode))
+    return min(window, key=lambda cpeak: abs(distance(peak, cpeak) - mode))
 
 METHODS = {'mode': match_mode, 'closest': match_closest, 'largest': match_largest}
 
@@ -351,9 +352,9 @@
                                               match[2],
                                               match[3], '-',
                                               midpoint,
-                                              peak[3]+match[3],
+                                              peak[3] + match[3],
                                               d))
-                i = bisect.bisect_left(keys, (match[1]+match[2])/2)
+                i = bisect.bisect_left(keys, (match[1] + match[2]) / 2)
                 del crick[i]
                 del keys[i]
             else: