Answers.Body: <p>well I came up with the solution. I think it is a little unconventional.</p>
  <pre><code>    rule gatk_CombineGVCFs:                                                 
      
          input:
              vcf_dummy = expand(&quot;gvcf/{sample}.g.vcf.gz&quot;, sample = SAMPLES), # a dummy vcf to connect this rule to gatk_HaplotypeCaller
              fa = &quot;data/genome.fa&quot;,
      
          output:
              gvcf = &quot;gvcf_combined/all.g.vcf.gz&quot;,
              #index = directory(&quot;gvcf_index&quot;)                                 #index generated without seperate output
          params:
              list = &quot;gvcfs.list&quot;
              log: &quot;logs/CombineGVCFs.log&quot;
          shell:
              &quot;ls gvcf/*.gz &gt; gvcfs.list &amp;&amp; gatk --java-options -Xmx7g CombineGVCFs -R {input.fa} --variant {params.list} -O {output.gvcf} &quot;   
               #Two bash comands running sequentially to make a gvcf.list as during my testing the combineGVCFs tool takes lists as input. 
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-26T14:30:32.913Z
Answers.Text: You came up with *a* solution, not *the* solution (by your own admission).
Answers.UserDisplayName: Ram RS
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-26T20:21:18.907Z
Answers.Text: The solution to your problem should be described elaborately. Either describe your answer elaborately else add your question separately and then answer
Answers.UserDisplayName: Shafayet Rahat
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-27T04:55:10.550Z
Answers.Text: The comments in the code describe the solution pretty elaborately. The problem was in executing the the combineGVCF to which my solution was to add  --variant in the shell and first make a list of vcfs with ls and pass it as a list to combineGVCF.
Answers.UserDisplayName: Ayam Gupta
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-26T04:51:26.013Z
Answers.LastActivityDate: 2022-07-26T05:01:30.233Z
Answers.LastEditDate: 2022-07-26T05:01:30.233Z
Answers.UserDisplayName: Ayam Gupta
Answers.Body: <p>Found out the problem. Turns out I can write a lambda function as follows</p>
  <pre><code>params:
          extra=lambda wildcards, input: ' -V '.join(input.all_gvcf_list)
  </code></pre>
  <p>and add '-V' before {params.extra} in the &quot;shell&quot; sction. That solves the problem</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-15T08:54:42.113Z
Answers.Text: i am facing a similar issue can you please paste the whole code for your solution?
Answers.UserDisplayName: Ayam Gupta
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-07-16T10:51:45.473Z
Answers.Text: That is the whole rule/code actually.  get_all_gvcf_list() will give the absolute path of the files in a dataset. You just need to see if the problem really matches with you. If u still need any more help then maybe you can write the entire problem and tag the question with me.
Answers.UserDisplayName: Shafayet Rahat
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-16T17:19:47.027Z
Answers.LastActivityDate: 2021-09-20T14:49:11.760Z
Answers.LastEditDate: 2021-09-20T14:49:11.760Z
Answers.UserDisplayName: Shafayet Rahat
Body: <p>I have written a rule for CombineGVCFs in gatk4. The rule is as follow</p>
  <pre><code>all_gvcf = get_all_gvcf_list()
  
  rule cohort:
    input:
      all_gvcf_list = all_gvcf,
      ref=&quot;/data/refgenome/hg38.fa&quot;,
      interval_list = prefix+&quot;/bedfiles/hg38.interval_list&quot;,
    params:
      extra = &quot;--variant&quot;,
    output:
      prefix+&quot;/vcf/cohort.g.vcf&quot;,
    shell:
      &quot;gatk CombineGVCFs -R {input.ref} {params.extra} {input.all_gvcf_list} -O {output} --tmp-dir=/data/tmp -L {input.interval_list}&quot;
  
  </code></pre>
  <p>all_gvcf is the dataset for all gvcf files which will be combined. But the problem is I need to add --variant parameter before every input. Command I'm getting right now is as follows</p>
  <pre><code>gatk CombineGVCFs -R /data/refgenome/hg38.fa --variant /data/prjna644607/vcf/SRR12165216_HC.g.vcf /data/prjna644607/vcf/SRR12165217_HC.g.vcf /data/prjna644607/vcf/SRR12165218_HC.g.vcf /data/prjna644607/vcf/SRR12165219_HC.g.vcf -O /data/prjna644607/vcf/cohort.g.vcf --tmp-dir=/data/tmp -L /data/prjna644607/bedfiles/hg38.interval_list
  
  </code></pre>
  <p>The command I want to achieve is as follows</p>
  <pre><code>gatk CombineGVCFs -R /data/refgenome/hg38.fa --variant /data/prjna644607/vcf/SRR12165216_HC.g.vcf --variant /data/prjna644607/vcf/SRR12165217_HC.g.vcf --variant /data/prjna644607/vcf/SRR12165218_HC.g.vcf --variant /data/prjna644607/vcf/SRR12165219_HC.g.vcf -O /data/prjna644607/vcf/cohort.g.vcf --tmp-dir=/data/tmp -L /data/prjna644607/bedfiles/hg38.interval_list
  </code></pre>
  <p>How can I add this extra &quot;--variant&quot; tag before every input? I have added it in the get_all_gvcf_list() function. But then snakmake gives me inputfiles not found problem.</p>
  
Tags: <python><snakemake><gatk>
Title: snakemake multiple parameters for multiple input and single output in snakemake. ConbineGVCFs gatk problem
ThreadText: # snakemake multiple parameters for multiple input and single output in snakemake. ConbineGVCFs gatk problem
  
  (Asked by: username_0 on 2021-09-16)
  
  I have written a rule for CombineGVCFs in gatk4. The rule is as follow
  
  ```
  all_gvcf = get_all_gvcf_list()
  
  rule cohort:
    input:
      all_gvcf_list = all_gvcf,
      ref="/data/refgenome/hg38.fa",
      interval_list = prefix+"/bedfiles/hg38.interval_list",
    params:
      extra = "--variant",
    output:
      prefix+"/vcf/cohort.g.vcf",
    shell:
      "gatk CombineGVCFs -R {input.ref} {params.extra} {input.all_gvcf_list} -O {output} --tmp-dir=/data/tmp -L {input.interval_list}"
  
  ```
  
  all\_gvcf is the dataset for all gvcf files which will be combined. But the problem is I need to add --variant parameter before every input. Command I'm getting right now is as follows
  
  ```
  gatk CombineGVCFs -R /data/refgenome/hg38.fa --variant /data/prjna644607/vcf/SRR12165216_HC.g.vcf /data/prjna644607/vcf/SRR12165217_HC.g.vcf /data/prjna644607/vcf/SRR12165218_HC.g.vcf /data/prjna644607/vcf/SRR12165219_HC.g.vcf -O /data/prjna644607/vcf/cohort.g.vcf --tmp-dir=/data/tmp -L /data/prjna644607/bedfiles/hg38.interval_list
  
  ```
  
  The command I want to achieve is as follows
  
  ```
  gatk CombineGVCFs -R /data/refgenome/hg38.fa --variant /data/prjna644607/vcf/SRR12165216_HC.g.vcf --variant /data/prjna644607/vcf/SRR12165217_HC.g.vcf --variant /data/prjna644607/vcf/SRR12165218_HC.g.vcf --variant /data/prjna644607/vcf/SRR12165219_HC.g.vcf -O /data/prjna644607/vcf/cohort.g.vcf --tmp-dir=/data/tmp -L /data/prjna644607/bedfiles/hg38.interval_list
  
  ```
  
  How can I add this extra "--variant" tag before every input? I have added it in the get\_all\_gvcf\_list() function. But then snakmake gives me inputfiles not found problem.
  
  **Tags:** python, snakemake, gatk
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2021-09-16. Score: 5 | Accepted answer
  
  Found out the problem. Turns out I can write a lambda function as follows
  
  ```
  params:
          extra=lambda wildcards, input: ' -V '.join(input.all_gvcf_list)
  
  ```
  
  and add '-V' before {params.extra} in the "shell" sction. That solves the problem
  
  > **Comments:**
  > **username_1**: i am facing a similar issue can you please paste the whole code for your solution?  
  > **username_0**: That is the whole rule/code actually.  get_all_gvcf_list() will give the absolute path of the files in a dataset. You just need to see if the problem really matches with you. If u still need any more help then maybe you can write the entire problem and tag the question with me.  
  
  ---
  
  ### Answer by username_1 on 2022-07-26. Score: -1
  
  well I came up with the solution. I think it is a little unconventional.
  
  ```
      rule gatk_CombineGVCFs:                                                 
      
          input:
              vcf_dummy = expand("gvcf/{sample}.g.vcf.gz", sample = SAMPLES), # a dummy vcf to connect this rule to gatk_HaplotypeCaller
              fa = "data/genome.fa",
      
          output:
              gvcf = "gvcf_combined/all.g.vcf.gz",
              #index = directory("gvcf_index")                                 #index generated without seperate output
          params:
              list = "gvcfs.list"
              log: "logs/CombineGVCFs.log"
          shell:
              "ls gvcf/*.gz > gvcfs.list && gatk --java-options -Xmx7g CombineGVCFs -R {input.fa} --variant {params.list} -O {output.gvcf} "   
               #Two bash comands running sequentially to make a gvcf.list as during my testing the combineGVCFs tool takes lists as input. 
  
  ```
  
  > **Comments:**
  > **username_2**: You came up with *a* solution, not *the* solution (by your own admission).  
  > **username_0**: The solution to your problem should be described elaborately. Either describe your answer elaborately else add your question separately and then answer  
  > **username_1**: The comments in the code describe the solution pretty elaborately. The problem was in executing the the combineGVCF to which my solution was to add  --variant in the shell and first make a list of vcfs with ls and pass it as a list to combineGVCF.  
  
  ---
  
  