0

So I have a pipeline written in shell which loops over three folders and then an inside loop which loops over files inside the folder.

For next step, I have a snakemake file, which takes an input folder and output folder. For trial run I gave the folder path inside the snakemake file. So I was wondering is there any way I can give input and output folder path explicitly.

For e.g. snakemake --cores 30 -s trial.snakemake /path/to/input /path/to/output

Since I want to change the input and output according to the main loop.

I tried import sys and using sys.argv[1] and sys.argv[2] inside the snakemake file but its not working.

Below is the snippet of my pipeline, it takes three folder for now, ABC_Samples, DEF_Samples, XYZ_Samples

for folder in /path/to/*_Samples do folderName=$(basename $folder _Samples) mkdir -p /path/to/output/$fodlerName for files in $folder/*.gz do / do something / done snakemake --cores 30 -s trial.snakemake /path/to/output/$fodlerName /path/to/output2/ done 

But the above doesn't work. So is there any way I can do this. I am really new to snakemake.

Thank you in advance.

1 Answer 1

3

An efficient way could be to incorporate the folder structure explicitly inside your Snakefile. For example, you could use the content of a parameter, e.g. example_path, inside the Snakefile and then pass it via config:

snakemake --config example_path_in=/path/to/input example_path_out=/path/to/output 
Sign up to request clarification or add additional context in comments.

4 Comments

but the thing is $fodlerName will be change as the loop goes, so how can I pass that to the snakemake file. It cant read the shell variable right?
You could stick this into a bash loop and replace example_path_in with the bash variable (e.g. example_path_in=$folderName). However, this is not efficient because it doesn't let snakemake exploit parallelisation opportunities... a better way would be to re-write the snakefile, but from your question it's not clear what is inside the snakefile.
Actually my pipeline processes a biological data and in that one process is little bit complicated but for that i got a ready made snakemake file. I have very less knowledge of snakemake, I am learning now.
Thank you for your advice :) I guess I can work around it.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.