Home > Software engineering >  How to give explicitly input and output to Snakemake file?
How to give explicitly input and output to Snakemake file?

Time:10-02

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.

CodePudding user response:

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
  • Related