3698 |
18 Jan 16 |
nicklas |
#!/bin/sh |
3698 |
18 Jan 16 |
nicklas |
# $Id $ |
3698 |
18 Jan 16 |
nicklas |
3 |
|
3698 |
18 Jan 16 |
nicklas |
# Nicklas Nordborg, 2015 |
3698 |
18 Jan 16 |
nicklas |
5 |
# |
3698 |
18 Jan 16 |
nicklas |
# Finds information about a sequencing run given the barcode of a flow cell |
5474 |
05 Jun 19 |
nicklas |
# It is expected that the sequencing is done with a NextSeq sequencer |
3698 |
18 Jan 16 |
nicklas |
8 |
# |
4045 |
03 Aug 16 |
nicklas |
# run ./nextseq_status.sh <barcode> <run-archive-root-1> [<run-archive-root-2> ...] |
3698 |
18 Jan 16 |
nicklas |
10 |
# |
3698 |
18 Jan 16 |
nicklas |
# The output is a number of key-value pairs. All values may not be present. |
3698 |
18 Jan 16 |
nicklas |
12 |
# |
3698 |
18 Jan 16 |
nicklas |
# RunArchive: The path to the data folder for the flow cell |
3698 |
18 Jan 16 |
nicklas |
# Config: Date and time the 'Config' folder was last modified |
3698 |
18 Jan 16 |
nicklas |
# RunParameters: Date and time the 'RunParameters.xml' file was last modified |
3698 |
18 Jan 16 |
nicklas |
# BgzfCount: Number of files ending with 'bgzf.bci' |
3698 |
18 Jan 16 |
nicklas |
# NumLanes: Value from <NumLanes> tag in RunParameters.xml |
3698 |
18 Jan 16 |
nicklas |
# Read1: Value from <Read1> tag in RunParameters.xml |
3698 |
18 Jan 16 |
nicklas |
# Read2: Value from <Read2> tag in RunParameters.xml |
3698 |
18 Jan 16 |
nicklas |
# Index1Read: Value from <Index1Read> tag in RunParameters.xml |
5474 |
05 Jun 19 |
nicklas |
# Index2Read: Value from <Index2Read> tag in RunParameters.xml |
5474 |
05 Jun 19 |
nicklas |
# NextSeqSerial: Value from <InstrumentID> tag in RunParameters.xml |
3698 |
18 Jan 16 |
nicklas |
# RunCompletionStatus: Date and time the 'RunCompletionStatus.xml' was last modified |
3698 |
18 Jan 16 |
nicklas |
24 |
|
4045 |
03 Aug 16 |
nicklas |
25 |
BARCODE=$1 |
4045 |
03 Aug 16 |
nicklas |
26 |
shift |
4045 |
03 Aug 16 |
nicklas |
27 |
RUN_ARCHIVE=$@ |
3698 |
18 Jan 16 |
nicklas |
28 |
|
3698 |
18 Jan 16 |
nicklas |
# Format string for file dates/times |
3698 |
18 Jan 16 |
nicklas |
30 |
DATE_FORMAT="%Y%m%d %H%M%S" |
3698 |
18 Jan 16 |
nicklas |
31 |
|
3698 |
18 Jan 16 |
nicklas |
# Try to find a folder inside run-archive that has the barcode in the name |
3698 |
18 Jan 16 |
nicklas |
# The folder may not yet exist so a missing folder is not an error |
4045 |
03 Aug 16 |
nicklas |
34 |
DATA_FOLDER=`find ${RUN_ARCHIVE} -maxdepth 2 -iname "*${BARCODE}*" -type d -print 2> /dev/null || true`; |
3698 |
18 Jan 16 |
nicklas |
35 |
|
3698 |
18 Jan 16 |
nicklas |
# Fail if more than one folder is found |
3698 |
18 Jan 16 |
nicklas |
37 |
readarray -t lines <<< "${DATA_FOLDER}" |
3698 |
18 Jan 16 |
nicklas |
38 |
if [ ! ${#lines[@]} -eq 1 ]; then |
3698 |
18 Jan 16 |
nicklas |
39 |
echo "Found ${#lines[@]} data folders for flow cell ${BARCODE}" 1>&2 |
3698 |
18 Jan 16 |
nicklas |
40 |
echo ${DATA_FOLDER} 1>&2 |
3698 |
18 Jan 16 |
nicklas |
41 |
exit 1 |
3698 |
18 Jan 16 |
nicklas |
42 |
fi |
3698 |
18 Jan 16 |
nicklas |
43 |
|
3698 |
18 Jan 16 |
nicklas |
44 |
echo RunArchive: ${DATA_FOLDER} |
3698 |
18 Jan 16 |
nicklas |
# Config folder is created immediately when starting the NextSeq |
3698 |
18 Jan 16 |
nicklas |
# We use the date of this folder to set the start date of the job |
3698 |
18 Jan 16 |
nicklas |
47 |
if [ -d "${DATA_FOLDER}/Config" ]; then |
3698 |
18 Jan 16 |
nicklas |
48 |
echo "Config: `date +"${DATE_FORMAT}" -r "${DATA_FOLDER}/Config"`" |
3698 |
18 Jan 16 |
nicklas |
49 |
fi |
3698 |
18 Jan 16 |
nicklas |
50 |
|
3698 |
18 Jan 16 |
nicklas |
# RunParameters.xml is created after clustering |
3698 |
18 Jan 16 |
nicklas |
# We extract information about number of reads and lanes |
3698 |
18 Jan 16 |
nicklas |
# and compare that to the number of *.bgzf.bci files we can find |
3698 |
18 Jan 16 |
nicklas |
# This gives an estimate of the current sequencing cycle and we can |
3698 |
18 Jan 16 |
nicklas |
# use this for progress reporting |
3698 |
18 Jan 16 |
nicklas |
56 |
RUN_PARAMETERS=${DATA_FOLDER}/RunParameters.xml |
3698 |
18 Jan 16 |
nicklas |
57 |
if [ -f "${RUN_PARAMETERS}" ]; then |
3698 |
18 Jan 16 |
nicklas |
58 |
echo "RunParameters: `date +"${DATE_FORMAT}" -r "${RUN_PARAMETERS}"`" |
3698 |
18 Jan 16 |
nicklas |
59 |
echo "BgzfCount: `find "${DATA_FOLDER}" -type f -name *.bgzf.bci | wc -l`" |
3698 |
18 Jan 16 |
nicklas |
60 |
echo "NumLanes: `grep '<NumLanes>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`" |
3698 |
18 Jan 16 |
nicklas |
61 |
echo "Read1: `grep '<Read1>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`" |
3698 |
18 Jan 16 |
nicklas |
62 |
echo "Read2: `grep '<Read2>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`" |
3698 |
18 Jan 16 |
nicklas |
63 |
echo "Index1Read: `grep '<Index1Read>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`" |
5474 |
05 Jun 19 |
nicklas |
64 |
echo "Index2Read: `grep '<Index2Read>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`" |
3698 |
18 Jan 16 |
nicklas |
65 |
echo "NextSeqSerial: `grep '<InstrumentID>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`" |
3698 |
18 Jan 16 |
nicklas |
66 |
fi |
3698 |
18 Jan 16 |
nicklas |
67 |
|
3698 |
18 Jan 16 |
nicklas |
# RunCompletionStatus.xml is created when everything is complete |
3698 |
18 Jan 16 |
nicklas |
# This becomes the end date of the job and should trigger |
3698 |
18 Jan 16 |
nicklas |
# Reggie to start file checks and secondary analysis |
3698 |
18 Jan 16 |
nicklas |
71 |
if [ -f "${DATA_FOLDER}/RunCompletionStatus.xml" ]; then |
3698 |
18 Jan 16 |
nicklas |
72 |
echo "RunCompletionStatus: `date +"${DATE_FORMAT}" -r "${DATA_FOLDER}/RunCompletionStatus.xml"`" |
3698 |
18 Jan 16 |
nicklas |
73 |
fi |