Skip to content

Commit

Permalink
Merge pull request #5 from moka-guys/tso_upload_helper
Browse files Browse the repository at this point in the history
Tso upload helper (#5)
  • Loading branch information
RachelDuffin authored Feb 20, 2024
2 parents 4b14b9a + 590a098 commit 3139013
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
44 changes: 44 additions & 0 deletions tso_upload_helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Check if a project name is provided
if [ "$#" -ne 1 ]; then
echo "Usage: $0 <project_name>"
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"

0 comments on commit 3139013

Please sign in to comment.