Skip to content

Samtools sort has wrong -m parameter #50

@haraldgrove

Description

@haraldgrove

I tried running the arabidopsis test case using the default config.yaml file, and got an error from the samtools sort step in rule_aln.

snakemake --cores 8 --config sample=arabidopsis fasta=case-example-arabidopsis/Col-CEN_v1.2.fasta

It seems like the memory parameter SAMTOOLS_MEM is set to "4 MB" instead of what should presumably be "4". This causes the samtools sort option to read the value for the -m parameter as just 4 instead of 4G.

Any suggestions on how to fix this?

RuleException:
CalledProcessError in file "/net/fs-2/scale/OrionStore/Home/harag/StainedGlass/workflow/Snakefile", line 279:
Command 'source /cluster/software/Miniconda3/24.7.1-0/bin/activate '/net/fs-2/scale/OrionStore/Home/harag/StainedGlass/.snakemake/c
onda/a597df0467c03591a35889f1c2575793_'; set -eo pipefail;
        ( minimap2             -t 4             -f 10000 -s 400             -ax ava-ont              --dual=yes --eqx             t
emp/arabidopsis.2000.10000.ref_0.fasta.mmi temp/arabidopsis.2000.2.query.fasta                 | samtools sort -m 4 MBG -@ 4
              -o temp/arabidopsis.2000.10000.2.ref_0.bam         ) 2> logs/aln.arabidopsis.2000.10000.2.ref_0.log' returned non-zer
o exit status 1.
[Fri Mar 13 08:42:48 2026]
Error in rule aln:
    message: None
    jobid: 12
    input: temp/arabidopsis.2000.10000.ref_0.fasta.mmi, temp/arabidopsis.2000.2.query.fasta
    output: temp/arabidopsis.2000.10000.2.ref_0.bam
    log: logs/aln.arabidopsis.2000.10000.2.ref_0.log (check log file(s) for error details)
    conda-env: /net/fs-2/scale/OrionStore/Home/harag/StainedGlass/.snakemake/conda/a597df0467c03591a35889f1c2575793_
    shell:

        ( minimap2             -t 4             -f 10000 -s 400             -ax ava-ont              --dual=yes --eqx             temp/arabidopsis.2000.10000.ref_0.fasta.mmi temp/arabidopsis.2000.2.query.fasta                 | samtools sort -m 4 MBG -@ 4                     -o temp/arabidopsis.2000.10000.2.ref_0.bam         ) 2> logs/aln.arabidopsis.2000.10000.2.ref_0.log

        (command exited with non-zero exit code)
Logfile logs/aln.arabidopsis.2000.10000.2.ref_0.log:
================================================================================
[bam_sort] -m setting (4 bytes) is less than the minimum required (1M).

Trying to run with -m too small can lead to the creation of a very large number
of temporary files.  This may make sort fail due to it exceeding limits on the
number of files it can have open at the same time.

Please check your -m parameter.  It should be an integer followed by one of the
letters K (for kilobytes), M (megabytes) or G (gigabytes).  You should ensure it
is at least the minimum above, and much higher if you are sorting a large file.
================================================================================

Thanks
-Harald Grove

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions