|
1 | | -process PRETEXT_GRAPH { |
2 | | - tag "$meta.id" |
3 | | - label 'process_single' |
4 | | - |
5 | | - container "quay.io/sanger-tol/pretext:0.0.9-yy5-c2" |
6 | | - |
7 | | - input: |
8 | | - tuple val(meta), path(pretext_file) |
9 | | - path(gap_file, stageAs: 'gap_file.bed') |
10 | | - path(coverage, stageAs: 'coverage.bw') |
11 | | - path(telomere_file, stageAs: 'telomere/*') |
12 | | - path(repeat_density, stageAs: 'repeat_density.bw') |
13 | | - val (split_telo_bool) |
14 | | - |
15 | | - output: |
16 | | - tuple val(meta), path("*.pretext") , emit: pretext |
17 | | - path "versions.yml" , emit: versions |
18 | | - |
19 | | - when: |
20 | | - task.ext.when == null || task.ext.when |
21 | | - |
22 | | - script: |
23 | | - // Exit if running this module with -profile conda / -profile mamba |
24 | | - if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { |
25 | | - error "PRETEXT GRAPH module does not _currently_ support Conda. Please use Docker / Singularity instead." |
26 | | - } |
27 | | - |
28 | | - def args = task.ext.args ?: '' |
29 | | - def prefix = task.ext.prefix ?: "${meta.id}" |
30 | | - def UCSC_VERSION = '447' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. |
31 | | - |
32 | | - // Using single [ ] as nextflow will use sh where possible not bash |
33 | | - |
34 | | - // Duplicate the telo chunk for the 5' and 3' and then another telox |
35 | | - """ |
36 | | - shopt -s nullglob |
37 | | -
|
38 | | - echo "PROCESSING ESSENTIAL FILES" |
39 | | -
|
40 | | - if [ -s "${coverage}" ]; then |
41 | | - echo "PROCESSING COVERAGE..." |
42 | | - bigWigToBedGraph ${coverage} /dev/stdout | PretextGraph ${args} -i ${pretext_file} -n "coverage" -o coverage.pretext.part |
43 | | - else |
44 | | - echo "SKIPPING COVERAGE" |
45 | | - mv ${pretext_file} coverage.pretext.part |
46 | | - fi |
47 | | -
|
48 | | - if [ -s "${repeat_density}" ]; then |
49 | | - echo "PROCESSING REPEAT_DENSITY..." |
50 | | - bigWigToBedGraph ${repeat_density} /dev/stdout | PretextGraph ${args} -i coverage.pretext.part -n "repeat_density" -o repeat.pretext.part |
51 | | - else |
52 | | - echo "SKIPPING REPEAT_DENSITY" |
53 | | - mv coverage.pretext.part repeat.pretext.part |
54 | | - fi |
55 | | -
|
56 | | - echo "NOW PROCESSING NON-ESSENTIAL files" |
57 | | -
|
58 | | - input_file="repeat.pretext.part" |
59 | | -
|
60 | | - if [ -s "${gap_file}" ]; then |
61 | | - echo "Processing GAP file..." |
62 | | - cat "${gap_file}" | PretextGraph ${args} -i repeat.pretext.part -n "gap" -o gap.pretext.part |
63 | | - input_file="gap.pretext.part" |
64 | | - fi |
65 | | -
|
66 | | - mkdir -p telomere/ |
67 | | - if [ -n "\$(ls -A telomere/ 2>/dev/null)" ]; then |
68 | | - FILES=(telomere/*.bedgraph); |
69 | | -
|
70 | | - echo "Found /telomere/ has contents:" |
71 | | -
|
72 | | - file_telox="" |
73 | | - file_5p="" |
74 | | - file_3p="" |
75 | | - file_og="" |
76 | | -
|
77 | | - for file in telomere/*.bedgraph; do |
78 | | - [ -e "\$file" ] || continue # skip if no match |
79 | | - fname=\$(basename "\$file") |
80 | | -
|
81 | | - case "\$fname" in |
82 | | - *telox*) |
83 | | - echo "Found TELOX: \$file" |
84 | | - file_telox="\$file" |
85 | | - ;; |
86 | | - *5P*) |
87 | | - echo "Found 5P: \$file" |
88 | | - file_5p="\$file" |
89 | | - ;; |
90 | | - *3P*) |
91 | | - echo "Found 3P: \$file" |
92 | | - file_3p="\$file" |
93 | | - ;; |
94 | | - *) |
95 | | - echo "Found OG: \$file" |
96 | | - file_og="\$file" |
97 | | - ;; |
98 | | - esac |
99 | | - done |
100 | | -
|
101 | | - if [ -s "\$file_og" ]; then |
102 | | - echo "Processing OG_TELOMERE file..." |
103 | | - cat "\$file_og" | PretextGraph ${args} -i "\$input_file" -n "og_telomere" -o telo_0.pretext |
104 | | - else |
105 | | - mv "\$input_file" telo_0.pretext |
106 | | - fi |
107 | | -
|
108 | | - if [ -s "\$file_telox" ]; then |
109 | | - echo "Processing TELOX_TELOMERE file..." |
110 | | - cat "\$file_telox}" | PretextGraph ${args} -i telo_0.pretext -n "telox_telomere" -o telo_1.pretext |
111 | | - else |
112 | | - mv telo_0.pretext telo_1.pretext |
113 | | - fi |
114 | | -
|
115 | | - if [ -s "\$file_5p" ]; then |
116 | | - echo "Processing 5 Prime TELOMERE file..." |
117 | | - cat "\$file_5p" | PretextGraph ${args} -i telo_1.pretext -n "5p_telomere" -o telo_2.pretext |
118 | | - else |
119 | | - mv telo_1.pretext telo_2.pretext |
120 | | - fi |
121 | | -
|
122 | | - if [ -s "\$file_3p" ]; then |
123 | | - echo "Processing 3 Prime TELOMERE file..." |
124 | | - cat "\$file_3p" | PretextGraph ${args} -i telo_2.pretext -n "3p_telomere" -o "${prefix}.pretext" |
125 | | - else |
126 | | - mv telo_2.pretext "${prefix}.pretext" |
127 | | - fi |
128 | | -
|
129 | | - else |
130 | | - mv "\$input_file" "${prefix}.pretext" |
131 | | - fi |
132 | | -
|
133 | | -
|
134 | | - cat <<-END_VERSIONS > versions.yml |
135 | | - "${task.process}": |
136 | | - PretextGraph: \$(PretextGraph | grep "Version" | sed 's/Pretext.* Version //;') |
137 | | - PretextMap: \$(PretextMap | grep "Version" | sed 's/Pretext.* Version//;') |
138 | | - bigWigToBedGraph: ${UCSC_VERSION} |
139 | | - END_VERSIONS |
140 | | - """ |
141 | | - |
142 | | - stub: |
143 | | - // Exit if running this module with -profile conda / -profile mamba |
144 | | - if (workflow.profile.tokenize(',').intersect(['conda', 'mamba']).size() >= 1) { |
145 | | - error "PRETEXT GRAPH module does not _currently_ support Conda. Please use Docker / Singularity instead." |
146 | | - } |
147 | | - |
148 | | - def prefix = task.ext.prefix ?: "${meta.id}" |
149 | | - def UCSC_VERSION = '448' // WARN: Version information not provided by tool on CLI. Please update this string when bumping container versions. |
150 | | - """ |
151 | | - touch ${prefix}.pretext |
152 | | -
|
153 | | - cat <<-END_VERSIONS > versions.yml |
154 | | - "${task.process}": |
155 | | - PretextGraph: \$(PretextGraph | grep "Version" | sed 's/Pretext* Version //;') |
156 | | - PretextMap: \$(PretextMap | grep "Version" | sed 's/PretextMap Version//;') |
157 | | - bigWigToBedGraph: ${UCSC_VERSION} |
158 | | - END_VERSIONS |
159 | | - """ |
160 | | -} |
0 commit comments