Unconfigured Ad

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • xy6699
    Member
    • Oct 2011
    • 12

    extract positions from alignment

    Hi all,

    I got some short (~220bp) pair-ended DNA sequences targeted in one region. The raw data are in fastq and I aligned them using bwa, which give me sam file. Now I want to extract some positions from each read. For example,
    The original aligned read sequence is:

    TTGAATGGGGGATGTTTTTGGGATATAGATTATGTTTTTATATC

    I want to extract position 3, 6, 8, so I want:
    GTG
    on each line.

    The reason that I can't simply pick up the position from sam file is that sometimes there are indels which will shift my positions.

    I googled this problem but most answers only give me the count summary of each position like using pileup, bamtobed... But in my case, the sequence of GTG is important and can not be split. Namely, I'm interested in how many GTGs rather than how many G, how many T and how many G.

    Any help is very appreciated!
  • maubp
    Peter (Biopython etc)
    • Jul 2009
    • 1544

    #2
    Which computer languages can you program in?

    For example, if you said Python, I would suggest looking at the pysam library for working with SAM/BAM files from Python using the C samtools library.

    Comment

    • vincentdemolombe
      Junior Member
      • Apr 2013
      • 1

      #3
      Extracting nucleotid at given position

      Hi,

      i am facing the same issue. I have sam-files resulting from an alignment with CASAVA and I have a list of positons, i.e chr1:63229714.
      I want to extract the bases in the aligned reads at these positions.

      Easy to do when CIGAR=50M (provided reads are 50bp long).
      But tricky when indels are present, i.e. CIGAR=34M1D16M, or CIGAR=10M1467N40M.

      I wrote a perl-script to do the job, but it's too slow.

      I hope there exist a tool which perform this job and would apreciate any help.
      Regards.

      Comment

      • swbarnes2
        Senior Member
        • May 2008
        • 910

        #4
        Something like

        Code:
        samtools view file.bam | cut -f 10 | cut -c 3,6,8 > output.txt
        Will work, but not around indels. You could cut out the sequence and the cigar together, and maybe use awk to use the data from the one to know which letters to cut from the other.

        Comment

        • obk
          Member
          • Dec 2012
          • 12

          #5
          I also had a very similar (exact same?) problem: http://seqanswers.com/forums/showthread.php?t=27648

          I ended up doing something similar to vincentdemolombe, by writing a custom perl script.

          I used Bio::Perl and Bio:B::Sam, and parsed the CIGAR string and padded_alignment method to get the read bases from particular positions/regions on the reference.

          Comment

          • swbarnes2
            Senior Member
            • May 2008
            • 910

            #6
            I think you might be better off generating a pileup, and parsing the desired line of that. Let the pileup program deal with shifting the reads around properly.

            Comment

            • obk
              Member
              • Dec 2012
              • 12

              #7
              Great point.. though in the 5 minutes I played around with samtools mpileup, it doesn't seem to keep the cluster ID in the output. In my case, I needed to know the cluster ID AND its bases at particular positions on the reference after alignment.

              This is as far as I got:
              Code:
              samtools mpileup -f ref.fasta read1.sorted.bam | less -S -N

              Comment

              Latest Articles

              Collapse

              • SEQadmin2
                Advanced Sequencing Platforms Tackle Neuroscience’s Toughest Genomics Problems
                by SEQadmin2



                Genomics studies in neuroscience face a special challenge due to the brain’s complexity and scarcity of samples. Mapping changes in cell type and state using conventional next-generation sequencing methods remains challenging. Advances in technologies like single-cell sequencing, spatial transcriptomics, and long-read sequencing have opened the door to deeper studies of the brain and diseases like Alzheimer’s, amyotrophic lateral sclerosis (ALS), and schizophrenia.
                ...
                07-09-2026, 11:10 AM
              • SEQadmin2
                Cancer Drug Resistance: The Lingering Barrier to Rising Survival
                by SEQadmin2



                Cancer survival rates have significantly increased in the last few decades in the United States, reaching a combined 70% 5-year survival rate by 2021. Behind this number, there are years of research to find new therapies, drug targets, and early detection methods. But there is one core challenge that keeps slowing down these advances, and it’s about drug resistance.

                There is no single reason why many patients don’t respond to treatment as expected. Cancer is...
                07-08-2026, 05:17 AM
              • GATTACAT
                Reply to Nine Things a Sample Prep Scientist Thinks About Before Sequencing
                by GATTACAT
                Love this - good data definitely starts from good input, and poor input can only give relatively poor data. I particularly like the mention of Nanodrop/absorbance based methods for quantification. It's such a toss up if you'll get an accurate reading or what amounts to a randomly generated number, and a lot of library/sequencing related issues can be traced back to poor quant.
                07-01-2026, 11:43 AM

              ad_right_rmr

              Collapse

              News

              Collapse

              Topics Statistics Last Post
              Started by SEQadmin2, Yesterday, 10:26 AM
              0 responses
              14 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-09-2026, 10:04 AM
              0 responses
              26 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-08-2026, 10:08 AM
              0 responses
              16 views
              0 reactions
              Last Post SEQadmin2  
              Started by SEQadmin2, 07-07-2026, 11:05 AM
              0 responses
              33 views
              0 reactions
              Last Post SEQadmin2  
              Working...