Repository navigation
Expand file tree
/
Copy pathprepare_reference.wdl
More file actions
108 lines (99 loc) · 5.39 KB
/
Copy pathprepare_reference.wdl
File metadata and controls
108 lines (99 loc) · 5.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
version 1.0
import "../../tasks/bioinfo_utils.wdl" as utils
import "../../tasks/validation.wdl" as validation
import "../../tasks/vg_map_hts.wdl" as map
workflow PrepareReference {
meta {
description: "## Prepare reference workflow \n Work out which contigs to work on and get a FASTA reference for them, with its .fai and .dict. Anything the caller provides is used as it is. If a contig list and a reference aren't provided, they are extracted from the graph."
}
parameter_meta {
GBZ_FILE: "Path to the .gbz index file to take contigs and reference bases from"
CONTIGS: "(OPTIONAL) Desired reference genome contigs, which are all paths in the GBZ index. If using REFERENCE_PREFIX, contig names in here should have the prefix."
PATH_LIST_FILE: "(OPTIONAL) Text file where each line is a path name in the GBZ index, to use instead of CONTIGS. If neither is given, paths are extracted from the GBZ and subset to chromosome-looking paths. If using REFERENCE_PREFIX, contig names in here should have the prefix."
REFERENCE_PREFIX: "Prefix to remove from path names to get reference contig names. If not empty, an extracted contig list is checked to make sure it carries the prefix."
REFERENCE_FILE: "(OPTIONAL) If specified, use this FASTA reference, gzipped or not, instead of extracting it from the graph. Required if the graph does not contain all bases of the reference. If using REFERENCE_PREFIX, contig names in here should not have the prefix."
REFERENCE_INDEX_FILE: "(OPTIONAL) If specified, use this .fai index instead of indexing the reference file."
REFERENCE_DICT_FILE: "(OPTIONAL) If specified, use this pre-computed .dict file of sequence lengths."
EXTRACT_MEM: "Memory, in GB, to use when extracting contigs and reference bases from the graph. Default is 120."
VG_DOCKER: "Container image to use when running vg"
}
input {
File GBZ_FILE
Array[String]+? CONTIGS
File? PATH_LIST_FILE
String REFERENCE_PREFIX = ""
File? REFERENCE_FILE
File? REFERENCE_INDEX_FILE
File? REFERENCE_DICT_FILE
Int EXTRACT_MEM = 120
String VG_DOCKER = "quay.io/vgteam/vg:v1.64.0"
}
if (!defined(CONTIGS)) {
if (!defined(PATH_LIST_FILE)) {
# Extract path names to call against from the GBZ file if neither a
# path list nor a contig list was provided.
# Filter down to major paths, because GRCh38 includes thousands of
# decoys and unplaced/unlocalized contigs, and we can't efficiently
# scatter across them, nor do we care about accuracy on them, and also
# calling on the decoys is semantically meaningless.
call map.extractSubsetPathNames {
input:
in_gbz_file=GBZ_FILE,
in_reference_prefix=REFERENCE_PREFIX,
in_extract_mem=EXTRACT_MEM,
vg_docker=VG_DOCKER
}
if (REFERENCE_PREFIX != "") {
# A list we made ourselves can still come out wrong, if the
# graph's paths aren't named the way the prefix says they are.
call validation.checkPathList as checkExtractedPathList {
input:
in_path_list_file=extractSubsetPathNames.output_path_list_file,
in_reference_prefix=REFERENCE_PREFIX
}
}
}
}
if (defined(CONTIGS)) {
# Put the paths in a file to use later. We know the value is defined,
# but WDL is a bit low on unboxing calls for optionals so we use
# select_first.
File written_path_names_file = write_lines(select_first([CONTIGS]))
}
File pipeline_path_list_file = select_first([PATH_LIST_FILE, extractSubsetPathNames.output_path_list_file, written_path_names_file])
# To make sure that we have a FASTA reference with a contig set that
# exactly matches the graph (except for removing the name prefix), we
# generate it ourselves, from the graph.
if (!defined(REFERENCE_FILE)) {
call map.extractReference {
input:
in_gbz_file=GBZ_FILE,
in_path_list_file=pipeline_path_list_file,
in_prefix_to_strip=REFERENCE_PREFIX,
in_extract_mem=EXTRACT_MEM,
vg_docker=VG_DOCKER
}
}
if (defined(REFERENCE_FILE)) {
call utils.uncompressReferenceIfNeeded {
input:
# We know REFERENCE_FILE is defined but the WDL type system doesn't.
in_reference_file=select_first([REFERENCE_FILE])
}
}
File resolved_reference_file = select_first([uncompressReferenceIfNeeded.reference_file, extractReference.reference_file])
# The .fai and the .dict are made by the same task, so a caller that brought
# only one of them still needs it run.
if (!defined(REFERENCE_INDEX_FILE) || !defined(REFERENCE_DICT_FILE)) {
call utils.indexReference {
input:
in_reference_file=resolved_reference_file
}
}
output {
File path_list_file = pipeline_path_list_file
File reference_file = resolved_reference_file
File reference_index_file = select_first([REFERENCE_INDEX_FILE, indexReference.reference_index_file])
File reference_dict_file = select_first([REFERENCE_DICT_FILE, indexReference.reference_dict_file])
}
}