Skip to content

Commit

Permalink
envar to realtime delete pod5
Browse files Browse the repository at this point in the history
  • Loading branch information
hasindu2008 committed Dec 19, 2024
1 parent fb1d6f1 commit 812070c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
8 changes: 8 additions & 0 deletions scripts/realtime-p2s/pipeline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,14 @@ do
then
END_TIME=$(date)
echo "[pipeline.sh::${END_TIME}] Finished converting $FILE to $SLOW5_FILEPATH"
if [ "$POD5_DELETE" = "1" ]; then
if $SLOW5TOOLS quickcheck $SLOW5_FILEPATH 2>> $LOG_FILEPATH; then
rm -f $FILE
else
echo -e $RED"quickcheck failed for $SLOW5_FILEPATH. Not deleting $FILE. Please check log at $LOG_FILEPATH"$NORMAL
echo $FILE >> $TMP_FAILED;
fi
fi
else
echo -e $RED"Converting $FILE to $SLOW5_FILEPATH failed. Please check log at $LOG_FILEPATH"$NORMAL
echo $FILE >> $TMP_FAILED;
Expand Down
1 change: 1 addition & 0 deletions scripts/realtime-p2s/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ The following optional environment variables will be honoured by the real-time c
- REALP2S_AUTO: make the script terminate as soon as the sequencing run in MinKNOW stops as explained above.
- SLOW5TOOLS: path to the slow5tools binary
- BLUECRAB: path to the blue-crab [launcher script](../../README.md#optional-wrapper-script-and-adding-to-path)
- POD5_DELETE: delete the POD5 file as soon as conversion finish

## Simulation

Expand Down
33 changes: 21 additions & 12 deletions scripts/realtime-p2s/realp2s.sh
Original file line number Diff line number Diff line change
Expand Up @@ -251,20 +251,29 @@ else # Else assume realtime analysis is desired
fi

test -e $FAILED_LIST && echo -e $RED"[realp2s.sh] $(wc -l $FAILED_LIST) pod5 files failed to convert. See $FAILED_LIST for the list"$NORMAL | tee -a $LOG
NUMPOD5=$(find $MONITOR_PARENT_DIR/ -name '*.pod5' | wc -l)
NUMBLOW5=$(find $MONITOR_PARENT_DIR/ -name '*.blow5' | wc -l)
if [ ${NUMPOD5} -ne ${NUMBLOW5} ] ; then
echo -e $RED"[realp2s.sh] In $MONITOR_PARENT_DIR, $NUMPOD5 pod5 files, but only $NUMBLOW5 blow5 files. Check the logs for any failures."$NORMAL | tee -a $LOG

if [ "$POD5_DELETE" = "1" ]; then
NUMBLOW5=$(find $MONITOR_PARENT_DIR/ -name '*.blow5' | wc -l)
BLOW5_SIZE=$(find $MONITOR_PARENT_DIR/ -name '*.blow5' -printf "%s\t%p\n" | awk 'BEGIN{sum=0}{sum=sum+$1}END{print sum/(1024*1024*1024)}')
echo "[realp2s.sh] In $MONITOR_PARENT_DIR, $NUMBLOW5 blow5 files." | tee -a $LOG
BLOW5_SIZE=$(find $MONITOR_PARENT_DIR/ -name '*.blow5' -printf "%s\t%p\n" | awk 'BEGIN{sum=0}{sum=sum+$1}END{print sum/(1024*1024*1024)}')
echo "BLOW5 size: $BLOW5_SIZE GB" | tee -a $LOG
else
echo "[realp2s.sh] In $MONITOR_PARENT_DIR, $NUMPOD5 pod5 files, $NUMBLOW5 blow5 files." | tee -a $LOG
NUMPOD5=$(find $MONITOR_PARENT_DIR/ -name '*.pod5' | wc -l)
NUMBLOW5=$(find $MONITOR_PARENT_DIR/ -name '*.blow5' | wc -l)
if [ ${NUMPOD5} -ne ${NUMBLOW5} ] ; then
echo -e $RED"[realp2s.sh] In $MONITOR_PARENT_DIR, $NUMPOD5 pod5 files, but $NUMBLOW5 blow5 files. Check the logs for any failures."$NORMAL | tee -a $LOG
else
echo "[realp2s.sh] In $MONITOR_PARENT_DIR, $NUMPOD5 pod5 files, $NUMBLOW5 blow5 files." | tee -a $LOG
fi
POD5_SIZE=$(find $MONITOR_PARENT_DIR/ -name '*.pod5' -printf "%s\t%p\n" | awk 'BEGIN{sum=0}{sum=sum+$1}END{print sum/(1024*1024*1024)}')
BLOW5_SIZE=$(find $MONITOR_PARENT_DIR/ -name '*.blow5' -printf "%s\t%p\n" | awk 'BEGIN{sum=0}{sum=sum+$1}END{print sum/(1024*1024*1024)}')
SAVINGS=$(echo $POD5_SIZE - $BLOW5_SIZE | bc)
SAVINGS_PERCENT=$(echo "scale=2; $SAVINGS/$POD5_SIZE*100" | bc)
echo "POD5 size: $POD5_SIZE GB" | tee -a $LOG
echo "BLOW5 size: $BLOW5_SIZE GB" | tee -a $LOG
echo "Savings: $SAVINGS GB ($SAVINGS_PERCENT%)" | tee -a $LOG
fi
POD5_SIZE=$(find $MONITOR_PARENT_DIR/ -name '*.pod5' -printf "%s\t%p\n" | awk 'BEGIN{sum=0}{sum=sum+$1}END{print sum/(1024*1024*1024)}')
BLOW5_SIZE=$(find $MONITOR_PARENT_DIR/ -name '*.blow5' -printf "%s\t%p\n" | awk 'BEGIN{sum=0}{sum=sum+$1}END{print sum/(1024*1024*1024)}')
SAVINGS=$(echo $POD5_SIZE - $BLOW5_SIZE | bc)
SAVINGS_PERCENT=$(echo "scale=2; $SAVINGS/$POD5_SIZE*100" | bc)
echo "POD5 size: $POD5_SIZE GB" | tee -a $LOG
echo "BLOW5 size: $BLOW5_SIZE GB" | tee -a $LOG
echo "Savings: $SAVINGS GB ($SAVINGS_PERCENT%)" | tee -a $LOG

echo "Scanning for errors in log files" | tee -a $LOG
find $MONITOR_PARENT_DIR/ -name '*.log' -exec cat {} \; | grep -i "ERROR" | tee -a $LOG
Expand Down

0 comments on commit 812070c

Please sign in to comment.