Skip to content
Commits on Source (6)
......@@ -4,6 +4,11 @@ os:
language: c
stages:
- test
- name: deploy
if: tag IS present
env:
matrix:
- CONDA_PY=2.7
......@@ -12,12 +17,26 @@ env:
global:
- PYSAM_LINKING_TEST=1
- TWINE_USERNAME=grepall
- secure: 'OcwwP8/o21+SGW0UVAnnCQwllhGSCq2HJzpI9EhX3kh6J9RTkyx/+drkg45bx1Z5u8zymuAFappEYzlpzqZE886XezkjOYGVa/u+Coqr1oT/BEJHFCkCA4o26yESp7Zy8aNj/juhB7Rfa77pIDXBayqTzbALz/AURMtZapasB18='
- secure: bTbky3Un19NAl62lix8bMLmBv9IGNhFkRXlZH+B253nYub7jwQwPQKum3ct9ea+XHJT5//uM0B8WAF6eyugpNkPQ7+S7SEH5BJuCt30nv6qvGhSO2AffZKeHEDnfW2kqGrivn87TqeomlSBlO742CD/V0wOIUwkTT9tutd+E7FU=
_deploy_common: &deploy_common
if: tag IS present
_cibw_common: &cibw_common
addons: {}
install:
- python3 -m pip install cibuildwheel twine
- python3 -m pip install cibuildwheel>=1.1.0 twine
script:
- set -e
- cibuildwheel --output-dir dist
- twine check dist/*
- twine upload --skip-existing dist/*
_cibw_linux: &cibw_linux
stage: deploy
os: linux
language: python
python: '3.5'
services:
- docker
<<: *cibw_common
matrix:
include:
......@@ -25,11 +44,6 @@ matrix:
os: linux
language: python
python: '3.5'
services:
- docker
env:
- CIBW_BEFORE_BUILD="yum install -y zlib-devel bzip2-devel xz-devel && pip install -r requirements.txt"
- CIBW_ENVIRONMENT='HTSLIB_CONFIGURE_OPTIONS="--disable-libcurl"'
addons:
apt:
packages:
......@@ -37,28 +51,36 @@ matrix:
- g++
- libcurl4-openssl-dev # for libcurl support in sdist
- libssl-dev # for s3 support in sdist
<<: *deploy_common
install:
- python3 -m pip install Cython twine
script:
- set -e
- cibuildwheel --output-dir dist
- python3 -m pip install Cython
- python3 setup.py build_ext --inplace
- python3 setup.py sdist
- twine check dist/*
- twine upload --skip-existing dist/*
- <<: *cibw_linux
env:
- CIBW_BUILD="*_x86_64"
- CIBW_BEFORE_BUILD="yum install -y zlib-devel bzip2-devel xz-devel && python -m pip install -r requirements.txt"
- CIBW_ENVIRONMENT='HTSLIB_CONFIGURE_OPTIONS="--disable-libcurl"'
- CIBW_REPAIR_WHEEL_COMMAND_LINUX='auditwheel repair -L . -w {dest_dir} {wheel}'
- CIBW_TEST_COMMAND='python -c "import pysam"'
- <<: *cibw_linux
env:
- CIBW_BUILD="*_i686"
- CIBW_BEFORE_BUILD="yum install -y zlib-devel bzip2-devel xz-devel && python -m pip install -r requirements.txt"
- CIBW_ENVIRONMENT='HTSLIB_CONFIGURE_OPTIONS="--disable-libcurl"'
- CIBW_REPAIR_WHEEL_COMMAND_LINUX='auditwheel repair -L . -w {dest_dir} {wheel}'
- CIBW_TEST_COMMAND='python -c "import pysam"'
- stage: deploy
os: osx
language: generic
env:
- CIBW_BEFORE_BUILD="pip install -r requirements.txt"
- CIBW_BEFORE_BUILD="python -m pip install -r requirements.txt"
- CIBW_ENVIRONMENT='HTSLIB_CONFIGURE_OPTIONS="--disable-libcurl"'
addons: {}
<<: *deploy_common
script:
- set -e
- cibuildwheel --output-dir dist
- twine check dist/*
- twine upload --skip-existing dist/*
- CIBW_TEST_COMMAND='python -c "import pysam"'
<<: *cibw_common
addons:
apt:
......
python-pysam (0.15.4+ds-1) unstable; urgency=medium
* Team upload.
* New upstream version
* python-pysam-tests: Multi-Arch: foreign
* Try to keep example_no_seq_in_header_null_bytes.bam from being deleted
-- Michael R. Crusoe <michael.crusoe@gmail.com> Thu, 23 Jan 2020 15:00:17 +0100
python-pysam (0.15.3+ds-5) unstable; urgency=medium
[ Chris Lamb ]
......
......@@ -52,6 +52,7 @@ Description: interface for the SAM/BAM sequence alignment and mapping format (Py
This package installs the module for Python 3.
Package: python-pysam-tests
Multi-Arch: foreign
Architecture: all
Depends: ${misc:Depends}
Enhances: python-pysam
......
--- python-pysam.orig/tests/pysam_data/Makefile
+++ python-pysam/tests/pysam_data/Makefile
@@ -87,7 +87,7 @@
cp ex1.cram $@
clean:
- rm -fr *.bam *.bai *.fai *.pileup* *.cram \
+ rm -fr *.bai *.fai *.pileup* *.cram \
*~ calDepth *.dSYM pysam_*.sam \
ex2.sam ex2.sam.gz ex1.sam \
with_md.sam.gz \
......@@ -4,3 +4,4 @@ hts1.10
samtools_v1.10_full
# samtools_v1.10
bcftools_v1.10_full
clean_less
......@@ -2,6 +2,26 @@
Release notes
=============
Release 0.15.4
==============
Bugfix release. Principal reason for release is to update cython
version in order to fix pip install pysam with python 3.8.
* [#879] Fix add_meta function in libcbcf.pyx, so meta-information
lines in header added with this function have double-quoting rules
in accordance to rules specified in VCF4.2 and VCF4.3 specifications
* [#863] Force arg to bytes to support non-ASCII encoding
* [#875] Bump minimum Cython version
* [#868] Prevent segfault on Python 2.7 AlignedSegment.compare(other=None)
* [#867] Fix wheel building on TravisCI
* [#863] Force arg to bytes to support non-ASCII encoding
* [#799] disambiguate interpretation of bcf_read return code
* [#841] Fix silent truncation of FASTQ with bad q strings
* [#846] Prevent segmentation fault on ID, when handling malformed records
* [#829] Run configure with the correct CC/CFLAGS/LDFLAGS env vars
Release 0.15.3
==============
......
from utils import PysamDispatcher
from pysam.utils import PysamDispatcher
BCFTOOLS_DISPATCH = [
"index",
......
......@@ -924,7 +924,8 @@ cdef class AlignedSegment:
Parameters
----------
header -- :class:`~pysam.AlignmentHeader` object to map numerical
header:
:class:`~pysam.AlignmentHeader` object to map numerical
identifiers to chromosome names. If not given, an empty
header is created.
'''
......@@ -999,6 +1000,10 @@ cdef class AlignedSegment:
<,=,> to *other*
'''
# avoid segfault when other equals None
if other is None:
return -1
cdef int retval, x
cdef bam1_t *t
cdef bam1_t *o
......@@ -1088,7 +1093,8 @@ cdef class AlignedSegment:
Parameters
----------
sam -- :term:`SAM` formatted string
sam:
:term:`SAM` formatted string
"""
cdef AlignedSegment dest = cls.__new__(cls)
......@@ -1110,7 +1116,8 @@ cdef class AlignedSegment:
Parameters
----------
htsfile -- (deprecated) AlignmentFile object to map numerical
htsfile:
(deprecated) AlignmentFile object to map numerical
identifiers to chromosome names. This parameter is present
for backwards compatibility and ignored.
"""
......@@ -1133,7 +1140,8 @@ cdef class AlignedSegment:
Parameters
----------
sam_dict -- dictionary of alignment values, keys corresponding to output from
sam_dict:
dictionary of alignment values, keys corresponding to output from
:meth:`todict()`.
"""
......@@ -2075,15 +2083,11 @@ cdef class AlignedSegment:
If no cigar string is present, empty arrays will be returned.
Parameters
----------
Returns
-------
arrays : two arrays. The first contains the nucleotide counts within
each cigar operation, the second contains the number of blocks for
each cigar operation.
Returns:
arrays :
two arrays. The first contains the nucleotide counts within
each cigar operation, the second contains the number of blocks
for each cigar operation.
"""
......@@ -2406,24 +2410,21 @@ cdef class AlignedSegment:
specification) as well as additional value type 'd' as
implemented in htslib.
Parameters
----------
Parameters:
tag :
data tag.
with_value_type : Optional[bool]
if set to True, the return value is a tuple of (tag value, type code).
(default False)
if set to True, the return value is a tuple of (tag value, type
code). (default False)
Returns
-------
Returns:
A python object with the value of the `tag`. The type of the
object depends on the data type in the data record.
Raises
------
Raises:
KeyError
If `tag` is not present, a KeyError is raised.
......
......@@ -1705,15 +1705,13 @@ cdef class AlignmentFile(HTSFile):
'''
write a single :class:`pysam.AlignedSegment` to disk.
Raises
------
Raises:
ValueError
if the writing failed
Returns
-------
int : the number of bytes written. If the file is closed,
Returns:
int :
the number of bytes written. If the file is closed,
this will be 0.
'''
if not self.is_open:
......@@ -1800,10 +1798,10 @@ cdef class AlignmentFile(HTSFile):
"""return statistics about mapped/unmapped reads per chromosome as
they are stored in the index.
Returns
-------
list : a list of records for each chromosome. Each record has the attributes 'contig',
'mapped', 'unmapped' and 'total'.
Returns:
list :
a list of records for each chromosome. Each record has the
attributes 'contig', 'mapped', 'unmapped' and 'total'.
"""
self.check_index()
......
......@@ -2124,6 +2124,7 @@ cdef class VariantHeader(object):
if self.ptr.dirty:
bcf_hdr_sync(self.ptr)
def add_meta(self, key, value=None, items=None):
"""Add metadata to this header"""
if not ((value is not None) ^ (items is not None)):
......@@ -2140,11 +2141,16 @@ cdef class VariantHeader(object):
hrec.value = strdup(force_bytes(value))
else:
for key, value in items:
quoted = True
if key in set(("ID", "Number", "Type")):
quoted = False
key = force_bytes(key)
bcf_hrec_add_key(hrec, key, <int>len(key))
value = force_bytes(str(value))
quoted = strpbrk(value, ' ;,"\t<>') != NULL
bcf_hrec_set_val(hrec, hrec.nkeys-1, value, <int>len(value), quoted)
except:
bcf_hrec_destroy(hrec)
......@@ -3134,6 +3140,8 @@ cdef class VariantRecord(object):
raise ValueError('Error unpacking VariantRecord')
# causes a memory leak https://github.com/pysam-developers/pysam/issues/773
# return bcf_str_cache_get_charptr(r.d.id) if r.d.id != b'.' else None
if (r.d.m_id == 0):
raise ValueError('Error extracing ID')
return charptr_to_str(r.d.id) if r.d.id != b'.' else None
@id.setter
......@@ -4080,6 +4088,7 @@ cdef class VariantFile(HTSFile):
def __next__(self):
cdef int ret
cdef int errcode
cdef bcf1_t *record = bcf_init1()
if not record:
......@@ -4093,7 +4102,10 @@ cdef class VariantFile(HTSFile):
ret = bcf_read1(self.htsfile, self.header.ptr, record)
if ret < 0:
errcode = record.errcode
bcf_destroy1(record)
if errcode:
raise IOError('unable to parse next record')
if ret == -1:
raise StopIteration
elif ret == -2:
......@@ -4445,3 +4457,4 @@ cdef class VariantFile(HTSFile):
# potentially unnecessary optimization that also sets max_unpack
if not include_samples:
self.drop_samples = True
......@@ -646,8 +646,14 @@ cdef class FastxFile:
if self.persist:
return FastxRecord(proxy=makeFastqProxy(self.entry))
return makeFastqProxy(self.entry)
else:
elif (l == -1):
raise StopIteration
elif (l == -2):
raise ValueError('truncated quality string in {0}'
.format(self._filename))
else:
raise ValueError('unknown problem parsing {0}'
.format(self._filename))
# Compatibility Layer for pysam 0.8.1
cdef class FastqFile(FastxFile):
......
......@@ -617,7 +617,8 @@ cdef class HTSFile(object):
Returns
-------
tuple : a tuple of `flag`, :term:`tid`, `start` and
tuple :
a tuple of `flag`, :term:`tid`, `start` and
`stop`. The flag indicates whether no coordinates were
supplied and the genomic region is the complete genomic space.
......
......@@ -284,7 +284,7 @@ def _pysam_dispatch(collection,
if skip_next:
skip_next = False
continue
if arg in SIMPLE_FLAGS or (len(arg) > 2 and arg.startswith('-@')):
if arg in SIMPLE_FLAGS or (len(arg) > 2 and force_bytes(arg).startswith(b'-@')):
continue
if arg in ARGUMENTS:
skip_next = True
......
from utils import PysamDispatcher
from pysam.utils import PysamDispatcher
# samtools command line options to export in python
#
......
# pysam versioning information
__version__ = "0.15.3"
__version__ = "0.15.4"
# TODO: upgrade number
__samtools_version__ = "1.9"
......
......@@ -29,7 +29,7 @@ import subprocess
import sys
import sysconfig
from contextlib import contextmanager
from setuptools import Extension, setup
from setuptools import setup
from cy_build import CyExtension as Extension, cy_build_ext as build_ext
try:
import cython
......@@ -443,7 +443,7 @@ metadata = {
'classifiers': [_f for _f in classifiers.split("\n") if _f],
'url': "https://github.com/pysam-developers/pysam",
'packages': package_list,
'requires': ['cython (>=0.21)'],
'requires': ['cython (>=0.29.12)'],
'ext_modules': [Extension(**opts) for opts in modules],
'cmdclass': cmdclass,
'package_dir': package_dirs,
......
......@@ -78,6 +78,12 @@ class TestAlignedSegment(ReadTest):
def testCompare(self):
'''check comparison functions.'''
a = self.build_read()
b = None
self.assertFalse(a is b)
self.assertFalse(a == b)
self.assertEqual(-1, a.compare(b))
b = self.build_read()
self.assertEqual(0, a.compare(b))
......