Commits

jsilter committed 07aca5a

Alter bbi_file.pyx ZoomLevel._summary_blocks_in_region to be slightly more efficient. Should skip reading data when chrom_id doesn't match equery

Comments (0)

Files changed (1)

lib/bx/bbi/bbi_file.pyx

         Provides a different view of summary for region, a list of dictionaries
         with keys: mean, max, min, coverage, std_dev
         """
+        
         if end > 2147483647 or start < 0:
             raise ValueError
         results = self.summarize(chrom, start, end, summary_size)
         `chrom_id`:`start`-`end`
         """
         cdef CIRTreeFile ctf
+        cdef SummaryBlock summary
         rval = deque()
         reader = self.bbi_file.reader
         reader.seek( self.index_offset )
                 ## NOTE: Look carefully at bbiRead again to be sure the endian
                 ##       conversion here is all correct. It looks like it is 
                 ##       just pushing raw data into memory and not swapping
+                
+                sum_chrom_id = block_reader.read_uint32()
+                # A block can contain summaries from more that one chrom_id
+                if sum_chrom_id != chrom_id:
+                    block_reader.skip(7*4)
+                    continue
+                       
                 summary = SummaryBlock()
-                summary.chrom_id = block_reader.read_uint32()
+                summary.chrom_id = sum_chrom_id
                 summary.start = block_reader.read_uint32()
                 summary.end = block_reader.read_uint32()
                 summary.valid_count = block_reader.read_uint32()
                 summary.max_val = block_reader.read_float()
                 summary.sum_data = block_reader.read_float()
                 summary.sum_squares = block_reader.read_float()
-                # A block can contain summaries from more that one chrom_id
-                if summary.chrom_id == chrom_id:
-                    rval.append( summary )
+                rval.append( summary )
+                
+
         return rval
     
     cdef _get_summary_slice( self, bits32 base_start, bits32 base_end, summaries ):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.