Skip to content

samtools sort: failed to create "lgs.part001.sort.bam": Stale file handle #144

Open

Description

@Peterhhb

I do not have permission to write temporary files in the cloud platform
No permission to write temporary files in the cloud platform
How to enable software such as samtools to write to local directories

this is problem.
hostname

  • hostname
    cd /data/work/pipeline_assemble_env/test/test_megahit_opera_ms/polished_output1/00.lgs_polish/02.map.ref.sh.work/map_genome2
  • cd /data/work/pipeline_assemble_env/test/test_megahit_opera_ms/polished_output1/00.lgs_polish/02.map.ref.sh.work/map_genome2
    minimap2 --split-prefix tmp -a -x map-ont -t 4 /data/work/pipeline_assemble_env/test/test_megahit_opera_ms/polished_output1/00.lgs_polish/input.genome.fasta /data/work/pipeline_assemble_env/test/test_megahit_opera_ms/polished_output1/input.lgspart.001.fasta.gz|samtools view --threads 5 -F 0x4 -b - |samtools sort - -m 2g --threads 4 -o lgs.part001.sort.bam
  • minimap2 --split-prefix tmp -a -x map-ont -t 4 /data/work/pipeline_assemble_env/test/test_megahit_opera_ms/polished_output1/00.lgs_polish/input.genome.fasta /data/work/pipeline_assemble_env/test/test_megahit_opera_ms/polished_output1/input.lgspart.001.fasta.gz
  • samtools view --threads 5 -F 0x4 -b -
  • samtools sort - -m 2g --threads 4 -o lgs.part001.sort.bam
    [M::mm_idx_gen::0.3810.98] collected minimizers
    [M::mm_idx_gen::0.464
    1.39] sorted minimizers
    [M::main::0.4641.39] loaded/built the index for 2571 target sequence(s)
    [M::mm_mapopt_update::0.495
    1.36] mid_occ = 10
    [M::mm_idx_stat] kmer size: 15; skip: 10; is_hpc: 0; #seq: 2571
    [M::mm_idx_stat::0.516*1.34] distinct minimizers: 1395384 (96.62% are singletons); average occurrences: 1.041; average spacing: 5.386; total length: 7824854
    [ERROR]�[1;31m failed to write to temporary file 'tmp.0000.tmp'�[0m: Stale file handle
    [E::hts_open_format] Failed to open file "lgs.part001.sort.bam" : Stale file handle
    samtools sort: failed to create "lgs.part001.sort.bam": Stale file handle

Activity

  1. moold commented on Aug 8, 2025

    @moold
    Member

    Try your own alignment pipeline, see here

  2. Peterhhb commented on Aug 8, 2025

    @Peterhhb
    Author

    Try your own alignment pipeline, see here
    Thank you very much for your answer, but I just looked at the document and I want to use mixed reading to perform polishing, but he doesn't have any examples. I would like to know how to assemble the final polishing fasta file after both polishing

  3. moold commented on Aug 8, 2025

    @moold
    Member

    You can edit the bash file
    /data/work/pipeline_assemble_env/test/test_megahit_opera_ms/polished_output1/00.lgs_polish/02.map.ref.sh
    so that it runs:

    samtools sort -T PREFIX - -m 2g --threads 4 -o lgs.part001.sort.bam

    where PREFIX: Write temporary files to PREFIX.nnnn.bam.
    After saving the change, execute the shell script manually, and then run the main NextPolish command again.

  4. reopened this on Aug 8, 2025
  5. Peterhhb commented on Aug 8, 2025

    @Peterhhb
    Author
  6. moold commented on Aug 8, 2025

    @moold
    Member

    Yes, edit the source code here

  7. Peterhhb commented on Aug 8, 2025

    @Peterhhb
    Author

    是的,在这里编辑源代码

    Are you saying that I now need to modify the 02.map.ref.sh file to make the data run smoothly before modifying the source code to solve my current problem? However, I ran the test data without any problem, and when I replaced it with my own data, the above error occurred. If I were to modify the source code, would it be enough to only modify the path in map_genome? Thank you for your answer

  8. Peterhhb commented on Aug 8, 2025

    @Peterhhb
    Author

    If we only modify the file path without modifying the source code, can we solve this problem? Is there a corresponding one in the configuration file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions