[Biopython-dev] samtools threaded daemon

Chris Mitchell chris.mit7 at gmail.com
Thu Apr 11 18:21:36 UTC 2013

Here's the branch I'm starting with, including a working mpileup daemon for
those who want to use it:


sample usage:
from Bio.SamTools import SamTools
sTools = '/home/chris/bin/samtools'
hg19 = '/media/chris/ChrisSSD/ref/human/hg19.fa'
bamSource = '/media/chris/ChrisSSD/TH1Alignment/NK/accepted_hits.bam'
st = SamTools(bamSource,binary=sTools,threads=30)

#now with a callback, which is advisable to use to process data as it is
def processPileup(pileup):
    print 'to process',pileup

#st.mpileup(f=hg19,r=['chr1:%d-%d'%(i,i+1) for i in
xrange(2000001,2001001)],callback=processPileup) #with callback
#print st.mpileup(f=hg19,r=['chr1:%d-%d'%(i,i+1) for i in
xrange(2000001,2000101)]) #will just return as a list

On Thu, Apr 11, 2013 at 10:04 AM, Chris Mitchell <chris.mit7 at gmail.com>wrote:

> Given that we'd be chasing after the samtools development cycle, I think
> it's just easier to implement command line wrappers that are dynamic enough
> to handle future versions.  For instance, some of the code doesn't seem too
> set in stone and appears empirical (the BAQ computation comes to mind) and
> therefore probable to change in future versions.  I can package in my
> existing pileup parser, but in general I think most people will be using a
> callback routine to handle it themselves since use cases of the final
> output sort of vary project by project.
> Chris
> On Thu, Apr 11, 2013 at 9:54 AM, Peter Cock <p.j.a.cock at googlemail.com>wrote:
>> On Thu, Apr 11, 2013 at 2:46 PM, Chris Mitchell <chris.mit7 at gmail.com>
>> wrote:
>> > Also, if a binary can't be found, having it fallback to the future
>> > BioPython parser seems like it might be a good idea (provided it has
>> > similar functionality like creating pileups, does it?).
>> It has the low level random access via the BAI index done, but
>> does not yet have a reimplementation of the mpileup code, no.
>> (Would that be useful compared to calling samtools and parsing
>> its output?)
>> Peter

More information about the Biopython-dev mailing list