Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bash external script: is it possibile to use it #294

Closed
aborruso opened this issue Mar 25, 2020 · 7 comments · Fixed by #1821
Closed

bash external script: is it possibile to use it #294

aborruso opened this issue Mar 25, 2020 · 7 comments · Fixed by #1821
Labels
enhancement New feature or request

Comments

@aborruso
Copy link

Hi,
I think it's not possible, but it would be great to use something like echo ${input[1]} in an external bash script.

Thank you for this great tool

@aborruso aborruso added the enhancement New feature or request label Mar 25, 2020
@aborruso
Copy link
Author

I must use mailing list, I'm closing it

@bricoletc
Copy link
Contributor

Hi @aborruso , what came out of this? I'm quite keen on this feature too!

@aborruso
Copy link
Author

@bricoletc
Copy link
Contributor

Thanks for your reply @aborruso !

I'm a little confused by that answer. Have you successfully called bash scripts from script directive inside a rule?

Here's what I get when running the following snakefile:

rule mkfiles:
	params:
		pref="test"
	script:
		"mkfiles.sh"

where the bash script contains:

for i in $(seq 1 5); do
	echo {snakemake.params.pref}$i
done

Stderr:

ValueError in line 5 of /path/to/tests/Snakefile:

Unsupported script: Expecting either Python (.py), R (.R), RMarkdown (.Rmd) or Julia (.jl) script.
  File "/path/to/tests/Snakefile", line 5, in __rule_mkfiles
  File "/usr/lib/python3.6/concurrent/futures/thread.py", line 56, in run

@aborruso
Copy link
Author

aborruso commented Apr 16, 2020 via email

@bricoletc
Copy link
Contributor

I think this is worth re-examining then.

Is lack of support for shell script because it is hard to implement, or for design reasons?

@bricoletc bricoletc reopened this Apr 17, 2020
@bricoletc bricoletc assigned bricoletc and unassigned bricoletc Apr 17, 2020
@mbhall88
Copy link
Member

I think this is doable.

Since Bash v4, there are associative arrays, which are analogous to python dictionaries. There is a nice tutorial here showing how to work with these.

The main task for getting this working I expect is converting a python dictionary to a bash dictionary. I couldn't find any (obvious) existing libraries for this, but we could easily write a sublibrary within snakemake to do this conversion and then inject it into the bash script.

I'd be happy to dig into this once #1053 is merged (and provided @johanneskoester is happy to include such a feature).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants