Tuesday 26 October 2021

python function executed in the 'run:' context returns the path of the output file, provide that to 'output:' context

I have snakemake workflow in which the python function executed in the 'run:' context returns the path of the output file. I want to capture that as a variable in the Snakefile provide it to the 'output:' context.

That way I could have my output: automatically filled. I wonder if there is any way to do this in snakemake. Please let me know.

Further information on the python function: It processes the file provided in the input: context and returns a single string which is the path of the output file.

The rule looks like this:

rule task01:
    input:
        "path/to/input.tsv"
    run:
        from module import function
        p=function(metadata=metadata)
        # p is the path where the output file needs to be saved
        # For that I would like to access the variable p in the `output:` context below
    output:
        # can I access the variable p here?


from python function executed in the 'run:' context returns the path of the output file, provide that to 'output:' context

No comments:

Post a Comment