Skip to content

Commits on Source 5

......@@ -6,14 +6,12 @@ python:
- '3.7'
- '3.6'
- '3.5'
- '3.4'
- '2.7'
- 'pypy'
- 'pypy3'
install:
- pip wheel -f wheelhouse cython pysam numpy || true
- pip install -f wheelhouse cython pysam pyfasta coverage pyvcf numpy || true
- pip install -f wheelhouse -e git+https://github.com/biopython/biopython.git#egg=biopython || true
- pip install -f wheelhouse cython pysam biopython requests coverage pyfasta pyvcf numpy || 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
......@@ -26,8 +24,7 @@ install:
- export PATH=$PATH:$PWD
- cd ..
before_script:
- if [ $(python --version) -gt 2.6 ]; then env pip install biopython; fi
- env python tests/data/download_gene_fasta.py
- python tests/data/download_gene_fasta.py
script: nosetests --with-coverage --cover-package=pyfaidx
deploy:
provider: pypi
......@@ -36,14 +33,24 @@ deploy:
secure: MbSaeuitkVTZqxa0PJ3RcR1aMf+B/sMbcx2sWOo9xfLlRFDFpYWJZ0EfXWEhrVu2YWXpBsasgunTDWSi0jNcZMH92MzOC+UTVYr45LO5sy6hm4iSiAgm/DPgYWdjP0SFKr7eL/HWPS+gHvgkXL1upleX21O358bxaezoasuKFvs=
on:
all_branches: true
python: 3.6
python: 3.7
tags: true
repo: mdshw5/pyfaidx
matrix:
include:
- os: windows
language: sh
python: "3.7"
before_install:
- choco install python3
- export PATH="/c/Python37:/c/Python37/Scripts:$PATH"
- python -m virtualenv $HOME/venv
- source $HOME/venv/Scripts/activate
allow_failures:
- python: 'nightly'
- python: 'pypy3'
- python: 'pypy'
- python: nightly
- python: pypy3
- python: pypy
- os: windows
fast_finish: true
cache:
directories:
......@@ -53,4 +60,4 @@ cache:
- wheelhouse
after_success:
- bash <(curl -s https://codecov.io/bash)
- if [ $TRAVIS_PYTHON_VERSION == '3.4' ] && [ $TRAVIS_TAG ]; then python scripts/benchmark.py 1000; fi
environment:
matrix:
# For Python versions available on Appveyor, see
# http://www.appveyor.com/docs/installed-software#python
- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python33"
- PYTHON: "C:\\Python34"
- PYTHON: "C:\\Python35"
- PYTHON: "C:\\Python27-x64"
- PYTHON: "C:\\Python33-x64"
DISTUTILS_USE_SDK: "1"
- PYTHON: "C:\\Python34-x64"
DISTUTILS_USE_SDK: "1"
- PYTHON: "C:\\Python35-x64"
install:
# Fix for problem building extensions for x64 under Python 3.3 and 3.4
# See: http://help.appveyor.com/discussions/problems/4278-cant-build-some-c-extensions-with-python-34-x64
# Used same solution as Matplotlib: https://github.com/matplotlib/matplotlib/blob/master/appveyor.yml
- cmd: copy ci\appveyor\vcvars64.bat "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin\amd64"
# We need wheel installed to build wheels
- "%PYTHON%\\python.exe -m pip install -r dev-requirements.txt"
build: off
test_script:
- "%PYTHON%\\python.exe setup.py nosetests"
CALL "C:\Program Files\Microsoft SDKs\Windows\v7.1\Bin\SetEnv.cmd" /x64
python-pyfaidx (0.5.8-1) unstable; urgency=medium
* Team upload.
* New upstream version
* Standards-Version: 4.5.0
* Set upstream metadata fields: Bug-Database, Bug-Submit, Repository.
* Improved clean.
* Creating bgzipped test data
-- Steffen Moeller <moeller@debian.org> Sat, 25 Jan 2020 18:58:55 +0100
python-pyfaidx (0.5.7-1) unstable; urgency=medium
* Team upload.
......
......@@ -12,8 +12,9 @@ Build-Depends: debhelper-compat (= 12),
python3-nose,
python3-numpy,
python3-six,
python3-mock
Standards-Version: 4.4.1
python3-mock,
samtools
Standards-Version: 4.5.0
Vcs-Browser: https://salsa.debian.org/med-team/python-pyfaidx
Vcs-Git: https://salsa.debian.org/med-team/python-pyfaidx.git
Homepage: https://github.com/mdshw5/pyfaidx
......
......@@ -11,9 +11,16 @@ export PYBUILD_NAME=pyfaidx
override_dh_auto_test:
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
bgzip -c tests/data/genes.fasta > tests/data/genes.fasta.gz
dh_auto_test -- --test --system=custom --test-args='set -e; \
{interpreter} -m "nose" --with-coverage --cover-package=pyfaidx'
endif
override_dh_compress:
dh_compress --exclude=gz.tbi
override_dh_auto_clean:
dh_auto_clean
rm -f .coverage
rm -f tests/data/genes.fasta.gz
rm -rf pyfaidx.egg-info
Bug-Database: https://github.com/mdshw5/pyfaidx/issues
Bug-Submit: https://github.com/mdshw5/pyfaidx/issues/new
Reference:
- Author: >
Matthew D. Shirley and Zhaorong Ma and Brent S. Pedersen and Sarah
......@@ -13,5 +15,5 @@ Reference:
Registry:
- Name: bio.tools
Entry: pyfaidx
Repository: https://github.com/mdshw5/pyfaidx
Repository: https://github.com/mdshw5/pyfaidx.git
Repository-Browse: https://github.com/mdshw5/pyfaidx
......@@ -25,7 +25,7 @@ if sys.version_info > (3, ):
dna_bases = re.compile(r'([ACTGNactgnYRWSKMDVHBXyrwskmdvhbx]+)')
__version__ = '0.5.7'
__version__ = '0.5.8'
class KeyFunctionError(ValueError):
......@@ -198,6 +198,13 @@ class Sequence(object):
"""
return len(self.seq)
def __eq__(self, other):
"""
>>> Sequence('chr1', 'ACT') == 'ACT'
True
"""
return str(self) == str(other)
@property
def fancy_name(self):
""" Return the fancy name for the sequence, including start, end, and complementation.
......@@ -1021,6 +1028,10 @@ class Fasta(object):
for rname in self.keys():
yield self[rname]
def __len__(self):
"""Return the cumulative length of all FastaRecords in self.records."""
return sum(len(record) for record in self)
def get_seq(self, name, start, end, rc=False):
"""Return a sequence by record name and interval [start, end).
......
......@@ -34,15 +34,13 @@ def fetch_genes(filename, suffix=None):
lower.write(line)
def fetch_chr22(filename):
from subprocess import Popen, PIPE
import requests
import gzip
grch36 = 'ftp://ftp-trace.ncbi.nih.gov//1000genomes/ftp/pilot_data/technical/reference/human_b36_male.fa.gz'
curl = Popen(['curl', '-s', grch36], stdout=PIPE)
gz = Popen(['gzip', '-dcq'], stdin=curl.stdout, stdout=PIPE)
with gz.stdout as remote:
with open(filename, 'w') as fasta:
with requests.get('https://ftp-trace.ncbi.nih.gov/1000genomes/ftp/pilot_data/technical/reference/human_b36_male.fa.gz') as compressed:
with open(filename, 'w') as fasta, gzip.GzipFile(fileobj=compressed.raw) as gz:
chr22 = False
for line in remote:
for line in gz:
if line[0:3] == '>22':
fasta.write(line)
chr22 = True
......@@ -66,17 +64,20 @@ def fake_chr22(filename):
fake_file.write('N' * mod_70 + '\n')
def bgzip_compress_fasta(filename):
from subprocess import call
call(' '.join(['bgzip', '-c', filename, '>', filename + '.gz']), shell=True)
from Bio.bgzf import BgzfWriter
with BgzfWriter(filename=filename + '.gz') as compressed, open(filename, 'r') as fasta:
for line in fasta:
compressed.write(line)
def fetch_chr22_vcf(filename):
from subprocess import call
call(['curl', '-s', 'ftp://ftp-trace.ncbi.nih.gov//1000genomes/ftp/pilot_data/release/2010_07/exon/snps/CEU.exon.2010_03.genotypes.vcf.gz',
'-o', filename])
call(['curl', '-s', 'ftp://ftp-trace.ncbi.nih.gov//1000genomes/ftp/pilot_data/release/2010_07/exon/snps/CEU.exon.2010_03.genotypes.vcf.gz.tbi',
'-o', filename + '.tbi'])
import requests
with requests.get('https://ftp-trace.ncbi.nih.gov/1000genomes/ftp/pilot_data/release/2010_07/exon/snps/CEU.exon.2010_03.genotypes.vcf.gz') as vcf:
with open(filename, 'wb') as out:
out.write(vcf.content)
with requests.get('https://ftp-trace.ncbi.nih.gov/1000genomes/ftp/pilot_data/release/2010_07/exon/snps/CEU.exon.2010_03.genotypes.vcf.gz.tbi') as tbi:
with open(filename + '.tbi', 'wb') as out:
out.write(tbi.content)
if __name__ == "__main__":
......
[tox]
envlist = init, py26, py27, py33, py34, py35, pypy, pypy3, final
[testenv]
deps = nose
mock; python_version < '3.3'
coverage
nose-cov
biopython
pysam; python_version > '2.6' and platform_python_implementation != 'PyPy'
pyvcf
commands = nosetests --with-cov --cov-report term-missing --cov {envsitepackagesdir}/pyfaidx -P tests
coverage combine
bash -c 'mv {toxinidir}/.coverage {toxworkdir}/.coverage.{envname}'
whitelist_externals = bash
[testenv:init]
basepython = python2.7
commands = coverage erase
bash -c 'rm -rf {toxworkdir}/.coverage.*'
python tests/data/download_gene_fasta.py
[testenv:final]
basepython = python2.7
commands = coverage combine {toxworkdir}
coverage report -m