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
            Exploring the Dynamics of the Tumor Microenvironment
            by seqadmin




            The complexity of cancer is clearly demonstrated in the diverse ecosystem of the tumor microenvironment (TME). The TME is made up of numerous cell types and its development begins with the changes that happen during oncogenesis. “Genomic mutations, copy number changes, epigenetic alterations, and alternative gene expression occur to varying degrees within the affected tumor cells,” explained Andrea O’Hara, Ph.D., Strategic Technical Specialist at Azenta. “As...
            07-08-2024, 03:19 PM
          • seqadmin
            Exploring Human Diversity Through Large-Scale Omics
            by seqadmin


            In 2003, researchers from the Human Genome Project (HGP) announced the most comprehensive genome to date1. Although the genome wasn’t fully completed until nearly 20 years later2, numerous large-scale projects, such as the International HapMap Project and 1000 Genomes Project, continued the HGP's work, capturing extensive variation and genomic diversity within humans. Recently, newer initiatives have significantly increased in scale and expanded beyond genomics, offering a more detailed...
            06-25-2024, 06:43 AM

          ad_right_rmr

          Collapse

          News

          Collapse

          Topics Statistics Last Post
          Started by seqadmin, 07-19-2024, 07:20 AM
          0 responses
          28 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 07-16-2024, 05:49 AM
          0 responses
          41 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 07-15-2024, 06:53 AM
          0 responses
          46 views
          0 likes
          Last Post seqadmin  
          Started by seqadmin, 07-10-2024, 07:30 AM
          0 responses
          43 views
          0 likes
          Last Post seqadmin  
          Working...
          X