<p>You can use join to convert the list of input file into a string. 
I think this would work as expected.:</p>

<pre class="lang-py prettyprint-override"><code>rule run_prog:
    input: "a", "b"
    output: "output"
    run: f"prog {','.join(input)}"
</code></pre>

CC BY-SA 4.0
2020-04-22T03:19:32.380Z
This works great. It works for `f"prog {','.join(input.variable)}"`  if I define `variable` under `input:` section. Can you explain why have to use `input[:]` instead of `input`?
zhanxw
CC BY-SA 4.0
2020-04-22T09:28:33.033Z
Right, using `input` by itself is the same ! I edited my answer.
cmdoret
CC BY-SA 4.0
2020-04-21T09:01:09.900Z
2020-04-22T09:28:53.430Z
2020-04-22T09:28:53.430Z
cmdoret
<p>I want to pass a series of files (e.g., <code>a</code>, <code>b</code>) to a program <code>prog</code> like: <code>prog a,b</code>.</p>

<p>Is there a way to do this in Snakemake?</p>

<p>My attempt is:</p>

<pre><code>rule run_prog:
  input: "a", "b"
  output: "output"
  run: "prog {input}"
</code></pre>

<p>But the actual command Snakemake generated is <code>prog a b</code> instead of <code>prog a,b</code>.</p>

<p>Any solution to pass a comma concatenated file names to Snakemake?</p>

CC BY-SA 4.0
2020-04-20T12:51:22.383Z
`run: "prog {input[0]},{input[1]}"` ?
Chris_Rands
CC BY-SA 4.0
2020-04-20T15:22:58.003Z
@Chris_Rands that works, is there a general solution, as there can be ~20 input files. Thanks!
zhanxw
<snakemake>
How to concatename file names in Snakemake?
# How to concatename file names in Snakemake?

(Asked by: username_0 on 2020-04-20)

I want to pass a series of files (e.g., a, b) to a program prog like: prog a,b.
Is there a way to do this in Snakemake?
My attempt is:
rule run_prog:
  input: "a", "b"
  output: "output"
  run: "prog {input}"

But the actual command Snakemake generated is prog a b instead of prog a,b.
Any solution to pass a comma concatenated file names to Snakemake?

**Tags:** snakemake
> **Comments:**
> **username_1**: `run: "prog {input[0]},{input[1]}"` ?  
> **username_0**: @Chris_Rands that works, is there a general solution, as there can be ~20 input files. Thanks!  

---

## 1 answers

### Answer by username_2 on 2020-04-21. Score: 1 | Accepted answer

You can use join to convert the list of input file into a string. 
I think this would work as expected.:
rule run_prog:
    input: "a", "b"
    output: "output"
    run: f"prog {','.join(input)}"

> **Comments:**
> **username_0**: This works great. It works for `f"prog {','.join(input.variable)}"`  if I define `variable` under `input:` section. Can you explain why have to use `input[:]` instead of `input`?  
> **username_2**: Right, using `input` by itself is the same ! I edited my answer.  

---

