Search code examples
pythonpipelineruffus

How to use subdirectories with Ruffus pipelines


The Ruffus pipeline documentation seems to assume that one's code and data are in the same directory. All the examples have input and output file specifiers without any relative paths. How should one modify the syntax below if, say, the files to be transformed are not in the current directory?

@transform(map_dna_sequence,                   # Input = previous stage
        suffix(".sam"),                    #         suffix = .sam
        ".bam")  

Solution

  • The lastest version of Ruffus allows you to output to a new directory:

    @transform(map_dna_sequence,           # Input = previous stage
        suffix(".sam"),                    #         suffix = .sam
        ".bam",
        output_dir = "/path/to/a/new_directory")  
    

    Otherwise, you can change directories using either formatter() or regex rather than suffix. Both of these are considerably more powerful but have more complicated syntax...

    BTW, it is a good idea to post on the ruffus newsgroup as well.