Having trouble using collate() with formatter()

15 views
Skip to first unread message

Tom Harrop

unread,
Feb 18, 2016, 6:03:20 AM2/18/16
to ruffus_discuss
Hello,

I am struggling to get my head around the collate syntax using formatters.

I've made an example where I try to collate ['data/aa_data', 'output/aa/analysis1/results.txt'] to ['output/aa/analysis2/results.txt'].

I have tried a few variations, this is what I have at the moment:

from ruffus import *


def orig(output_files):
   
print("readfile = ", output_files)
   
with open(output_files, "w") as oo:
       
pass


def next_task(input_files, output_parameters):
   
print("input_parameters = ", input_files)
   
print("output_parameters = ", output_parameters)
   
for f in output_parameters:
       
with open(f, "w") as oo:
           
pass


def main():
    main_pipeline
= Pipeline.pipelines["main"]

    data
= main_pipeline.originate(name="data",
                                    task_func
=orig,
                                    output
="data/aa_data")

    result
= main_pipeline.originate(
        name
="result",
        task_func
=orig,
        output
="output/aa/analysis1/results.txt")

    main_pipeline
.collate(
        name
="next_task",
        task_func
=next_task,
        input
=[result, data],
        filter
=formatter(),
        output
=["output/{subdir[0][1]}/analysis2/results.txt",
               
"output/{basename[1][0:2]}/analysis2/results.txt"])

    pipeline_printout_graph
("flowchart.pdf", "pdf")

    main_pipeline
.run(verbose=5)

if __name__ == "__main__":
    main
()


According to my understanding of the Ruffus manual I expect both {subdir[0][1]} and {basename[1][0:2]} to resolve to "aa", so this should collate the output. However I am getting the following message:

Task = 'next_task' 
       !!! No jobs for this task.
       Are you sure there is not a error in your code / regular expression?
       Job Warning: Input substitution failed:
         Missing key = {} in 'output/{basename[1][0:2]}/analysis2/results.txt'.
               input =  '',
              filter = formatter(['output/aa/analysis1/results.txt'])..
       Job Warning: Input substitution failed:
         Missing key = {} in 'output/{basename[1][0:2]}/analysis2/results.txt'.
               input =  '',
              filter = formatter(['data/aa_data'])..

Can anyone tell me what I'm missing?

Thanks for reading,

Tom






Reply all
Reply to author
Forward
0 new messages