I am almost there with creating a downstream sampl...
# help
e
I am almost there with creating a downstream samplesheet with the new workflow output syntax, but struggling in the last bit. It's a very simple samplesheet with two columns:
Copy code
proteinfold_samplesheet = NFCORE_PROTEINFAMILIES.out.family_reps
        .map { meta, file ->
            [
                id: meta.id,
                fasta: file
            ]
        }

    publish:
    proteinfold_samplesheet = proteinfold_samplesheet
This is my current output directive:
Copy code
output {
    proteinfold_samplesheet {
        path { sample -> "proteinfold/${sample.id}/" }
        mode params.publish_dir_mode
        enabled !params.skip_proteinfold_samplesheet
        index {
            path 'proteinfold/samplesheet.csv'
            header true
            sep ','
        }
    }
}
It works fine but: 1. Can I also use sample.id somehow in the index? It keeps giving me errors whatever I tried. Otherwise two different runs will overwrite each other. 2. Can I turn off quoting in the index file that is created? currently it is like this:
Copy code
"id","fasta"
"mgnifams_test","/path/to/results/proteinfold/mgnifams_test/mgnifams_test_reps.faa"
m
1. I think it's not possible to name the index with the sample id. 2. Why would you want to get rid of the quotes? It's a safety feature so
,
aren't misinterpretted and spaces and special characters in file paths are treated correctly.
e
Ooh I see..I guess it would just be nice to have the option, for both of the above
m
I think it's possible in the classical way with a native process, but you would be responsible to make sure if someone tuned the output path, then the corresponding native process would need the path updated. Use
groupTuple
and pass input to a native process. Use the
workflow.outputDir
and publishing structure with the filenames to form the expected path to the files in the results folder, and then write them out to file to publish.
e
This is what I had done already..well with the workDir instead of publishDir, but I know what you mean. Then we figured we should switch to the new output syntax with @James Fellows Yates
Another problem (at least for now) is that end to end nf-test cannot capture these new output syntax files. Or at least I haven't figured out how
b
There is a Nextflow issue in the backlog about being more frugal with the quoting, just haven't gotten around to it. I suspect people would be better off producing JSON files anyway
Why do you want to use the sample id in the index file name? I don't understand what you mean about two runs overwriting each other
e
In case I execute two different runs (two different samplesheets in the upstream pipeline), the output samplesheet.csv for the downstream pipeline will always have the same name.
b
so there is only one sample id per pipeline run?
e
Not necessarily, but that's what I tested with. I make a subfolder with sample id for the published file path, but then the index gets in the same name folder. Feel free to have a look in this PR, going from modules publishing the samplesheet, to the new output format: https://github.com/nf-core/proteinfamilies/pull/134/files
b
Okay I think I understand. It sounds like you are performing multiple pipeline runs with the same output directory and so the index files will clobber each other If that's what you're doing then you'll need to use a param to distinguish between different runs, such as a timestamp. The index file path can be a dynamic string, so it can reference things like params
e
Ooh good to know, thanks!
t
Normally you would (should) be using different output directories for different runs. If you don't do that, clobbered files should not be surprising. It might be nice to have a(n optional) safety check in the pipeline that refuses to run with a nonempty output directory (or renames such an existing directory).
e
In nfcore pipelines you usually prefix folders and/or files with sample ids, to avoid that. So given that two different samplesheets that are used in two different runs, dont have any common sample ids, then there wont be overwrites. But definitely, giving a timestamp or a different name at the outdir would work