Skip to content

Commit 3962312

Browse files
authored
Merge pull request #683 from umccr/enhancement/update-qc-coverage
2 parents a1f4752 + 96beb3f commit 3962312

File tree

8 files changed

+344
-10
lines changed

8 files changed

+344
-10
lines changed

schemas/dragen-qc-coverage/1.0.0/dragen-qc-coverage__1.0.0.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ export enum ReportType {
66
}
77

88
export interface DragenQcCoverage {
9+
/*
10+
name:
11+
The name of the qc coverage, used when renaming
12+
*/
13+
name: string
914
/*
1015
region:
1116
Generate the coverage region report using this bed file

schemas/dragen-qc-coverage/1.0.0/dragen-qc-coverage__1.0.0.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
type: record
22
name: dragen-qc-coverage
33
fields:
4+
name:
5+
label: name
6+
doc: |
7+
Name of the coverage file
8+
type: string
49
region:
510
label: region
611
doc: |

tools/dragen-wgts-dna-variant-calling-step/4.4.4/dragen-wgts-dna-variant-calling-step__4.4.4.cwl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,10 +210,21 @@ requirements:
210210
mv "$(inputs.dragen_options.output_directory)/$(inputs.dragen_options.output_file_prefix).bam.bai" "$(inputs.dragen_options.output_directory)/$(inputs.dragen_options.sample_name)_normal.bam.bai"
211211
mv "$(inputs.dragen_options.output_directory)/$(inputs.dragen_options.output_file_prefix).bam.md5sum" "$(inputs.dragen_options.output_directory)/$(inputs.dragen_options.sample_name)_normal.bam.md5sum"
212212
fi
213+
214+
# Rename qc stats if we set
215+
# below is js function is_not_null(inputs.dragen_options.alignment_options.qc_coverage) == "true"
216+
# This may look like "true" == "true" when the script is written or "false" == "true"
217+
if [[ "$(is_not_null(inputs.dragen_options.alignment_options.qc_coverage))" == "true" ]]; then
218+
bash "mv_qc_files.sh"
219+
fi
213220
- |
214221
${
215222
return generate_sequence_data_mount_points(inputs.dragen_options.sequence_data, inputs.dragen_options.tumor_sequence_data);
216223
}
224+
- |
225+
${
226+
return generate_mv_qc_files_script_mount_points(inputs.dragen_options);
227+
}
217228

218229
baseCommand: [ "bash", "run_dragen.sh" ]
219230

typescript-expressions/dragen-tools/4.4.0/dragen-tools__4.4.0.cwljs

Lines changed: 100 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,105 @@ function generate_alignment_data_mount_points(alignment_data, tumor_alignment_da
901901
/* @ts-ignore Type '{ entryname:string; entry:FileProperties; }[]' is not assignable to type 'DirentProperties[]' */
902902
return e;
903903
}
904+
function generate_mv_qc_files_script_mount_points(options_list) {
905+
/*
906+
If alignment_options.qc_coverage is defined, we generate a script to move the qc files to their name attribute
907+
*/
908+
var qc_files_script = generate_mv_qc_files_script(options_list);
909+
if (!qc_files_script) {
910+
return [];
911+
}
912+
else {
913+
return [
914+
{
915+
entryname:qc_files_script.basename,
916+
/* @ts-ignore Type '{ entryname:string; entry:FileProperties; }[]' is not assignable to type 'DirentProperties[]' */
917+
entry:qc_files_script
918+
}
919+
];
920+
}
921+
}
922+
function generate_mv_qc_files_script(options_list) {
923+
/*
924+
Generate mv qc files script
925+
*/
926+
/* Check if alignment_options.qc_coverage is defined */
927+
if (!options_list.alignment_options.qc_coverage || options_list.alignment_options.qc_coverage.length === 0) {
928+
return null;
929+
}
930+
/* Initialise vars */
931+
var output_file_prefix = options_list.output_file_prefix;
932+
var output_directory = options_list.output_directory;
933+
/* Initialise the script */
934+
var mv_qc_files_script = "#!/usr/bin/env bash\n\n";
935+
mv_qc_files_script += "# Exit on failure\n";
936+
mv_qc_files_script += "set -euo pipefail\n\n";
937+
mv_qc_files_script += "# Log start\n";
938+
mv_qc_files_script += "echo \"Start Moving QC files\" 1>&2\n\n";
939+
/* Arrays to make */
940+
var qc_files_suffixes = [
941+
/* Germline */
942+
"contig_mean_cov.csv",
943+
"cov_report.bed",
944+
"coverage_metrics.csv",
945+
"fine_hist.csv",
946+
"hist.csv",
947+
"overall_mean_cov.csv",
948+
"read_cov_report.bed",
949+
/* Somatic */
950+
"contig_mean_cov_normal.csv",
951+
"contig_mean_cov_tumor.csv",
952+
"cov_report_normal.bed",
953+
"cov_report_tumor.bed",
954+
"coverage_metrics_normal.csv",
955+
"coverage_metrics_tumor.csv",
956+
"fine_hist_normal.csv",
957+
"fine_hist_tumor.csv",
958+
"hist_normal.csv",
959+
"hist_tumor.csv",
960+
"overall_mean_cov_normal.csv",
961+
"overall_mean_cov_tumor.csv",
962+
"read_cov_report_normal.bed",
963+
"read_cov_report_tumor.bed",
964+
"somatic_callable_regions.bed",
965+
];
966+
var qc_file_names = options_list.alignment_options.qc_coverage.map(function (qc_coverage) { return qc_coverage.name; });
967+
/* Create the qc suffixes array */
968+
mv_qc_files_script += "# Initialise coverage arrays \n";
969+
mv_qc_files_script += "QC_SUFFIXES=( \\\n";
970+
for (var _i = 0, qc_files_suffixes_1 = qc_files_suffixes; _i < qc_files_suffixes_1.length; _i++) {
971+
var qc_suffix = qc_files_suffixes_1[_i];
972+
mv_qc_files_script += " \"".concat(qc_suffix, "\" \\\n");
973+
}
974+
mv_qc_files_script += ")\n\n";
975+
/* QC Array complete */
976+
/* Create the array of qc names */
977+
mv_qc_files_script += "QC_COVERAGE_NAMES=( \\\n";
978+
for (var _a = 0, qc_file_names_1 = qc_file_names; _a < qc_file_names_1.length; _a++) {
979+
var qc_coverage_name = qc_file_names_1[_a];
980+
mv_qc_files_script += " \"".concat(qc_coverage_name, "\" \\\n");
981+
}
982+
mv_qc_files_script += ")\n\n";
983+
/* Now iterate through each qc name and suffix to move the files */
984+
mv_qc_files_script += "# Move the QC files to the output directory\n";
985+
mv_qc_files_script += "for qc_name_idx in \"${!QC_COVERAGE_NAMES[@]}\"; do\n";
986+
mv_qc_files_script += " qc_name=\"${QC_COVERAGE_NAMES[$qc_name_idx]}\"\n";
987+
mv_qc_files_script += " for qc_suffix in \"${QC_SUFFIXES[@]}\"; do\n";
988+
mv_qc_files_script += " if [[ -f \"".concat(output_directory, "/").concat(output_file_prefix, ".qc-coverage-region-$((qc_name_idx+1))_${qc_suffix}\" ]]; then\n");
989+
mv_qc_files_script += " mv \\\n";
990+
mv_qc_files_script += " \"".concat(output_directory, "/").concat(output_file_prefix, ".qc-coverage-region-$((qc_name_idx+1))_${qc_suffix}\" \\\n");
991+
mv_qc_files_script += " \"".concat(output_directory, "/").concat(output_file_prefix, ".qc-coverage-region-${qc_name}_${qc_suffix}\"\n");
992+
mv_qc_files_script += " fi\n";
993+
mv_qc_files_script += " done\n";
994+
mv_qc_files_script += "done\n\n";
995+
mv_qc_files_script += "# Log completion\n";
996+
mv_qc_files_script += "echo \"Finish Moving QC files\" 1>&2\n";
997+
return {
998+
class:"File",
999+
basename:"mv_qc_files.sh",
1000+
contents:mv_qc_files_script
1001+
};
1002+
}
9041003
function dragen_merge_options(options_list) {
9051004
/*
9061005
Merge a list of objects, ignoring null or undefined values
@@ -1114,7 +1213,7 @@ function get_dragen_wgts_rna_variant_calling_stage_options_from_pipeline(props)
11141213
ref_tar:props.reference.tarball,
11151214
/* Ora reference */
11161215
ora_reference:props.ora_reference ? props.ora_reference :null,
1117-
/* Annotation file, used for a lot of the variant calling optoins */
1216+
/* Annotation file, used for a lot of the variant calling options */
11181217
annotation_file:props.annotation_file,
11191218
/* Stage specific options */
11201219
/* Use tumor_sample_name if it exists otherwise use the standard sample name */

typescript-expressions/dragen-tools/4.4.0/dragen-tools__4.4.0.js

Lines changed: 102 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ exports.get_dragen_config_path = get_dragen_config_path;
2424
exports.dragen_to_config_toml = dragen_to_config_toml;
2525
exports.generate_sequence_data_mount_points = generate_sequence_data_mount_points;
2626
exports.generate_alignment_data_mount_points = generate_alignment_data_mount_points;
27+
exports.generate_mv_qc_files_script_mount_points = generate_mv_qc_files_script_mount_points;
28+
exports.generate_mv_qc_files_script = generate_mv_qc_files_script;
2729
exports.dragen_merge_options = dragen_merge_options;
2830
exports.get_dragen_wgts_dna_alignment_stage_options_from_pipeline = get_dragen_wgts_dna_alignment_stage_options_from_pipeline;
2931
exports.get_dragen_wgts_rna_alignment_stage_options_from_pipeline = get_dragen_wgts_rna_alignment_stage_options_from_pipeline;
@@ -946,6 +948,105 @@ function generate_alignment_data_mount_points(alignment_data, tumor_alignment_da
946948
// @ts-ignore Type '{ entryname: string; entry: FileProperties; }[]' is not assignable to type 'DirentProperties[]'
947949
return e;
948950
}
951+
function generate_mv_qc_files_script_mount_points(options_list) {
952+
/*
953+
If alignment_options.qc_coverage is defined, we generate a script to move the qc files to their name attribute
954+
*/
955+
var qc_files_script = generate_mv_qc_files_script(options_list);
956+
if (!qc_files_script) {
957+
return [];
958+
}
959+
else {
960+
return [
961+
{
962+
entryname: qc_files_script.basename,
963+
// @ts-ignore Type '{ entryname: string; entry: FileProperties; }[]' is not assignable to type 'DirentProperties[]'
964+
entry: qc_files_script
965+
}
966+
];
967+
}
968+
}
969+
function generate_mv_qc_files_script(options_list) {
970+
/*
971+
Generate mv qc files script
972+
*/
973+
/* Check if alignment_options.qc_coverage is defined */
974+
if (!options_list.alignment_options.qc_coverage || options_list.alignment_options.qc_coverage.length === 0) {
975+
return null;
976+
}
977+
/* Initialise vars */
978+
var output_file_prefix = options_list.output_file_prefix;
979+
var output_directory = options_list.output_directory;
980+
/* Initialise the script */
981+
var mv_qc_files_script = "#!/usr/bin/env bash\n\n";
982+
mv_qc_files_script += "# Exit on failure\n";
983+
mv_qc_files_script += "set -euo pipefail\n\n";
984+
mv_qc_files_script += "# Log start\n";
985+
mv_qc_files_script += "echo \"Start Moving QC files\" 1>&2\n\n";
986+
/* Arrays to make */
987+
var qc_files_suffixes = [
988+
/* Germline */
989+
"contig_mean_cov.csv",
990+
"cov_report.bed",
991+
"coverage_metrics.csv",
992+
"fine_hist.csv",
993+
"hist.csv",
994+
"overall_mean_cov.csv",
995+
"read_cov_report.bed",
996+
/* Somatic */
997+
"contig_mean_cov_normal.csv",
998+
"contig_mean_cov_tumor.csv",
999+
"cov_report_normal.bed",
1000+
"cov_report_tumor.bed",
1001+
"coverage_metrics_normal.csv",
1002+
"coverage_metrics_tumor.csv",
1003+
"fine_hist_normal.csv",
1004+
"fine_hist_tumor.csv",
1005+
"hist_normal.csv",
1006+
"hist_tumor.csv",
1007+
"overall_mean_cov_normal.csv",
1008+
"overall_mean_cov_tumor.csv",
1009+
"read_cov_report_normal.bed",
1010+
"read_cov_report_tumor.bed",
1011+
"somatic_callable_regions.bed",
1012+
];
1013+
var qc_file_names = options_list.alignment_options.qc_coverage.map(function (qc_coverage) { return qc_coverage.name; });
1014+
/* Create the qc suffixes array */
1015+
mv_qc_files_script += "# Initialise coverage arrays \n";
1016+
mv_qc_files_script += "QC_SUFFIXES=( \\\n";
1017+
for (var _i = 0, qc_files_suffixes_1 = qc_files_suffixes; _i < qc_files_suffixes_1.length; _i++) {
1018+
var qc_suffix = qc_files_suffixes_1[_i];
1019+
mv_qc_files_script += " \"".concat(qc_suffix, "\" \\\n");
1020+
}
1021+
mv_qc_files_script += ")\n\n";
1022+
/* QC Array complete */
1023+
/* Create the array of qc names */
1024+
mv_qc_files_script += "QC_COVERAGE_NAMES=( \\\n";
1025+
for (var _a = 0, qc_file_names_1 = qc_file_names; _a < qc_file_names_1.length; _a++) {
1026+
var qc_coverage_name = qc_file_names_1[_a];
1027+
mv_qc_files_script += " \"".concat(qc_coverage_name, "\" \\\n");
1028+
}
1029+
mv_qc_files_script += ")\n\n";
1030+
/* Now iterate through each qc name and suffix to move the files */
1031+
mv_qc_files_script += "# Move the QC files to the output directory\n";
1032+
mv_qc_files_script += "for qc_name_idx in \"${!QC_COVERAGE_NAMES[@]}\"; do\n";
1033+
mv_qc_files_script += " qc_name=\"${QC_COVERAGE_NAMES[$qc_name_idx]}\"\n";
1034+
mv_qc_files_script += " for qc_suffix in \"${QC_SUFFIXES[@]}\"; do\n";
1035+
mv_qc_files_script += " if [[ -f \"".concat(output_directory, "/").concat(output_file_prefix, ".qc-coverage-region-$((qc_name_idx+1))_${qc_suffix}\" ]]; then\n");
1036+
mv_qc_files_script += " mv \\\n";
1037+
mv_qc_files_script += " \"".concat(output_directory, "/").concat(output_file_prefix, ".qc-coverage-region-$((qc_name_idx+1))_${qc_suffix}\" \\\n");
1038+
mv_qc_files_script += " \"".concat(output_directory, "/").concat(output_file_prefix, ".qc-coverage-region-${qc_name}_${qc_suffix}\"\n");
1039+
mv_qc_files_script += " fi\n";
1040+
mv_qc_files_script += " done\n";
1041+
mv_qc_files_script += "done\n\n";
1042+
mv_qc_files_script += "# Log completion\n";
1043+
mv_qc_files_script += "echo \"Finish Moving QC files\" 1>&2\n";
1044+
return {
1045+
class_: cwl_ts_auto_1.File_class.FILE,
1046+
basename: "mv_qc_files.sh",
1047+
contents: mv_qc_files_script
1048+
};
1049+
}
9491050
function dragen_merge_options(options_list) {
9501051
/*
9511052
Merge a list of objects, ignoring null or undefined values
@@ -1159,7 +1260,7 @@ function get_dragen_wgts_rna_variant_calling_stage_options_from_pipeline(props)
11591260
ref_tar: props.reference.tarball,
11601261
/* Ora reference */
11611262
ora_reference: props.ora_reference ? props.ora_reference : null,
1162-
/* Annotation file, used for a lot of the variant calling optoins */
1263+
/* Annotation file, used for a lot of the variant calling options */
11631264
annotation_file: props.annotation_file,
11641265
/* Stage specific options */
11651266
/* Use tumor_sample_name if it exists otherwise use the standard sample name */

0 commit comments

Comments
 (0)