Seqanswers Leaderboard Ad

Collapse

Announcement

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

  • Help with sam flags

    Hi guys
    I would like to ask you a help with the sam format flag. I am using samtools to extract reads from a bam file. Briefly I need to extract all mapped reads in a certain range which is easy to achieve by using the samtools view command. However I need to extract together with the mapped reads also the eventual corresponding unmapped mates.
    How can I do that?
    thanks for the help!

  • #2
    There's no built-in way to do that. If the number of reads in your region of interest is relatively small, then you can "samtools view -F foo.bam region | cut -f 1 > rnames" and then just "samtools view -f 4 foo.bam | grep -f rnames > unmapped_in_region.sam". You could also write a program to do this a bit more efficiently in python (just use a dict of the read names), or just query-sort things and then have the program look for overlaps pair at a time.

    Comment


    • #3
      Thanks

      Thanks for the answer. Sam files I am using are very large so an ad hoc C or python script would not be the best option for me. I'll work on it anyway, thanks for the advice

      Comment


      • #4
        how to extract reads 1 from a sam file

        Hello, there,

        I found that samtools filter function works only for bam file. What if I have a sam file, and I would like to only keep read1 (flag: 64)?

        Do I need to convert this sam file back to bam?

        Thanks!!

        Capricy

        Comment


        • #5
          I'm pretty sure this works with sam input as well.

          samtools view -Sf 64 mapped.sam
          Last edited by Brian Bushnell; 02-27-2015, 03:18 PM. Reason: Added -S

          Comment


          • #6
            Originally posted by Brian Bushnell View Post
            I'm pretty sure this works with sam input as well.

            samtools view -f 64 mapped.sam
            Add a -S and that should work.

            Comment


            • #7
              en. My problem seems to be the missing header

              Thanks for all the replies!!

              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 on Modified Bases...
                Yesterday, 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, 04-11-2024, 12:08 PM
              0 responses
              39 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 04-10-2024, 10:19 PM
              0 responses
              41 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 04-10-2024, 09:21 AM
              0 responses
              35 views
              0 likes
              Last Post seqadmin  
              Started by seqadmin, 04-04-2024, 09:00 AM
              0 responses
              55 views
              0 likes
              Last Post seqadmin  
              Working...
              X