@AndreasHeger AndreasHeger released this Jan 22, 2017 · 5 commits to master since this release

This release implements further functionality in the VariantFile API
and includes several bugfixes:

  • treat special case -c option in samtools view outputs to stdout even if -o given, fixes #315
  • permit reading BAM files with CSI index, closes #370
  • raise Error if query name exceeds maximum length, fixes #373
  • new method to compute hash value for AlignedSegment
  • AlignmentFile, VariantFile and TabixFile all inherit from HTSFile
  • Avoid segfault by detecting out of range reference_id and next_reference in AlignedSegment.tostring
  • Issue #355: Implement streams using file descriptors for VariantFile
  • upgrade to htslib 1.3.2
  • fix compilation with musl libc
  • Issue #316, #360: Rename all Cython modules to have lib as a prefix
  • Issue #332, hardclipped bases in cigar included by pysam.AlignedSegment.infer_query_length()
  • Added support for Python 3.6 filename encoding protocol
  • Issue #371, fix incorrect parsing of scalar INFO and FORMAT fields in VariantRecord
  • Issue #331, fix failure in VariantFile.reset() method
  • Issue #314, add VariantHeader.new_record(), VariantFile.new_record() and VariantRecord.copy() methods to create new VariantRecord objects
  • Added VariantRecordFilter.add() method to allow setting new VariantRecord filters
  • Preliminary (potentially unsafe) support for removing and altering header metadata
  • Many minor fixes and improvements to VariantFile and related objects

Please note that all internal cython extensions now have a lib prefix. Any user cython extensions
using cimport to import pysam definitions will need changes.



@AndreasHeger AndreasHeger released this Jul 18, 2016 · 143 commits to master since this release

This release is (almost) identical to 0.9.1 but aims to improve installation by querying htslib configuration directly.

Many thanks @jmarshall

This release also fixes a bug when parsing tags following CL tags in SAM/BAM headers.



@AndreasHeger AndreasHeger released this Jul 1, 2016 · 153 commits to master since this release

This release is identical but aims to improve installation on systems without cython.



@AndreasHeger AndreasHeger released this Jun 23, 2016 · 158 commits to master since this release

This release is identical to pysam 0.9.1 in functionality, but aims to improve installation without libcurl.



@AndreasHeger AndreasHeger released this Jun 22, 2016 · 162 commits to master since this release

This release is functionally equivalent to 0.9.1, but aims to resolve installation issues on systems without cython.



@AndreasHeger AndreasHeger released this Jun 14, 2016 · 176 commits to master since this release

This is a bugfix release addressing some installation problems
in pysam 0.9.0, in particular:

  • patch included htslib to work with older libcurl versions, fixes #262.
  • do not require cython for python 3 install, fixes #260
  • FastaFile does not accept filepath_index any more, see #270
  • add AlignedSegment.get_cigar_stats method.
  • py3 bugfix in VariantFile.subset_samples, fixes #272
  • add missing sysconfig import, fixes #278
  • do not redirect stdout, but instead write to a separately
    created file. This should resolve issues when pysam is used
    in notebooks or other environments that redirect stdout.
  • wrap htslib-1.3.1, samtools-1.3.1 and bcftools-1.3.1
  • use bgzf throughout instead of gzip
  • allow specifying a fasta reference for CRAM file when opening
    for both read and write, fixes #280



@AndreasHeger AndreasHeger released this Mar 1, 2016 · 245 commits to master since this release

The 0.9.0 release upgrades htslib to htslib 1.3 and numerous other
enchancements and bugfixes. See below for a detailed list.

Htslib 1.3 <>_
comes with additional capabilities for remote file access which depend
on the presence of optional system libraries. As a consequence, the
installation script has become more complex. For an
overview, see :ref:installation. We have tested installation on
linux and OS X, but could not capture all variations. It is possible
that a 0.9.1 release might follow soon addressing installation issues.

The pysam.VariantFile class provides access to
vcf and bcf formatted files. The class is certainly
usable and interface is reaching completion, but the API and the
functionality is subject to change.

  • upgrade to htslib 1.3
  • python 3 compatibility tested throughout.
  • added a first set of bcftools commands in the pysam.bcftools submodule.
  • samtools commands are now in the pysam.samtools module. For backwards compatibility they are still imported into the pysam namespace.
  • samtools/bcftools return stdout as a single (byte) string. As output
    can be binary (VCF.gz, BAM) this is necessary to ensure py2/py3
    compatibility. To replicate the previous behaviour in py2.7,
  • get_tags() returns the tag type as a character, not an integer (#214)
  • TabixFile now raises ValueError on indices created by tabix <1.0 (#206)
  • improve OSX installation and develop mode
  • FastxIterator now handles empty sequences (#204)
  • TabixFile.isremote is not TabixFile.is_remote in line with AlignmentFile
  • AlignmentFile.count() has extra optional argument read_callback
  • has been changed to:
    • install a single builtin htslib library. Previously, each pysam module contained its own version. This reduces compilation time and code bloat
    • run configure for the builtin htslib library in order to detect optional libraries such as libcurl. Configure behaviour can be controlled by setting the environment variable HTSLIB_CONFIGURE_OPTIONS.
  • get_reference_sequence() now returns the reference sequence and not something looking like it. This bug had effects on get_aligned_pairs(with_seq=True), see #225. If you have relied on get_aligned_pairs(with_seq=True) in pysam-0.8.4, please check your results.
  • improved autodetection of file formats in AlignmentFile and VariantFile.



@AndreasHeger AndreasHeger released this Nov 9, 2015 · 527 commits to master since this release

This release contains numerous bugfixes and a first implementation of
a pythonic interface to VCF/BCF files thanks to Kevin Jacobs.

Potential isses when upgrading from v0.8.3:

  • binary tags are now returned as python arrays
  • renamed several methods for pep8 compatibility, old names still retained for
    backwards compatibility, but should be considered deprecated.
    • gettid() is now get_tid()
    • getrname() is now get_reference_name()
    • parseRegion() is now parse_region()
  • faidx now returns strings and not binary strings in py3.
  • The cython components have been broken up into smaller files with
    more specific content. This will affect users using the cython

A full list of changes is at



@AndreasHeger AndreasHeger released this Apr 29, 2015 · 659 commits to master since this release

This is a minor bugfix/feature release
tying off a few things in 0.8.2. These are:

  • samtools command now accept the "catch_stdout" option.
  • get_aligned_pairs now works for soft-clipped reads.
  • query_position is now None when a PileupRead is not aligned
    to a particular position.
  • AlignedSegments are now comparable and hashable.



@AndreasHeger AndreasHeger released this Feb 17, 2015 · 698 commits to master since this release

  • Pysam now wraps htslib 1.2.1 and samtools version 1.2
  • Added CRAM file support to pysam
  • New alignment info interface.
    • opt() and setTag are deprecated, use get_tag() and set_tag()
    • added has_tag()
    • tags is deprecated, use get_tags() and set_tags() instead.
  • FastqFile is now FastxFile to reflect that the latter permits
    iteration over both fastq- and fasta-formatted files.
  • A Cython wrapper for htslib VCF/BCF reader/writer. The wrapper
    provides a nearly complete Pythonic interface to VCF/BCF metadata
    with reading and writing capability. However, the interface is still
    incomplete and preliminary and lacks capability to mutate the
    resulting data.