[med-svn] [Git][med-team/python-pyfaidx][upstream] New upstream version 0.5.9.1

Andreas Tille gitlab at salsa.debian.org
Tue Sep 29 08:45:01 BST 2020



Andreas Tille pushed to branch upstream at Debian Med / python-pyfaidx


Commits:
9b47e8cb by Andreas Tille at 2020-09-29T09:37:21+02:00
New upstream version 0.5.9.1
- - - - -


3 changed files:

- .travis.yml
- pyfaidx/__init__.py
- tests/test_feature_indexing.py


Changes:

=====================================
.travis.yml
=====================================
@@ -1,8 +1,9 @@
 language: python
 sudo: required
-dist: xenial
+dist: bionic
 python:
     - 'nightly'
+    - '3.8'
     - '3.7'
     - '3.6'
     - '3.5'
@@ -10,8 +11,8 @@ python:
     - 'pypy'
     - 'pypy3'
 install:
-    - pip wheel -f wheelhouse cython pysam numpy || true
-    - pip install -f wheelhouse cython pysam biopython requests coverage pyfasta pyvcf numpy || true
+    - pip install cython pysam requests coverage pyfasta pyvcf numpy
+    - pip install biopython || true
     - python setup.py install
     - if [ ! -f samtools-1.2 ]; then curl -sL https://github.com/samtools/samtools/releases/download/1.2/samtools-1.2.tar.bz2 | tar -xjv; fi
     - cd samtools-1.2
@@ -23,8 +24,10 @@ install:
     - make
     - export PATH=$PATH:$PWD
     - cd ..
-before_script:
-    - python tests/data/download_gene_fasta.py
+before_install: 
+    - sudo apt-get install -y python3.6 python3-pip
+    - env python3.6 -m pip install biopython requests
+    - env python3.6 tests/data/download_gene_fasta.py
 script: nosetests --with-coverage --cover-package=pyfaidx
 deploy:
   provider: pypi
@@ -33,7 +36,7 @@ deploy:
     secure: MbSaeuitkVTZqxa0PJ3RcR1aMf+B/sMbcx2sWOo9xfLlRFDFpYWJZ0EfXWEhrVu2YWXpBsasgunTDWSi0jNcZMH92MzOC+UTVYr45LO5sy6hm4iSiAgm/DPgYWdjP0SFKr7eL/HWPS+gHvgkXL1upleX21O358bxaezoasuKFvs=
   on:
     all_branches: true
-    python: 3.7
+    python: 3.8
     tags: true
     repo: mdshw5/pyfaidx
 matrix:
@@ -57,7 +60,6 @@ cache:
         - tests/data
         - samtools-1.2
         - htslib-1.4
-        - wheelhouse
 after_success:
     - bash <(curl -s https://codecov.io/bash)
 


=====================================
pyfaidx/__init__.py
=====================================
@@ -4,28 +4,32 @@ Fasta file -> Faidx -> Fasta -> FastaRecord -> Sequence
 """
 
 from __future__ import division
+
 import os
+import re
+import string
 import sys
+import warnings
+from collections import namedtuple
+from itertools import islice
+from math import ceil
 from os.path import getmtime
-from six import PY2, PY3, string_types, integer_types
+from threading import Lock
+
+from six import PY2, PY3, integer_types, string_types
 from six.moves import zip_longest
+
 try:
     from collections import OrderedDict
 except ImportError:  #python 2.6
     from ordereddict import OrderedDict
-from collections import namedtuple
-import re
-import string
-import warnings
-from math import ceil
-from threading import Lock
 
 if sys.version_info > (3, ):
     buffer = memoryview
 
 dna_bases = re.compile(r'([ACTGNactgnYRWSKMDVHBXyrwskmdvhbx]+)')
 
-__version__ = '0.5.8'
+__version__ = '0.5.9.1'
 
 
 class KeyFunctionError(ValueError):
@@ -301,7 +305,7 @@ class IndexRecord(
         return tuple.__getitem__(self, key)
 
     def __str__(self):
-        return "{rlen:n}\t{offset:n}\t{lenc:n}\t{lenb:n}\n".format(
+        return "{rlen:d}\t{offset:d}\t{lenc:d}\t{lenb:d}".format(
             **self._asdict())
 
     def __len__(self):
@@ -456,7 +460,7 @@ class Faidx(object):
     def _index_as_string(self):
         """ Returns the string representation of the index as iterable """
         for k, v in self.index.items():
-            yield '\t'.join([k, str(v)])
+          yield '{k}\t{v}\n'.format(k=k, v=str(v))
 
     def read_fai(self):
         try:
@@ -603,7 +607,7 @@ class Faidx(object):
     def write_fai(self):
         with self.lock:
             with open(self.indexname, 'w') as outfile:
-                for line in self._index_as_string:
+                for line in self._index_as_string():
                     outfile.write(line)
 
     def from_buffer(self, start, end):
@@ -1015,7 +1019,7 @@ class Fasta(object):
     def __getitem__(self, rname):
         """Return a chromosome by its name, or its numerical index."""
         if isinstance(rname, integer_types):
-            rname = tuple(self.keys())[rname]
+            rname = next(islice(self.records.keys(), rname, None))
         try:
             return self.records[rname]
         except KeyError:
@@ -1025,9 +1029,8 @@ class Fasta(object):
         return 'Fasta("%s")' % (self.filename)
 
     def __iter__(self):
-        for rname in self.keys():
-            yield self[rname]
-            
+        return iter(self.records.values())
+
     def __len__(self):
         """Return the cumulative length of all FastaRecords in self.records."""
         return sum(len(record) for record in self)


=====================================
tests/test_feature_indexing.py
=====================================
@@ -317,12 +317,24 @@ class TestIndexing(TestCase):
         finally:
             shutil.rmtree(tmp_dir)
 
+    def test_read_back_index(self):
+        """Ensure that index files written with write_fai() can be read back"""
+        import locale
+        old_locale = locale.getlocale(locale.LC_NUMERIC)
+        try:
+            locale.setlocale(locale.LC_NUMERIC, 'en_US.utf8')
+            faidx = Faidx('data/genes.fasta')
+            faidx.write_fai()
+            faidx = Faidx('data/genes.fasta', build_index=False)
+        finally:
+            locale.setlocale(locale.LC_NUMERIC, old_locale)
+
     @raises(IndexNotFoundError)
     def test_issue_134_no_build_index(self):
         """ Ensure that index file is not built when build_index=False. See mdshw5/pyfaidx#134.
         """
         faidx = Faidx('data/genes.fasta', build_index=False)
-        
+
     @raises(FastaIndexingError)
     def test_issue_144_no_defline(self):
         """ Ensure that an exception is raised when a file contains no deflines. See mdshw5/pyfaidx#144.



View it on GitLab: https://salsa.debian.org/med-team/python-pyfaidx/-/commit/9b47e8cbd309a93e2cf4be207eab69572298911d

-- 
View it on GitLab: https://salsa.debian.org/med-team/python-pyfaidx/-/commit/9b47e8cbd309a93e2cf4be207eab69572298911d
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/20200929/41127532/attachment-0001.html>


More information about the debian-med-commit mailing list