Skip to content

Commit

Permalink
Merge pull request #12 from moka-guys/develop
Browse files Browse the repository at this point in the history
Develop (#12)

Co-Authored-By: rebeccahaines1 <84131466+rebeccahaines1@users.noreply.github.com>
Co-Authored-By: Graeme <graeme_c_smith@hotmail.com>
Co-Authored-By: Natasha Pinto <33454960+natashapinto@users.noreply.github.com>
Co-Authored-By: Bioin4matics <i.malashchuk@gmail.com>
  • Loading branch information
4 people authored Jun 28, 2024
2 parents b5ea367 + 3fb9a9f commit b2a82a5
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 26 deletions.
3 changes: 2 additions & 1 deletion Readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# DNAnexus Duty CSV

This is the DNAnexus implementation of [duty_csv v2.3.0](https://github.com/moka-guys/duty_csv/releases/tag/v2.3.0). It is intended to run at the end of all DNAnexus workflows. For further details on what the underlying script does and produces, please refer to that repository.
This is the DNAnexus implementation of [duty_csv v2.4.0](https://github.com/moka-guys/duty_csv/releases/tag/v2.4.0). It is intended to run at the end of all DNAnexus workflows. For further details on what the underlying script does and produces, please refer to that repository.

## Inputs

Expand All @@ -17,6 +17,7 @@ The app takes the following inputs:
The app sends an email to config-specified address, and produces the following outputs:
* CSV (optional) - file containing DNAnexus URLs
* HTML - used for email message
* TXT - text file containing chrome downloads commands
* Logfile - for audit trail

This app sends an email to mokaguys containg a csv file attachment with URL links for files required to be transfered to Dry Lab by the Duty Bioinformatician
Expand Down
15 changes: 11 additions & 4 deletions dxapp.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "duty_csv_v1.3.0",
"name": "duty_csv_v1.4.0",
"summary": "Uses a python script to search for files required for Dry Lab transfer, creates a CSV file with URL links for the files and sends an email to MokaGuys",
"properties": {
"github release": "v1.3.0"
"github release": "v1.4.0"
},
"dxapi": "1.0.0",
"inputSpec": [
Expand Down Expand Up @@ -49,17 +49,24 @@
},
{
"name": "csv",
"label": "csv",
"label": "DNAnexus URLs csv",
"class": "file",
"help": "CSV file containing DNAnexus URLs",
"optional": true
},
{
"name": "html",
"label": "html",
"label": "Email html",
"class": "file",
"help": "HTML file used for email message",
"optional": false
},
{
"name": "txt",
"label": "Chrome downloads txt file",
"class": "file",
"help": "TXT file containing the chrome downloads commands",
"optional": true
}
],
"runSpec": {
Expand Down
42 changes: 21 additions & 21 deletions src/code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,52 +11,52 @@ function main() {
AUTH_TOKEN=$(dx cat project-FQqXfYQ0Z0gqx7XG9Z2b4K43:mokaguys_nexus_auth_key)

# Get project ID form project name
if (dx find projects --auth $AUTH_TOKEN | grep $project_name);
if (dx find projects --auth "${AUTH_TOKEN}" | grep "${project_name}");
then
echo "Project $project_name exists"
PROJ_ID=$(dx find projects --auth $AUTH_TOKEN | grep $project_name | grep -Eo '^\S*')
PROJ_ID=$(dx find projects --auth "${AUTH_TOKEN}" | grep "${project_name}" | grep -Eo '^\S*')
else
echo "Project $project_name does not exist"
exit 1
fi

OUTDIR=/home/dnanexus/out
CSV_OUTDIR=${OUTDIR}/csv/duty_csv
HTML_OUTDIR=${OUTDIR}/html/duty_csv
LOGFILE_OUTDIR=${OUTDIR}/logfile/duty_csv
CSV_OUTDIR="${OUTDIR}/csv/duty_csv"
HTML_OUTDIR="${OUTDIR}/html/duty_csv"
TXT_OUTDIR="${OUTDIR}/txt/duty_csv"
LOGFILE_OUTDIR="${OUTDIR}/logfile/duty_csv"

mkdir -p $CSV_OUTDIR $HTML_OUTDIR $LOGFILE_OUTDIR # Create in and out dirs
mkdir -p $CSV_OUTDIR $HTML_OUTDIR $LOGFILE_OUTDIR $TXT_OUTDIR # Create in and out dirs

DOCKER_FILEID='project-ByfFPz00jy1fk6PjpZ95F27J:file-Gb6PGp00jy1yzfZ3vYbq47zY'
DOCKER_FILEID='project-ByfFPz00jy1fk6PjpZ95F27J:file-GkkzFq00jy1j4G1pPJQFyjkx'
dx download $DOCKER_FILEID
DOCKER_FILENAME=$(dx describe $DOCKER_FILEID --name)
# --force-local required as if tarfile name contains a colon it tries to resolve the tarfile to a machine name
DOCKER_IMAGENAME=$(tar xfO $DOCKER_FILENAME manifest.json --force-local | sed -E 's/.*"RepoTags":\["?([^"]*)"?.*/\1/')
DOCKER_IMAGENAME=$(tar xfO "${DOCKER_FILENAME}" manifest.json --force-local | sed -E 's/.*"RepoTags":\["?([^"]*)"?.*/\1/')
docker load < "$DOCKER_FILENAME" # Load docker image
sudo docker images

# Turn comma separated strings into space separated strings
CP_CAP_PANNOS=${cp_capture_pannos//,/ }
STG_PANNOS=${stg_pannumbers//,/ }
TSO_PANNOS=${tso_pannumbers//,/ }
DOCKER_CMD="docker run -e DX_API_TOKEN=$AUTH_TOKEN -v /data/:/data/ -v $OUTDIR:/outputs/ $DOCKER_IMAGENAME -P $project_name -I $PROJ_ID -EU $AMAZON_U -PW $AMAZON_PW -TP $tso_pannumbers -SP $stg_pannumbers -CP $cp_capture_pannos"

DOCKER_CMD="docker run -e DX_API_TOKEN=$AUTH_TOKEN -v /data/:/data/ -v $OUTDIR:/outputs/ $DOCKER_IMAGENAME -P $project_name -I $PROJ_ID -EU $AMAZON_U -PW $AMAZON_PW -TP $TSO_PANNOS -SP $STG_PANNOS -CP $CP_CAP_PANNOS"

if [ "$testing" == true ];
if [ "${testing}" == true ];
then
DOCKER_CMD+=" -T"
fi

eval $DOCKER_CMD
eval "${DOCKER_CMD}"

# Move outputs into output folders to delocalise into dnanexus project
mv ${OUTDIR}/*.log $LOGFILE_OUTDIR
mv ${OUTDIR}/*.html $HTML_OUTDIR

if compgen -G "$OUTDIR/*.csv" > /dev/null; # If CSV exists
then
mv ${OUTDIR}/*.csv $CSV_OUTDIR
fi

declare -A dir_dict
dir_dict=( [".csv"]="$CSV_OUTDIR" [".txt"]="$TXT_OUTDIR" )

for filetype in "${!dir_dict[@]}"; do
if compgen -G "${OUTDIR}/*${filetype}" > /dev/null; then # If file exists (i.e. run has files requiring download)
mv ${OUTDIR}/*${filetype} ${dir_dict[$filetype]}
fi
done

dx-upload-all-outputs --parallel
}

0 comments on commit b2a82a5

Please sign in to comment.