commit/galaxy-central: jgoecks: Enable IntervalIndex data provider to work with pileup datasets.
1 new commit in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/98b6216e42f5/ Changeset: 98b6216e42f5 User: jgoecks Date: 2013-04-17 01:01:50 Summary: Enable IntervalIndex data provider to work with pileup datasets. Affected #: 1 file diff -r 46133ca43f322fe8b042ac0c0b393fe72579cecc -r 98b6216e42f5beec89052cccf7c98820b978bf92 lib/galaxy/visualization/data_providers/genome.py --- a/lib/galaxy/visualization/data_providers/genome.py +++ b/lib/galaxy/visualization/data_providers/genome.py @@ -770,6 +770,10 @@ else: pos = source.tell() + # If last line is a comment, there are no data lines. + if line.startswith( "#" ): + return [] + # Match chrom naming format. if line: dataset_chrom = line.split()[0] @@ -1272,7 +1276,7 @@ class IntervalIndexDataProvider( FilterableMixin, GenomeDataProvider ): """ - Interval index files used only for GFF files. + Interval index files used for GFF, Pileup files. """ col_name_data_attr_mapping = { 4 : { 'index': 4 , 'name' : 'Score' } } @@ -1282,20 +1286,26 @@ source = open( self.original_dataset.file_name ) index = Indexes( self.converted_dataset.file_name ) out = open( filename, 'w' ) - + for region in regions: # Write data from region. chrom = region.chrom start = region.start end = region.end - for start, end, offset in index.find(chrom, start, end): + for start, end, offset in index.find( chrom, start, end ): source.seek( offset ) - - reader = GFFReaderWrapper( source, fix_strand=True ) - feature = reader.next() - for interval in feature.intervals: - out.write( '\t'.join( interval.fields ) + '\n' ) - + + # HACK: write differently depending on original dataset format. + if self.original_dataset.ext not in [ 'gff', 'gff3', 'gtf' ]: + line = source.readline() + out.write( line ) + else: + reader = GFFReaderWrapper( source, fix_strand=True ) + feature = reader.next() + for interval in feature.intervals: + out.write( '\t'.join( interval.fields ) + '\n' ) + + source.close() out.close() def get_iterator( self, chrom, start, end, **kwargs ): Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
commits-noreply@bitbucket.org