-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathStealBindingBeds.py
26 lines (24 loc) · 1012 Bytes
/
StealBindingBeds.py
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
import urllib
from os import path
from glob import glob
import time
url_base = 'http://bdtnp.lbl.gov/Fly-Net/archives/chipper/Post_Processing/{chip}/{chip}-sym-25_primary_peaks.bed'
pwm_base = ('http://bdtnp.lbl.gov/Fly-Net/archives/'
'chipper/Post_Processing/{chip}/{chip}.cm')
file_base = 'Reference/peaks-25-dm2/{chip}-sym-25_peaks.bed'
files = glob('prereqs/BDTNP_in_vivo_binding_Release.2.1/Supplemental_Tables/*.txt')
for file in files:
chip = path.basename(file).split('-')[0]
print chip
fh = urllib.urlopen(url_base.format(chip=chip), )
fh.readline() # The track line makes liftOver unhappy
of = open(file_base.format(chip=chip), 'w')
for line in fh:
data = line.split()
data[2] = str(int(data[2]) + 1)
of.write('\t'.join(data) + '\n')
#of.write(line.replace('\t',' '))
#of.write(line)
urllib.urlretrieve(pwm_base.format(chip=chip),
'prereqs/BDTNP_pwms/'+chip.split('_')[0]+'.cm')
time.sleep(1)