Skip to content

Commit

Permalink
Remove --versioned_outdir param (#52)
Browse files Browse the repository at this point in the history
* Remove --versioned_outdir param

* Add test to check for expected outputs
  • Loading branch information
dfornika authored May 16, 2024
1 parent d014d32 commit c8b63aa
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 11 deletions.
38 changes: 37 additions & 1 deletion .github/scripts/check_outputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,36 @@ def check_provenance_format_valid(provenance_files, schema):

return True

def check_expected_files_exist(output_dir, sample_ids):
"""
Check that the expected files exist in the output directory.
:param output_dir: Path to the output directory
:param sample_ids: List of sample IDs
:return: True if all expected files exist, False otherwise
:rtype: bool
"""
for sample_id in sample_ids:
expected_files = [
f"{sample_id}/{sample_id}_fastp.csv",
f"{sample_id}/{sample_id}_fastp.json",
f"{sample_id}/{sample_id}_unicycler_short.fa",
f"{sample_id}/{sample_id}_unicycler_short.gfa",
f"{sample_id}/{sample_id}_unicycler_short.log",
f"{sample_id}/{sample_id}_unicycler_short_bandage.png",
f"{sample_id}/{sample_id}_unicycler_short_prokka.gbk",
f"{sample_id}/{sample_id}_unicycler_short_prokka.gff",
f"{sample_id}/{sample_id}_unicycler_short_quast.csv",
]

for expected_file in expected_files:
expected_file_path = os.path.join(output_dir, expected_file)
if not os.path.exists(expected_file_path):
print(f"Expected file {expected_file_path} not found")
return False

return True


def main(args):

Expand All @@ -44,12 +74,18 @@ def main(args):
provenace_files_glob = f"{args.pipeline_outdir}/**/*_provenance.yml"
provenance_files = glob.glob(provenace_files_glob, recursive=True)

# TODO: add more tests
sample_ids = [os.path.basename(provenance_file).split("_")[0] for provenance_file in provenance_files]

# TODO: Add more tests
tests = [
{
"test_name": "provenance_format_valid",
"test_passed": check_provenance_format_valid(provenance_files, provenance_schema),
},
{
"test_name": "all_expected_files_exist",
"test_passed": check_expected_files_exist(args.pipeline_outdir, sample_ids),
},
]

output_fields = [
Expand Down
2 changes: 1 addition & 1 deletion modules/bakta.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ process bakta {

errorStrategy 'ignore'

publishDir params.versioned_outdir ? "${params.outdir}/${sample_id}/${params.pipeline_short_name}-v${params.pipeline_minor_version}-output" : "${params.outdir}/${sample_id}", pattern: "${sample_id}*.{gbk,gff,json,log}", mode: 'copy'
publishDir "${params.outdir}/${sample_id}", pattern: "${sample_id}*.{gbk,gff,json,log}", mode: 'copy'

input:
tuple val(sample_id), path(assembly), val(assembler), val(assembly_mode)
Expand Down
4 changes: 2 additions & 2 deletions modules/fastp.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ process fastp {

tag { sample_id }

publishDir params.versioned_outdir ? "${params.outdir}/${sample_id}/${params.pipeline_short_name}-v${params.minor_version}-output" : "${params.outdir}/${sample_id}", pattern: "${sample_id}_fastp.json", mode: 'copy'
publishDir "${params.outdir}/${sample_id}", pattern: "${sample_id}_fastp.json", mode: 'copy'

input:
tuple val(sample_id), path(reads)
Expand Down Expand Up @@ -40,7 +40,7 @@ process fastp_json_to_csv {

executor 'local'

publishDir params.versioned_outdir ? "${params.outdir}/${sample_id}/${params.pipeline_short_name}-v${params.pipeline_minor_version}-output" : "${params.outdir}/${sample_id}", pattern: "${sample_id}_fastp.csv", mode: 'copy'
publishDir "${params.outdir}/${sample_id}", pattern: "${sample_id}_fastp.csv", mode: 'copy'

input:
tuple val(sample_id), path(fastp_json)
Expand Down
4 changes: 2 additions & 2 deletions modules/long_read_qc.nf
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ process merge_nanoq_reports {

executor 'local'

publishDir params.versioned_outdir ? "${params.outdir}/${sample_id}/${params.pipeline_short_name}-v${params.minor_version}-output" : "${params.outdir}/${sample_id}", pattern: "${sample_id}_nanoq.csv", mode: 'copy'
publishDir "${params.outdir}/${sample_id}", pattern: "${sample_id}_nanoq.csv", mode: 'copy'

input:
tuple val(sample_id), path(nanoq_pre_filter), path(nanoq_post_filter)
Expand All @@ -82,7 +82,7 @@ process bandage {
executor 'local'
errorStrategy 'ignore'

publishDir params.versioned_outdir ? "${params.outdir}/${sample_id}/${params.pipeline_short_name}-v${params.minor_version}-output" : "${params.outdir}/${sample_id}", pattern: "${sample_id}_${assembler}_${assembly_mode}_bandage.png", mode: 'copy'
publishDir "${params.outdir}/${sample_id}", pattern: "${sample_id}_${assembler}_${assembly_mode}_bandage.png", mode: 'copy'

input:
tuple val(sample_id), path(assembly_graph), val(assembler), val(assembly_mode)
Expand Down
2 changes: 1 addition & 1 deletion modules/prokka.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ process prokka {

errorStrategy 'ignore'

publishDir params.versioned_outdir ? "${params.outdir}/${sample_id}/${params.pipeline_short_name}-v${params.pipeline_minor_version}-output" : "${params.outdir}/${sample_id}", pattern: "${sample_id}_${assembler}_${assembly_mode}_prokka.{gbk,gff}", mode: 'copy'
publishDir "${params.outdir}/${sample_id}", pattern: "${sample_id}_${assembler}_${assembly_mode}_prokka.{gbk,gff}", mode: 'copy'

input:
tuple val(sample_id), path(assembly), val(assembler), val(assembly_mode)
Expand Down
2 changes: 1 addition & 1 deletion modules/provenance.nf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ process collect_provenance {

executor 'local'

publishDir params.versioned_outdir ? "${params.outdir}/${sample_id}/${params.pipeline_short_name}-v${params.pipeline_minor_version}-output" : "${params.outdir}/${sample_id}", pattern: "${sample_id}_*_provenance.yml", mode: 'copy'
publishDir "${params.outdir}/${sample_id}", pattern: "${sample_id}_*_provenance.yml", mode: 'copy'

input:
tuple val(sample_id), path(provenance_files)
Expand Down
2 changes: 1 addition & 1 deletion modules/quast.nf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ process parse_quast_report {

executor 'local'

publishDir params.versioned_outdir ? "${params.outdir}/${sample_id}/${params.pipeline_short_name}-v${params.pipeline_minor_version}-output" : "${params.outdir}/${sample_id}", pattern: "${sample_id}_${assembler}_${assembly_mode}_quast.csv", mode: 'copy'
publishDir "${params.outdir}/${sample_id}", pattern: "${sample_id}_${assembler}_${assembly_mode}_quast.csv", mode: 'copy'

input:
tuple val(sample_id), path(quast_report), val(assembler), val(assembly_mode)
Expand Down
2 changes: 1 addition & 1 deletion modules/unicycler.nf
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ process unicycler {

tag { sample_id + ' / ' + assembly_mode }

publishDir params.versioned_outdir ? "${params.outdir}/${sample_id}/${params.pipeline_short_name}-v${params.pipeline_minor_version}-output" : "${params.outdir}/${sample_id}", pattern: "${sample_id}_unicycler_${assembly_mode}.{fa,gfa,log}", mode: 'copy'
publishDir "${params.outdir}/${sample_id}", pattern: "${sample_id}_unicycler_${assembly_mode}.{fa,gfa,log}", mode: 'copy'

input:
tuple val(sample_id), path(reads), val(assembly_mode)
Expand Down
1 change: 0 additions & 1 deletion nextflow.config
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ params {
filtlong_min_length = 1000
filtlong_keep_percent = 90
samplesheet_input = 'NO_FILE'
versioned_outdir = false
pipeline_short_name = parsePipelineName(manifest.toMap().get('name'))
pipeline_minor_version = parseMinorVersion(manifest.toMap().get('version'))
}
Expand Down

0 comments on commit c8b63aa

Please sign in to comment.