Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • Heisman
    Senior Member
    • Dec 2010
    • 534

    How to replace select reads in a bam file?

    Hey all,

    I want to take an aligned file, run it through Dindel, output realigned windows, and merge the realigned windows with the original aligned file. If I ran the entire aligned file through Dindel I could just use the realigned windows and be done. However, to save time, I'd rather just have Dindel look at candidate windows. Thus, only a subset of reads in the aligned file will be pulled to be run through Dindel.

    Another way to state this, I want to take a subset of reads in an aligned file, alter them, and replace the original versions with the altered versions. Is there an easy way to do this? Thanks!
  • gringer
    David Eccles (gringer)
    • May 2011
    • 845

    #2
    This isn't a trivial thing to do in BAM files due to the compressed and block-based nature of the file. Any change of the contents within a block is likely to alter the compressed size of the contents, meaning that the block boundaries will need to be shifted in the file, requiring a rewrite of the remainder of the file.

    Comment

    • Heisman
      Senior Member
      • Dec 2010
      • 534

      #3
      That is logical. How about SAM files then? I should have just specified that originally.

      Comment

      • adaptivegenome
        Super Moderator
        • Nov 2009
        • 436

        #4
        You could do this with SAM but given that it is text, random access will be a real pain. It really would be easier to take a BAM file and write it to a new file, swapping reads that you want to change. This is how local realignment methods work.

        Comment

        • Heisman
          Senior Member
          • Dec 2010
          • 534

          #5
          I see. Is there anything already written that can do this? The real problem here is that my coding skills are very limited. I imagined that something designed for this purpose (replacing specific reads) would have already been publicly available but perhaps not.

          Comment

          • adaptivegenome
            Super Moderator
            • Nov 2009
            • 436

            #6
            I agree it would be useful but I do not know of any end user tools that could do this. Is this a one-time need or would you do this over and over again? If you send me a PM I might be able to help more.

            Comment

            • Heisman
              Senior Member
              • Dec 2010
              • 534

              #7
              Originally posted by genericforms View Post
              I agree it would be useful but I do not know of any end user tools that could do this. Is this a one-time need or would you do this over and over again? If you send me a PM I might be able to help more.
              I would be using it for a high throughput targeted sequencing project. We have 5000 samples which is why I would like to speed things up as quickly as possible. I'm at Washington University and surrounded by a lot of people who are far better at coding than I am, so don't worry about specifically helping me; I'll figure something out. I appreciate the offer, though.

              Comment

              • adaptivegenome
                Super Moderator
                • Nov 2009
                • 436

                #8
                Originally posted by Heisman View Post
                I would be using it for a high throughput targeted sequencing project. We have 5000 samples which is why I would like to speed things up as quickly as possible. I'm at Washington University and surrounded by a lot of people who are far better at coding than I am, so don't worry about specifically helping me; I'll figure something out. I appreciate the offer, though.
                If you want to speed things up maximally I highly recommend you work with some computer guys to:

                (1) build a list of changes you want to make to the entire file
                (2) use the samtools or bamtools API to rewrite the BAM file and specifically modify reads in your list from #1

                The text file option will probably be too slow. Good luck!

                Comment

                • Heisman
                  Senior Member
                  • Dec 2010
                  • 534

                  #9
                  Originally posted by genericforms View Post
                  If you want to speed things up maximally I highly recommend you work with some computer guys to:

                  (1) build a list of changes you want to make to the entire file
                  (2) use the samtools or bamtools API to rewrite the BAM file and specifically modify reads in your list from #1

                  The text file option will probably be too slow. Good luck!
                  Alright, sounds good. Thanks for the advice!

                  Comment

                  Latest Articles

                  Collapse

                  ad_right_rmr

                  Collapse

                  News

                  Collapse

                  Topics Statistics Last Post
                  Started by SEQadmin2, 06-05-2026, 10:09 AM
                  0 responses
                  12 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 06-04-2026, 08:59 AM
                  0 responses
                  23 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 06-02-2026, 12:03 PM
                  0 responses
                  28 views
                  0 reactions
                  Last Post SEQadmin2  
                  Started by SEQadmin2, 06-02-2026, 11:40 AM
                  0 responses
                  22 views
                  0 reactions
                  Last Post SEQadmin2  
                  Working...