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

      • kinpict.com
        Reply to 16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
        by kinpict.com
        The part about this topic feels surprisingly grounded, and the details on the page is the bit that made me slow down. I’d keep <a href="https://kinpict.com/">ai family photo generator</a> bookmarked for later.
        Today, 06:37 PM
      • SEQadmin2
        16S/ITS Profiling vs. Shotgun Metagenomics: What Changes in Your Workflow?
        by SEQadmin2





        NGS has revolutionized clinical microbiology by offering new ways to identify and surveil pathogens without prior knowledge of the target. One popular approach is 16S rRNA and ITS amplicon sequencing, which targets specific microbial markers. But studies are increasingly incorporating shotgun metagenomics, a technique that sequences all DNA from a sample without targeting specific microbial markers. This approach allows more detailed taxonomic classification,...
        10-30-2026, 06:46 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, 11-12-2026, 07:59 AM
      0 responses
      27 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 11-05-2026, 09:25 AM
      0 responses
      35 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 11-03-2026, 11:54 AM
      2 responses
      56 views
      0 reactions
      Last Post kinpict.com  
      Started by SEQadmin2, 10-28-2026, 09:57 AM
      0 responses
      175 views
      0 reactions
      Last Post SEQadmin2  
      Working...