|
| 1 | +// See the NOTICE file distributed with this work for additional information |
| 2 | +// regarding copyright ownership. |
| 3 | +// |
| 4 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +// you may not use this file except in compliance with the License. |
| 6 | +// You may obtain a copy of the License at |
| 7 | +// |
| 8 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +// |
| 10 | +// Unless required by applicable law or agreed to in writing, software |
| 11 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +// See the License for the specific language governing permissions and |
| 14 | +// limitations under the License. |
| 15 | + |
| 16 | +process FASTA_RECOMBINE { |
| 17 | + |
| 18 | + tag "${meta.id}" |
| 19 | + label 'process_medium' |
| 20 | + |
| 21 | + conda "${moduleDir}/environment.yml" |
| 22 | + container "${workflow.containerEngine in ['singularity', 'apptainer'] && !task.ext.singularity_pull_docker_container |
| 23 | + ? 'https://depot.galaxyproject.org/singularity/ensembl-genomio:1.6.1--pyhdfd78af_0' |
| 24 | + : 'quay.io/biocontainers/ensembl-genomio:1.6.1--pyhdfd78af_0'}" |
| 25 | + |
| 26 | + input: |
| 27 | + tuple val(meta), path(fasta_manifest), path(agp) |
| 28 | + |
| 29 | + output: |
| 30 | + tuple val(meta), path("${meta.id}.fa"), emit: recombined_fasta |
| 31 | + tuple val("${task.process}"), val('fasta_recombine'), eval("fasta_recombine --version"), emit: versions_fasta_recombine, topic: versions |
| 32 | + |
| 33 | + when: |
| 34 | + task.ext.when == null || task.ext.when |
| 35 | + |
| 36 | + script: |
| 37 | + def args = [] |
| 38 | + |
| 39 | + if (params.chunk_id_regex) { |
| 40 | + def rx = params.chunk_id_regex.replace("'", "'\"'\"'") |
| 41 | + args << "--chunk-id-regex '${rx}'" |
| 42 | + } |
| 43 | + |
| 44 | + if (params.allow_revcomp) { |
| 45 | + args << "--allow-revcomp" |
| 46 | + } |
| 47 | + |
| 48 | + def has_agp = agp && agp.baseName != 'NO_FILE' |
| 49 | + if (has_agp) { |
| 50 | + args << "--agp-file ${agp}" |
| 51 | + } |
| 52 | + |
| 53 | + def out_fasta = "${meta.id}.fa" |
| 54 | + """ |
| 55 | + fasta_recombine \\ |
| 56 | + --fasta-manifest ${fasta_manifest} \\ |
| 57 | + --out-fasta ${out_fasta} \\ |
| 58 | + ${args.join(' ')} |
| 59 | + """ |
| 60 | + |
| 61 | + stub: |
| 62 | + """ |
| 63 | + out_fa="${meta.id}.fa" |
| 64 | + touch "\$out_fa" |
| 65 | + """ |
| 66 | +} |
0 commit comments