aboutsummaryrefslogtreecommitdiff
path: root/workflows/tools
diff options
context:
space:
mode:
authorPjotr Prins2021-01-05 12:35:05 +0000
committerPjotr Prins2021-01-05 12:35:05 +0000
commitced9613aa1c18c6a68056d1898b69865beac9ac2 (patch)
tree0bae81b6c6e9f9533bf94b13a9642f6bec2c5aa8 /workflows/tools
parent2ceeccd5e5158362548b868390e9d411f73cd9ff (diff)
downloadbh20-seq-resource-ced9613aa1c18c6a68056d1898b69865beac9ac2.tar.gz
bh20-seq-resource-ced9613aa1c18c6a68056d1898b69865beac9ac2.tar.lz
bh20-seq-resource-ced9613aa1c18c6a68056d1898b69865beac9ac2.zip
Add option for fetching fasta
Diffstat (limited to 'workflows/tools')
-rwxr-xr-xworkflows/tools/pubseq-fetch-data.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/workflows/tools/pubseq-fetch-data.py b/workflows/tools/pubseq-fetch-data.py
index 3f5e6cf..23c4dea 100755
--- a/workflows/tools/pubseq-fetch-data.py
+++ b/workflows/tools/pubseq-fetch-data.py
@@ -12,6 +12,7 @@ Fetch metadata (JSON) from PubSeq and optionally the FASTA files. IDs
can be passed in on the command line or in a file.
""")
+parser.add_argument('--fasta', action='store_true', help='Also fetch FASTA records')
parser.add_argument('--out', type=str, help='Directory to write to',
required=True)
parser.add_argument('--ids', type=str, help='File with ids', required=False)
@@ -36,5 +37,10 @@ for id in ids:
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}")