aboutsummaryrefslogtreecommitdiff
path: root/workflows
diff options
context:
space:
mode:
authorPjotr Prins2021-01-05 07:13:15 -0600
committerPjotr Prins2021-01-05 07:13:15 -0600
commit17cd8caa85991784f205109f2b64b255726a0e80 (patch)
tree7d49c4a404d4361ee4609e10ad3918498d0090a4 /workflows
parentced9613aa1c18c6a68056d1898b69865beac9ac2 (diff)
downloadbh20-seq-resource-17cd8caa85991784f205109f2b64b255726a0e80.tar.gz
bh20-seq-resource-17cd8caa85991784f205109f2b64b255726a0e80.tar.lz
bh20-seq-resource-17cd8caa85991784f205109f2b64b255726a0e80.zip
Fetching fixes
Diffstat (limited to 'workflows')
-rwxr-xr-xworkflows/tools/pubseq-fetch-data.py30
1 files changed, 17 insertions, 13 deletions
diff --git a/workflows/tools/pubseq-fetch-data.py b/workflows/tools/pubseq-fetch-data.py
index 23c4dea..2119fdf 100755
--- a/workflows/tools/pubseq-fetch-data.py
+++ b/workflows/tools/pubseq-fetch-data.py
@@ -31,16 +31,20 @@ if (len(ids)==0):
for id in ids:
print(id)
- r = requests.get(f"http://covid19.genenetwork.org/api/sample/{id}.json")
- if r:
- m_url = r.json()[0]['metadata']
- mr = requests.get(m_url)
- with open(dir+"/"+id+".json","w") as outf:
- outf.write(mr.text)
- if args.fasta:
- fa_url = r.json()[0]['fasta']
- fr = requests.get(fa_url)
- with open(dir+"/"+id+".fa","w") as outf:
- outf.write(fr.text)
- else:
- raise Exception(f"Can not find record for {id}")
+ jsonfn = dir+"/"+id+".json"
+ if not os.path.exists(jsonfn):
+ r = requests.get(f"http://covid19.genenetwork.org/api/sample/{id}.json")
+ if r:
+ m_url = r.json()[0]['metadata']
+ mr = requests.get(m_url)
+ with open(dir+"/"+id+".json","w") as outf:
+ outf.write(mr.text)
+ if args.fasta:
+ fastafn = dir+"/"+id+".fa"
+ if os.path.exists(fastafn): continue
+ fa_url = r.json()[0]['fasta']
+ fr = requests.get(fa_url)
+ with open(fastafn,"w") as outf:
+ outf.write(fr.text)
+ else:
+ raise Exception(f"Can not find record for {id}")