Commit 7010864f authored by Piotr Gawron's avatar Piotr Gawron
Browse files

bin dir is created when necessary

parent d7f36232
......@@ -6,6 +6,8 @@ import sys
import urllib.request
from pathlib import Path
BIN_PATH = "bin/"
def transform(input_line):
chromosome = input_line[2]
......@@ -32,12 +34,15 @@ def transform(input_line):
def downloadUcscFile(filename):
if not Path('bin/' + filename).is_file():
print('Beginning file download ' + filename + '...')
if not os.path.isdir(BIN_PATH):
os.makedirs(BIN_PATH)
if not Path(BIN_PATH + filename).is_file():
url = 'http://hgdownload.soe.ucsc.edu/admin/exe/linux.x86_64/' + filename
urllib.request.urlretrieve(url, 'bin/' + filename)
os.chmod('bin/' + filename, 0o755)
print('Beginning file download ' + filename + ' (' + url + ')')
urllib.request.urlretrieve(url, BIN_PATH + filename)
os.chmod(BIN_PATH + filename, 0o755)
inputFile = sys.argv[1]
......@@ -49,7 +54,7 @@ downloadUcscFile("fetchChromSizes")
chrom_sizes = basename + ".chrom.sizes"
with open(chrom_sizes, 'w') as output_chrom_sizes:
print('Fetching chrom sizes: ' + chrom_sizes)
subprocess.call(["bin/fetchChromSizes", db], stdout=output_chrom_sizes)
subprocess.call([BIN_PATH + "fetchChromSizes", db], stdout=output_chrom_sizes)
chromosomes = {}
unkown_chromosomes = {}
......@@ -91,18 +96,15 @@ else:
output.close()
if not Path('bin').is_dir():
os.mkdir('bin')
downloadUcscFile("sortBed")
downloadUcscFile("bedSort")
output_file_sorted = basename + "-sorted.bed"
print('Sorting bed file: ' + output_file_sorted)
subprocess.call(["bin/sortBed", output_file_unsorted, output_file_sorted])
subprocess.call([BIN_PATH + "bedSort", output_file_unsorted, output_file_sorted])
downloadUcscFile("bedToBigBed")
output_big_bed = basename + ".bb"
print('Creating big bed file: ' + output_big_bed)
subprocess.call(["bin/bedToBigBed", output_file_sorted, chrom_sizes, output_big_bed])
subprocess.call([BIN_PATH + "bedToBigBed", output_file_sorted, chrom_sizes, output_big_bed])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment