diff options
author | Pjotr Prins | 2021-01-01 16:24:37 +0000 |
---|---|---|
committer | Pjotr Prins | 2021-01-01 16:24:37 +0000 |
commit | 3f059ebde6fe6888e62f4fc232d05fb3a322b011 (patch) | |
tree | 3702eff9a11381947716954f529b92cce9399b58 /workflows/pull-data/genbank/update-from-genbank.py | |
parent | ee01616a8c5ab5449325599dfaea32341f049784 (diff) | |
download | bh20-seq-resource-3f059ebde6fe6888e62f4fc232d05fb3a322b011.tar.gz bh20-seq-resource-3f059ebde6fe6888e62f4fc232d05fb3a322b011.tar.lz bh20-seq-resource-3f059ebde6fe6888e62f4fc232d05fb3a322b011.zip |
gzip output
Diffstat (limited to 'workflows/pull-data/genbank/update-from-genbank.py')
-rwxr-xr-x | workflows/pull-data/genbank/update-from-genbank.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/workflows/pull-data/genbank/update-from-genbank.py b/workflows/pull-data/genbank/update-from-genbank.py index 6d6d90c..d92f87a 100755 --- a/workflows/pull-data/genbank/update-from-genbank.py +++ b/workflows/pull-data/genbank/update-from-genbank.py @@ -8,6 +8,7 @@ # See also directory .guix-run and README.md import argparse +import gzip import os import sys from utils import chunks @@ -35,9 +36,9 @@ if not os.path.exists(dir): request_num = min(BATCH,args.max) for i, idsx in enumerate(chunks(list(ids), request_num)): - xmlfn = os.path.join(dir, f"metadata_{i}.xml") + xmlfn = os.path.join(dir, f"metadata_{i}.xml.gz") print(f"Fetching {xmlfn} ({i*request_num})",file=sys.stderr) - with open(xmlfn, 'w') as f: - f.write(Entrez.efetch(db='nuccore', id=idsx, retmode='xml').read()) + with gzip.open(xmlfn, 'w') as f: + f.write((Entrez.efetch(db='nuccore', id=idsx, retmode='xml').read()).encode()) if i*request_num >= args.max: break |