cgat-developers / ruffus

CGAT-ruffus is a lightweight python module for running computational pipelines
MIT License
173 stars 34 forks source link

output_dir parameter for more decorators #42

Closed ghost closed 9 years ago

ghost commented 9 years ago

The output_dir named parameter for @transform in combination with suffix(...) is a tremendously helpful simplification that allows for an explicit separation of directory structure(s) from file naming. Extending that to, e.g., subdivide might clarify the pipeline code for these cases.

bunbun commented 9 years ago

Thanks. This will be available in the next point release of ruffus 2.6.3 (?)

In the meantime, support is available in the git repository.

There is test code in test_suffix_output_dir.py.

Important:

For both @tranform(suffix(...), output_dir = "something") and @subdivide(suffix(...), output_dir = "something"), the onus is on the Ruffus programmer not to do something senseless, like have a suffix() which includes a path / the parent directory:

    @transform(input = prev_task, filter = suffix("parent_dir/a.txt"), output = "parent_dir/b.txt", output_dir = "working_dir")
    def stupid_code(inputs, outputs):
        pass

There is no reasonable way of interpreting such code. Don't do it.