diff --git a/bamnostic/utils.py b/bamnostic/utils.py index 5a9b714..2d75da3 100644 --- a/bamnostic/utils.py +++ b/bamnostic/utils.py @@ -248,7 +248,7 @@ def _handle_split_region(split_roi, until_eof=False): # if the user gives an integer description of chromosome, convert to string if isinstance(split_roi[0], (str, int)): - split_roi[0] = str(split_roi[0]).lower() + split_roi[0] = str(split_roi[0]) if None in split_roi[1:]: # make sure the user wants to continue if they have used an open-ended region diff --git a/codemeta.json b/codemeta.json index 8d41642..319bb25 100644 --- a/codemeta.json +++ b/codemeta.json @@ -37,8 +37,8 @@ "description": "BAMnostic is a Pure Python OS, version, and runtime agnostic BAM file parser", "keywords": "BAM, pysam, genomics, genetics, htslib, samtools", "license": "https://github.com/betteridiot/bamnostic/blob/master/LICENSE", - "softwareVersion": "v1.0.0, - "version": "v1.0.0", + "softwareVersion": "v1.0.1, + "version": "v1.0.1", "readme": "https://github.com/betteridiot/bamnostic/blob/master/README.md", "buildInstructions": "https://github.com/betteridiot/bamnostic/blob/master/README.md", "issueTracker": "https://github.com/betteridiot/bamnostic/issues", diff --git a/docs/build/doctrees/bamnostic.doctree b/docs/build/doctrees/bamnostic.doctree index 15db9fd..12d3618 100644 Binary files a/docs/build/doctrees/bamnostic.doctree and b/docs/build/doctrees/bamnostic.doctree differ diff --git a/docs/build/doctrees/environment.pickle b/docs/build/doctrees/environment.pickle index 5aeae06..468f88d 100644 Binary files a/docs/build/doctrees/environment.pickle and b/docs/build/doctrees/environment.pickle differ diff --git a/docs/build/doctrees/index.doctree b/docs/build/doctrees/index.doctree index 9ddf7f2..4cdb219 100644 Binary files a/docs/build/doctrees/index.doctree and b/docs/build/doctrees/index.doctree differ diff --git a/docs/build/doctrees/install.doctree b/docs/build/doctrees/install.doctree index 57106f7..967310e 100644 Binary files a/docs/build/doctrees/install.doctree and b/docs/build/doctrees/install.doctree differ diff --git a/docs/build/doctrees/quickstart.doctree b/docs/build/doctrees/quickstart.doctree index fbdd8f0..d51450b 100644 Binary files a/docs/build/doctrees/quickstart.doctree and b/docs/build/doctrees/quickstart.doctree differ diff --git a/docs/build/doctrees/support.doctree b/docs/build/doctrees/support.doctree index 36009fe..0ed3d43 100644 Binary files a/docs/build/doctrees/support.doctree and b/docs/build/doctrees/support.doctree differ diff --git a/docs/build/html/.buildinfo b/docs/build/html/.buildinfo index a3d5775..4591a08 100644 --- a/docs/build/html/.buildinfo +++ b/docs/build/html/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 05da12486de356c99fdddd217c848d20 +config: 7fe887b2cbc5b91bf05ea54ef36c1a08 tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docs/build/html/_modules/bamnostic/bai.html b/docs/build/html/_modules/bamnostic/bai.html index c982e1c..8d3331a 100644 --- a/docs/build/html/_modules/bamnostic/bai.html +++ b/docs/build/html/_modules/bamnostic/bai.html @@ -8,7 +8,7 @@ - bamnostic.bai — bamnostic 0.8.4b5 documentation + bamnostic.bai — bamnostic 1.0.1 documentation @@ -24,8 +24,7 @@ - - + @@ -57,7 +56,7 @@
- 0.8.4 + 1.0.1
@@ -187,21 +186,16 @@

Source code for bamnostic.bai

 from array import array
 from collections import namedtuple
 
-_PY_VERSION = sys.version
+_PY_VERSION = sys.version_info
 
-if _PY_VERSION.startswith('2'):
+if _PY_VERSION[0] == 2:
     from io import open
-
-if not _PY_VERSION.startswith('2'):
+else:
     from functools import lru_cache
 
 from bamnostic.utils import *
 
 
-def format_warnings(message, category, filename, lineno, file=None, line=None):
-    return ' {}:{}: {}:{}'.format(filename, lineno, category.__name__, message)
-
-
 warnings.formatwarning = format_warnings
 
 # Helper compiled structs
@@ -227,19 +221,14 @@ 

Source code for bamnostic.bai

 RefIdx = namedtuple('RefIdx', ('start_offset', 'end_offset', 'n_bins'))
 
 
-class Bin(object):
-    __slots__ = ['bin_id', 'chunks']
-
-    def __init__(self, *args):
-        self.bin_id, self.chunks = args
-
-
 class Chunk(object):
     __slots__ = ['voffset_beg', 'voffset_end']
 
     def __init__(self, handle):
         self.voffset_beg, self.voffset_end = unpack_chunk(handle.read(16))
 
+    def __repr__(self):
+        return 'Chunk(voffset_beg={}, voffset_end={})'.format(self.voffset_beg, self.voffset_end)
 
 class Ref(object):
     __slots__ = ['bins', 'intervals', 'ref_id']
@@ -247,6 +236,9 @@ 

Source code for bamnostic.bai

     def __init__(self, *args):
         self.bins, self.intervals, self.ref_id = args
 
+    def __getitem__(self, key):
+        return self.bins[key]
+
 
 class Unmapped(object):
     __slots__ = ['unmapped_beg', 'unmapped_end', 'n_mapped', 'n_unmapped']
@@ -258,20 +250,20 @@ 

Source code for bamnostic.bai

         self.n_unmapped = numap
 
 
-
[docs]def reg2bin(beg, end): +
[docs]def reg2bin(rbeg, rend): """Finds the largest superset bin of region. Numeric values taken from hts-specs Args: - beg (int): inclusive beginning position of region - end (int): exclusive end position of region + rbeg (int): inclusive beginning position of region + rend (int): exclusive end position of region Returns: (int): distinct bin ID for largest superset bin of region """ left_shift = 15 for i in range(14, 27, 3): - if beg >> i == (end - 1) >> i: - return int(((1 << left_shift) - 1) / 7 + (beg >> i)) + if rbeg >> i == (rend - 1) >> i: + return int(((1 << left_shift) - 1) / 7 + (rbeg >> i)) left_shift -= 3 else: return 0
@@ -281,8 +273,8 @@

Source code for bamnostic.bai

     """Generates bin ids which overlap the specified region.
 
     Args:
-        beg (int): inclusive beginning position of region
-        end (int): exclusive end position of region
+        rbeg (int): inclusive beginning position of region
+        rend (int): exclusive end position of region
 
     Yields:
         (int): bin IDs for overlapping bins of region
@@ -357,7 +349,6 @@ 

Source code for bamnostic.bai

             self._io = open(filename, 'rb')
         else:
             raise OSError('{} not found. Please change check your path or index your BAM file'.format(filename))
-        self._io = open(filename, 'rb')
 
         # Constant for linear index window size and unmapped bin id
         self._LINEAR_INDEX_WINDOW = 16384
@@ -477,7 +468,7 @@ 

Source code for bamnostic.bai

 
     # @functools.lru_cache(maxsize=256, typed=True)
     # @lru_cache(6)
-
[docs] @conditional_decorator(lambda func: lru_cache(maxsize=6)(func), _PY_VERSION.startswith('2')) +
[docs] @conditional_decorator(lambda func: lru_cache(maxsize=6)(func), _PY_VERSION[0] == 2) def get_ref(self, ref_id=None, idx=False): """Interatively unpacks all the bins, linear intervals, and chunks for a given reference @@ -567,12 +558,12 @@

Source code for bamnostic.bai

 
         for binID in reg2bins(start, stop):
             try:
-                bin_chunks = self.current_ref.bins[binID]
+                bin_chunks = self.current_ref[binID]
             except KeyError:
                 continue
 
             for chunk in bin_chunks:
-                if not linear_offset <= chunk.voffset_end:
+                if not chunk.voffset_beg <= linear_offset <= chunk.voffset_end:
                     continue
                 else:
                     return chunk.voffset_beg
@@ -632,7 +623,7 @@

Source code for bamnostic.bai

 
   

- © Copyright 2018, Marcus D. Sherman. + © Copyright 2018, Marcus D. Sherman

@@ -651,28 +642,18 @@

Source code for bamnostic.bai

 
   
 
-    
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+  
 
   
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+  
 
   
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+  
 
   
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+  
 
   
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+  
 
   
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+  
 
   
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+  
 
   
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+  
 
   
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+  
 
   
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+  
 
   
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+  
 
   
-      
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+  
 
   
-      
-      
-      
-      
+    
+    
+      
+        
+        
+        
+        
+    
 
   
 
-  
-  
-    
-  
+