View Single Post
Old 07-20-2012, 06:53 AM   #12
Location: Cambridge, MA

Join Date: Apr 2011
Posts: 18

Originally Posted by vinay427 View Post
What exactly do you mean by a wrapper? From what I've seen, would it basically pass through arguments to bowtie (or bowtie2) so that you can integrate it into your Python loop?
I'm thinking of being able to align sequences one by one. For example, my reads often have custom barcodes at the beginning that need to be removed before alignment and written to a different file for each barcode:

files = dict([
    ["ATGCG", pysam.Samfile("sample1.bam", "wb")],
    ["GACTA", pysam.Samfile("sample2.bam", "wb")]
bwt = bowtie.load("/path/to/index")
for((seq, qual) in FastqReader("reads.fastq")):
    barcode = seq[0:5]
    if barcode in files:
        files[barcode].write(bwt.align(seq[5:], qual[5:]))
        pass #handle nonmatching barcodes here
There are also a lot of cases where I would want to store additional information in the auxiliary data, set certain flags, or otherwise modify the alignment before writing it. Of course, this can already be done with pysam, the trick is getting the alignment in the first place.
alec is offline   Reply With Quote