Unconfigured Ad

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rcorbett
    Member
    • Sep 2009
    • 29

    #1

    get read position from Samtools pileup

    Hi all,
    Has anyone come across a way to get information about the location of a snp within the reads? I have the usual bam/sam/pileup files.

    For example,
    r1: GAG
    r2: GGG
    r3: AGA
    ref: AAAGGGTTTT

    In this very contrived example that was hopefully preserved by the editor we would have a single snp represented at pos 2 in read 1, and pos 3 in read 3 . What I am looking for is a way to get that information that says this snp is at pos 2 in r1, and position 3 in r3 from bam/sam/pileup files.

    Does anyone know of a tool that can do this?

    thanks for any help.
  • rcorbett
    Member
    • Sep 2009
    • 29

    #2
    Hmm. The editor ate the example.
    I'll use '#' to mark spaces:

    r1: ###GAG###
    r2: ###GGG###
    r3: ##AGA####
    rf: AAAGGGTTTT

    Comment

    • krobison
      Senior Member
      • Nov 2007
      • 734

      #3
      Probably not the answer you were looking for, but you could certainly roll your own using one of the SAMTools libraries for Perl, Python or Java. The Perl SNP caller example shows this:



      (I've added some additional comments; the code is not mine)

      Code:
       my @SNPs;  # this will be list of SNPs
       my $snp_caller = sub {
              my ($seqid,$pos,$p) = @_;
              my $refbase = $sam->segment($seqid,$pos,$pos)->dna;
              my ($total,$different);
              for my $pileup (@$p) {
                  my $b     = $pileup->b;
                  next if $pileup->indel;  # don't deal with these ;-)
      
                  # $pileup->qpos is the position in $b->qseq (the read)
                  my $qbase  = substr($b->qseq,$pileup->qpos,1);
                  next if $qbase =~ /[nN]/;
      
                  my $qscore = substr($b->qscore,$pileup->qpos,1);
                  next unless $qscore > 25;
      
                  $total++;
                 # next line finds the variant; 
                  $different++ if $refbase ne $qbase;
              }
              if ($total >= 4 && $different/$total >= 0.25) {
                 push @SNPs,"$seqid:$pos";
              }
          };
      
       $sam->pileup('seq1',$snp_caller);
       print "Found SNPs: @SNPs\n";

      Comment

      Latest Articles

      Collapse

      • SEQadmin2
        Multiomic Liquid Biopsy: What DNA/RNA Panels Reveal That DNA Alone Can’t
        by SEQadmin2



        Tumors contain complex mixtures of cell populations that evolve in response to treatment and host-specific factors. Tissue biopsies provide only static snapshots of a tumor’s state. But what if we could follow that evolution over time using a minimally invasive technique?

        Liquid biopsies can detect tumor-derived material circulating in the bloodstream, providing a way to study treatment response, detect emerging resistance, and discover new biomarkers. Circulating
        ...
        10-14-2026, 09:55 AM
      • SEQadmin2
        New Genomics Technologies Take Aim at Long-Standing Limits
        by SEQadmin2


        Researchers using sequencing and genomics tools often have to make trade-offs. They can choose between speed or scale, short reads or long-range information, or targeted panels or a view of the whole transcriptome. New technologies that have been released this year are built to address those tough choices.

        We asked six companies the same four questions to learn about their latest products. The new technologies bring a lot to the table, including rethinking sequencing
        ...
        09-28-2026, 10:25 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, Yesterday, 11:13 AM
      0 responses
      21 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, Yesterday, 10:48 AM
      0 responses
      18 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 10-15-2026, 10:52 AM
      0 responses
      36 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 10-14-2026, 05:39 AM
      0 responses
      42 views
      0 reactions
      Last Post SEQadmin2  
      Working...