Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Kennels
    Senior Member
    • Feb 2011
    • 149

    #1

    bam to paired AND unpaired fastq reads

    Hi,

    Some of the posts I found here are a bit old, so in case there new tools...

    Does anyone know of a tool that extracts from a .bam file into both the paired reads fastq AND unpaired (single) reads fastq?
    Picard SamtoFastq does not do this, and a tool from bamUtils does it but it is quite slow.

    I don't care about mapping information, I just want the paired and orphaned reads.

    Thank you
  • dpryan
    Devon Ryan
    • Jul 2011
    • 3478

    #2
    If you're familiar with programming, the samtools C API is pretty convenient and could be used to do this quickly. There's also pysam in python, which I assume is a bit more approachable than using C (I've never used it and don't know what your background is).

    Comment

    • kmcarr
      Senior Member
      • May 2008
      • 1181

      #3
      Try piping samtools and picard together. Using the filtering flags for samtools view you can output only single or paired reads and strem those to picard SamToFastq.

      Paired end
      Code:
      samtools view -uf 1 input.bam | java -jar SamToFastq INPUT=/dev/stdin [rest of options]
      For single end change the 'f' to 'F' in the samtools command.

      *This solution is untested

      Comment

      • sBeier
        Member
        • Jan 2013
        • 41

        #4
        If you filter your bamfile to get a) only the mappings where both reads map and b) the others you could use bedtools bamtofastq. It's not fast, but you can get both paired fastq for the first file and single ones for the second.

        Comment

        • Kennels
          Senior Member
          • Feb 2011
          • 149

          #5
          thanks everyone.
          I tried kmcarr's solution, but ran into errors due to some mates not being present in the .bam.

          I found this solution: http://seqanswers.com/forums/showthread.php?t=16395

          and eventually was able to compile the code, and it works very nicely and quickly (under 5 mins for a 2.5Gb bam). It outputs both the paired reads and orphan'ed reads, but found that it will also duplicate a read if there are multiple alignments for it.

          Since my goal was to just get the reads that could simply align, I regenerated the .bam (accepted_hits.bam from tophat2 output) to report only one alignment per read.

          Comment

          Latest Articles

          Collapse

          • SEQadmin2
            16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
            by SEQadmin2




            NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification, detection...
            Today, 06:46 AM
          • SEQadmin2
            Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
            by SEQadmin2



            Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

            Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
            ...
            10-14-2026, 09:55 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by SEQadmin2, 10-28-2026, 09:57 AM
          0 responses
          22 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-28-2026, 09:51 AM
          0 responses
          14 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-22-2026, 11:13 AM
          0 responses
          67 views
          0 reactions
          Last Post SEQadmin2  
          Started by SEQadmin2, 10-22-2026, 10:48 AM
          0 responses
          47 views
          0 reactions
          Last Post SEQadmin2  
          Working...