[med-svn] [Git][med-team/python-bx][upstream] New upstream version 0.8.4

Michael R. Crusoe gitlab at salsa.debian.org
Tue Jul 23 14:51:21 BST 2019



Michael R. Crusoe pushed to branch upstream at Debian Med / python-bx


Commits:
d00e2e62 by Michael R. Crusoe at 2019-07-23T13:09:56Z
New upstream version 0.8.4
- - - - -


10 changed files:

- .gitignore
- .travis.yml
- README.md
- doc/source/index.rst
- lib/bx/align/score_tests.py
- lib/bx/bbi/bpt_file.pyx
- lib/bx/bitset_tests.py
- lib/bx/seq/twobit.py
- setup.cfg
- setup.py


Changes:

=====================================
.gitignore
=====================================
@@ -22,3 +22,6 @@ nose*.egg
 
 # .eggs directory
 .eggs
+
+# Virtualenv
+.venv


=====================================
.travis.yml
=====================================
@@ -1,27 +1,59 @@
 language: python
-sudo: false
+cache: pip
 os:
-    - linux
-    ## - osx
+  - linux
 python:
-    - 2.7
-    - 3.3
+  - '2.7'
+  - '3.5'
+
+env:
+  global:
+    - PYTHON=python
+    - TWINE_USERNAME=nsoranzo
+    - secure: 'kFoqHCxat/ETS2SUc2q9M7YvzvnlR7sgHmx7SRvVgTyLkk1efpJ++YPwDBEYZ3v+GLf2nRfc20GxtZkH6ey1f//aj4CT2q2CJiUsKAlkFAOHzKo/3mTLl/WDHkPAr9MW7AdnbNk6W8sIPCKqFsyKL2FTH70dBcxa1e7trQ2RC64hnOOkt/tm2cQhj6sX0gROggN5QrpHE8tDZb9ugF0uf92L/CGxeClAebWgb7zVChHDMTNsmnOvWUF9m6LZOvkgFmuIeh70EPuOWh6LxU/n5JyevYIGO5vVDbjgfmNELlG2KUTm6dWeoyofcj6hUqYmQsmI1ATrf7ThY1+b6asQGy+Exp/76MBXiYRh+RgVKifwaZMOWehzfjDQvPYOGvf6rXOVGeVZ+nBkskr0HARsX1KnyDE+k+XPoP7zqvW6mCic9ZQ+IdQJtxMHOTxxFjuPAlunvaUqDNM9VP6YEWOI4UqIOO1nQh4E2zkPhXI2yY744q+BV/5+3HHqNQj1+5qFPoZeyDEuNXwgDCjrJ8i3hna/LTTvRigx6/YQL1PF/C30R4h/nkqp8ghA4VpNRPnQ8nOO+oD6AdN7Pswc3C4qGPEwoeqfNzEIR1KfEWzB7HsfTFbgyGFFNGuQ/P26DMK+kPBNZ6GhZ9wb5/xT226OA+ovcAmVGn/Hnt/qVaylXNk='
+
+_deploy_common: &deploy_common
+  if: tag IS present
+  install:
+    - $PYTHON -m pip install cibuildwheel twine
+
+matrix:
+  include:
+    - stage: deploy
+      python: '3.5'
+      services:
+        - docker
+      env: CIBW_BEFORE_BUILD="yum install -y zlib-devel && pip install Cython numpy"
+      <<: *deploy_common
+      script:
+        - cibuildwheel --output-dir dist
+        - $PYTHON -m pip install Cython nose numpy python-lzo six
+        - $PYTHON setup.py build_ext --inplace
+        - $PYTHON setup.py sdist
+        - twine check dist/*
+        - twine upload --skip-existing dist/*
+    - stage: deploy
+      os: osx
+      language: generic
+      env:
+        - PYTHON=python3
+        - CIBW_BEFORE_BUILD="pip install Cython numpy"
+      addons: {}
+      <<: *deploy_common
+      script:
+        - cibuildwheel --output-dir dist
+        - twine check dist/*
+        - twine upload --skip-existing dist/*
+
 addons:
-    apt:
-        packages:
-            - liblzo2-dev
-before_install:
-    # Use miniconda for dependencies, pip is too slow -- https://gist.github.com/zonca/9958333
-    - wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
-    - chmod +x miniconda.sh
-    - ./miniconda.sh -b
-    - export PATH=/home/travis/miniconda2/bin:$PATH
-    - conda update --yes conda
-install: 
-    - conda create --yes -n testenv python=$TRAVIS_PYTHON_VERSION Cython numpy nose
-    - source activate testenv
-    - pip install python-lzo
-    - python setup.py build_ext --inplace
-    - python setup.py install
-script: 
-    - nosetests
+  apt:
+    packages:
+      - liblzo2-dev
+
+install:
+  - $PYTHON -m pip install Cython nose numpy python-lzo six
+  - $PYTHON setup.py build_ext --inplace
+  - $PYTHON setup.py install
+
+script:
+  - nosetests


=====================================
README.md
=====================================
@@ -7,7 +7,7 @@
 The bx-python project is a python library and associated set of scripts to allow for rapid implementation of genome scale analyses. The library contains a variety of useful modules, but the particular strengths are:
 
   * Classes for reading and working with genome-scale multiple local alignments (in MAF, AXT, and LAV formats)
-  * Generic data structure for indexing on disk files that contain blocks of data associated with intervals on various sequences (used, for example, to provide random access to individual alignments in huge files; optomized for use over network filesystems)
+  * Generic data structure for indexing on disk files that contain blocks of data associated with intervals on various sequences (used, for example, to provide random access to individual alignments in huge files; optimized for use over network filesystems)
   * Data structures for working with intervals on sequences
     * "Binned bitsets" which act just like chromosome sized bit arrays, but lazily allocate regions and allow large blocks of all set or all unset bits to be stored compactly
     * "Intersecter" for performing fast intersection tests that preserve both query and target intervals and associated annotation


=====================================
doc/source/index.rst
=====================================
@@ -4,7 +4,7 @@ About bx-python
 The bx-python project is a python library and associated set of scripts to allow for rapid implementation of genome scale analyses. The library contains a variety of useful modules, but the particular strengths are:
 
  * Classes for reading and working with genome-scale multiple local alignments (in MAF, AXT, and LAV formats)
- * Generic data structure for indexing on disk files that contain blocks of data associated with intervals on various sequences (used, for example, to provide random access to individual alignments in huge files; optomized for use over network filesystems)
+ * Generic data structure for indexing on disk files that contain blocks of data associated with intervals on various sequences (used, for example, to provide random access to individual alignments in huge files; optimized for use over network filesystems)
  * Data structures for working with intervals on sequences
  * "Binned bitsets" which act just like chromosome sized bit arrays, but lazily allocate regions and allow large blocks of all set or all unset bits to be stored compactly
  * "Intersecter" for performing fast intersection tests that preserve both query and target intervals and associated annotation 


=====================================
lib/bx/align/score_tests.py
=====================================
@@ -1,7 +1,6 @@
 """
 Tests for `bx.align.score`.
 """
-import sys
 import unittest
 
 from numpy import array, cumsum, allclose
@@ -10,22 +9,21 @@ from six import StringIO
 import bx.align.maf
 import bx.align.score
 
-aligns = [ ( "CCACTAGTTTTTAAATAATCTACTATCAAATAAAAGATTTGTTAATAATAAATTTTAAATCATTAACACTT",
-             "CCATTTGGGTTCAAAAATTGATCTATCA----------TGGTGGATTATTATTTAGCCATTAAGGACAAAT", 
-             -111 ),
-           ( "CCACTAGTTTTTAAATAATCTAC-----AATAAAAGATTTGTTAATAAT---AAATTTTAAATCATTAA-----CACTT",
-             "CCATTTGGGTTCAAAAATTGATCTATCA----------TGGTGGAT---TATTATTT-----AGCCATTAAGGACAAAT", 
-             -3626 ),
-           ( "CCACTAGTTTTTGATTC",
-             "CCATTTGGGTTC-----", 
-             -299 ),
-           ( "CTTAGTTTTTGATCACC",
-             "-----CTTGGGTTTACC", 
-             -299 ),
-           ( "gggaattgaacaatgagaacacatggacacaggaaggggaacatcacacacc----------ggggcctgttgtggggtggggggaag",
-             "ggaactagaacaagggagacacatacaaacaacaacaacaacaacacagcccttcccttcaaagagcttatagtctgatggaggagag",
-             1690 )
-         ]
+aligns = [("CCACTAGTTTTTAAATAATCTACTATCAAATAAAAGATTTGTTAATAATAAATTTTAAATCATTAACACTT",
+           "CCATTTGGGTTCAAAAATTGATCTATCA----------TGGTGGATTATTATTTAGCCATTAAGGACAAAT",
+           -111),
+          ("CCACTAGTTTTTAAATAATCTAC-----AATAAAAGATTTGTTAATAAT---AAATTTTAAATCATTAA-----CACTT",
+           "CCATTTGGGTTCAAAAATTGATCTATCA----------TGGTGGAT---TATTATTT-----AGCCATTAAGGACAAAT",
+           -3626),
+          ("CCACTAGTTTTTGATTC",
+           "CCATTTGGGTTC-----",
+           -299),
+          ("CTTAGTTTTTGATCACC",
+           "-----CTTGGGTTTACC",
+           -299),
+          ("gggaattgaacaatgagaacacatggacacaggaaggggaacatcacacacc----------ggggcctgttgtggggtggggggaag",
+           "ggaactagaacaagggagacacatacaaacaacaacaacaacaacacagcccttcccttcaaagagcttatagtctgatggaggagag",
+           1690)]
 
 mafs = """##maf
 a score=2883.0
@@ -38,54 +36,51 @@ s panTro1.chr1          49673 40 + 229575298 TGCGTGATTAATGCCTGAGATTGTGTGAAGTAAAA
 s rheMac1.SCAFFOLD45837 26063 33 -     31516 TGTGTGATTAATGCCTGAGATTGTGTGAAGTAA-------
 """
 
-nonsymm_scheme = bx.align.score.build_scoring_scheme ( """  A    C    G    T
+nonsymm_scheme = bx.align.score.build_scoring_scheme("""  A    C    G    T
                                                            91    0  -31 -123
                                                          -114  100 -125  -31
                                                           -31 -125  100 -114
-                                                         -123  -31 -114   91 """, 400, 30 )
+                                                         -123  -31 -114   91 """, 400, 30)
 
-aligns_for_nonsymm_scheme = [ ( "AAAACCCCGGGGTTTT",
-                                "ACGTACGTACGTACGT", 
-                                -580 )
-                            ]
+aligns_for_nonsymm_scheme = [("AAAACCCCGGGGTTTT",
+                              "ACGTACGTACGTACGT",
+                              -580)]
 
-
-asymm_scheme = bx.align.score.build_scoring_scheme ( """    01   02    A    C    G    T
+asymm_scheme = bx.align.score.build_scoring_scheme("""    01   02    A    C    G    T
                                                        01  200 -200  -50  100  -50  100
                                                        02 -200  200  100  -50  100  -50 """,
-                                                       0, 0, gap1='\x00' )
+                                                   0, 0, gap1='\x00')
 
-aligns_for_asymm_scheme = [ ( "\x01\x01\x01\x01\x01\x01",
-                              "ACGT\x01\x02", 
-                              100 )
-                          ]
+aligns_for_asymm_scheme = [("\x01\x01\x01\x01\x01\x01",
+                            "ACGT\x01\x02",
+                            100)]
 
 
-class BasicTests( unittest.TestCase ):
+class BasicTests(unittest.TestCase):
 
-    def test_scoring_text( self ):
+    def test_scoring_text(self):
         ss = bx.align.score.hox70
         for t1, t2, score in aligns:
-            self.assertEquals( bx.align.score.score_texts( ss, t1, t2 ), score )
-            
-    def test_align( self ):
+            self.assertEqual(bx.align.score.score_texts(ss, t1, t2), score)
+
+    def test_align(self):
         ss = bx.align.score.hox70
-        for block in bx.align.maf.Reader( StringIO( mafs ) ):
-            self.assertEquals( bx.align.score.score_alignment( ss, block ), float( block.score ) )
-            
-    def test_accumulate( self ):
+        for block in bx.align.maf.Reader(StringIO(mafs)):
+            self.assertEqual(bx.align.score.score_alignment(ss, block), float(block.score))
+
+    def test_accumulate(self):
         ss = bx.align.score.hox70
-        self.assert_( allclose( bx.align.score.accumulate_scores( ss, "-----CTTT", "CTTAGTTTA"  ),
-                           cumsum( array( [ -430, -30, -30, -30, -30, -31, 91, 91, -123 ] ) ) ) )
-        self.assert_( allclose( bx.align.score.accumulate_scores( ss, "-----CTTT", "CTTAGTTTA", skip_ref_gaps=True ),
-                           cumsum( array( [ -581, 91, 91, -123 ] ) ) ) )
+        self.assert_(allclose(bx.align.score.accumulate_scores(ss, "-----CTTT", "CTTAGTTTA"),
+                              cumsum(array([-430, -30, -30, -30, -30, -31, 91, 91, -123]))))
+        self.assert_(allclose(bx.align.score.accumulate_scores(ss, "-----CTTT", "CTTAGTTTA", skip_ref_gaps=True),
+                              cumsum(array([-581, 91, 91, -123]))))
 
-    def test_nonsymm_scoring( self ):
+    def test_nonsymm_scoring(self):
         ss = nonsymm_scheme
         for t1, t2, score in aligns_for_nonsymm_scheme:
-            self.assertEquals( bx.align.score.score_texts( ss, t1, t2 ), score )
+            self.assertEqual(bx.align.score.score_texts(ss, t1, t2), score)
 
-    def test_asymm_scoring( self ):
+    def test_asymm_scoring(self):
         ss = asymm_scheme
         for t1, t2, score in aligns_for_asymm_scheme:
-            self.assertEquals( bx.align.score.score_texts( ss, t1, t2 ), score )
+            self.assertEqual(bx.align.score.score_texts(ss, t1, t2), score)


=====================================
lib/bx/bbi/bpt_file.pyx
=====================================
@@ -54,7 +54,7 @@ cdef class BPTFile:
             self.reader.read( self.key_size )
             offset = self.reader.read_uint64()
             # Loop until correct subtree is found
-            for i from 0 <= i < child_count:
+            for i from 0 <= i < child_count - 1:
                 node_key = self.reader.read( self.key_size )
                 if node_key > key:
                     break


=====================================
lib/bx/bitset_tests.py
=====================================
@@ -5,108 +5,115 @@ Tests for `bx.bitset`.
 import bx.bitset
 import unittest
 
-class AbstractTests( object ):
-
-    def assert_bits( self, bits, list ):
-        assert bits.size == len( list ), "Bitset size and verification list size do not match"
-        for i in range( bits.size ):
-            self.assertEquals( bits[i], list[i] )
-
-    def test_overflow_create( self ):
-        self.assertRaises( ValueError, self.new_bits, 4000000000 )
-        
-    def test_overflow_access( self ):
-        bits = self.new_bits( 100 )
-        self.assertRaises( IndexError, bits.set, -5 )
-        self.assertRaises( IndexError, bits.set, 110 )
-
-    def test_access( self ):
+
+class AbstractTests(object):
+
+    def assert_bits(self, bits, list):
+        assert bits.size == len(list), "Bitset size and verification list size do not match"
+        for i in range(bits.size):
+            self.assertEqual(bits[i], list[i])
+
+    def test_overflow_create(self):
+        self.assertRaises(ValueError, self.new_bits, 4000000000)
+
+    def test_overflow_access(self):
+        bits = self.new_bits(100)
+        self.assertRaises(IndexError, bits.set, -5)
+        self.assertRaises(IndexError, bits.set, 110)
+
+    def test_access(self):
         # Create and assert empty
-        bits = self.new_bits( 100 )
-        l = [ 0 ] * 100
-        self.assert_bits( bits, l )
+        bits = self.new_bits(100)
+        l = [0] * 100
+        self.assert_bits(bits, l)
         # Set some positions
-        for pos in ( 11, 14, 70, 16 ):
-            bits.set( pos )
-            l[ pos ] = 1
+        for pos in (11, 14, 70, 16):
+            bits.set(pos)
+            l[pos] = 1
         # Clear some positions
-        for pos in ( 14, 80, 16 ):
-            bits.clear( pos )
-            l[ pos ] = 0
-        self.assert_bits( bits, l )
+        for pos in (14, 80, 16):
+            bits.clear(pos)
+            l[pos] = 0
+        self.assert_bits(bits, l)
 
-    def test_range_access( self ):
+    def test_range_access(self):
         # Create and assert empty
-        bits = self.new_bits( 100 )
-        l = [ 0 ] * 100
-        self.assert_bits( bits, l )
+        bits = self.new_bits(100)
+        l = [0] * 100
+        self.assert_bits(bits, l)
         # Set some positions
-        for b, e in ( ( 11, 14 ), (20,75), (90,99) ):
-            bits.set_range( b, e-b)
-            for pos in range( b, e ): l[ pos ] = 1
-        self.assert_bits( bits, l )
+        for b, e in ((11, 14), (20, 75), (90, 99)):
+            bits.set_range(b, e-b)
+            for pos in range(b, e):
+                l[pos] = 1
+        self.assert_bits(bits, l)
 
-    def test_count( self ):
+    def test_count(self):
         # Create and assert empty
-        bits = self.new_bits( 100 )
+        bits = self.new_bits(100)
         # Set some positions
-        for b, e in ( ( 11, 14 ), (20,75), (90,100) ):
-            bits.set_range( b, e-b)
-        self.assertEquals( bits.count_range( 0, 0 ), 0 )
-        self.assertEquals( bits.count_range( 0, 20 ), 3 )
-        self.assertEquals( bits.count_range( 25, 25 ), 25 )
-        self.assertEquals( bits.count_range( 80, 20 ), 10 )
-        self.assertEquals( bits.count_range( 0, 100 ), 68 )
-
-    def test_find( self ):
+        for b, e in ((11, 14), (20, 75), (90, 100)):
+            bits.set_range(b, e-b)
+        self.assertEqual(bits.count_range(0, 0), 0)
+        self.assertEqual(bits.count_range(0, 20), 3)
+        self.assertEqual(bits.count_range(25, 25), 25)
+        self.assertEqual(bits.count_range(80, 20), 10)
+        self.assertEqual(bits.count_range(0, 100), 68)
+
+    def test_find(self):
         # Create and assert empty
-        bits = self.new_bits( 100 )
+        bits = self.new_bits(100)
         # Set some positions
-        for b, e in ( ( 11, 14 ), (20,75), (90,100) ):
-            bits.set_range( b, e-b)
+        for b, e in ((11, 14), (20, 75), (90, 100)):
+            bits.set_range(b, e-b)
         # Next set
-        self.assertEquals( bits.next_set( 0 ), 11 )
-        self.assertEquals( bits.next_set( 13 ), 13 )
-        self.assertEquals( bits.next_set( 15 ), 20 )
+        self.assertEqual(bits.next_set(0), 11)
+        self.assertEqual(bits.next_set(13), 13)
+        self.assertEqual(bits.next_set(15), 20)
         # Next clear
-        self.assertEquals( bits.next_clear( 0 ), 0 )
-        self.assertEquals( bits.next_clear( 11 ), 14 )
-        self.assertEquals( bits.next_clear( 20 ), 75 )
-        self.assertEquals( bits.next_clear( 92 ), 100 )
-
-    def test_and( self ):
-        bits1 = self.new_bits( 100 )
-        bits2 = self.new_bits( 100 )
-        bits1.set_range( 20, 40 )
-        bits2.set_range( 50, 25 )
-        bits1.iand( bits2 )
+        self.assertEqual(bits.next_clear(0), 0)
+        self.assertEqual(bits.next_clear(11), 14)
+        self.assertEqual(bits.next_clear(20), 75)
+        self.assertEqual(bits.next_clear(92), 100)
+
+    def test_and(self):
+        bits1 = self.new_bits(100)
+        bits2 = self.new_bits(100)
+        bits1.set_range(20, 40)
+        bits2.set_range(50, 25)
+        bits1.iand(bits2)
         l = [0]*100
-        for i in range( 50, 60 ): l[i] = 1
-        self.assert_bits( bits1, l )
-    
-    def test_or( self ):
-        bits1 = self.new_bits( 100 )
-        bits2 = self.new_bits( 100 )
-        bits1.set_range( 20, 40 )
-        bits2.set_range( 50, 25 )
-        bits1.ior( bits2 )
+        for i in range(50, 60):
+            l[i] = 1
+        self.assert_bits(bits1, l)
+
+    def test_or(self):
+        bits1 = self.new_bits(100)
+        bits2 = self.new_bits(100)
+        bits1.set_range(20, 40)
+        bits2.set_range(50, 25)
+        bits1.ior(bits2)
         l = [0]*100
-        for i in range( 20, 75 ): l[i] = 1
-        self.assert_bits( bits1, l )
-        
-    def test_not( self ):
-        bits = self.new_bits( 100 )
-        bits.set_range( 20, 40 )
+        for i in range(20, 75):
+            l[i] = 1
+        self.assert_bits(bits1, l)
+
+    def test_not(self):
+        bits = self.new_bits(100)
+        bits.set_range(20, 40)
         bits.invert()
         l = [1]*100
-        for i in range( 20, 60 ): l[i] = 0
-        self.assert_bits( bits, l )
-        
-class BitSetTests( AbstractTests, unittest.TestCase ):
-    def new_bits( self, size ):
-        return bx.bitset.BitSet( size ) 
-
-class BinnedBitSetTests( AbstractTests, unittest.TestCase ):
-    def new_bits( self, size ):
-        granularity = size % 11 
-        return bx.bitset.BinnedBitSet( size, granularity ) 
\ No newline at end of file
+        for i in range(20, 60):
+            l[i] = 0
+        self.assert_bits(bits, l)
+
+
+class BitSetTests(AbstractTests, unittest.TestCase):
+    def new_bits(self, size):
+        return bx.bitset.BitSet(size)
+
+
+class BinnedBitSetTests(AbstractTests, unittest.TestCase):
+    def new_bits(self, size):
+        granularity = size % 11
+        return bx.bitset.BinnedBitSet(size, granularity)


=====================================
lib/bx/seq/twobit.py
=====================================
@@ -1,9 +1,7 @@
 """
 Access to files containing sequence data in 'twobit' format.
 """
-import sys
-
-from struct import *
+from struct import calcsize, unpack
 from collections import Mapping
 
 from . import _twobit
@@ -14,8 +12,9 @@ TWOBIT_MAGIC_SIZE = 4
 
 TWOBIT_VERSION = 0
 
-class TwoBitSequence( object ):
-    def __init__( self, tbf, header_offset=None ):
+
+class TwoBitSequence(object):
+    def __init__(self, tbf, header_offset=None):
         self.tbf = tbf
         self.header_offset = header_offset
         self.sequence_offset = None
@@ -23,18 +22,18 @@ class TwoBitSequence( object ):
         self.n_blocks = None
         self.masked_blocks = None
         self.loaded = False
-        
-    def __getitem__( self, slice ):
-        start, stop, stride = slice.indices( self.size )
+
+    def __getitem__(self, slice):
+        start, stop, stride = slice.indices(self.size)
         assert stride == 1, "Striding in slices not supported"
         if stop - start < 1:
             return ""
-        return _twobit.read( self.tbf.file, self, start, stop, self.tbf.do_mask  )
-        
-    def __len__( self ):
+        return _twobit.read(self.tbf.file, self, start, stop, self.tbf.do_mask)
+
+    def __len__(self):
         return self.size
-        
-    def get( self, start, end ):
+
+    def get(self, start, end):
         # Trim start / stop
         if start < 0:
             start = 0
@@ -42,46 +41,47 @@ class TwoBitSequence( object ):
             end = self.size
         out_size = end - start
         if out_size < 1:
-            raise Exception( "end before start (%s,%s)" % ( start,end ) )
+            raise Exception("end before start (%s,%s)" % (start, end))
         # Find position of packed portion
-        dna = _twobit.read( self.tbf.file, self, start, end, self.tbf.do_mask )
+        dna = _twobit.read(self.tbf.file, self, start, end, self.tbf.do_mask)
         # Return
         return dna
-        
-class TwoBitFile( Mapping ):
-    def __init__( self, file, do_mask=True ):
+
+
+class TwoBitFile(Mapping):
+    def __init__(self, file, do_mask=True):
         self.do_mask = do_mask
         # Read magic and determine byte order
         self.byte_order = ">"
-        strng = file.read( TWOBIT_MAGIC_SIZE )
-        magic = unpack( ">L", strng )[0]
+        strng = file.read(TWOBIT_MAGIC_SIZE)
+        magic = unpack(">L", strng)[0]
         if magic != TWOBIT_MAGIC_NUMBER:
-            if magic == TWOBIT_MAGIC_NUMBER_SWAP: 
+            if magic == TWOBIT_MAGIC_NUMBER_SWAP:
                 self.byte_order = "<"
-            else: 
-                raise Exception( "Not a NIB file" )
+            else:
+                raise Exception("Not a NIB file")
         self.magic = magic
         self.file = file
         # Read version
-        self.version = self.read( "L" )
+        self.version = self.read("L")
         if self.version != TWOBIT_VERSION:
-            raise Exception( "File is version '%d' but I only know about '%d'" % ( self.version, TWOBIT_VERSION ) )
+            raise Exception("File is version '%d' but I only know about '%d'" % (self.version, TWOBIT_VERSION))
         # Number of sequences in file
-        self.seq_count = self.read( "L" )
+        self.seq_count = self.read("L")
         # Header contains some reserved space
-        self.reserved = self.read( "L" )
+        self.reserved = self.read("L")
         # Read index of sequence names to offsets
         index = dict()
-        for i in range( self.seq_count ):
+        for i in range(self.seq_count):
             name = self.read_p_string()
-            offset = self.read( "L" )
-            index[name] = TwoBitSequence( self, offset )
+            offset = self.read("L")
+            index[name] = TwoBitSequence(self, offset)
         self.index = index
 
-    def __getitem__( self, name ):
+    def __getitem__(self, name):
         seq = self.index[name]
         if not seq.loaded:
-            self.load_sequence( name )
+            self.load_sequence(name)
         return seq
 
     def __iter__(self):
@@ -89,42 +89,41 @@ class TwoBitFile( Mapping ):
 
     def __len__(self):
         return len(self.index)
-        
-    def load_sequence( self, name ):
+
+    def load_sequence(self, name):
         seq = self.index[name]
         # Seek to start of sequence block
-        self.file.seek( seq.header_offset )
+        self.file.seek(seq.header_offset)
         # Size of sequence
-        seq.size = self.read( "L" )
+        seq.size = self.read("L")
         # Read N and masked block regions
         seq.n_block_starts, seq.n_block_sizes = self.read_block_coords()
         seq.masked_block_starts, seq.masked_block_sizes = self.read_block_coords()
         # Reserved
-        self.read( "L" )
+        self.read("L")
         # Save start of actualt sequence
         seq.sequence_offset = self.file.tell()
         # Mark as loaded
         seq.loaded = True
-        
-    def read_block_coords( self ):
-        blocks = []
-        block_count = self.read( "L" )
+
+    def read_block_coords(self):
+        block_count = self.read("L")
         if block_count == 0:
             return [], []
-        starts = self.read( str( block_count ) + "L", untuple=False )
-        sizes = self.read( str( block_count ) + "L", untuple=False  )
-        return list( starts ), list( sizes )
-        
-    def read( self, pattern, untuple=True ):
-        rval = unpack( self.byte_order + pattern, 
-                       self.file.read( calcsize( self.byte_order + pattern ) ) )
-        if untuple and len( rval ) == 1: 
+        starts = self.read(str(block_count) + "L", untuple=False)
+        sizes = self.read(str(block_count) + "L", untuple=False)
+        return list(starts), list(sizes)
+
+    def read(self, pattern, untuple=True):
+        rval = unpack(self.byte_order + pattern,
+                      self.file.read(calcsize(self.byte_order + pattern)))
+        if untuple and len(rval) == 1:
             return rval[0]
         return rval
-        
-    def read_p_string( self ):
+
+    def read_p_string(self):
         """
-        Read a length-prefixed string 
+        Read a length-prefixed string
         """
-        length = self.read( "B" )
-        return self.file.read( length )
+        length = self.read("B")
+        return self.file.read(length)


=====================================
setup.cfg
=====================================
@@ -2,6 +2,9 @@
 snapshot = egg_info -rb_DEV bdist_egg rotate -m.egg -k1
 build_docs = build_sphinx build_apidocs
 
+[flake8]
+ignore = E226,E501,E741
+
 [nosetests]
 tests=lib/, script_tests/
 #verbosity=2


=====================================
setup.py
=====================================
@@ -19,7 +19,7 @@ def main():
 
     metadata = \
       dict( name = "bx-python",
-            version = "0.8.2",
+            version = "0.8.4",
             setup_requires=['numpy', 'cython'],
             install_requires=['numpy', 'six'],
             py_modules = [ 'psyco_full' ],



View it on GitLab: https://salsa.debian.org/med-team/python-bx/commit/d00e2e62745b03285ebe9f67f89095b0a7769084

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-bx/commit/d00e2e62745b03285ebe9f67f89095b0a7769084
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20190723/7b80a700/attachment-0001.html>


More information about the debian-med-commit mailing list