Last active
July 10, 2024 21:41
-
-
Save tomkinsc/ef62de93fbe847c555bfe0e47e55fe79 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -eq 0 ]; then | |
echo "This script can be used to transfer all files from a DNAnexus project to a GS bucket for Terra." | |
echo "Usage: $0 DNAnexus_project-id:/path/to/recurse gs://bucket/path [pattern_to_match]" | |
echo " Before running, be sure to log in to both BaseSpace and DNAnexus via:" | |
echo " dx login" | |
echo " The CLI toolkits for bs and dx can be found here and must be installed first:" | |
echo " https://documentation.dnanexus.com/downloads" | |
exit 1 | |
fi | |
dxprojectpath="$1" | |
bucketpath="$2" | |
match_pattern="$3" | |
dx_project_id="$(echo ${dxprojectpath} | cut -d':' -f1)" | |
for dx_file_path in $(dx find data --path "${dxprojectpath}" --delimiter=',' | cut -f4 -d',' | grep "${pattern_to_match}"); do | |
echo "Transferring ${dx_file_path}" | |
echo "dx download --output - ${dx_project_id}:${dx_file_path} | gsutil cp - ${bucketpath}${dx_file_path}" | |
dx download --output - "${dx_project_id}:${dx_file_path}" | gsutil cp - "${bucketpath}${dx_file_path}" | |
echo "" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment