Unconfigured Ad

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

    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
        Proteomic Platforms: How to Choose the Right Analytical Strategy to Improve Detection and Clinical Applications
        by SEQadmin2


        Proteomics platforms are evolving rapidly, with advances in mass spectrometry and affinity-based approaches expanding what researchers can detect and at what scale. As the field moves toward deeper proteome coverage and clinical applications, scientists face an increasingly complex landscape of tools. This article will explore how researchers are navigating these choices to find the right platform for their work.

        The systematic characterization of the human proteome has
        ...
        07-20-2026, 11:48 AM
      • 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

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by SEQadmin2, 07-24-2026, 12:17 PM
      0 responses
      18 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 07-23-2026, 11:41 AM
      0 responses
      18 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 07-20-2026, 11:10 AM
      0 responses
      24 views
      0 reactions
      Last Post SEQadmin2  
      Started by SEQadmin2, 07-13-2026, 10:26 AM
      0 responses
      37 views
      0 reactions
      Last Post SEQadmin2  
      Working...