diff options
author | Pjotr Prins | 2021-01-05 12:35:05 +0000 |
---|---|---|
committer | Pjotr Prins | 2021-01-05 12:35:05 +0000 |
commit | ced9613aa1c18c6a68056d1898b69865beac9ac2 (patch) | |
tree | 0bae81b6c6e9f9533bf94b13a9642f6bec2c5aa8 /workflows/tools | |
parent | 2ceeccd5e5158362548b868390e9d411f73cd9ff (diff) | |
download | bh20-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-x | workflows/tools/pubseq-fetch-data.py | 6 |
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}") |