[med-svn] [Git][med-team/python-pyfaidx][upstream] New upstream version 0.7.2.1
Étienne Mollier (@emollier)
gitlab at salsa.debian.org
Tue Jul 18 17:20:58 BST 2023
Étienne Mollier pushed to branch upstream at Debian Med / python-pyfaidx
Commits:
a372ba32 by Étienne Mollier at 2023-07-18T17:51:33+02:00
New upstream version 0.7.2.1
- - - - -
7 changed files:
- README.rst
- dev-requirements.txt
- pyfaidx/__init__.py
- + pyproject.toml
- − setup.py
- tests/test_FastaVariant.py
- tests/test_feature_indexing.py
Changes:
=====================================
README.rst
=====================================
@@ -36,7 +36,7 @@ or download a `release <https://github.com/mdshw5/pyfaidx/releases>`_ and:
::
- python setup.py install
+ pip install .
If using ``pip install --user`` make sure to add ``/home/$USER/.local/bin`` to your ``$PATH`` (on linux) or ``/Users/$USER/Library/Python/{python version}/bin`` (on macOS) if you want to run the ``faidx`` script.
@@ -413,6 +413,9 @@ Examples:
.. code:: bash
+ $ faidx -v tests/data/genes.fasta
+ ### Creates an .fai index, but supresses sequence output using --invert-match ###
+
$ faidx tests/data/genes.fasta NM_001282543.1:201-210 NM_001282543.1:300-320
>NM_001282543.1:201-210
CTCGTTCCGC
=====================================
dev-requirements.txt
=====================================
@@ -4,7 +4,7 @@ pytest-cov
setuptools
mock
cython
-pysam
+# pysam
requests
coverage
pyfasta
=====================================
pyfaidx/__init__.py
=====================================
@@ -304,6 +304,34 @@ class Sequence(object):
c = self.seq.count('C')
c += self.seq.count('c')
return (g + c) / len(self.seq)
+
+ @property
+ def gc_strict(self):
+ """ Return the GC content of seq as a float, ignoring non ACGT characters
+ >>> x = Sequence(name='chr1', seq='NMRATCGTA')
+ >>> y = round(x.gc, 2)
+ >>> y == 0.33
+ True
+ """
+ trimSeq = re.sub(r'[^ACGT]', '', self.seq.upper())
+ gc = sum(trimSeq.count(i) for i in ['G','C'])
+ return gc / len(trimSeq)
+
+ @property
+ def gc_iupac(self):
+ """ Return the GC content of seq as a float, accounting for IUPAC ambiguity
+ >>> x = Sequence(name='chr1', seq='NMRATCGTA')
+ >>> y = round(x.gc, 2)
+ >>> y == 0.36
+ True
+ """
+ trimSeq = re.sub(r'[^ACGTMRWSYKVHDBN]', '', self.seq.upper())
+ gc = sum(trimSeq.count(i) for i in ['S','C','G'])
+ gc += sum(trimSeq.count(i) for i in ['B','V']) * 0.67
+ gc += sum(trimSeq.count(i) for i in ['M','R','Y','K']) * 0.5
+ gc += sum(trimSeq.count(i) for i in ['H','D']) * 0.33
+ gc += trimSeq.count('N') * 0.25
+ return gc / len(trimSeq)
class IndexRecord(
@@ -405,7 +433,7 @@ class Faidx(object):
self._bgzf = True
try:
# mutable mode is not supported for bzgf anyways
- self.file = bgzf.BgzfReader(fileobj=self.file, mode="b")
+ self.file = bgzf.BgzfReader(fileobj=self.file, mode="rb")
except (ValueError, IOError):
raise UnsupportedCompressionFormat(
"Compressed FASTA is only supported in BGZF format. Use "
@@ -857,6 +885,9 @@ class Faidx(object):
def close(self):
self.__exit__()
+ def __del__(self):
+ self.__exit__()
+
def __enter__(self):
return self
=====================================
pyproject.toml
=====================================
@@ -0,0 +1,43 @@
+[build-system]
+requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2", "wheel"]
+build-backend = "setuptools.build_meta"
+
+[project]
+name = "pyfaidx"
+authors = [
+ { name="Matthew Shirley", email="mdshw5 at gmail.com"}
+]
+description = "pyfaidx: efficient pythonic random access to fasta subsequences"
+readme = "README.rst"
+requires-python = ">=3.7"
+license = {text = "BSD-3-Clause"}
+classifiers = [
+ "Development Status :: 5 - Production/Stable",
+ "License :: OSI Approved :: BSD License",
+ "Environment :: Console",
+ "Intended Audience :: Science/Research",
+ "Natural Language :: English",
+ "Operating System :: Unix",
+ "Programming Language :: Python :: 3.11",
+ "Programming Language :: Python :: 3.10",
+ "Programming Language :: Python :: 3.9",
+ "Programming Language :: Python :: 3.8",
+ "Programming Language :: Python :: 3.7",
+ "Programming Language :: Python :: Implementation :: PyPy",
+ "Topic :: Scientific/Engineering :: Bio-Informatics"
+]
+dependencies = [
+ "six",
+ "setuptools"
+]
+dynamic = ["version"]
+
+[project.urls]
+"Homepage" = "https://github.com/mdshw5/pyfaidx/"
+"Author homepage" = "http://mattshirley.com"
+
+[project.scripts]
+faidx = "pyfaidx.cli:main"
+
+[tool.setuptools_scm]
+local_scheme = "no-local-version"
=====================================
setup.py deleted
=====================================
@@ -1,39 +0,0 @@
-from setuptools import setup
-from io import open
-import sys
-
-install_requires = ['six', 'setuptools >= 0.7']
-if sys.version_info[0] == 2 and sys.version_info[1] == 6:
- install_requires.extend(['ordereddict', 'argparse'])
-
-setup(
- name='pyfaidx',
- provides='pyfaidx',
- author='Matthew Shirley',
- author_email='mdshw5 at gmail.com',
- url='http://mattshirley.com',
- description='pyfaidx: efficient pythonic random '
- 'access to fasta subsequences',
- long_description=open('README.rst', encoding='utf-8').read(),
- license='BSD',
- packages=['pyfaidx'],
- install_requires=install_requires,
- use_scm_version={"local_scheme": "no-local-version"},
- setup_requires=['setuptools_scm'],
- entry_points={'console_scripts': ['faidx = pyfaidx.cli:main']},
- classifiers=[
- "Development Status :: 5 - Production/Stable",
- "License :: OSI Approved :: BSD License",
- "Environment :: Console",
- "Intended Audience :: Science/Research",
- "Natural Language :: English",
- "Operating System :: Unix",
- "Programming Language :: Python :: 3.7",
- "Programming Language :: Python :: 3.6",
- "Programming Language :: Python :: 3.5",
- "Programming Language :: Python :: 3.4",
- "Programming Language :: Python :: 2.7",
- "Programming Language :: Python :: Implementation :: PyPy",
- "Topic :: Scientific/Engineering :: Bio-Informatics"
- ]
-)
=====================================
tests/test_FastaVariant.py
=====================================
@@ -58,6 +58,7 @@ def test_all_pos(remove_index):
def test_all_diff(remove_index):
try:
+ import pysam
fasta = FastaVariant('data/chr22.fasta', 'data/chr22.vcf.gz', hom=True, het=True, as_raw=True)
ref = Fasta('data/chr22.fasta', as_raw=True)
print([(ref['22'][pos-1], fasta['22'][pos-1]) for pos in fasta['22'].variant_sites])
=====================================
tests/test_feature_indexing.py
=====================================
@@ -24,6 +24,10 @@ def remove_index():
os.remove('data/genes.fasta.fai')
except EnvironmentError:
pass # some tests may delete this file
+
+def test_version_issue_206():
+ import pyfaidx
+ assert isinstance(pyfaidx.__version__, str)
def test_build(remove_index):
expect_index = ("gi|563317589|dbj|AB821309.1| 3510 114 70 71\n"
@@ -349,4 +353,4 @@ def test_issue_144_no_defline(remove_index):
with pytest.raises(FastaIndexingError):
faidx = Faidx(fasta_path)
finally:
- shutil.rmtree(tmp_dir)
\ No newline at end of file
+ shutil.rmtree(tmp_dir)
View it on GitLab: https://salsa.debian.org/med-team/python-pyfaidx/-/commit/a372ba32b6480dfea5ac735ebda7ce71a1b6ee1a
--
View it on GitLab: https://salsa.debian.org/med-team/python-pyfaidx/-/commit/a372ba32b6480dfea5ac735ebda7ce71a1b6ee1a
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/20230718/e8ccc8af/attachment-0001.htm>
More information about the debian-med-commit
mailing list