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
            Advanced Methods for the Detection of Infectious Disease
            by seqadmin




            The recent pandemic caused worldwide health, economic, and social disruptions with its reverberations still felt today. A key takeaway from this event is the need for accurate and accessible tools for detecting and tracking infectious diseases. Timely identification is essential for early intervention, managing outbreaks, and preventing their spread. This article reviews several valuable tools employed in the detection and surveillance of infectious diseases.
            ...
            11-27-2023, 01:15 PM
          • seqadmin
            Strategies for Investigating the Microbiome
            by seqadmin




            Microbiome research has led to the discovery of important connections to human and environmental health. Sequencing has become a core investigational tool in microbiome research, a subject that we covered during a recent webinar. Our expert speakers shared a number of advancements including improved experimental workflows, research involving transmission dynamics, and invaluable analysis resources. This article recaps their informative presentations, offering insights...
            11-09-2023, 07:02 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, Yesterday, 02:24 PM
          0 responses
          11 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, Yesterday, 07:37 AM
          0 responses
          21 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 12-04-2023, 08:23 AM
          0 responses
          8 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 12-01-2023, 09:55 AM
          0 responses
          24 views
          0 likes
          Last Post seqadmin  
          Working...
          X