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
            Essential Discoveries and Tools in Epitranscriptomics
            by seqadmin




            The field of epigenetics has traditionally concentrated more on DNA and how changes like methylation and phosphorylation of histones impact gene expression and regulation. However, our increased understanding of RNA modifications and their importance in cellular processes has led to a rise in epitranscriptomics research. “Epitranscriptomics brings together the concepts of epigenetics and gene expression,” explained Adrien Leger, PhD, Principal Research Scientist...
            04-22-2024, 07:01 AM
          • seqadmin
            Current Approaches to Protein Sequencing
            by seqadmin


            Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
            04-04-2024, 04:25 PM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, Yesterday, 08:47 AM
          0 responses
          16 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-11-2024, 12:08 PM
          0 responses
          60 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-10-2024, 10:19 PM
          0 responses
          60 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 04-10-2024, 09:21 AM
          0 responses
          54 views
          0 likes
          Last Post seqadmin  
          Working...
          X