Skip to content

Commit

Permalink
Added progress bar to src/batch_download.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
jpmikhail committed Feb 25, 2025
1 parent b113c1d commit 39e1679
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/batch_download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,9 @@ contents=$(cat $listfile)
# see https://stackoverflow.com/questions/918886/how-do-i-split-a-string-on-a-delimiter-in-bash#tab-top
IFS=',' read -ra tokens <<< "$contents"

total=${#tokens[@]}
count=0

for token in "${tokens[@]}"
do
if [ "$cif" == true ]
Expand Down Expand Up @@ -110,6 +113,12 @@ do
download ${token}_mr.str.gz $outdir
fi

((count++))
progress=$((count * 100 / total))
bar=$(printf "#%.0s" $(seq 1 $((progress / 2))))
spaces=$(printf " %.0s" $(seq 1 $((50 - ${#bar}))))
echo -ne "\r[$bar$spaces] $progress%"

done


Expand Down
2 changes: 1 addition & 1 deletion stages/01_download.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ FILE=$srcpath/pdb_ids.txt
BATCH_SCRIPT=$srcpath/batch_download.sh

# Ensure batch_download.sh is present
if [ ! -f BATCH_SCRIPT ]; then
if [ ! -f "$BATCH_SCRIPT" ]; then
echo "Error: batch_download.sh not found. Please place it in the src directory." >&2
exit 1
fi
Expand Down

0 comments on commit 39e1679

Please sign in to comment.