-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Parallel and download function (#10)
* cpu count * cpu count default * add chrM columns in create script * Update README.md * Update README.md * source db * utils * packages * packages * rm package * package * Update README.md * rename * Update README.md * variable names * final adj Co-authored-by: Kalin Nonchev <[email protected]>
- Loading branch information
1 parent
3890d6d
commit 79860bb
Showing
9 changed files
with
164 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import urllib.request | ||
import gzip | ||
import shutil | ||
from tqdm import tqdm | ||
import os | ||
import time | ||
|
||
|
||
class DownloadProgressBar(tqdm): | ||
def update_to(self, b=1, bsize=1, tsize=None): | ||
if tsize is not None: | ||
self.total = tsize | ||
self.update(b * bsize - self.n) | ||
|
||
|
||
def download_url(url, output_dir): | ||
with DownloadProgressBar(unit='B', unit_scale=True, | ||
miniters=1, desc=url.split('/')[-1]) as t: | ||
urllib.request.urlretrieve(url, filename=f"{output_dir}/gnomad_db.sqlite3.gz", reporthook=t.update_to) | ||
time.sleep(5) | ||
|
||
def unzip(output_dir): | ||
file_name_in = f"{output_dir}/gnomad_db.sqlite3.gz" | ||
file_name_out = f"{output_dir}/gnomad_db.sqlite3" | ||
with gzip.open(file_name_in, 'rb') as f_in: | ||
with open(file_name_out, 'wb') as f_out: | ||
shutil.copyfileobj(f_in, f_out) | ||
time.sleep(5) | ||
os.remove(file_name_in) | ||
print(f"Database location: {file_name_out}") | ||
|
||
def download_and_unzip_file(url, output_dir): | ||
print("Starting downloading...") | ||
download_url(url, output_dir) | ||
print("Starting unzipping. This can take some time...") | ||
unzip(output_dir) | ||
print("Done!") | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,3 +4,4 @@ numpy | |
pyyaml | ||
pytest | ||
joblib | ||
tqdm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
from setuptools import setup, find_packages | ||
|
||
setup(name='gnomad_db', | ||
version='0.0.4', | ||
version='0.0.5', | ||
description='This package scales the huge gnomAD files to a SQLite database, which is easy and fast to query. It extracts from a gnomAD vcf the minor allele frequency for each variant.', | ||
author='KalinNonchev', | ||
author_email='[email protected]', | ||
|
@@ -11,6 +11,6 @@ | |
url="https://github.com/KalinNonchev/gnomAD_MAF", | ||
packages=find_packages(), # find packages | ||
include_package_data=True, | ||
install_requires=['pandas', 'numpy', 'joblib'], # external packages as dependencies, | ||
install_requires=['pandas', 'numpy', 'joblib', 'tqdm'], # external packages as dependencies, | ||
python_requires='>=3.6' | ||
) |