Go Back   SEQanswers > Bioinformatics > Bioinformatics
Similar Threads
Thread Thread Starter Forum Replies Last Post
samtools pileup c-option changes read quality DNAjunk Bioinformatics 1 08-01-2011 01:24 AM
the pileup result from samtools doesn't mach to read data Anney Bioinformatics 3 07-18-2011 04:44 PM
samtools pileup raghu1990 Bioinformatics 0 06-28-2011 02:26 AM
samtools pileup wisosonic Bioinformatics 0 05-11-2011 04:57 AM
pileup only on a specific position foxyg Bioinformatics 8 12-22-2010 05:46 PM

Thread Tools
Old 02-10-2010, 10:09 AM   #1
Location: canada

Join Date: Sep 2009
Posts: 29
Default 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

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 is offline   Reply With Quote
Old 02-10-2010, 10:12 AM   #2
Location: canada

Join Date: Sep 2009
Posts: 29

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

r1: ###GAG###
r2: ###GGG###
r3: ##AGA####
rcorbett is offline   Reply With Quote
Old 02-10-2010, 03:38 PM   #3
Senior Member
Location: Boston area

Join Date: Nov 2007
Posts: 747

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)

 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;

           # next line finds the variant; 
            $different++ if $refbase ne $qbase;
        if ($total >= 4 && $different/$total >= 0.25) {
           push @SNPs,"$seqid:$pos";

 print "Found SNPs: @SNPs\n";
krobison is offline   Reply With Quote

pileup sam bam

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

All times are GMT -8. The time now is 09:45 AM.

Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2022, vBulletin Solutions, Inc.
Single Sign On provided by vBSSO