aboutsummaryrefslogtreecommitdiff
path: root/workflows/pull-data
diff options
context:
space:
mode:
Diffstat (limited to 'workflows/pull-data')
-rwxr-xr-xworkflows/pull-data/genbank/update-from-genbank.py7
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