extensions/net.sf.basedb.reggie/trunk/src/net/sf/basedb/reggie/grid/scripts/nextseq_status.sh

Code
Comments
Other
Rev Date Author Line
6662 01 Apr 22 nicklas 1 #!/bin/bash
6662 01 Apr 22 nicklas 2 ##
6662 01 Apr 22 nicklas 3 ## Pipeline script for checking status of NextSeq sequencing run.
6662 01 Apr 22 nicklas 4 ## 
6662 01 Apr 22 nicklas 5 ## Environment variables that should be defined before calling this script
6662 01 Apr 22 nicklas 6 ##  -AllRunArchives: White-space separated list of locations to search for sequencing data
6662 01 Apr 22 nicklas 7 ##  -BARCODE: Barcode of the flow cell that we want to find information for
6662 01 Apr 22 nicklas 8 ##
6662 01 Apr 22 nicklas 9 ## The output is a number of key-value pairs. All values may not be present.
6662 01 Apr 22 nicklas 10 ##
6662 01 Apr 22 nicklas 11 ##  -RunArchive: The path to the data folder for the flow cell
6662 01 Apr 22 nicklas 12 ##  -Config: Date and time the 'Config' folder was last modified
6662 01 Apr 22 nicklas 13 ##  -RunParameters: Date and time the 'RunParameters.xml' file was last modified
6662 01 Apr 22 nicklas 14 ##  -BgzfCount: Number of files ending with 'bgzf.bci'
6662 01 Apr 22 nicklas 15 ##  -NumLanes: Value from <NumLanes> tag in RunParameters.xml
6662 01 Apr 22 nicklas 16 ##  -Read1: Value from <Read1> tag in RunParameters.xml
6662 01 Apr 22 nicklas 17 ##  -Read2: Value from <Read2> tag in RunParameters.xml
6662 01 Apr 22 nicklas 18 ##  -Index1Read: Value from <Index1Read> tag in RunParameters.xml
6662 01 Apr 22 nicklas 19 ##  -Index2Read: Value from <Index2Read> tag in RunParameters.xml
6662 01 Apr 22 nicklas 20 ##  -NextSeqSerial: Value from <InstrumentID> tag in RunParameters.xml
6662 01 Apr 22 nicklas 21 ##  -RunCompletionStatus: Date and time the 'RunCompletionStatus.xml' was last modified
6662 01 Apr 22 nicklas 22
6662 01 Apr 22 nicklas 23 # Format string for file dates/times
6662 01 Apr 22 nicklas 24 DATE_FORMAT="%Y%m%d %H%M%S"
6662 01 Apr 22 nicklas 25
6662 01 Apr 22 nicklas 26 # Try to find a folder inside run-archive that has the barcode in the name
6662 01 Apr 22 nicklas 27 # The folder may not yet exist so a missing folder is not an error
6663 01 Apr 22 nicklas 28 DATA_FOLDER=`find ${AllRunArchives} -maxdepth 2 -iname "*${BARCODE}*" -type d -print 2> /dev/null || true`
6662 01 Apr 22 nicklas 29
6662 01 Apr 22 nicklas 30 # Fail if more than one folder is found
6662 01 Apr 22 nicklas 31 readarray -t lines <<< "${DATA_FOLDER}"
6662 01 Apr 22 nicklas 32 if [ ! ${#lines[@]} -eq 1 ]; then
6662 01 Apr 22 nicklas 33   echo "Found ${#lines[@]} data folders for flow cell ${BARCODE}" 1>&2
6662 01 Apr 22 nicklas 34   echo ${DATA_FOLDER} 1>&2
6662 01 Apr 22 nicklas 35   exit 1
6662 01 Apr 22 nicklas 36 fi
6662 01 Apr 22 nicklas 37
6662 01 Apr 22 nicklas 38 echo RunArchive: ${DATA_FOLDER}
6662 01 Apr 22 nicklas 39 # Config folder is created immediately when starting the NextSeq
6662 01 Apr 22 nicklas 40 # We use the date of this folder to set the start date of the job
6662 01 Apr 22 nicklas 41 if [ -d "${DATA_FOLDER}/Config" ]; then
6662 01 Apr 22 nicklas 42   echo "Config: `date +"${DATE_FORMAT}" -r "${DATA_FOLDER}/Config"`"
6662 01 Apr 22 nicklas 43 fi
6662 01 Apr 22 nicklas 44
6662 01 Apr 22 nicklas 45 # RunParameters.xml is created after clustering
6662 01 Apr 22 nicklas 46 # We extract information about number of reads and lanes
6662 01 Apr 22 nicklas 47 # and compare that to the number of *.bgzf.bci files we can find
6662 01 Apr 22 nicklas 48 # This gives an estimate of the current sequencing cycle and we can
6662 01 Apr 22 nicklas 49 # use this for progress reporting
6662 01 Apr 22 nicklas 50 RUN_PARAMETERS=${DATA_FOLDER}/RunParameters.xml
6662 01 Apr 22 nicklas 51 if [ -f "${RUN_PARAMETERS}" ]; then
6662 01 Apr 22 nicklas 52   echo "RunParameters: `date +"${DATE_FORMAT}" -r "${RUN_PARAMETERS}"`"
6662 01 Apr 22 nicklas 53   echo "BgzfCount: `find "${DATA_FOLDER}" -type f -name *.bgzf.bci | wc -l`"
6662 01 Apr 22 nicklas 54   echo "NumLanes: `grep '<NumLanes>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`"
6662 01 Apr 22 nicklas 55   echo "Read1: `grep '<Read1>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`"
6662 01 Apr 22 nicklas 56   echo "Read2: `grep '<Read2>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`"
6662 01 Apr 22 nicklas 57   echo "Index1Read: `grep '<Index1Read>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`"
6662 01 Apr 22 nicklas 58   echo "Index2Read: `grep '<Index2Read>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`"
6662 01 Apr 22 nicklas 59   echo "NextSeqSerial: `grep '<InstrumentID>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`"
6662 01 Apr 22 nicklas 60 fi
6662 01 Apr 22 nicklas 61
6662 01 Apr 22 nicklas 62 # RunCompletionStatus.xml is created when everything is complete
6662 01 Apr 22 nicklas 63 # This becomes the end date of the job and should trigger
6662 01 Apr 22 nicklas 64 # Reggie to start file checks and secondary analysis
6662 01 Apr 22 nicklas 65 if [ -f "${DATA_FOLDER}/RunCompletionStatus.xml" ]; then
6662 01 Apr 22 nicklas 66   echo "RunCompletionStatus: `date +"${DATE_FORMAT}" -r "${DATA_FOLDER}/RunCompletionStatus.xml"`"
6662 01 Apr 22 nicklas 67 fi