2022-01-27 14:36:18 +00:00
|
|
|
process BUSCO {
|
|
|
|
tag "$meta.id"
|
|
|
|
label 'process_medium'
|
2022-05-03 08:42:56 +00:00
|
|
|
|
|
|
|
conda (params.enable_conda ? "bioconda::busco=5.3.2" : null)
|
2022-01-27 14:36:18 +00:00
|
|
|
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
|
2022-05-03 08:42:56 +00:00
|
|
|
'https://depot.galaxyproject.org/singularity/busco:5.3.2--pyhdfd78af_0':
|
|
|
|
'quay.io/biocontainers/busco:5.3.2--pyhdfd78af_0' }"
|
2022-01-27 14:36:18 +00:00
|
|
|
|
|
|
|
input:
|
2022-05-05 15:09:45 +00:00
|
|
|
tuple val(meta), path('tmp_input/*')
|
2022-05-06 11:48:21 +00:00
|
|
|
each lineage // Required: lineage to check against, "auto" enables --auto-lineage instead
|
2022-05-05 14:33:32 +00:00
|
|
|
path busco_lineages_path // Recommended: path to busco lineages - downloads if not set
|
|
|
|
path config_file // Optional: busco configuration file
|
2022-01-27 14:36:18 +00:00
|
|
|
|
|
|
|
output:
|
2022-05-04 09:22:43 +00:00
|
|
|
tuple val(meta), path("*-busco.batch_summary.txt"), emit: batch_summary
|
2022-05-04 11:52:42 +00:00
|
|
|
tuple val(meta), path("short_summary.*.txt") , emit: short_summaries_txt, optional: true
|
|
|
|
tuple val(meta), path("short_summary.*.json") , emit: short_summaries_json, optional: true
|
2022-05-04 09:22:43 +00:00
|
|
|
tuple val(meta), path("*-busco") , emit: busco_dir
|
|
|
|
path "versions.yml" , emit: versions
|
2022-05-03 08:42:56 +00:00
|
|
|
|
|
|
|
when:
|
|
|
|
task.ext.when == null || task.ext.when
|
2022-01-27 14:36:18 +00:00
|
|
|
|
|
|
|
script:
|
|
|
|
def args = task.ext.args ?: ''
|
2022-05-03 08:42:56 +00:00
|
|
|
def prefix = task.ext.prefix ?: "${meta.id}-${lineage}"
|
|
|
|
def busco_config = config_file ? "--config $config_file" : ''
|
2022-05-06 11:48:21 +00:00
|
|
|
def busco_lineage = lineage.equals('auto') ? '--auto-lineage' : "--lineage_dataset ${lineage}"
|
2022-05-03 14:02:11 +00:00
|
|
|
def busco_lineage_dir = busco_lineages_path ? "--offline --download_path ${busco_lineages_path}" : ''
|
2022-01-27 14:36:18 +00:00
|
|
|
"""
|
2022-02-25 13:26:23 +00:00
|
|
|
# Nextflow changes the container --entrypoint to /bin/bash (container default entrypoint: /usr/local/env-execute)
|
|
|
|
# Check for container variable initialisation script and source it.
|
|
|
|
if [ -f "/usr/local/env-activate.sh" ]; then
|
2022-05-03 14:02:11 +00:00
|
|
|
set +u # Otherwise, errors out because of various unbound variables
|
|
|
|
. "/usr/local/env-activate.sh"
|
|
|
|
set -u
|
2022-02-25 13:26:23 +00:00
|
|
|
fi
|
2022-05-03 08:42:56 +00:00
|
|
|
|
|
|
|
# If the augustus config directory is not writable, then copy to writeable area
|
|
|
|
if [ ! -w "\${AUGUSTUS_CONFIG_PATH}" ]; then
|
|
|
|
# Create writable tmp directory for augustus
|
|
|
|
AUG_CONF_DIR=\$( mktemp -d -p \$PWD )
|
|
|
|
cp -r \$AUGUSTUS_CONFIG_PATH/* \$AUG_CONF_DIR
|
|
|
|
export AUGUSTUS_CONFIG_PATH=\$AUG_CONF_DIR
|
|
|
|
echo "New AUGUSTUS_CONFIG_PATH=\${AUGUSTUS_CONFIG_PATH}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Ensure the input is uncompressed
|
2022-05-03 13:26:49 +00:00
|
|
|
INPUT_SEQS=input_seqs
|
|
|
|
mkdir "\$INPUT_SEQS"
|
|
|
|
cd "\$INPUT_SEQS"
|
|
|
|
for FASTA in ../tmp_input/*; do
|
|
|
|
if [ "\${FASTA##*.}" == 'gz' ]; then
|
|
|
|
gzip -cdf "\$FASTA" > \$( basename "\$FASTA" .gz )
|
|
|
|
else
|
|
|
|
ln -s "\$FASTA" .
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
cd ..
|
2022-05-03 08:42:56 +00:00
|
|
|
|
|
|
|
busco \\
|
|
|
|
--cpu $task.cpus \\
|
2022-05-03 13:26:49 +00:00
|
|
|
--in "\$INPUT_SEQS" \\
|
2022-05-03 08:42:56 +00:00
|
|
|
--out ${prefix}-busco \\
|
2022-05-06 11:48:21 +00:00
|
|
|
$busco_lineage \\
|
2022-05-03 08:42:56 +00:00
|
|
|
$busco_lineage_dir \\
|
|
|
|
$busco_config \\
|
|
|
|
$args
|
|
|
|
|
|
|
|
# clean up
|
2022-05-03 13:26:49 +00:00
|
|
|
rm -rf "\$INPUT_SEQS"
|
2022-01-27 14:36:18 +00:00
|
|
|
|
2022-05-04 09:22:43 +00:00
|
|
|
# Move files to avoid staging/publishing issues
|
|
|
|
mv ${prefix}-busco/batch_summary.txt ${prefix}-busco.batch_summary.txt
|
2022-05-04 11:52:42 +00:00
|
|
|
mv ${prefix}-busco/*/short_summary.*.{json,txt} . || echo "Short summaries were not available: No genes were found."
|
2022-05-04 09:22:43 +00:00
|
|
|
|
2022-01-27 14:36:18 +00:00
|
|
|
cat <<-END_VERSIONS > versions.yml
|
|
|
|
"${task.process}":
|
|
|
|
busco: \$( busco --version 2>&1 | sed 's/^BUSCO //' )
|
|
|
|
END_VERSIONS
|
|
|
|
"""
|
|
|
|
}
|