-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenbank_url_compiler.sh
More file actions
41 lines (37 loc) · 1 KB
/
Copy pathgenbank_url_compiler.sh
File metadata and controls
41 lines (37 loc) · 1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
help()
{
echo
echo "Script to download NCBI genbank files associated with nucleotide accession ID"
echo "Binomica labs GPLv3"
echo
echo "Syntax: script [-i|-a|-h]"
echo "options:"
echo "-i Input nucleotide accession"
echo "-a NCBI API key"
echo " You can visit the NCBI page for more info"
echo " https://support.nlm.nih.gov/knowledgebase/article/KA-05317/en-us"
echo "-h This help screen"
echo
}
efetch1="'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/efetch.fcgi?retmode=text&id="
efetch2="&db=nucleotide&api_key="
efetch3="&rettype=gbwithparts'"
today=$(date +"%Y%m%d_%H%M")
while getopts "i:a:h" option;
do
case "${option}" in
i) inputid=${OPTARG};;
a) apikey=${OPTARG};;
h) help exit;;
\?) echo "Invalid option, please run -h for help"
exit;;
esac
done
if [[ -f $inputid ]];
then
while IFS= read -r line; do
echo $line > /dev/null
echo 'wget -w 20 -O '$line.gbk $efetch1$line$efetch2$apikey$efetch3 >> $today.txt
done < $inputid
fi