Answers.Body: <p><em>Answer from @mjoppich, converted from comment:</em></p>
  <p>Late answer, but it looks like you are running out of memory, hence the intptr is invalid.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-07-04T04:40:39.627Z
Answers.LastActivityDate: 2021-07-04T04:40:39.627Z
Answers.UserDisplayName: gringer
Body: <p>I try to perform a hybrid assembly using Unicycler. Unicycler use SPAdes to assembly the illumina sequences, and the program crashes while in SPAdes. The spades.log file says something about an invalid argument and error code 22. I have run the <code>spades.py --test</code>, and everything seems to work fine. </p>
  
  <pre><code>Command line: /home/user/SPAdes-3.11.1-Linux/bin/spades.py    -1  /home/user/minion/organism/Illumina/BD_S3_L001_R1_001.fastq.gz -2  /home/user/minion/organism/Illumina/BD_S3_L001_R2_001.fastq.gz -o  /home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction --threads   8   --only-error-correction 
  
  System information:
    SPAdes version: 3.11.1
    Python version: 2.7.12
    OS: Linux-4.10.0-40-generic-x86_64-with-Ubuntu-16.04-xenial
  
  Output dir: /home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction
  Mode: ONLY read error correction (without assembling)
  Debug mode is turned OFF
  
  Dataset parameters:
    Multi-cell mode (you should set '--sc' flag if input data was obtained with MDA (single-cell) technology or --meta flag if processing metagenomic dataset)
    Reads:
      Library number: 1, library type: paired-end
        orientation: fr
        left reads: ['/home/user/minion/organism/Illumina/BD_S3_L001_R1_001.fastq.gz']
        right reads: ['/home/user/minion/organism/Illumina/BD_S3_L001_R2_001.fastq.gz']
        interlaced reads: not specified
        single reads: not specified
  Read error correction parameters:
    Iterations: 1
    PHRED offset will be auto-detected
    Corrected reads will be compressed (with gzip)
  Other parameters:
    Dir for temp files: /home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction/tmp
    Threads: 8
    Memory limit (in Gb): 87
  
  
  ======= SPAdes pipeline started. Log can be found here: /home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction/spades.log
  
  
  ===== Read error correction started. 
  
  
  == Running read error correction tool: /home/user/SPAdes-3.11.1-Linux/bin/hammer /home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction/corrected/configs/config.info
  
    0:00:00.000     4M / 4M    INFO    General                 (main.cpp                  :  83)   Starting BayesHammer, built from N/A, git revision N/A
    0:00:00.001     4M / 4M    INFO    General                 (main.cpp                  :  84)   Loading config from /home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction/corrected/configs/config.info
    0:00:00.045     4M / 4M    INFO    General                 (memory_limit.hpp          :  51)   Memory limit set to 87 Gb
    0:00:00.045     4M / 4M    INFO    General                 (main.cpp                  :  93)   Trying to determine PHRED offset
    0:00:00.071     4M / 4M    INFO    General                 (main.cpp                  :  99)   Determined value is 33
    0:00:00.071     4M / 4M    INFO    General                 (hammer_tools.cpp          :  36)   Hamming graph threshold tau=1, k=21, subkmer positions = [ 0 10 ]
    0:00:00.072     4M / 4M    INFO    General                 (main.cpp                  : 120)   Size of aux. kmer data 24 bytes
       === ITERATION 0 begins ===
    0:00:00.100     4M / 4M    INFO   K-mer Index Building     (kmer_index_builder.hpp    : 289)   Building kmer index
    0:00:00.101     4M / 4M    INFO    General                 (kmer_index_builder.hpp    : 106)   Splitting kmer instances into 128 buckets using 8 threads. This might take a while.
    0:00:00.101     4M / 4M    INFO    General                 (file_limit.hpp            :  32)   Open file limit set to 1024
    0:00:00.101     4M / 4M    INFO    General                 (kmer_splitters.hpp        :  74)   Memory available for splitting buffers: 3.62484 Gb
    0:00:00.101     4M / 4M    INFO    General                 (kmer_splitters.hpp        :  82)   Using cell size of 524288
    0:00:00.102     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             :  96)   Processing /home/user/minion/organism/Illumina/BD_S3_L001_R1_001.fastq.gz
    0:00:57.279     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             : 106)   Processed 1338594 reads
    0:03:30.505     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             : 106)   Processed 2152556 reads
    0:03:30.505     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             :  96)   Processing /home/user/minion/organism/Illumina/BD_S3_L001_R2_001.fastq.gz
    0:09:23.290     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             : 106)   Processed 3442412 reads
    0:14:08.692     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             : 106)   Processed 4305112 reads
    0:14:08.692     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             : 111)   Total 4305112 reads processed
    0:14:08.726    32M / 8G    INFO    General                 (kmer_index_builder.hpp    : 109)   Starting k-mer counting.
    0:20:36.408    32M / 8G    INFO    General                 (kmer_index_builder.hpp    : 115)   K-mer counting done. There are 205776690 kmers in total.
    0:20:36.409    32M / 8G    INFO    General                 (kmer_index_builder.hpp    : 121)   Merging temporary buckets.
    0:24:43.505    32M / 8G    INFO   K-mer Index Building     (kmer_index_builder.hpp    : 298)   Building perfect hash indices
    0:25:40.125   100M / 8G    INFO    General                 (kmer_index_builder.hpp    : 137)   Merging final buckets.
    1:11:46.553   100M / 8G    INFO   K-mer Index Building     (kmer_index_builder.hpp    : 320)   Index built. Total 95426752 bytes occupied (3.70991 bits per kmer).
    1:11:46.598   100M / 8G    INFO   K-mer Counting           (kmer_data.cpp             : 357)   Arranging kmers in hash map order
    1:12:55.597     3G / 8G    INFO    General                 (main.cpp                  : 155)   Clustering Hamming graph.
    1:21:35.596     3G / 8G    INFO    General                 (main.cpp                  : 162)   Extracting clusters
  === Stack Trace ===
  [0x407a6a]
  [0x409561]
  [0x40c79b]
  [0x40129a]
  [0x5442b0]
  [0x40620d]
  Verification of expression '(intptr_t) MappedRegion != -1L' failed in function 'void MMappedWriter::reserve(size_t)'. In file '/spades/src/common/io/kmers/mmapped_writer.hpp' on line 94. Message 'mmap(2) failed. Reason: Invalid argument. Error code: 22'.
  Verification of expression '(intptr_t) MappedRegion != -1L' failed in function 'void MMappedWriter::reserve(size_t)'. In file '/spades/src/common/io/kmers/mmapped_writer.hpp' on line 94. Message 'mmap(2) failed. Reason: Invalid argument. Error code: 22'.
  hammer: /spades/src/common/io/kmers/mmapped_writer.hpp:94: void MMappedWriter::reserve(size_t): Assertion `(intptr_t) MappedRegion != -1L' failed.
  
  
  == Error ==  system call for: "['/home/user/SPAdes-3.11.1-Linux/bin/hammer', '/home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction/corrected/configs/config.info']" finished abnormally, err code: -6
  
  In case you have troubles running SPAdes, you can write to spades.support@cab.spbu.ru
  or report an issue on our GitHub repository github.com/ablab/spades
  Please provide us with params.txt and spades.log files from the output directory.
  </code></pre>
  
Tags: <fasta><assembly>
Title: SPAdes error during assembly
ThreadText: # SPAdes error during assembly
  
  (Asked by: username_0 on 2017-11-30)
  
  I try to perform a hybrid assembly using Unicycler. Unicycler use SPAdes to assembly the illumina sequences, and the program crashes while in SPAdes. The spades.log file says something about an invalid argument and error code 22. I have run the `spades.py --test`, and everything seems to work fine.
  
  ```
  Command line: /home/user/SPAdes-3.11.1-Linux/bin/spades.py    -1  /home/user/minion/organism/Illumina/BD_S3_L001_R1_001.fastq.gz -2  /home/user/minion/organism/Illumina/BD_S3_L001_R2_001.fastq.gz -o  /home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction --threads   8   --only-error-correction 
  
  System information:
    SPAdes version: 3.11.1
    Python version: 2.7.12
    OS: Linux-4.10.0-40-generic-x86_64-with-Ubuntu-16.04-xenial
  
  Output dir: /home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction
  Mode: ONLY read error correction (without assembling)
  Debug mode is turned OFF
  
  Dataset parameters:
    Multi-cell mode (you should set '--sc' flag if input data was obtained with MDA (single-cell) technology or --meta flag if processing metagenomic dataset)
    Reads:
      Library number: 1, library type: paired-end
        orientation: fr
        left reads: ['/home/user/minion/organism/Illumina/BD_S3_L001_R1_001.fastq.gz']
        right reads: ['/home/user/minion/organism/Illumina/BD_S3_L001_R2_001.fastq.gz']
        interlaced reads: not specified
        single reads: not specified
  Read error correction parameters:
    Iterations: 1
    PHRED offset will be auto-detected
    Corrected reads will be compressed (with gzip)
  Other parameters:
    Dir for temp files: /home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction/tmp
    Threads: 8
    Memory limit (in Gb): 87
  
  ======= SPAdes pipeline started. Log can be found here: /home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction/spades.log
  
  ===== Read error correction started. 
  
  == Running read error correction tool: /home/user/SPAdes-3.11.1-Linux/bin/hammer /home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction/corrected/configs/config.info
  
    0:00:00.000     4M / 4M    INFO    General                 (main.cpp                  :  83)   Starting BayesHammer, built from N/A, git revision N/A
    0:00:00.001     4M / 4M    INFO    General                 (main.cpp                  :  84)   Loading config from /home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction/corrected/configs/config.info
    0:00:00.045     4M / 4M    INFO    General                 (memory_limit.hpp          :  51)   Memory limit set to 87 Gb
    0:00:00.045     4M / 4M    INFO    General                 (main.cpp                  :  93)   Trying to determine PHRED offset
    0:00:00.071     4M / 4M    INFO    General                 (main.cpp                  :  99)   Determined value is 33
    0:00:00.071     4M / 4M    INFO    General                 (hammer_tools.cpp          :  36)   Hamming graph threshold tau=1, k=21, subkmer positions = [ 0 10 ]
    0:00:00.072     4M / 4M    INFO    General                 (main.cpp                  : 120)   Size of aux. kmer data 24 bytes
       === ITERATION 0 begins ===
    0:00:00.100     4M / 4M    INFO   K-mer Index Building     (kmer_index_builder.hpp    : 289)   Building kmer index
    0:00:00.101     4M / 4M    INFO    General                 (kmer_index_builder.hpp    : 106)   Splitting kmer instances into 128 buckets using 8 threads. This might take a while.
    0:00:00.101     4M / 4M    INFO    General                 (file_limit.hpp            :  32)   Open file limit set to 1024
    0:00:00.101     4M / 4M    INFO    General                 (kmer_splitters.hpp        :  74)   Memory available for splitting buffers: 3.62484 Gb
    0:00:00.101     4M / 4M    INFO    General                 (kmer_splitters.hpp        :  82)   Using cell size of 524288
    0:00:00.102     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             :  96)   Processing /home/user/minion/organism/Illumina/BD_S3_L001_R1_001.fastq.gz
    0:00:57.279     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             : 106)   Processed 1338594 reads
    0:03:30.505     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             : 106)   Processed 2152556 reads
    0:03:30.505     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             :  96)   Processing /home/user/minion/organism/Illumina/BD_S3_L001_R2_001.fastq.gz
    0:09:23.290     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             : 106)   Processed 3442412 reads
    0:14:08.692     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             : 106)   Processed 4305112 reads
    0:14:08.692     8G / 8G    INFO   K-mer Splitting          (kmer_data.cpp             : 111)   Total 4305112 reads processed
    0:14:08.726    32M / 8G    INFO    General                 (kmer_index_builder.hpp    : 109)   Starting k-mer counting.
    0:20:36.408    32M / 8G    INFO    General                 (kmer_index_builder.hpp    : 115)   K-mer counting done. There are 205776690 kmers in total.
    0:20:36.409    32M / 8G    INFO    General                 (kmer_index_builder.hpp    : 121)   Merging temporary buckets.
    0:24:43.505    32M / 8G    INFO   K-mer Index Building     (kmer_index_builder.hpp    : 298)   Building perfect hash indices
    0:25:40.125   100M / 8G    INFO    General                 (kmer_index_builder.hpp    : 137)   Merging final buckets.
    1:11:46.553   100M / 8G    INFO   K-mer Index Building     (kmer_index_builder.hpp    : 320)   Index built. Total 95426752 bytes occupied (3.70991 bits per kmer).
    1:11:46.598   100M / 8G    INFO   K-mer Counting           (kmer_data.cpp             : 357)   Arranging kmers in hash map order
    1:12:55.597     3G / 8G    INFO    General                 (main.cpp                  : 155)   Clustering Hamming graph.
    1:21:35.596     3G / 8G    INFO    General                 (main.cpp                  : 162)   Extracting clusters
  === Stack Trace ===
  [0x407a6a]
  [0x409561]
  [0x40c79b]
  [0x40129a]
  [0x5442b0]
  [0x40620d]
  Verification of expression '(intptr_t) MappedRegion != -1L' failed in function 'void MMappedWriter::reserve(size_t)'. In file '/spades/src/common/io/kmers/mmapped_writer.hpp' on line 94. Message 'mmap(2) failed. Reason: Invalid argument. Error code: 22'.
  Verification of expression '(intptr_t) MappedRegion != -1L' failed in function 'void MMappedWriter::reserve(size_t)'. In file '/spades/src/common/io/kmers/mmapped_writer.hpp' on line 94. Message 'mmap(2) failed. Reason: Invalid argument. Error code: 22'.
  hammer: /spades/src/common/io/kmers/mmapped_writer.hpp:94: void MMappedWriter::reserve(size_t): Assertion `(intptr_t) MappedRegion != -1L' failed.
  
  == Error ==  system call for: "['/home/user/SPAdes-3.11.1-Linux/bin/hammer', '/home/user/minion/organism/hybrid_assembly/spades_assembly/read_correction/corrected/configs/config.info']" finished abnormally, err code: -6
  
  In case you have troubles running SPAdes, you can write to spades.support@cab.spbu.ru
  or report an issue on our GitHub repository github.com/ablab/spades
  Please provide us with params.txt and spades.log files from the output directory.
  
  ```
  
  **Tags:** fasta, assembly
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-07-04. Score: 1 | Accepted answer
  
  *Answer from @mjoppich, converted from comment:*
  
  Late answer, but it looks like you are running out of memory, hence the intptr is invalid.
  
  
  ---
  
  