diff --git a/README.md b/README.md index 41e44e9..9349e18 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,11 @@ This is a static webpage that can be used to automate the download of multiple U - The files will be downloaded one by one. If you are prompted for permission to download multiple files try adjusting the download delay in the HTML file which is currently set at 1 second. ![image](./bulkUploader.png) + +### tso_upload_helper.sh + +If run with the name of a TSO related project in DNA nexus as an argument, this script will partly populate the command required to upload the zip files to Qiagen: + +```bash tso_upload.sh 002_240216_A01229_0290_AHNL5GDMXY_TSO24006``` + +The resulting command will be sent to std out with just the APP_ID and MOKAGUYS_AUTH_TOKEN needing to be added to each line, this can be done using find & replace. IMPORTANT: HD200 and NTC samples (HD200 or 00000_00000 in sample name) should have their lines removed manually as these should not be uploaded. diff --git a/tso_upload_helper.sh b/tso_upload_helper.sh new file mode 100644 index 0000000..316877c --- /dev/null +++ b/tso_upload_helper.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Check if a project name is provided +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Assign the first argument to a variable +project_name="$1" + +# Capture the output from dx find into a variable +table_output=$(dx find data --name "*.zip" --json --path "${project_name}":results | jq -r ' + ["ID", "Name", "State", "Folder", "Modified", "Size"] as $headers + | ["---", "---", "---", "---", "---", "---"] as $separator + | [$headers, $separator] + + (map([.id, .describe.name, .describe.state, .describe.folder, (.describe.modified / 1000 | todate), .describe.size])) + | .[] + | @tsv' | column -t) + +# Define APP_ID and MOKAGUYS_AUTH_TOKEN +APP_ID="APP_ID" +MOKAGUYS_AUTH_TOKEN="MOKAGUYS_AUTH_TOKEN" + +# Now you can manipulate $table_output with awk or any other tool. +# Iterate over the table row by row +while IFS= read -r line; do + # Skip the header and separator lines + if [[ "$line" == ID* ]] || [[ "$line" == "---"* ]]; then + continue + fi + + # Extract the Name, Folder, and ID using awk + FILE_NAME=$(echo "$line" | awk '{print $2}') + FOLDER=$(echo "$line" | awk '{print $4}') + ID=$(echo "$line" | awk '{print $1}') + + FILE_ID="${FOLDER}/${FILE_NAME}" + SAMPLE_NAME="${FILE_NAME%.zip}" + + # Print the dx run command + echo "dx run project-ByfFPz00jy1fk6PjpZ95F27J:$APP_ID --priority high -y --name=$SAMPLE_NAME -isample_name=$SAMPLE_NAME -isample_zip_folder=$project_name:$FILE_ID --project=$project_name --auth $MOKAGUYS_AUTH_TOKEN" + + done <<< "$table_output" \ No newline at end of file