blob: d250c98c8df97a425e574bfc96d84420976438ca (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#!/usr/bin/env python
import sys
import os
debug = os.environ.get("debug", False)
from subprocess import Popen
from subprocess import PIPE
def get_length(fn):
cmd = 'grep "^>" ' + fn + " -v | tr -d '\\n' | wc -c"
if debug:
print "loading sequence end points"
print "executing: " + cmd
points_fh = Popen(cmd, stdout=PIPE, shell=True)
return int(points_fh.stdout.readline())
if len(sys.argv) < 2:
print "filter_average_binding.py foreground.fa binding_distance"
exit()
foreground = sys.argv[1]
distance = int(sys.argv[2])
genome_length = get_length(foreground)
for line in sys.stdin:
(mer, count) = line.split()
if (genome_length / int(count)) < distance:
sys.stdout.write(line)
|