5474 |
05 Jun 19 |
nicklas |
#!/bin/sh |
5474 |
05 Jun 19 |
nicklas |
# $Id $ |
5474 |
05 Jun 19 |
nicklas |
3 |
|
5474 |
05 Jun 19 |
nicklas |
# Nicklas Nordborg, 2019 |
5474 |
05 Jun 19 |
nicklas |
5 |
# |
5474 |
05 Jun 19 |
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 HiSeq sequencer |
5474 |
05 Jun 19 |
nicklas |
8 |
# |
5474 |
05 Jun 19 |
nicklas |
# run ./hiseq_status.sh <barcode> <run-archive-root-1> [<run-archive-root-2> ...] |
5474 |
05 Jun 19 |
nicklas |
10 |
# |
5474 |
05 Jun 19 |
nicklas |
# The output is a number of key-value pairs. All values may not be present. |
5474 |
05 Jun 19 |
nicklas |
12 |
# |
5474 |
05 Jun 19 |
nicklas |
# RunArchive: The path to the data folder for the flow cell |
5474 |
05 Jun 19 |
nicklas |
# Config: Date and time the 'Config' folder was last modified |
5474 |
05 Jun 19 |
nicklas |
# RunParameters: Date and time the 'runParameters.xml' file was last modified |
5474 |
05 Jun 19 |
nicklas |
16 |
|
5474 |
05 Jun 19 |
nicklas |
# BclCount: Number of files ending with '.bcl' |
5474 |
05 Jun 19 |
nicklas |
# LaneCount: Value from <FlowcellLayout LaneCount> tag in RunInfo.xml |
5474 |
05 Jun 19 |
nicklas |
# SurfaceCount: Value from <FlowcellLayout SurfaceCount> tag in RunInfo.xml |
5474 |
05 Jun 19 |
nicklas |
# SwathCount: Value from <FlowcellLayout SwathCount> tag in RunInfo.xml |
5474 |
05 Jun 19 |
nicklas |
# TileCount: Value from <FlowcellLayout TileCount> tag in RunInfo.xml |
5474 |
05 Jun 19 |
nicklas |
# Read1: Value from <Read1> tag in runParameters.xml |
5474 |
05 Jun 19 |
nicklas |
# Read2: Value from <Read2> tag in runParameters.xml |
5474 |
05 Jun 19 |
nicklas |
# IndexRead1: Value from <IndexRead1> tag in runParameters.xml |
5474 |
05 Jun 19 |
nicklas |
# IndexRead2: Value from <IndexRead2> tag in runParameters.xml |
5474 |
05 Jun 19 |
nicklas |
# RTAComplete: Date and time the 'RTAComplete.txt' was last modified |
5474 |
05 Jun 19 |
nicklas |
# HiSeqSerial: Value from <ScannerID> tag in runParameters.xml |
5474 |
05 Jun 19 |
nicklas |
28 |
|
5474 |
05 Jun 19 |
nicklas |
29 |
BARCODE=$1 |
5474 |
05 Jun 19 |
nicklas |
30 |
shift |
5474 |
05 Jun 19 |
nicklas |
31 |
RUN_ARCHIVE=$@ |
5474 |
05 Jun 19 |
nicklas |
32 |
|
5474 |
05 Jun 19 |
nicklas |
# Format string for file dates/times |
5474 |
05 Jun 19 |
nicklas |
34 |
DATE_FORMAT="%Y%m%d %H%M%S" |
5474 |
05 Jun 19 |
nicklas |
35 |
|
5474 |
05 Jun 19 |
nicklas |
# Try to find a folder inside run-archive that has the barcode in the name |
5474 |
05 Jun 19 |
nicklas |
# The folder may not yet exist so a missing folder is not an error |
5474 |
05 Jun 19 |
nicklas |
38 |
DATA_FOLDER=`find ${RUN_ARCHIVE} -maxdepth 2 -iname "*${BARCODE}*" -type d -print 2> /dev/null || true`; |
5474 |
05 Jun 19 |
nicklas |
39 |
|
5474 |
05 Jun 19 |
nicklas |
# Fail if more than one folder is found |
5474 |
05 Jun 19 |
nicklas |
41 |
readarray -t lines <<< "${DATA_FOLDER}" |
5474 |
05 Jun 19 |
nicklas |
42 |
if [ ! ${#lines[@]} -eq 1 ]; then |
5474 |
05 Jun 19 |
nicklas |
43 |
echo "Found ${#lines[@]} data folders for flow cell ${BARCODE}" 1>&2 |
5474 |
05 Jun 19 |
nicklas |
44 |
echo ${DATA_FOLDER} 1>&2 |
5474 |
05 Jun 19 |
nicklas |
45 |
exit 1 |
5474 |
05 Jun 19 |
nicklas |
46 |
fi |
5474 |
05 Jun 19 |
nicklas |
47 |
|
5474 |
05 Jun 19 |
nicklas |
48 |
echo RunArchive: ${DATA_FOLDER} |
5474 |
05 Jun 19 |
nicklas |
# Config folder is created immediately when starting the HiSeq |
5474 |
05 Jun 19 |
nicklas |
# We use the date of this folder to set the start date of the job |
5474 |
05 Jun 19 |
nicklas |
51 |
if [ -d "${DATA_FOLDER}/Config" ]; then |
5474 |
05 Jun 19 |
nicklas |
52 |
echo "Config: `date +"${DATE_FORMAT}" -r "${DATA_FOLDER}/Config"`" |
5474 |
05 Jun 19 |
nicklas |
53 |
fi |
5474 |
05 Jun 19 |
nicklas |
54 |
|
5474 |
05 Jun 19 |
nicklas |
# runParameters.xml is created after clustering |
5474 |
05 Jun 19 |
nicklas |
# We extract information about number of reads and lanes |
5474 |
05 Jun 19 |
nicklas |
# and compare that to the number of *.bgzf.bci files we can find |
5474 |
05 Jun 19 |
nicklas |
# This gives an estimate of the current sequencing cycle and we can |
5474 |
05 Jun 19 |
nicklas |
# use this for progress reporting |
5474 |
05 Jun 19 |
nicklas |
60 |
RUN_PARAMETERS=${DATA_FOLDER}/runParameters.xml |
5474 |
05 Jun 19 |
nicklas |
61 |
if [ -f "${RUN_PARAMETERS}" ]; then |
5474 |
05 Jun 19 |
nicklas |
62 |
echo "RunParameters: `date +"${DATE_FORMAT}" -r "${RUN_PARAMETERS}"`" |
5474 |
05 Jun 19 |
nicklas |
63 |
echo "Read1: `grep '<Read1>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`" |
5474 |
05 Jun 19 |
nicklas |
64 |
echo "Read2: `grep '<Read2>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`" |
5474 |
05 Jun 19 |
nicklas |
65 |
echo "IndexRead1: `grep '<IndexRead1>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`" |
5474 |
05 Jun 19 |
nicklas |
66 |
echo "IndexRead2: `grep '<IndexRead2>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`" |
5474 |
05 Jun 19 |
nicklas |
67 |
echo "HiSeqSerial: `grep '<ScannerID>' "${RUN_PARAMETERS}" | cut -d '>' -f 2 | cut -d '<' -f 1`" |
5474 |
05 Jun 19 |
nicklas |
68 |
fi |
5474 |
05 Jun 19 |
nicklas |
69 |
|
5476 |
10 Jun 19 |
nicklas |
# Count number of BCL files which gives us information about |
5476 |
10 Jun 19 |
nicklas |
# the progress of the sequencing |
5476 |
10 Jun 19 |
nicklas |
72 |
BCL_FOLDER=${DATA_FOLDER}/Data/Intensities/BaseCalls |
5476 |
10 Jun 19 |
nicklas |
73 |
if [ -d "${BCL_FOLDER}" ]; then |
5476 |
10 Jun 19 |
nicklas |
74 |
echo "BclCount: `find "${BCL_FOLDER}" -type f -name *.bcl | wc -l`" |
5476 |
10 Jun 19 |
nicklas |
75 |
fi |
5476 |
10 Jun 19 |
nicklas |
76 |
|
5476 |
10 Jun 19 |
nicklas |
# RunInfo.xml contains information about the layout of the flowcell |
5476 |
10 Jun 19 |
nicklas |
# which we need to be able to compare the number of BCL files |
5476 |
10 Jun 19 |
nicklas |
79 |
RUN_INFO=${DATA_FOLDER}/RunInfo.xml |
5476 |
10 Jun 19 |
nicklas |
80 |
if [ -f "${RUN_PARAMETERS}" ]; then |
5476 |
10 Jun 19 |
nicklas |
81 |
echo "LaneCount: `grep -o 'LaneCount="[^"]*"' "${RUN_INFO}" | cut -d '"' -f 2`" |
5476 |
10 Jun 19 |
nicklas |
82 |
echo "SurfaceCount: `grep -o 'SurfaceCount="[^"]*"' "${RUN_INFO}" | cut -d '"' -f 2`" |
5476 |
10 Jun 19 |
nicklas |
83 |
echo "SwathCount: `grep -o 'SwathCount="[^"]*"' "${RUN_INFO}" | cut -d '"' -f 2`" |
5476 |
10 Jun 19 |
nicklas |
84 |
echo "TileCount: `grep -o 'TileCount="[^"]*"' "${RUN_INFO}" | cut -d '"' -f 2`" |
5476 |
10 Jun 19 |
nicklas |
85 |
fi |
5476 |
10 Jun 19 |
nicklas |
86 |
|
5476 |
10 Jun 19 |
nicklas |
87 |
|
5476 |
10 Jun 19 |
nicklas |
88 |
|
5474 |
05 Jun 19 |
nicklas |
# RTAComplete.txt is created when everything is complete |
5474 |
05 Jun 19 |
nicklas |
# This becomes the end date of the job and should trigger |
5474 |
05 Jun 19 |
nicklas |
# Reggie to start file checks and secondary analysis |
5474 |
05 Jun 19 |
nicklas |
92 |
if [ -f "${DATA_FOLDER}/RTAComplete.txt" ]; then |
5474 |
05 Jun 19 |
nicklas |
93 |
echo "RTAComplete: `date +"${DATE_FORMAT}" -r "${DATA_FOLDER}/RTAComplete.txt"`" |
5474 |
05 Jun 19 |
nicklas |
94 |
fi |