Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • zhanghao
    Member
    • Nov 2015
    • 17

    BBmap can not produce sorted bam

    I used BBmap to map RNAseq data with the command:
    /home/bac/software/bbmap/bbmap.sh in1=CYP51C_2_1.fq.gz in2=CYP51C_2_2.fq.gz ref=genome.fasta nodisk out=cyp51c_bb.sam bamscript=bs.sh; sh bs.sh

    samtools-1.3.1 is setted in PAYH. But it just produced sam file, seems samtools did not work. It showed:

    bs.sh: 2: bs.sh: module: not found
    bs.sh: 3: bs.sh: module: not found
    Note: This script is designed to run with the amount of memory detected by BBMap.
    If Samtools crashes, please ensure you are running on the same platform as BBMap,
    or reduce Samtools' memory setting (the -m flag).
    Note: Please ignore any warnings about 'EOF marker is absent'; this is a bug in samtools that occurs when using piped input.
    [bam_sort] Use -T PREFIX / -o FILE to specify temporary and final output files
    Usage: samtools sort [options...] [in.bam]
    Options:
    -l INT Set compression level, from 0 (uncompressed) to 9 (best)
    -m INT Set maximum memory per thread; suffix K/M/G recognized [768M]
    -n Sort by read name
    -o FILE Write final output to FILE rather than standard output
    -T PREFIX Write temporary files to PREFIX.nnnn.bam
    -@, --threads INT
    Set number of sorting and compression threads [1]
    --input-fmt-option OPT[=VAL]
    Specify a single input file format option in the form
    of OPTION or OPTION=VALUE
    -O, --output-fmt FORMAT[,OPT[=VAL]]...
    Specify output format (SAM, BAM, CRAM)
    --output-fmt-option OPT[=VAL]
    Specify a single output file format option in the form
    of OPTION or OPTION=VALUE
    --reference FILE
    Reference sequence FASTA FILE [null]
    [E::hts_open_format] fail to open file 'cyp51c_bb_sorted.bam'
    samtools index: failed to open "cyp51c_bb_sorted.bam": No such file or directory

    I checked the bs.sh file:

    #!/bin/bash
    module unload samtools
    module load samtools/0.1.19
    echo "Note: This script is designed to run with the amount of memory detected by BBMap."
    echo " If Samtools crashes, please ensure you are running on the same platform as BBMap,"
    echo " or reduce Samtools' memory setting (the -m flag)."
    echo "Note: Please ignore any warnings about 'EOF marker is absent'; this is a bug in samtools that occurs when using piped input."
    samtools view -bSh1 cyp51c_bb.sam | samtools sort -m 13G -@ 3 - cyp51c_bb_sorted
    samtools index cyp51c_bb_sorted.bam
    bs.sh (END)
  • zhanghao
    Member
    • Nov 2015
    • 17

    #2
    another question is:

    I have 3 pairs of pair-end fastq data sets, how to set them as input? In hisat2, I can use "-1 read_A_1.fq,reads_B_1.fq,reads_C_1.fq -2 read_A_2.fq,reads_B_2.fq,reads_C_2.fq", in bbmap, it seems just in1 and in2 are supported.

    Comment

    • antoinefelden
      Junior Member
      • Dec 2016
      • 4

      #3
      I have the same problem, looking at the SAMTools manual, I have the feeling there is a problem on the output option of this command:

      Originally posted by zhanghao View Post
      samtools view -bSh1 cyp51c_bb.sam | samtools sort -m 13G -@ 3 - cyp51c_bb_sorted
      samtools index cyp51c_bb_sorted.bam
      bs.sh (END)
      Could it be missing a "-o" before the filename? Have a look at the SAMTools page here : http://www.htslib.org/doc/samtools.html

      Then it would be
      Code:
      samtools view -bSh1 cyp51c_bb.sam | samtools sort -m 13G -@ 3 -[B]o[/B] cyp51c_bb_sorted
      samtools index cyp51c_bb_sorted.bam
      bs.sh
      However, I could not find any trace of this bs.sh file (I could only find it in my output), so I'm a bit puzzled about how to fix this.

      Also, about your second question, you have to use bbwrap instead of bbmap, that will do the job I think

      Code:
      bbwrap.sh in1=read_A_1.fq,reads_B_1.fq,reads_C_1.fq in2=read_A_2.fq,reads_B_2.fq,reads_C_2.fq ref=genome.fasta nodisk out=cyp51c_bb.sam bamscript=bs.sh; sh bs.sh

      Comment

      • Brian Bushnell
        Super Moderator
        • Jan 2014
        • 2709

        #4
        Originally posted by zhanghao View Post
        another question is:

        I have 3 pairs of pair-end fastq data sets, how to set them as input? In hisat2, I can use "-1 read_A_1.fq,reads_B_1.fq,reads_C_1.fq -2 read_A_2.fq,reads_B_2.fq,reads_C_2.fq", in bbmap, it seems just in1 and in2 are supported.
        Hi! Sorry, somehow I missed your post. BBMap only supports a single library per run; if you have different libraries with different insert sizes, I recommend NOT combining them, since BBMap's alignment score is affected by how close the insert size of a pair is to the average.

        But you can use bbwrap.sh, as suggested by antoinefelden.

        As for the failures of "bs.sh" - this is strange. I'll look into it tomorrow. Maybe it's a difference between Samtools v0.x versus Samtools 1.x - some of the behavior was altered; and bs.sh was designed for Samtools 0.1.19.

        Comment

        • GenoMax
          Senior Member
          • Feb 2008
          • 7142

          #5
          @Brian: bs.sh is no longer in BBMap.

          Comment

          • Brian Bushnell
            Super Moderator
            • Jan 2014
            • 2709

            #6
            I just used it yesterday, and it worked fine for me... and it's documented on line 159 of bbmap.sh...?

            Comment

            • GenoMax
              Senior Member
              • Feb 2008
              • 7142

              #7
              Ah. It is inside bbmap.sh? I was expecting to see it at top level.

              Comment

              • Brian Bushnell
                Super Moderator
                • Jan 2014
                • 2709

                #8
                Oh! Yes, technically bs.sh is not part of the BBMap package. Rather, it gets produced by BBMap if you add the flag "bs=bs.sh", because it is a custom script specific to the name of the sam/bam file BBMap produced. bs.sh simply calls Samtools with the correct (or, in the above case, apparently incorrect) commands to produce a sorted, indexed bam file.

                Generally, you do this:

                Code:
                bbmap.sh in=reads.fq.gz out=mapped.bam bs=bs.sh; sh bs.sh
                That produces sorted_mapped.bam and sorted_mapped.bam.bai.
                Last edited by Brian Bushnell; 12-09-2016, 10:06 AM.

                Comment

                • antoinefelden
                  Junior Member
                  • Dec 2016
                  • 4

                  #9
                  Originally posted by Brian Bushnell View Post
                  bs.sh simply calls Samtools with the correct (or, in the above case, apparently incorrect) commands to produce a sorted, indexed bam file.
                  Hi Brian,

                  Would you say that the problem comes from the missing output option?
                  If so, do you know how to fix that error?

                  If that helps, it may also be related to the samtools version, I'm using version 1.3 and when executing the script bs.sh, the module commands on line 2 and 3 of bs.sh did not work (command not found error, which I don't understand why so far).

                  I'm re-running the whole job with samtools 0.1.19, I'll post the outcome here.

                  Comment

                  • Brian Bushnell
                    Super Moderator
                    • Jan 2014
                    • 2709

                    #10
                    OK! I've tested this with samtools 0.1.19 and 1.3.1, and it fails with samtools 1.3.1. Apparently this is caused by some basic parameters that were changed when samtools migrated from 0.x to 1.x; this is something that I advocate against, but it it is sometimes unavoidable. Sorry about that! I'll release a new version soon that will work with both samtools 0.x and samtools 1.x, if that's possible. In the meantime, of course, you can use samtools manually...

                    Comment

                    • Brian Bushnell
                      Super Moderator
                      • Jan 2014
                      • 2709

                      #11
                      Originally posted by antoinefelden View Post
                      I'm re-running the whole job with samtools 0.1.19, I'll post the outcome here.
                      You don't need to rerun the whole job... the only problematic part is sorting and indexing the mapped reads. If you use samtools 0.x, it will work fine using the existing output of BBMap. But you can also use samtools 1.x if you look into the manual and find whatever arcane invocation is appropriate now. Hopefully there is a command that will work with all versions of samtools; I'll adjust the "bs" output in the next release.
                      Last edited by Brian Bushnell; 12-10-2016, 12:23 AM.

                      Comment

                      Latest Articles

                      Collapse

                      • SEQadmin2
                        From Collection to Sequencing: Why Sample Preparation and Preservation Define Sequencing Data
                        by SEQadmin2


                        Data variability is still an issue in sequencing technologies despite the advances in reproducibility and accuracy of these platforms. But the problem does not originate in the sequencing itself, but in the previous steps, before the sample reaches the sequencer.


                        The first step is collection, followed by preservation and sample preparation for analysis. Most scientists overlook those steps, but not being careful might just be skewing the experiment’s results.
                        ...
                        06-02-2026, 10:05 AM
                      • SEQadmin2
                        Single-Cell Sequencing at an Inflection Point: Early Impacts of New Platforms and Emerging Trends
                        by SEQadmin2


                        With the launch of new single-cell sequencing platforms in 2026, the field stands at an exciting inflection point. This article surveys the most impactful advances in the field and discusses how they’re reshaping research in cancer, immunology, and beyond.


                        Introduction

                        Single-cell sequencing technologies have undergone remarkable advances over the past decade, transitioning from low-throughput experimental approaches to highly scalable platforms capable of...
                        05-22-2026, 06:42 AM
                      • SEQadmin2
                        Environmental Genomics in the Age of NGS: From Microbes to Conservation Strategies
                        by SEQadmin2

                        Studying ecosystems means dealing with complex, multi-species communities that are hard to observe at scale. This complexity, however, hides many important questions to be answered, from how biogeochemical cycles work and how climate change can affect species distribution to how conservation strategies can work best.


                        Genomics, particularly since the expansion of NGS, has transformed ecosystem ecology. By sequencing environmental DNA, we can now assess biodiversity without direct...
                        05-06-2026, 09:04 AM

                      ad_right_rmr

                      Collapse

                      News

                      Collapse

                      Topics Statistics Last Post
                      Started by SEQadmin2, Yesterday, 08:59 AM
                      0 responses
                      12 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 06-02-2026, 12:03 PM
                      0 responses
                      21 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 06-02-2026, 11:40 AM
                      0 responses
                      17 views
                      0 reactions
                      Last Post SEQadmin2  
                      Started by SEQadmin2, 05-28-2026, 11:40 AM
                      0 responses
                      31 views
                      0 reactions
                      Last Post SEQadmin2  
                      Working...