Mercurial > repos > iuc > cwpair2
diff cwpair2_util.py @ 2:d856e96b8ce2 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/cwpair2 commit ea49259a702be2cc2b70166770d09177019bb210
| author | iuc |
|---|---|
| date | Wed, 11 May 2016 04:00:46 -0400 |
| parents | afa47be0dc76 |
| children | 0533034acd09 |
line wrap: on
line diff
--- a/cwpair2_util.py Wed Dec 23 09:25:28 2015 -0500 +++ b/cwpair2_util.py Wed May 11 04:00:46 2016 -0400 @@ -3,8 +3,9 @@ import os import sys import traceback + import matplotlib -matplotlib.use('Agg') +matplotlib.use('Agg') # noqa from matplotlib import pyplot # Data outputs @@ -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:
