[hg] galaxy 3219: Add missing bam provider
details: http://www.bx.psu.edu/hg/galaxy/rev/195161a630bd changeset: 3219:195161a630bd user: Kanwei Li <kanwei@gmail.com> date: Thu Jan 07 18:48:38 2010 -0500 description: Add missing bam provider diffstat: lib/galaxy/visualization/tracks/data/bam.py | 24 ++++++++++++++++++++++++ 1 files changed, 24 insertions(+), 0 deletions(-) diffs (29 lines): diff -r 9ed3e27a6e4c -r 195161a630bd lib/galaxy/visualization/tracks/data/bam.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lib/galaxy/visualization/tracks/data/bam.py Thu Jan 07 18:48:38 2010 -0500 @@ -0,0 +1,24 @@ +import pkg_resources; pkg_resources.require( "pysam" ) +from pysam import csamtools +from math import floor, ceil, log +import logging + +class BamDataProvider( object ): + def __init__( self, index, original_dataset ): + self.log = logging.getLogger(__name__) + self.index = index + self.original_dataset = original_dataset + + def get_data( self, chrom, start, end, **kwargs ): + start, end = int(start), int(end) + bamfile = csamtools.Samfile(filename=self.original_dataset.file_name, mode='rb', index_filename=self.index.file_name) + + data = bamfile.fetch(start=start, end=end, reference=chrom) + results = [] + for read in data: + payload = { 'uid': str(read.pos) + str(read.seq), 'start': read.pos, 'end': read.pos + read.rlen, 'name': read.seq } + + results.append(payload) + bamfile.close() + return results + \ No newline at end of file
participants (1)
-
Greg Von Kuster