Skip to content

Commit e0cdc7e

Browse files
committed
add output tracking how long the alignment step took
1 parent 8dd4d1f commit e0cdc7e

File tree

3 files changed

+44
-1
lines changed

3 files changed

+44
-1
lines changed

wdl/pipelines/PacBio/Utility/ProcessOnInstrumentDemuxedChunk.wdl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ workflow ProcessOnInstrumentDemuxedChunk {
8888

8989
output {
9090
String last_processing_date = today.yyyy_mm_dd
91+
String aln_wallclock_time = AlignHiFiUBAM.total_runtime
9192

9293
File aligned_bam = FinalizeAlignedBam.gcs_path
9394
File aligned_bai = FinalizeAlignedBai.gcs_path

wdl/tasks/Alignment/AlignHiFiUBAM.wdl

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,38 @@ workflow AlignHiFiUBAM {
102102
File aBAM = select_first([MergeAlignedReads.merged_bam, AlignReadsTogether.aligned_bam])
103103
File aBAI = select_first([MergeAlignedReads.merged_bai, AlignReadsTogether.aligned_bai])
104104
call PB.PBIndex as IndexAlignedReads { input: bam = aBAM }
105-
}
105+
}
106+
107+
task sumRuntimes {
108+
input {
109+
Array[String] runtimes
110+
}
111+
112+
output {
113+
String total_runtime = read_string("total.txt")
114+
}
115+
command <<<
116+
total_minutes=0
117+
118+
# Read each runtime and sum up
119+
while IFS= read -r line; do
120+
# Extract hours and minutes from format "XX hours, YY minutes"
121+
hours=$(echo "$line" | grep -oP '\d+(?=H)')
122+
minutes=$(echo "$line" | grep -oP '\d+(?=M)')
123+
124+
# Convert to total minutes and add
125+
total_minutes=$((total_minutes + hours * 60 + minutes))
126+
done < ~{write_lines(runtimes)}
127+
128+
# Convert back to hours and minutes
129+
final_hours=$((total_minutes / 60))
130+
final_minutes=$((total_minutes % 60))
131+
132+
# Output in same format with padding
133+
printf "%02dH%02dM\n" $final_hours $final_minutes > total.txt
134+
>>>
135+
runtime {
136+
disks: "local-disk 10 HDD"
137+
docker: "gcr.io/cloud-marketplace/google/ubuntu2004:latest"
138+
}
139+
}

wdl/tasks/Utility/PBUtils.wdl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -943,6 +943,7 @@ task Align {
943943

944944
command <<<
945945
set -euxo pipefail
946+
start_time=$(date +%s)
946947
947948
pbmm2 align ~{bam} \
948949
~{ref_fasta} \
@@ -975,11 +976,18 @@ task Align {
975976
976977
samtools calmd -b --no-PG ~{prefix}.pre.bam ~{ref_fasta} > ~{prefix}.bam
977978
samtools index ~{prefix}.bam
979+
980+
end_time=$(date +%s)
981+
total_seconds=$((end_time - start_time))
982+
hours=$((total_seconds / 3600))
983+
minutes=$(((total_seconds % 3600) / 60))
984+
printf "%02dH%02dM\n" $hours $minutes > wallclocktime.txt
978985
>>>
979986

980987
output {
981988
File aligned_bam = "~{prefix}.bam"
982989
File aligned_bai = "~{prefix}.bam.bai"
990+
String wallclocktime = read_string("wallclocktime.txt")
983991
}
984992

985993
#########################

0 commit comments

Comments
 (0)