Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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

  • #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


    • #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


      • #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


        • #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

          • seqadmin
            Strategies for Sequencing Challenging Samples
            by seqadmin


            Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
            03-22-2024, 06:39 AM
          • seqadmin
            Techniques and Challenges in Conservation Genomics
            by seqadmin



            The field of conservation genomics centers on applying genomics technologies in support of conservation efforts and the preservation of biodiversity. This article features interviews with two researchers who showcase their innovative work and highlight the current state and future of conservation genomics.

            Avian Conservation
            Matthew DeSaix, a recent doctoral graduate from Kristen Ruegg’s lab at The University of Colorado, shared that most of his research...
            03-08-2024, 10:41 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, 03-27-2024, 06:37 PM
          0 responses
          12 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 03-27-2024, 06:07 PM
          0 responses
          11 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 03-22-2024, 10:03 AM
          0 responses
          53 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 03-21-2024, 07:32 AM
          0 responses
          69 views
          0 likes
          Last Post seqadmin  
          Working...
          X