Body: <p>I have started using snakemake 6.5.2 to align fastq files with reference file. I have pasted the error below in this question. How to allocate memory in the snakefile and read the header from samfile, '-'. This is the snakefile (wrapper for running alignment):</p>
  <pre><code> rule bwa_mem2_mem:
          input:
              reads=[&quot;/scicore/home/cichon/GROUP/test_workflow/samples/{sample}.1.fq&quot;, &quot;/scicore/home/cichon/GROUP/test_workflow/samples/{sample}.2.fq&quot;]
          output:
              &quot;/scicore/home/cichon/GROUP/test_workflow/output/{sample}.bam&quot;
          log:
              &quot;/scicore/home/cichon/GROUP/test_workflow/output/{sample}.log&quot;
          params:
              index=&quot;/scicore/home/cichon/GROUP/test_workflow/data/gch38.fa&quot;,
              extra=r&quot;-R '@RG\tID:{sample}\tSM:{sample}'&quot;,
              sort=&quot;none&quot;,             # Can be 'none', 'samtools' or 'picard'.
              sort_order=&quot;coordinate&quot;, # Can be 'coordinate' (default) or 'queryname'.
              sort_extra=&quot;&quot;     
  
          threads: 8
          wrapper:
              &quot;0.77.0/bio/bwa-mem2/mem&quot;
  </code></pre>
  <p>I used this command to execute the above snakemake file:</p>
  <pre><code>snakemake --use-conda --snakefile Snakefile --cores -p /scicore/home/cichon/GROUP/test_workflow/output/DE98NGSUKBD117612_1.bam /scicore/home/cichon/GROUP/test_workflow/output/DE71NGSUKBD117613_3.bam
  </code></pre>
  <p>Error from log file:</p>
  <pre><code>Looking to launch executable &quot;/scicore/home/cichon/GROUP/test_workflow/.snakemake/conda/0ecf6ba401c70d7501c73bb1c733a060/bin/bwa-mem2.avx&quot;, simd = .avx
  Launching executable &quot;/scicore/home/cichon/GROUP/test_workflow/.snakemake/conda/0ecf6ba401c70d7501c73bb1c733a060/bin/bwa-mem2.avx&quot;
  -----------------------------
  Executing in AVX mode!!
  -----------------------------
  * SA compression enabled with xfactor: 8
  * Ref file: /scicore/home/cichon/GROUP/test_workflow/data/gch38.fa
  * Entering FMI_search
  * Index file found. Loading index from /scicore/home/cichon/GROUP/test_workflow/data/gch38.fa.bwt.2bit.64
  * Reference seq len for bi-index = 6544178411
  * sentinel-index: 2782712944
  * Count:
  0,  1
  1,  1914743810
  2,  3272089206
  3,  4629434602
  4,  6544178411
  
  * Reading other elements of the index from files /scicore/home/cichon/GROUP/test_workflow/data/gch38.fa
  * Index prefix: /scicore/home/cichon/GROUP/test_workflow/data/gch38.fa
  * Read 0 ALT contigs
  [fread] Cannot allocate memory
  [main_samview] fail to read the header from &quot;-&quot;.
  </code></pre>
  <p>Thanks</p>
  <p>Priya</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-25T12:57:57.090Z
Comments.Text: Please don't close the question. I am the one posted the question in Biostars as I didn't get a clear answer, I have posted it here again . Thanks
Comments.UserDisplayName: Atom
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-08-26T12:10:17.640Z
Comments.Text: Clearly, this seems a problem with memory allocation. You should tell us what you tried from the suggestions of Biostars so we can help you in your problem.
Comments.UserDisplayName: user324810
Tags: <ngs><snakemake><python><workflow-management>
Title: BWA-MEM2 alignment-Snakemake
ThreadText: # BWA-MEM2 alignment-Snakemake
  
  (Asked by: username_0 on 2021-08-25)
  
  I have started using snakemake 6.5.2 to align fastq files with reference file. I have pasted the error below in this question. How to allocate memory in the snakefile and read the header from samfile, '-'. This is the snakefile (wrapper for running alignment):
  
  ```
   rule bwa_mem2_mem:
          input:
              reads=["/scicore/home/cichon/GROUP/test_workflow/samples/{sample}.1.fq", "/scicore/home/cichon/GROUP/test_workflow/samples/{sample}.2.fq"]
          output:
              "/scicore/home/cichon/GROUP/test_workflow/output/{sample}.bam"
          log:
              "/scicore/home/cichon/GROUP/test_workflow/output/{sample}.log"
          params:
              index="/scicore/home/cichon/GROUP/test_workflow/data/gch38.fa",
              extra=r"-R '@RG\tID:{sample}\tSM:{sample}'",
              sort="none",             # Can be 'none', 'samtools' or 'picard'.
              sort_order="coordinate", # Can be 'coordinate' (default) or 'queryname'.
              sort_extra=""     
  
          threads: 8
          wrapper:
              "0.77.0/bio/bwa-mem2/mem"
  
  ```
  
  I used this command to execute the above snakemake file:
  
  ```
  snakemake --use-conda --snakefile Snakefile --cores -p /scicore/home/cichon/GROUP/test_workflow/output/DE98NGSUKBD117612_1.bam /scicore/home/cichon/GROUP/test_workflow/output/DE71NGSUKBD117613_3.bam
  
  ```
  
  Error from log file:
  
  ```
  Looking to launch executable "/scicore/home/cichon/GROUP/test_workflow/.snakemake/conda/0ecf6ba401c70d7501c73bb1c733a060/bin/bwa-mem2.avx", simd = .avx
  Launching executable "/scicore/home/cichon/GROUP/test_workflow/.snakemake/conda/0ecf6ba401c70d7501c73bb1c733a060/bin/bwa-mem2.avx"
  -----------------------------
  Executing in AVX mode!!
  -----------------------------
  * SA compression enabled with xfactor: 8
  * Ref file: /scicore/home/cichon/GROUP/test_workflow/data/gch38.fa
  * Entering FMI_search
  * Index file found. Loading index from /scicore/home/cichon/GROUP/test_workflow/data/gch38.fa.bwt.2bit.64
  * Reference seq len for bi-index = 6544178411
  * sentinel-index: 2782712944
  * Count:
  0,  1
  1,  1914743810
  2,  3272089206
  3,  4629434602
  4,  6544178411
  
  * Reading other elements of the index from files /scicore/home/cichon/GROUP/test_workflow/data/gch38.fa
  * Index prefix: /scicore/home/cichon/GROUP/test_workflow/data/gch38.fa
  * Read 0 ALT contigs
  [fread] Cannot allocate memory
  [main_samview] fail to read the header from "-".
  
  ```
  
  Thanks
  
  Priya
  
  **Tags:** ngs, snakemake, python, workflow-management
  
  > **Comments:**
  > **username_0**: Please don't close the question. I am the one posted the question in Biostars as I didn't get a clear answer, I have posted it here again . Thanks  
  > **username_1**: Clearly, this seems a problem with memory allocation. You should tell us what you tried from the suggestions of Biostars so we can help you in your problem.  
  
  ---
  
  ## 0 answers
  
  