Seqanswers Leaderboard Ad

Collapse

Announcement

Collapse
No announcement yet.
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

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

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

    Comment


    • #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

      • seqadmin
        Current Approaches to Protein Sequencing
        by seqadmin


        Proteins are often described as the workhorses of the cell, and identifying their sequences is key to understanding their role in biological processes and disease. Currently, the most common technique used to determine protein sequences is mass spectrometry. While still a valuable tool, mass spectrometry faces several limitations and requires a highly experienced scientist familiar with the equipment to operate it. Additionally, other proteomic methods, like affinity assays, are constrained...
        04-04-2024, 04:25 PM
      • seqadmin
        Strategies for Sequencing Challenging Samples
        by seqadmin


        Despite advancements in sequencing platforms and related sample preparation technologies, certain sample types continue to present significant challenges that can compromise sequencing results. Pedro Echave, Senior Manager of the Global Business Segment at Revvity, explained that the success of a sequencing experiment ultimately depends on the amount and integrity of the nucleic acid template (RNA or DNA) obtained from a sample. “The better the quality of the nucleic acid isolated...
        03-22-2024, 06:39 AM

      ad_right_rmr

      Collapse

      News

      Collapse

      Topics Statistics Last Post
      Started by seqadmin, 04-11-2024, 12:08 PM
      0 responses
      17 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-10-2024, 10:19 PM
      0 responses
      22 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-10-2024, 09:21 AM
      0 responses
      16 views
      0 likes
      Last Post seqadmin  
      Started by seqadmin, 04-04-2024, 09:00 AM
      0 responses
      46 views
      0 likes
      Last Post seqadmin  
      Working...
      X