From a029c2329e748874bee88317e44d3f47547f71d8 Mon Sep 17 00:00:00 2001 From: Pjotr Prins Date: Fri, 1 Jan 2021 10:59:56 -0600 Subject: genbank: minor fixes --- workflows/pull-data/genbank/update-from-genbank.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'workflows/pull-data/genbank/update-from-genbank.py') diff --git a/workflows/pull-data/genbank/update-from-genbank.py b/workflows/pull-data/genbank/update-from-genbank.py index d92f87a..3faea39 100755 --- a/workflows/pull-data/genbank/update-from-genbank.py +++ b/workflows/pull-data/genbank/update-from-genbank.py @@ -34,11 +34,14 @@ dir = args.out if not os.path.exists(dir): raise Exception(f"Directory {dir} does not exist") -request_num = min(BATCH,args.max) +request_num = BATCH +if args.max: + 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.gz") print(f"Fetching {xmlfn} ({i*request_num})",file=sys.stderr) 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: + if args.max and i*request_num >= args.max: break -- cgit v1.2.3