[med-svn] [python-pysam] 01/05: Imported Upstream version 0.7.6

Charles Plessy plessy at moszumanska.debian.org
Sat Apr 19 02:48:43 UTC 2014


This is an automated email from the git hooks/post-receive script.

plessy pushed a commit to branch master
in repository python-pysam.

commit 15fc052c4cc165d27403584aa51010a057e62245
Author: Charles Plessy <plessy at debian.org>
Date:   Sat Apr 19 11:39:04 2014 +0900

    Imported Upstream version 0.7.6
---
 PKG-INFO                   |     2 +-
 distribute_setup.py        |   546 --
 doc/faq.rst                |    68 +
 doc/release.rst            |     8 +
 doc/usage.rst              |     7 +-
 pysam.egg-info/PKG-INFO    |     2 +-
 pysam.egg-info/SOURCES.txt |     1 -
 pysam/TabProxies.c         |    52 +-
 pysam/TabProxies.pyx       |     2 +-
 pysam/csamtools.c          | 12573 +++++++++++++++++++++++++------------------
 pysam/csamtools.pxd        |    31 +
 pysam/csamtools.pyx        |   260 +-
 pysam/ctabix.c             |   304 +-
 pysam/cvcf.c               |   396 +-
 pysam/pysam_util.c         |     3 +
 pysam/pysam_util.h         |     6 +
 pysam/tabix_util.c         |    22 +
 pysam/version.py           |     2 +-
 setup.py                   |    11 +-
 tests/Makefile             |     3 +-
 tests/pysam_test.py        |    49 +
 21 files changed, 8088 insertions(+), 6260 deletions(-)

diff --git a/PKG-INFO b/PKG-INFO
index 8d8f7c5..dbb2aed 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pysam
-Version: 0.7.5
+Version: 0.7.6
 Summary: pysam
 Home-page: http://code.google.com/p/pysam/
 Author: Andreas Heger
diff --git a/distribute_setup.py b/distribute_setup.py
deleted file mode 100644
index a1cc2a1..0000000
--- a/distribute_setup.py
+++ /dev/null
@@ -1,546 +0,0 @@
-#!python
-"""Bootstrap distribute installation
-
-If you want to use setuptools in your package's setup.py, just include this
-file in the same directory with it, and add this to the top of your setup.py::
-
-    from distribute_setup import use_setuptools
-    use_setuptools()
-
-If you want to require a specific version of setuptools, set a download
-mirror, or use an alternate download directory, you can do so by supplying
-the appropriate options to ``use_setuptools()``.
-
-This file can also be run as a script to install or upgrade setuptools.
-"""
-import os
-import shutil
-import sys
-import time
-import fnmatch
-import tempfile
-import tarfile
-import optparse
-
-from distutils import log
-
-try:
-    from site import USER_SITE
-except ImportError:
-    USER_SITE = None
-
-try:
-    import subprocess
-
-    def _python_cmd(*args):
-        args = (sys.executable,) + args
-        return subprocess.call(args) == 0
-
-except ImportError:
-    # will be used for python 2.3
-    def _python_cmd(*args):
-        args = (sys.executable,) + args
-        # quoting arguments if windows
-        if sys.platform == 'win32':
-            def quote(arg):
-                if ' ' in arg:
-                    return '"%s"' % arg
-                return arg
-            args = [quote(arg) for arg in args]
-        return os.spawnl(os.P_WAIT, sys.executable, *args) == 0
-
-DEFAULT_VERSION = "0.6.34"
-DEFAULT_URL = "http://pypi.python.org/packages/source/d/distribute/"
-SETUPTOOLS_FAKED_VERSION = "0.6c11"
-
-SETUPTOOLS_PKG_INFO = """\
-Metadata-Version: 1.0
-Name: setuptools
-Version: %s
-Summary: xxxx
-Home-page: xxx
-Author: xxx
-Author-email: xxx
-License: xxx
-Description: xxx
-""" % SETUPTOOLS_FAKED_VERSION
-
-
-def _install(tarball, install_args=()):
-    # extracting the tarball
-    tmpdir = tempfile.mkdtemp()
-    log.warn('Extracting in %s', tmpdir)
-    old_wd = os.getcwd()
-    try:
-        os.chdir(tmpdir)
-        tar = tarfile.open(tarball)
-        _extractall(tar)
-        tar.close()
-
-        # going in the directory
-        subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
-        os.chdir(subdir)
-        log.warn('Now working in %s', subdir)
-
-        # installing
-        log.warn('Installing Distribute')
-        if not _python_cmd('setup.py', 'install', *install_args):
-            log.warn('Something went wrong during the installation.')
-            log.warn('See the error message above.')
-            # exitcode will be 2
-            return 2
-    finally:
-        os.chdir(old_wd)
-        shutil.rmtree(tmpdir)
-
-
-def _build_egg(egg, tarball, to_dir):
-    # extracting the tarball
-    tmpdir = tempfile.mkdtemp()
-    log.warn('Extracting in %s', tmpdir)
-    old_wd = os.getcwd()
-    try:
-        os.chdir(tmpdir)
-        tar = tarfile.open(tarball)
-        _extractall(tar)
-        tar.close()
-
-        # going in the directory
-        subdir = os.path.join(tmpdir, os.listdir(tmpdir)[0])
-        os.chdir(subdir)
-        log.warn('Now working in %s', subdir)
-
-        # building an egg
-        log.warn('Building a Distribute egg in %s', to_dir)
-        _python_cmd('setup.py', '-q', 'bdist_egg', '--dist-dir', to_dir)
-
-    finally:
-        os.chdir(old_wd)
-        shutil.rmtree(tmpdir)
-    # returning the result
-    log.warn(egg)
-    if not os.path.exists(egg):
-        raise IOError('Could not build the egg.')
-
-
-def _do_download(version, download_base, to_dir, download_delay):
-    egg = os.path.join(to_dir, 'distribute-%s-py%d.%d.egg'
-                       % (version, sys.version_info[0], sys.version_info[1]))
-    if not os.path.exists(egg):
-        tarball = download_setuptools(version, download_base,
-                                      to_dir, download_delay)
-        _build_egg(egg, tarball, to_dir)
-    sys.path.insert(0, egg)
-    import setuptools
-    setuptools.bootstrap_install_from = egg
-
-
-def use_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
-                   to_dir=os.curdir, download_delay=15, no_fake=True):
-    # making sure we use the absolute path
-    to_dir = os.path.abspath(to_dir)
-    was_imported = 'pkg_resources' in sys.modules or \
-        'setuptools' in sys.modules
-    try:
-        try:
-            import pkg_resources
-            if not hasattr(pkg_resources, '_distribute'):
-                if not no_fake:
-                    _fake_setuptools()
-                raise ImportError
-        except ImportError:
-            return _do_download(version, download_base, to_dir, download_delay)
-        try:
-            pkg_resources.require("distribute>=" + version)
-            return
-        except pkg_resources.VersionConflict:
-            e = sys.exc_info()[1]
-            if was_imported:
-                sys.stderr.write(
-                "The required version of distribute (>=%s) is not available,\n"
-                "and can't be installed while this script is running. Please\n"
-                "install a more recent version first, using\n"
-                "'easy_install -U distribute'."
-                "\n\n(Currently using %r)\n" % (version, e.args[0]))
-                sys.exit(2)
-            else:
-                del pkg_resources, sys.modules['pkg_resources']    # reload ok
-                return _do_download(version, download_base, to_dir,
-                                    download_delay)
-        except pkg_resources.DistributionNotFound:
-            return _do_download(version, download_base, to_dir,
-                                download_delay)
-    finally:
-        if not no_fake:
-            _create_fake_setuptools_pkg_info(to_dir)
-
-
-def download_setuptools(version=DEFAULT_VERSION, download_base=DEFAULT_URL,
-                        to_dir=os.curdir, delay=15):
-    """Download distribute from a specified location and return its filename
-
-    `version` should be a valid distribute version number that is available
-    as an egg for download under the `download_base` URL (which should end
-    with a '/'). `to_dir` is the directory where the egg will be downloaded.
-    `delay` is the number of seconds to pause before an actual download
-    attempt.
-    """
-    # making sure we use the absolute path
-    to_dir = os.path.abspath(to_dir)
-    try:
-        from urllib.request import urlopen
-    except ImportError:
-        from urllib2 import urlopen
-    tgz_name = "distribute-%s.tar.gz" % version
-    url = download_base + tgz_name
-    saveto = os.path.join(to_dir, tgz_name)
-    src = dst = None
-    if not os.path.exists(saveto):  # Avoid repeated downloads
-        try:
-            log.warn("Downloading %s", url)
-            src = urlopen(url)
-            # Read/write all in one block, so we don't create a corrupt file
-            # if the download is interrupted.
-            data = src.read()
-            dst = open(saveto, "wb")
-            dst.write(data)
-        finally:
-            if src:
-                src.close()
-            if dst:
-                dst.close()
-    return os.path.realpath(saveto)
-
-
-def _no_sandbox(function):
-    def __no_sandbox(*args, **kw):
-        try:
-            from setuptools.sandbox import DirectorySandbox
-            if not hasattr(DirectorySandbox, '_old'):
-                def violation(*args):
-                    pass
-                DirectorySandbox._old = DirectorySandbox._violation
-                DirectorySandbox._violation = violation
-                patched = True
-            else:
-                patched = False
-        except ImportError:
-            patched = False
-
-        try:
-            return function(*args, **kw)
-        finally:
-            if patched:
-                DirectorySandbox._violation = DirectorySandbox._old
-                del DirectorySandbox._old
-
-    return __no_sandbox
-
-
-def _patch_file(path, content):
-    """Will backup the file then patch it"""
-    f = open(path)
-    existing_content = f.read()
-    f.close()
-    if existing_content == content:
-        # already patched
-        log.warn('Already patched.')
-        return False
-    log.warn('Patching...')
-    _rename_path(path)
-    f = open(path, 'w')
-    try:
-        f.write(content)
-    finally:
-        f.close()
-    return True
-
-_patch_file = _no_sandbox(_patch_file)
-
-
-def _same_content(path, content):
-    f = open(path)
-    existing_content = f.read()
-    f.close()
-    return existing_content == content
-
-
-def _rename_path(path):
-    new_name = path + '.OLD.%s' % time.time()
-    log.warn('Renaming %s to %s', path, new_name)
-    os.rename(path, new_name)
-    return new_name
-
-
-def _remove_flat_installation(placeholder):
-    if not os.path.isdir(placeholder):
-        log.warn('Unkown installation at %s', placeholder)
-        return False
-    found = False
-    for file in os.listdir(placeholder):
-        if fnmatch.fnmatch(file, 'setuptools*.egg-info'):
-            found = True
-            break
-    if not found:
-        log.warn('Could not locate setuptools*.egg-info')
-        return
-
-    log.warn('Moving elements out of the way...')
-    pkg_info = os.path.join(placeholder, file)
-    if os.path.isdir(pkg_info):
-        patched = _patch_egg_dir(pkg_info)
-    else:
-        patched = _patch_file(pkg_info, SETUPTOOLS_PKG_INFO)
-
-    if not patched:
-        log.warn('%s already patched.', pkg_info)
-        return False
-    # now let's move the files out of the way
-    for element in ('setuptools', 'pkg_resources.py', 'site.py'):
-        element = os.path.join(placeholder, element)
-        if os.path.exists(element):
-            _rename_path(element)
-        else:
-            log.warn('Could not find the %s element of the '
-                     'Setuptools distribution', element)
-    return True
-
-_remove_flat_installation = _no_sandbox(_remove_flat_installation)
-
-
-def _after_install(dist):
-    log.warn('After install bootstrap.')
-    placeholder = dist.get_command_obj('install').install_purelib
-    _create_fake_setuptools_pkg_info(placeholder)
-
-
-def _create_fake_setuptools_pkg_info(placeholder):
-    if not placeholder or not os.path.exists(placeholder):
-        log.warn('Could not find the install location')
-        return
-    pyver = '%s.%s' % (sys.version_info[0], sys.version_info[1])
-    setuptools_file = 'setuptools-%s-py%s.egg-info' % \
-            (SETUPTOOLS_FAKED_VERSION, pyver)
-    pkg_info = os.path.join(placeholder, setuptools_file)
-    if os.path.exists(pkg_info):
-        log.warn('%s already exists', pkg_info)
-        return
-
-    log.warn('Creating %s', pkg_info)
-    try:
-        f = open(pkg_info, 'w')
-    except EnvironmentError:
-        log.warn("Don't have permissions to write %s, skipping", pkg_info)
-        return
-    try:
-        f.write(SETUPTOOLS_PKG_INFO)
-    finally:
-        f.close()
-
-    pth_file = os.path.join(placeholder, 'setuptools.pth')
-    log.warn('Creating %s', pth_file)
-    f = open(pth_file, 'w')
-    try:
-        f.write(os.path.join(os.curdir, setuptools_file))
-    finally:
-        f.close()
-
-_create_fake_setuptools_pkg_info = _no_sandbox(
-    _create_fake_setuptools_pkg_info
-)
-
-
-def _patch_egg_dir(path):
-    # let's check if it's already patched
-    pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
-    if os.path.exists(pkg_info):
-        if _same_content(pkg_info, SETUPTOOLS_PKG_INFO):
-            log.warn('%s already patched.', pkg_info)
-            return False
-    _rename_path(path)
-    os.mkdir(path)
-    os.mkdir(os.path.join(path, 'EGG-INFO'))
-    pkg_info = os.path.join(path, 'EGG-INFO', 'PKG-INFO')
-    f = open(pkg_info, 'w')
-    try:
-        f.write(SETUPTOOLS_PKG_INFO)
-    finally:
-        f.close()
-    return True
-
-_patch_egg_dir = _no_sandbox(_patch_egg_dir)
-
-
-def _before_install():
-    log.warn('Before install bootstrap.')
-    _fake_setuptools()
-
-
-def _under_prefix(location):
-    if 'install' not in sys.argv:
-        return True
-    args = sys.argv[sys.argv.index('install') + 1:]
-    for index, arg in enumerate(args):
-        for option in ('--root', '--prefix'):
-            if arg.startswith('%s=' % option):
-                top_dir = arg.split('root=')[-1]
-                return location.startswith(top_dir)
-            elif arg == option:
-                if len(args) > index:
-                    top_dir = args[index + 1]
-                    return location.startswith(top_dir)
-        if arg == '--user' and USER_SITE is not None:
-            return location.startswith(USER_SITE)
-    return True
-
-
-def _fake_setuptools():
-    log.warn('Scanning installed packages')
-    try:
-        import pkg_resources
-    except ImportError:
-        # we're cool
-        log.warn('Setuptools or Distribute does not seem to be installed.')
-        return
-    ws = pkg_resources.working_set
-    try:
-        setuptools_dist = ws.find(
-            pkg_resources.Requirement.parse('setuptools', replacement=False)
-            )
-    except TypeError:
-        # old distribute API
-        setuptools_dist = ws.find(
-            pkg_resources.Requirement.parse('setuptools')
-        )
-
-    if setuptools_dist is None:
-        log.warn('No setuptools distribution found')
-        return
-    # detecting if it was already faked
-    setuptools_location = setuptools_dist.location
-    log.warn('Setuptools installation detected at %s', setuptools_location)
-
-    # if --root or --preix was provided, and if
-    # setuptools is not located in them, we don't patch it
-    if not _under_prefix(setuptools_location):
-        log.warn('Not patching, --root or --prefix is installing Distribute'
-                 ' in another location')
-        return
-
-    # let's see if its an egg
-    if not setuptools_location.endswith('.egg'):
-        log.warn('Non-egg installation')
-        res = _remove_flat_installation(setuptools_location)
-        if not res:
-            return
-    else:
-        log.warn('Egg installation')
-        pkg_info = os.path.join(setuptools_location, 'EGG-INFO', 'PKG-INFO')
-        if (os.path.exists(pkg_info) and
-            _same_content(pkg_info, SETUPTOOLS_PKG_INFO)):
-            log.warn('Already patched.')
-            return
-        log.warn('Patching...')
-        # let's create a fake egg replacing setuptools one
-        res = _patch_egg_dir(setuptools_location)
-        if not res:
-            return
-    log.warn('Patching complete.')
-    _relaunch()
-
-
-def _relaunch():
-    log.warn('Relaunching...')
-    # we have to relaunch the process
-    # pip marker to avoid a relaunch bug
-    _cmd1 = ['-c', 'install', '--single-version-externally-managed']
-    _cmd2 = ['-c', 'install', '--record']
-    if sys.argv[:3] == _cmd1 or sys.argv[:3] == _cmd2:
-        sys.argv[0] = 'setup.py'
-    args = [sys.executable] + sys.argv
-    sys.exit(subprocess.call(args))
-
-
-def _extractall(self, path=".", members=None):
-    """Extract all members from the archive to the current working
-       directory and set owner, modification time and permissions on
-       directories afterwards. `path' specifies a different directory
-       to extract to. `members' is optional and must be a subset of the
-       list returned by getmembers().
-    """
-    import copy
-    import operator
-    from tarfile import ExtractError
-    directories = []
-
-    if members is None:
-        members = self
-
-    for tarinfo in members:
-        if tarinfo.isdir():
-            # Extract directories with a safe mode.
-            directories.append(tarinfo)
-            tarinfo = copy.copy(tarinfo)
-            tarinfo.mode = 448  # decimal for oct 0700
-        self.extract(tarinfo, path)
-
-    # Reverse sort directories.
-    if sys.version_info < (2, 4):
-        def sorter(dir1, dir2):
-            return cmp(dir1.name, dir2.name)
-        directories.sort(sorter)
-        directories.reverse()
-    else:
-        directories.sort(key=operator.attrgetter('name'), reverse=True)
-
-    # Set correct owner, mtime and filemode on directories.
-    for tarinfo in directories:
-        dirpath = os.path.join(path, tarinfo.name)
-        try:
-            self.chown(tarinfo, dirpath)
-            self.utime(tarinfo, dirpath)
-            self.chmod(tarinfo, dirpath)
-        except ExtractError:
-            e = sys.exc_info()[1]
-            if self.errorlevel > 1:
-                raise
-            else:
-                self._dbg(1, "tarfile: %s" % e)
-
-
-def _build_install_args(options):
-    """
-    Build the arguments to 'python setup.py install' on the distribute package
-    """
-    install_args = []
-    if options.user_install:
-        if sys.version_info < (2, 6):
-            log.warn("--user requires Python 2.6 or later")
-            raise SystemExit(1)
-        install_args.append('--user')
-    return install_args
-
-def _parse_args():
-    """
-    Parse the command line for options
-    """
-    parser = optparse.OptionParser()
-    parser.add_option(
-        '--user', dest='user_install', action='store_true', default=False,
-        help='install in user site package (requires Python 2.6 or later)')
-    parser.add_option(
-        '--download-base', dest='download_base', metavar="URL",
-        default=DEFAULT_URL,
-        help='alternative URL from where to download the distribute package')
-    options, args = parser.parse_args()
-    # positional arguments are ignored
-    return options
-
-def main(version=DEFAULT_VERSION):
-    """Install or upgrade setuptools and EasyInstall"""
-    options = _parse_args()
-    tarball = download_setuptools(download_base=options.download_base)
-    return _install(tarball, _build_install_args(options))
-
-if __name__ == '__main__':
-    sys.exit(main())
diff --git a/doc/faq.rst b/doc/faq.rst
index cd4b4c5..a674e8f 100644
--- a/doc/faq.rst
+++ b/doc/faq.rst
@@ -38,3 +38,71 @@ avoid this, use::
  
 This will iterate through reads as they appear in the file.
 
+Weirdness with spliced reads in samfile.pileup(chr,start,end) given spliced alignments from an RNA-seq bam file
+===============================================================================================================
+
+Spliced reads are reported within samfile.pileup. To ignore these
+in your analysis, test the flags ``is_del == True and indel=0``
+in the :class:`~.PileupRead` object.
+
+I can't edit quality scores in place
+====================================
+
+Editing reads in-place generally works, though there is some
+quirk to be aware of. Assigning to AlignedRead.seq will invalidate 
+any quality scores in AlignedRead.qual. The reason is that samtools
+manages the memory of the sequence and quality scores together 
+and thus requires them to always be of the same length or 0.
+
+Thus, to in-place edit the sequence and quality scores, copies of
+the quality scores need to be taken. Consider trimming for example::
+
+    q = read.qual
+    read.seq = read.seq[5:10]
+    read.qual = q[5:10]
+ 
+
+Why is there no SNPCaller class anymore?
+=========================================
+
+SNP calling is highly complex and heavily parameterized. There was a
+danger that the pysam implementations might show different behaviour from the
+samtools implementation, which would have caused a lot of confusion.
+
+The best way to use samtools SNP calling from python is to use the 
+:meth:`pysam.mpileup` command and parse the output  directly.
+
+I get an error 'PileupProxy accessed after iterator finished'
+=============================================================
+
+Pysam works by providing proxy objects to objects defined within
+the C-samtools package. Thus, some attention must be paid at the
+lifetime of objects. The following to code snippets will cause an
+error::
+
+    s = Samfile( 'ex1.bam' )
+    for p in s.pileup('chr1', 1000,1010):
+        pass
+    
+    for pp in p.pileups:
+        print pp
+
+The iteration has finished, thus the contents of p are invalid. A
+variation of this::
+
+    p = Samfile( 'ex1.bam' ).pileup( 'chr1', 1000, 1010).next()
+    for pp in p.pileups:
+        print pp
+
+Again, the iteration finishes as the temporary iterator created
+by pileup goes out of scope. The solution is to keep a handle
+to the iterator that remains alive::
+
+    i = Samfile( 'ex1.bam' ).pileup( 'chr1', 1000, 1010)
+    p = i.next()
+    for pp in p.pileups:
+        print pp
+
+
+
+
diff --git a/doc/release.rst b/doc/release.rst
index 58a58aa..3413c1f 100644
--- a/doc/release.rst
+++ b/doc/release.rst
@@ -2,6 +2,14 @@
 Release notes
 =============
 
+Release 0.7.6
+=============
+
+   * added inferred_length property
+   * issue 122: MACOSX getline missing, now it works?
+   * seq and qual can be set None
+   * added Fastqfile
+
 Release 0.7.5
 =============
 
diff --git a/doc/usage.rst b/doc/usage.rst
index e438015..a3bc1c9 100644
--- a/doc/usage.rst
+++ b/doc/usage.rst
@@ -267,11 +267,8 @@ and consists of three files:
 	 return Extension(name = modname,
 			  sources=[pyxfilename],
 			  extra_link_args=[ os.path.join( dirname, "csamtools.so")],
-			  include_dirs = ['../samtools', 
-					  '../pysam',
-					  ] )
-
-
+			  include_dirs =  pysam.get_include(),
+			  define_macros = pysam.get_defines() )
 
 If the script :file:`pysam_flagstat.py` is called the first time, pyximport_ will 
 compile the cython_ extension :file:`_pysam_flagstat.pyx` and make it available 
diff --git a/pysam.egg-info/PKG-INFO b/pysam.egg-info/PKG-INFO
index 8d8f7c5..dbb2aed 100644
--- a/pysam.egg-info/PKG-INFO
+++ b/pysam.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: pysam
-Version: 0.7.5
+Version: 0.7.6
 Summary: pysam
 Home-page: http://code.google.com/p/pysam/
 Author: Andreas Heger
diff --git a/pysam.egg-info/SOURCES.txt b/pysam.egg-info/SOURCES.txt
index dcf1ced..49dc1f3 100644
--- a/pysam.egg-info/SOURCES.txt
+++ b/pysam.egg-info/SOURCES.txt
@@ -3,7 +3,6 @@ INSTALL
 KNOWN_BUGS
 MANIFEST.in
 THANKS
-distribute_setup.py
 pysam.py
 setup.cfg
 setup.py
diff --git a/pysam/TabProxies.c b/pysam/TabProxies.c
index 7c87ba2..099e19e 100644
--- a/pysam/TabProxies.c
+++ b/pysam/TabProxies.c
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.18 on Fri Jun 28 06:37:45 2013 */
+/* Generated by Cython 0.18 on Fri Sep 20 00:20:26 2013 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
@@ -342,8 +342,8 @@ static const char *__pyx_f[] = {
 struct __pyx_obj_5pysam_10TabProxies_TupleProxy;
 struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy;
 struct __pyx_obj_5pysam_10TabProxies_BedProxy;
-struct __pyx_obj_5pysam_10TabProxies_VCFProxy;
 struct __pyx_obj_5pysam_10TabProxies_GTFProxy;
+struct __pyx_obj_5pysam_10TabProxies_VCFProxy;
 
 /* "pysam/TabProxies.pxd":41
  *   ctypedef int uint64_t
@@ -393,31 +393,31 @@ struct __pyx_obj_5pysam_10TabProxies_BedProxy {
 };
 
 
-/* "pysam/TabProxies.pxd":83
+/* "pysam/TabProxies.pxd":60
  *     cdef update( self, char * buffer, size_t nbytes )
  * 
- * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
  * 
  *     cdef:
  */
-struct __pyx_obj_5pysam_10TabProxies_VCFProxy {
-  struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
-  char *contig;
-  uint32_t pos;
+struct __pyx_obj_5pysam_10TabProxies_GTFProxy {
+  struct __pyx_obj_5pysam_10TabProxies_TupleProxy __pyx_base;
+  char *_attributes;
+  int hasOwnAttributes;
 };
 
 
-/* "pysam/TabProxies.pxd":60
+/* "pysam/TabProxies.pxd":83
  *     cdef update( self, char * buffer, size_t nbytes )
  * 
- * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
  * 
  *     cdef:
  */
-struct __pyx_obj_5pysam_10TabProxies_GTFProxy {
-  struct __pyx_obj_5pysam_10TabProxies_TupleProxy __pyx_base;
-  char *_attributes;
-  int hasOwnAttributes;
+struct __pyx_obj_5pysam_10TabProxies_VCFProxy {
+  struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
+  char *contig;
+  uint32_t pos;
 };
 
 
@@ -454,32 +454,32 @@ struct __pyx_vtabstruct_5pysam_10TabProxies_NamedTupleProxy {
 static struct __pyx_vtabstruct_5pysam_10TabProxies_NamedTupleProxy *__pyx_vtabptr_5pysam_10TabProxies_NamedTupleProxy;
 
 
-/* "pysam/TabProxies.pyx":656
- *         TupleProxy._setindex(self, idx, str(value) )
+/* "pysam/TabProxies.pyx":590
+ *         return f( self.fields[idx] )
  * 
- * cdef class VCFProxy( NamedTupleProxy ):             # <<<<<<<<<<<<<<
- *     '''Proxy class for access to VCF fields.
+ * cdef class BedProxy( NamedTupleProxy ):             # <<<<<<<<<<<<<<
+ *     '''Proxy class for access to Bed fields.
  * 
  */
 
-struct __pyx_vtabstruct_5pysam_10TabProxies_VCFProxy {
+struct __pyx_vtabstruct_5pysam_10TabProxies_BedProxy {
   struct __pyx_vtabstruct_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
 };
-static struct __pyx_vtabstruct_5pysam_10TabProxies_VCFProxy *__pyx_vtabptr_5pysam_10TabProxies_VCFProxy;
+static struct __pyx_vtabstruct_5pysam_10TabProxies_BedProxy *__pyx_vtabptr_5pysam_10TabProxies_BedProxy;
 
 
-/* "pysam/TabProxies.pyx":590
- *         return f( self.fields[idx] )
+/* "pysam/TabProxies.pyx":656
+ *         TupleProxy._setindex(self, idx, str(value) )
  * 
- * cdef class BedProxy( NamedTupleProxy ):             # <<<<<<<<<<<<<<
- *     '''Proxy class for access to Bed fields.
+ * cdef class VCFProxy( NamedTupleProxy ):             # <<<<<<<<<<<<<<
+ *     '''Proxy class for access to VCF fields.
  * 
  */
 
-struct __pyx_vtabstruct_5pysam_10TabProxies_BedProxy {
+struct __pyx_vtabstruct_5pysam_10TabProxies_VCFProxy {
   struct __pyx_vtabstruct_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
 };
-static struct __pyx_vtabstruct_5pysam_10TabProxies_BedProxy *__pyx_vtabptr_5pysam_10TabProxies_BedProxy;
+static struct __pyx_vtabstruct_5pysam_10TabProxies_VCFProxy *__pyx_vtabptr_5pysam_10TabProxies_VCFProxy;
 
 
 /* "pysam/TabProxies.pyx":326
diff --git a/pysam/TabProxies.pyx b/pysam/TabProxies.pyx
index 396445b..b83e58b 100644
--- a/pysam/TabProxies.pyx
+++ b/pysam/TabProxies.pyx
@@ -169,7 +169,7 @@ cdef class TupleProxy:
         cdef char * old_pos
         cdef int field
         cdef int max_fields, x
-        
+
         assert strlen(buffer) == nbytes
 
         if buffer[nbytes] != 0:
diff --git a/pysam/csamtools.c b/pysam/csamtools.c
index 99a0350..66c8778 100644
--- a/pysam/csamtools.c
+++ b/pysam/csamtools.c
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.18 on Fri Jun 28 06:37:45 2013 */
+/* Generated by Cython 0.18 on Fri Sep 20 00:20:26 2013 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
@@ -347,30 +347,32 @@ static const char *__pyx_f[] = {
 };
 
 /*--- Type declarations ---*/
-struct __pyx_obj_5pysam_9csamtools_PileupRead;
-struct __pyx_obj_5pysam_9csamtools___pyx_scope_struct__genexpr;
 struct __pyx_obj_5pysam_9csamtools_IteratorRow;
-struct __pyx_obj_5pysam_9csamtools_IteratorRowRegion;
-struct __pyx_obj_5pysam_9csamtools___pyx_scope_struct_1_genexpr;
-struct __pyx_obj_5pysam_9csamtools_Samfile;
+struct __pyx_obj_5pysam_9csamtools_IteratorRowAllRefs;
+struct __pyx_obj_5pysam_9csamtools_SNPCall;
+struct __pyx_obj_5pysam_9csamtools_AlignedRead;
+struct __pyx_obj_5pysam_9csamtools_Fastqfile;
+struct __pyx_obj_5pysam_9csamtools_IteratorRowSelection;
+struct __pyx_obj_5pysam_9csamtools_IndexedReads;
+struct __pyx_obj_5pysam_9csamtools_IteratorRowAll;
 struct __pyx_obj_5pysam_9csamtools_IteratorColumn;
+struct __pyx_obj_5pysam_9csamtools_IteratorColumnRegion;
+struct __pyx_obj_5pysam_9csamtools_Samfile;
+struct __pyx_obj_5pysam_9csamtools___pyx_scope_struct_1_genexpr;
 struct __pyx_obj_5pysam_9csamtools_IteratorColumnAllRefs;
 struct __pyx_obj_5pysam_9csamtools_Fastafile;
+struct __pyx_obj_5pysam_9csamtools___pyx_scope_struct__genexpr;
 struct __pyx_obj_5pysam_9csamtools_PileupProxy;
-struct __pyx_obj_5pysam_9csamtools_IndexedReads;
-struct __pyx_obj_5pysam_9csamtools_IteratorRowAll;
-struct __pyx_obj_5pysam_9csamtools_IteratorColumnRegion;
-struct __pyx_obj_5pysam_9csamtools_IteratorRowAllRefs;
-struct __pyx_obj_5pysam_9csamtools_AlignedRead;
-struct __pyx_obj_5pysam_9csamtools_SNPCall;
-struct __pyx_obj_5pysam_9csamtools_IteratorRowSelection;
+struct __pyx_obj_5pysam_9csamtools_PileupRead;
+struct __pyx_obj_5pysam_9csamtools_FastqProxy;
+struct __pyx_obj_5pysam_9csamtools_IteratorRowRegion;
 struct __pyx_t_5pysam_9csamtools___iterdata;
 typedef struct __pyx_t_5pysam_9csamtools___iterdata __pyx_t_5pysam_9csamtools___iterdata;
 struct __pyx_opt_args_5pysam_9csamtools_14IteratorColumn_setupIteratorData;
 struct __pyx_t_5pysam_9csamtools_MateData;
 typedef struct __pyx_t_5pysam_9csamtools_MateData __pyx_t_5pysam_9csamtools_MateData;
 
-/* "pysam/csamtools.pxd":394
+/* "pysam/csamtools.pxd":414
  * # Utility types
  * 
  * ctypedef struct __iterdata:             # <<<<<<<<<<<<<<
@@ -386,7 +388,7 @@ struct __pyx_t_5pysam_9csamtools___iterdata {
   int seq_len;
 };
 
-/* "pysam/csamtools.pxd":523
+/* "pysam/csamtools.pxd":554
  *     cdef char * getSequence( self )
  *     cdef setMask( self, mask )
  *     cdef setupIteratorData( self,             # <<<<<<<<<<<<<<
@@ -398,7 +400,7 @@ struct __pyx_opt_args_5pysam_9csamtools_14IteratorColumn_setupIteratorData {
   int reopen;
 };
 
-/* "pysam/csamtools.pyx":518
+/* "pysam/csamtools.pyx":644
  *      counter[0] += 1;
  * 
  * ctypedef struct MateData:             # <<<<<<<<<<<<<<
@@ -411,113 +413,133 @@ struct __pyx_t_5pysam_9csamtools_MateData {
   uint32_t flag;
 };
 
-/* "pysam/csamtools.pxd":455
- *     cdef int n_pu
+/* "pysam/csamtools.pxd":495
+ *     cdef uint32_t _is_tail
+ * 
+ * cdef class IteratorRow:             # <<<<<<<<<<<<<<
+ *     pass
  * 
- * cdef class PileupRead:             # <<<<<<<<<<<<<<
- *     cdef AlignedRead _alignment
- *     cdef int32_t  _qpos
  */
-struct __pyx_obj_5pysam_9csamtools_PileupRead {
+struct __pyx_obj_5pysam_9csamtools_IteratorRow {
   PyObject_HEAD
-  struct __pyx_obj_5pysam_9csamtools_AlignedRead *_alignment;
-  int32_t _qpos;
-  int _indel;
-  int _level;
-  uint32_t _is_del;
-  uint32_t _is_head;
-  uint32_t _is_tail;
 };
 
 
-/* "pysam/csamtools.pyx":140
- * cdef char* CODE2CIGAR= "MIDNSHP=X"
- * if IS_PYTHON3:
- *     CIGAR2CODE = dict( [y,x] for x,y in enumerate( CODE2CIGAR) )             # <<<<<<<<<<<<<<
- * else:
- *     CIGAR2CODE = dict( [ord(y),x] for x,y in enumerate( CODE2CIGAR) )
+/* "pysam/csamtools.pxd":518
+ *     cdef int cnext(self)
+ * 
+ * cdef class IteratorRowAllRefs(IteratorRow):             # <<<<<<<<<<<<<<
+ *     cdef Samfile     samfile
+ *     cdef int         tid
  */
-struct __pyx_obj_5pysam_9csamtools___pyx_scope_struct__genexpr {
+struct __pyx_obj_5pysam_9csamtools_IteratorRowAllRefs {
+  struct __pyx_obj_5pysam_9csamtools_IteratorRow __pyx_base;
+  struct __pyx_obj_5pysam_9csamtools_Samfile *samfile;
+  int tid;
+  struct __pyx_obj_5pysam_9csamtools_IteratorRowRegion *rowiter;
+};
+
+
+/* "pysam/csamtools.pyx":3467
+ *     return retval, out_stderr, out_stdout
+ * 
+ * cdef class SNPCall:             # <<<<<<<<<<<<<<
+ *     '''the results of a SNP call.'''
+ *     cdef int _tid
+ */
+struct __pyx_obj_5pysam_9csamtools_SNPCall {
   PyObject_HEAD
-  PyObject *__pyx_v_x;
-  PyObject *__pyx_v_y;
-  PyObject *__pyx_t_0;
-  PyObject *__pyx_t_1;
-  PyObject *(*__pyx_t_2)(PyObject *);
+  int _tid;
+  int _pos;
+  char _reference_base;
+  char _genotype;
+  int _consensus_quality;
+  int _snp_quality;
+  int _rms_mapping_quality;
+  int _coverage;
 };
 
 
-/* "pysam/csamtools.pxd":464
- *     cdef uint32_t _is_tail
+/* "pysam/csamtools.pxd":446
+ *     cdef int cnext(self)
  * 
- * cdef class IteratorRow:             # <<<<<<<<<<<<<<
- *     pass
+ * cdef class AlignedRead:             # <<<<<<<<<<<<<<
  * 
+ *     # object that this AlignedRead represents
  */
-struct __pyx_obj_5pysam_9csamtools_IteratorRow {
+struct __pyx_obj_5pysam_9csamtools_AlignedRead {
   PyObject_HEAD
+  bam1_t *_delegate;
 };
 
 
-/* "pysam/csamtools.pxd":467
- *     pass
+/* "pysam/csamtools.pxd":438
+ *     cdef kseq_t * _delegate
  * 
- * cdef class IteratorRowRegion(IteratorRow):             # <<<<<<<<<<<<<<
- *     cdef bam_iter_t             iter # iterator state object
- *     cdef bam1_t *               b
+ * cdef class Fastqfile:             # <<<<<<<<<<<<<<
+ *     cdef char * _filename
+ *     cdef gzFile fastqfile
  */
-struct __pyx_obj_5pysam_9csamtools_IteratorRowRegion {
+struct __pyx_obj_5pysam_9csamtools_Fastqfile {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_5pysam_9csamtools_Fastqfile *__pyx_vtab;
+  char *_filename;
+  gzFile fastqfile;
+  kseq_t *entry;
+};
+
+
+/* "pysam/csamtools.pxd":523
+ *     cdef IteratorRowRegion rowiter
+ * 
+ * cdef class IteratorRowSelection(IteratorRow):             # <<<<<<<<<<<<<<
+ *     cdef bam1_t * b
+ *     cdef int current_pos
+ */
+struct __pyx_obj_5pysam_9csamtools_IteratorRowSelection {
   struct __pyx_obj_5pysam_9csamtools_IteratorRow __pyx_base;
-  struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowRegion *__pyx_vtab;
-  bam_iter_t iter;
+  struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowSelection *__pyx_vtab;
   bam1_t *b;
-  int retval;
-  struct __pyx_obj_5pysam_9csamtools_Samfile *samfile;
+  int current_pos;
   samfile_t *fp;
+  PyObject *positions;
   int owns_samfile;
 };
 
 
-/* "pysam/csamtools.pyx":142
- *     CIGAR2CODE = dict( [y,x] for x,y in enumerate( CODE2CIGAR) )
- * else:
- *     CIGAR2CODE = dict( [ord(y),x] for x,y in enumerate( CODE2CIGAR) )             # <<<<<<<<<<<<<<
- * CIGAR_REGEX = re.compile( "(\d+)([MIDNSHP=X])" )
+/* "pysam/csamtools.pxd":570
+ *     pass
  * 
+ * cdef class IndexedReads:             # <<<<<<<<<<<<<<
+ *     cdef Samfile samfile
+ *     cdef samfile_t * fp
  */
-struct __pyx_obj_5pysam_9csamtools___pyx_scope_struct_1_genexpr {
+struct __pyx_obj_5pysam_9csamtools_IndexedReads {
   PyObject_HEAD
-  PyObject *__pyx_v_x;
-  PyObject *__pyx_v_y;
-  PyObject *__pyx_t_0;
-  PyObject *__pyx_t_1;
-  PyObject *(*__pyx_t_2)(PyObject *);
+  struct __pyx_obj_5pysam_9csamtools_Samfile *samfile;
+  samfile_t *fp;
+  PyObject *index;
+  int owns_samfile;
 };
 
 
-/* "pysam/csamtools.pxd":420
- *     cdef bam1_t * _delegate
+/* "pysam/csamtools.pxd":511
+ *     cdef int cnext(self)
  * 
- * cdef class Samfile:             # <<<<<<<<<<<<<<
- *     cdef char * _filename
- *     # pointer to samfile
+ * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
+ *     cdef bam1_t * b
+ *     cdef samfile_t * fp
  */
-struct __pyx_obj_5pysam_9csamtools_Samfile {
-  PyObject_HEAD
-  struct __pyx_vtabstruct_5pysam_9csamtools_Samfile *__pyx_vtab;
-  char *_filename;
-  samfile_t *samfile;
-  bam_index_t *index;
-  int isbam;
-  int isstream;
-  int isremote;
+struct __pyx_obj_5pysam_9csamtools_IteratorRowAll {
+  struct __pyx_obj_5pysam_9csamtools_IteratorRow __pyx_base;
+  struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowAll *__pyx_vtab;
   bam1_t *b;
-  char *mode;
-  int64_t start_offset;
+  samfile_t *fp;
+  int owns_samfile;
 };
 
 
-/* "pysam/csamtools.pxd":504
+/* "pysam/csamtools.pxd":535
  *     cdef int cnext(self)
  * 
  * cdef class IteratorColumn:             # <<<<<<<<<<<<<<
@@ -542,7 +564,61 @@ struct __pyx_obj_5pysam_9csamtools_IteratorColumn {
 };
 
 
-/* "pysam/csamtools.pxd":536
+/* "pysam/csamtools.pxd":562
+ *     cdef reset( self, tid, start, end )
+ * 
+ * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
+ *     cdef int start
+ *     cdef int end
+ */
+struct __pyx_obj_5pysam_9csamtools_IteratorColumnRegion {
+  struct __pyx_obj_5pysam_9csamtools_IteratorColumn __pyx_base;
+  int start;
+  int end;
+  int truncate;
+};
+
+
+/* "pysam/csamtools.pxd":451
+ *     cdef bam1_t * _delegate
+ * 
+ * cdef class Samfile:             # <<<<<<<<<<<<<<
+ *     cdef char * _filename
+ *     # pointer to samfile
+ */
+struct __pyx_obj_5pysam_9csamtools_Samfile {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_5pysam_9csamtools_Samfile *__pyx_vtab;
+  char *_filename;
+  samfile_t *samfile;
+  bam_index_t *index;
+  int isbam;
+  int isstream;
+  int isremote;
+  bam1_t *b;
+  char *mode;
+  int64_t start_offset;
+};
+
+
+/* "pysam/csamtools.pyx":142
+ *     CIGAR2CODE = dict( [y,x] for x,y in enumerate( CODE2CIGAR) )
+ * else:
+ *     CIGAR2CODE = dict( [ord(y),x] for x,y in enumerate( CODE2CIGAR) )             # <<<<<<<<<<<<<<
+ * CIGAR_REGEX = re.compile( "(\d+)([MIDNSHP=X])" )
+ * 
+ */
+struct __pyx_obj_5pysam_9csamtools___pyx_scope_struct_1_genexpr {
+  PyObject_HEAD
+  PyObject *__pyx_v_x;
+  PyObject *__pyx_v_y;
+  PyObject *__pyx_t_0;
+  PyObject *__pyx_t_1;
+  PyObject *(*__pyx_t_2)(PyObject *);
+};
+
+
+/* "pysam/csamtools.pxd":567
  *     cdef int truncate
  * 
  * cdef class IteratorColumnAllRefs(IteratorColumn):             # <<<<<<<<<<<<<<
@@ -554,7 +630,7 @@ struct __pyx_obj_5pysam_9csamtools_IteratorColumnAllRefs {
 };
 
 
-/* "pysam/csamtools.pxd":408
+/* "pysam/csamtools.pxd":428
  * # Note: need to declare all C fields and methods here
  * #
  * cdef class Fastafile:             # <<<<<<<<<<<<<<
@@ -569,7 +645,24 @@ struct __pyx_obj_5pysam_9csamtools_Fastafile {
 };
 
 
-/* "pysam/csamtools.pxd":449
+/* "pysam/csamtools.pyx":140
+ * cdef char* CODE2CIGAR= "MIDNSHP=X"
+ * if IS_PYTHON3:
+ *     CIGAR2CODE = dict( [y,x] for x,y in enumerate( CODE2CIGAR) )             # <<<<<<<<<<<<<<
+ * else:
+ *     CIGAR2CODE = dict( [ord(y),x] for x,y in enumerate( CODE2CIGAR) )
+ */
+struct __pyx_obj_5pysam_9csamtools___pyx_scope_struct__genexpr {
+  PyObject_HEAD
+  PyObject *__pyx_v_x;
+  PyObject *__pyx_v_y;
+  PyObject *__pyx_t_0;
+  PyObject *__pyx_t_1;
+  PyObject *(*__pyx_t_2)(PyObject *);
+};
+
+
+/* "pysam/csamtools.pxd":480
  *     cdef char * _getrname( self, int tid )
  * 
  * cdef class PileupProxy:             # <<<<<<<<<<<<<<
@@ -585,154 +678,91 @@ struct __pyx_obj_5pysam_9csamtools_PileupProxy {
 };
 
 
-/* "pysam/csamtools.pxd":539
- *     pass
+/* "pysam/csamtools.pxd":486
+ *     cdef int n_pu
  * 
- * cdef class IndexedReads:             # <<<<<<<<<<<<<<
- *     cdef Samfile samfile
- *     cdef samfile_t * fp
+ * cdef class PileupRead:             # <<<<<<<<<<<<<<
+ *     cdef AlignedRead _alignment
+ *     cdef int32_t  _qpos
  */
-struct __pyx_obj_5pysam_9csamtools_IndexedReads {
+struct __pyx_obj_5pysam_9csamtools_PileupRead {
   PyObject_HEAD
-  struct __pyx_obj_5pysam_9csamtools_Samfile *samfile;
-  samfile_t *fp;
-  PyObject *index;
-  int owns_samfile;
-};
-
-
-/* "pysam/csamtools.pxd":480
- *     cdef int cnext(self)
- * 
- * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
- *     cdef bam1_t * b
- *     cdef samfile_t * fp
- */
-struct __pyx_obj_5pysam_9csamtools_IteratorRowAll {
-  struct __pyx_obj_5pysam_9csamtools_IteratorRow __pyx_base;
-  struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowAll *__pyx_vtab;
-  bam1_t *b;
-  samfile_t *fp;
-  int owns_samfile;
-};
-
-
-/* "pysam/csamtools.pxd":531
- *     cdef reset( self, tid, start, end )
- * 
- * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
- *     cdef int start
- *     cdef int end
- */
-struct __pyx_obj_5pysam_9csamtools_IteratorColumnRegion {
-  struct __pyx_obj_5pysam_9csamtools_IteratorColumn __pyx_base;
-  int start;
-  int end;
-  int truncate;
-};
-
-
-/* "pysam/csamtools.pxd":487
- *     cdef int cnext(self)
- * 
- * cdef class IteratorRowAllRefs(IteratorRow):             # <<<<<<<<<<<<<<
- *     cdef Samfile     samfile
- *     cdef int         tid
- */
-struct __pyx_obj_5pysam_9csamtools_IteratorRowAllRefs {
-  struct __pyx_obj_5pysam_9csamtools_IteratorRow __pyx_base;
-  struct __pyx_obj_5pysam_9csamtools_Samfile *samfile;
-  int tid;
-  struct __pyx_obj_5pysam_9csamtools_IteratorRowRegion *rowiter;
+  struct __pyx_obj_5pysam_9csamtools_AlignedRead *_alignment;
+  int32_t _qpos;
+  int _indel;
+  int _level;
+  uint32_t _is_del;
+  uint32_t _is_head;
+  uint32_t _is_tail;
 };
 
 
-/* "pysam/csamtools.pxd":415
+/* "pysam/csamtools.pxd":435
  *     cdef char * _fetch( self, char * reference, int start, int end, int * length )
  * 
- * cdef class AlignedRead:             # <<<<<<<<<<<<<<
+ * cdef class FastqProxy:             # <<<<<<<<<<<<<<
+ *     cdef kseq_t * _delegate
  * 
- *     # object that this AlignedRead represents
  */
-struct __pyx_obj_5pysam_9csamtools_AlignedRead {
+struct __pyx_obj_5pysam_9csamtools_FastqProxy {
   PyObject_HEAD
-  bam1_t *_delegate;
+  kseq_t *_delegate;
 };
 
 
-/* "pysam/csamtools.pyx":3250
- *     return retval, out_stderr, out_stdout
- * 
- * cdef class SNPCall:             # <<<<<<<<<<<<<<
- *     '''the results of a SNP call.'''
- *     cdef int _tid
- */
-struct __pyx_obj_5pysam_9csamtools_SNPCall {
-  PyObject_HEAD
-  int _tid;
-  int _pos;
-  char _reference_base;
-  char _genotype;
-  int _consensus_quality;
-  int _snp_quality;
-  int _rms_mapping_quality;
-  int _coverage;
-};
-
-
-/* "pysam/csamtools.pxd":492
- *     cdef IteratorRowRegion rowiter
+/* "pysam/csamtools.pxd":498
+ *     pass
  * 
- * cdef class IteratorRowSelection(IteratorRow):             # <<<<<<<<<<<<<<
- *     cdef bam1_t * b
- *     cdef int current_pos
+ * cdef class IteratorRowRegion(IteratorRow):             # <<<<<<<<<<<<<<
+ *     cdef bam_iter_t             iter # iterator state object
+ *     cdef bam1_t *               b
  */
-struct __pyx_obj_5pysam_9csamtools_IteratorRowSelection {
+struct __pyx_obj_5pysam_9csamtools_IteratorRowRegion {
   struct __pyx_obj_5pysam_9csamtools_IteratorRow __pyx_base;
-  struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowSelection *__pyx_vtab;
+  struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowRegion *__pyx_vtab;
+  bam_iter_t iter;
   bam1_t *b;
-  int current_pos;
+  int retval;
+  struct __pyx_obj_5pysam_9csamtools_Samfile *samfile;
   samfile_t *fp;
-  PyObject *positions;
   int owns_samfile;
 };
 
 
 
-/* "pysam/csamtools.pyx":545
+/* "pysam/csamtools.pyx":1921
+ *     return ret
  * 
+ * cdef class IteratorColumn:             # <<<<<<<<<<<<<<
+ *     '''abstract base class for iterators over columns.
  * 
- * cdef class Samfile:             # <<<<<<<<<<<<<<
- *     '''*(filename, mode=None, template = None, referencenames = None, referencelengths = None, text = NULL, header = None,
- *          add_sq_text = False, check_header = True, check_sq = True )*
  */
 
-struct __pyx_vtabstruct_5pysam_9csamtools_Samfile {
-  bam_header_t *(*_buildHeader)(struct __pyx_obj_5pysam_9csamtools_Samfile *, PyObject *);
-  bam1_t *(*getCurrent)(struct __pyx_obj_5pysam_9csamtools_Samfile *);
-  int (*cnext)(struct __pyx_obj_5pysam_9csamtools_Samfile *);
-  int (*write)(struct __pyx_obj_5pysam_9csamtools_Samfile *, struct __pyx_obj_5pysam_9csamtools_AlignedRead *, int __pyx_skip_dispatch);
-  char *(*_getrname)(struct __pyx_obj_5pysam_9csamtools_Samfile *, int);
+struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumn {
+  int (*cnext)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *);
+  char *(*getSequence)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *);
+  PyObject *(*setMask)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *, PyObject *);
+  PyObject *(*setupIteratorData)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *, int, int, int, struct __pyx_opt_args_5pysam_9csamtools_14IteratorColumn_setupIteratorData *__pyx_optional_args);
+  PyObject *(*reset)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *, PyObject *, PyObject *, PyObject *);
 };
-static struct __pyx_vtabstruct_5pysam_9csamtools_Samfile *__pyx_vtabptr_5pysam_9csamtools_Samfile;
+static struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumn *__pyx_vtabptr_5pysam_9csamtools_IteratorColumn;
 
 
-/* "pysam/csamtools.pyx":1545
- *         if self.owns_samfile: samclose( self.fp )
- * 
- * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
- *     """*(Samfile samfile, int reopen = True)*
+/* "pysam/csamtools.pyx":2083
+ *             self.iterdata.seq = NULL
  * 
+ * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
+ *     '''iterates over a region only.
+ *     '''
  */
 
-struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowAll {
-  bam1_t *(*getCurrent)(struct __pyx_obj_5pysam_9csamtools_IteratorRowAll *);
-  int (*cnext)(struct __pyx_obj_5pysam_9csamtools_IteratorRowAll *);
+struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnRegion {
+  struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumn __pyx_base;
 };
-static struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowAll *__pyx_vtabptr_5pysam_9csamtools_IteratorRowAll;
+static struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnRegion *__pyx_vtabptr_5pysam_9csamtools_IteratorColumnRegion;
 
 
-/* "pysam/csamtools.pyx":1466
+/* "pysam/csamtools.pyx":1597
  * 
  * 
  * cdef class IteratorRowRegion(IteratorRow):             # <<<<<<<<<<<<<<
@@ -747,39 +777,51 @@ struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowRegion {
 static struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowRegion *__pyx_vtabptr_5pysam_9csamtools_IteratorRowRegion;
 
 
-/* "pysam/csamtools.pyx":1771
- *     return ret
+/* "pysam/csamtools.pyx":1792
+ *                 raise StopIteration
  * 
- * cdef class IteratorColumn:             # <<<<<<<<<<<<<<
- *     '''abstract base class for iterators over columns.
+ * cdef class IteratorRowSelection(IteratorRow):             # <<<<<<<<<<<<<<
+ *     """*(Samfile samfile)*
  * 
  */
 
-struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumn {
-  int (*cnext)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *);
-  char *(*getSequence)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *);
-  PyObject *(*setMask)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *, PyObject *);
-  PyObject *(*setupIteratorData)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *, int, int, int, struct __pyx_opt_args_5pysam_9csamtools_14IteratorColumn_setupIteratorData *__pyx_optional_args);
-  PyObject *(*reset)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *, PyObject *, PyObject *, PyObject *);
+struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowSelection {
+  bam1_t *(*getCurrent)(struct __pyx_obj_5pysam_9csamtools_IteratorRowSelection *);
+  int (*cnext)(struct __pyx_obj_5pysam_9csamtools_IteratorRowSelection *);
 };
-static struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumn *__pyx_vtabptr_5pysam_9csamtools_IteratorColumn;
+static struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowSelection *__pyx_vtabptr_5pysam_9csamtools_IteratorRowSelection;
 
 
-/* "pysam/csamtools.pyx":1936
- *             self.iterdata.seq = NULL
+/* "pysam/csamtools.pyx":382
+ * ## Public methods
+ * ######################################################################
+ * cdef class Fastafile:             # <<<<<<<<<<<<<<
+ *     '''*(filename)*
  * 
- * cdef class IteratorColumnRegion(IteratorColumn):             # <<<<<<<<<<<<<<
- *     '''iterates over a region only.
- *     '''
  */
 
-struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnRegion {
-  struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumn __pyx_base;
+struct __pyx_vtabstruct_5pysam_9csamtools_Fastafile {
+  char *(*_fetch)(struct __pyx_obj_5pysam_9csamtools_Fastafile *, char *, int, int, int *);
 };
-static struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnRegion *__pyx_vtabptr_5pysam_9csamtools_IteratorColumnRegion;
+static struct __pyx_vtabstruct_5pysam_9csamtools_Fastafile *__pyx_vtabptr_5pysam_9csamtools_Fastafile;
+
+
+/* "pysam/csamtools.pyx":546
+ *             else: return None
+ * 
+ * cdef class Fastqfile:             # <<<<<<<<<<<<<<
+ *     '''*(filename)*
+ * 
+ */
+
+struct __pyx_vtabstruct_5pysam_9csamtools_Fastqfile {
+  kseq_t *(*getCurrent)(struct __pyx_obj_5pysam_9csamtools_Fastqfile *);
+  int (*cnext)(struct __pyx_obj_5pysam_9csamtools_Fastqfile *);
+};
+static struct __pyx_vtabstruct_5pysam_9csamtools_Fastqfile *__pyx_vtabptr_5pysam_9csamtools_Fastqfile;
 
 
-/* "pysam/csamtools.pyx":1973
+/* "pysam/csamtools.pyx":2120
  *                                      self.n_plp )
  * 
  * cdef class IteratorColumnAllRefs(IteratorColumn):             # <<<<<<<<<<<<<<
@@ -793,33 +835,37 @@ struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnAllRefs {
 static struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnAllRefs *__pyx_vtabptr_5pysam_9csamtools_IteratorColumnAllRefs;
 
 
-/* "pysam/csamtools.pyx":1646
- *                 raise StopIteration
+/* "pysam/csamtools.pyx":671
  * 
- * cdef class IteratorRowSelection(IteratorRow):             # <<<<<<<<<<<<<<
- *     """*(Samfile samfile)*
  * 
+ * cdef class Samfile:             # <<<<<<<<<<<<<<
+ *     '''*(filename, mode=None, template = None, referencenames = None, referencelengths = None, text = NULL, header = None,
+ *          add_sq_text = False, check_header = True, check_sq = True )*
  */
 
-struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowSelection {
-  bam1_t *(*getCurrent)(struct __pyx_obj_5pysam_9csamtools_IteratorRowSelection *);
-  int (*cnext)(struct __pyx_obj_5pysam_9csamtools_IteratorRowSelection *);
+struct __pyx_vtabstruct_5pysam_9csamtools_Samfile {
+  bam_header_t *(*_buildHeader)(struct __pyx_obj_5pysam_9csamtools_Samfile *, PyObject *);
+  bam1_t *(*getCurrent)(struct __pyx_obj_5pysam_9csamtools_Samfile *);
+  int (*cnext)(struct __pyx_obj_5pysam_9csamtools_Samfile *);
+  int (*write)(struct __pyx_obj_5pysam_9csamtools_Samfile *, struct __pyx_obj_5pysam_9csamtools_AlignedRead *, int __pyx_skip_dispatch);
+  char *(*_getrname)(struct __pyx_obj_5pysam_9csamtools_Samfile *, int);
 };
-static struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowSelection *__pyx_vtabptr_5pysam_9csamtools_IteratorRowSelection;
+static struct __pyx_vtabstruct_5pysam_9csamtools_Samfile *__pyx_vtabptr_5pysam_9csamtools_Samfile;
 
 
-/* "pysam/csamtools.pyx":375
- * ## Public methods
- * ######################################################################
- * cdef class Fastafile:             # <<<<<<<<<<<<<<
- *     '''*(filename)*
+/* "pysam/csamtools.pyx":1681
+ *         if self.owns_samfile: samclose( self.fp )
+ * 
+ * cdef class IteratorRowAll(IteratorRow):             # <<<<<<<<<<<<<<
+ *     """*(Samfile samfile, int reopen = True)*
  * 
  */
 
-struct __pyx_vtabstruct_5pysam_9csamtools_Fastafile {
-  char *(*_fetch)(struct __pyx_obj_5pysam_9csamtools_Fastafile *, char *, int, int, int *);
+struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowAll {
+  bam1_t *(*getCurrent)(struct __pyx_obj_5pysam_9csamtools_IteratorRowAll *);
+  int (*cnext)(struct __pyx_obj_5pysam_9csamtools_IteratorRowAll *);
 };
-static struct __pyx_vtabstruct_5pysam_9csamtools_Fastafile *__pyx_vtabptr_5pysam_9csamtools_Fastafile;
+static struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowAll *__pyx_vtabptr_5pysam_9csamtools_IteratorRowAll;
 #ifndef CYTHON_REFNANNY
   #define CYTHON_REFNANNY 0
 #endif
@@ -1441,6 +1487,8 @@ static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
 
 /* Module declarations from 'pysam.csamtools' */
 static PyTypeObject *__pyx_ptype_5pysam_9csamtools_Fastafile = 0;
+static PyTypeObject *__pyx_ptype_5pysam_9csamtools_FastqProxy = 0;
+static PyTypeObject *__pyx_ptype_5pysam_9csamtools_Fastqfile = 0;
 static PyTypeObject *__pyx_ptype_5pysam_9csamtools_AlignedRead = 0;
 static PyTypeObject *__pyx_ptype_5pysam_9csamtools_Samfile = 0;
 static PyTypeObject *__pyx_ptype_5pysam_9csamtools_PileupProxy = 0;
@@ -1470,6 +1518,7 @@ static PyObject *__pyx_f_5pysam_9csamtools__force_str(PyObject *); /*proto*/
 static PyObject *__pyx_f_5pysam_9csamtools_makeAlignedRead(bam1_t *); /*proto*/
 static PyObject *__pyx_f_5pysam_9csamtools_makePileupProxy(bam_pileup1_t **, int, int, int); /*proto*/
 static PyObject *__pyx_f_5pysam_9csamtools_makePileupRead(bam_pileup1_t *); /*proto*/
+static PyObject *__pyx_f_5pysam_9csamtools_makeFastqProxy(kseq_t *); /*proto*/
 static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *); /*proto*/
 static int __pyx_f_5pysam_9csamtools_fetch_callback(bam1_t *, void *); /*proto*/
 static int __pyx_f_5pysam_9csamtools_pileup_callback(uint32_t, uint32_t, int, bam_pileup1_t *, void *); /*proto*/
@@ -1493,6 +1542,7 @@ static PyObject *__pyx_builtin_ord;
 static PyObject *__pyx_builtin_map;
 static PyObject *__pyx_builtin_ValueError;
 static PyObject *__pyx_builtin_IOError;
+static PyObject *__pyx_builtin_StopIteration;
 static PyObject *__pyx_builtin_OverflowError;
 static PyObject *__pyx_builtin_NotImplementedError;
 static PyObject *__pyx_builtin_OSError;
@@ -1500,7 +1550,6 @@ static PyObject *__pyx_builtin_AttributeError;
 static PyObject *__pyx_builtin_zip;
 static PyObject *__pyx_builtin_sorted;
 static PyObject *__pyx_builtin_KeyError;
-static PyObject *__pyx_builtin_StopIteration;
 static PyObject *__pyx_builtin_min;
 static PyObject *__pyx_builtin_max;
 static PyObject *__pyx_builtin_chr;
@@ -1524,6 +1573,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_8close(struct __pyx_obj_5
 static void __pyx_pf_5pysam_9csamtools_9Fastafile_10__dealloc__(struct __pyx_obj_5pysam_9csamtools_Fastafile *__pyx_v_self); /* proto */
 static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_8filename___get__(struct __pyx_obj_5pysam_9csamtools_Fastafile *__pyx_v_self); /* proto */
 static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_12fetch(struct __pyx_obj_5pysam_9csamtools_Fastafile *__pyx_v_self, PyObject *__pyx_v_reference, PyObject *__pyx_v_start, PyObject *__pyx_v_end, PyObject *__pyx_v_region); /* proto */
+static int __pyx_pf_5pysam_9csamtools_10FastqProxy___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_9csamtools_FastqProxy *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5pysam_9csamtools_10FastqProxy_4name___get__(struct __pyx_obj_5pysam_9csamtools_FastqProxy *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5pysam_9csamtools_10FastqProxy_8sequence___get__(struct __pyx_obj_5pysam_9csamtools_FastqProxy *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5pysam_9csamtools_10FastqProxy_7comment___get__(struct __pyx_obj_5pysam_9csamtools_FastqProxy *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5pysam_9csamtools_10FastqProxy_7quality___get__(struct __pyx_obj_5pysam_9csamtools_FastqProxy *__pyx_v_self); /* proto */
+static int __pyx_pf_5pysam_9csamtools_9Fastqfile___cinit__(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_2_isOpen(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_4_open(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self, PyObject *__pyx_v_filename); /* proto */
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_6close(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self); /* proto */
+static void __pyx_pf_5pysam_9csamtools_9Fastqfile_8__dealloc__(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_8filename___get__(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_10__iter__(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_12__next__(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_14test(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self); /* proto */
 static int __pyx_pf_5pysam_9csamtools_7Samfile___cinit__(struct __pyx_obj_5pysam_9csamtools_Samfile *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs); /* proto */
 static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_2_isOpen(struct __pyx_obj_5pysam_9csamtools_Samfile *__pyx_v_self); /* proto */
 static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_4_hasIndex(struct __pyx_obj_5pysam_9csamtools_Samfile *__pyx_v_self); /* proto */
@@ -1652,6 +1715,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_9is_qcfail_2__set__(struct _
 static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12is_duplicate___get__(struct __pyx_obj_5pysam_9csamtools_AlignedRead *__pyx_v_self); /* proto */
 static int __pyx_pf_5pysam_9csamtools_11AlignedRead_12is_duplicate_2__set__(struct __pyx_obj_5pysam_9csamtools_AlignedRead *__pyx_v_self, PyObject *__pyx_v_val); /* proto */
 static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9positions___get__(struct __pyx_obj_5pysam_9csamtools_AlignedRead *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_15inferred_length___get__(struct __pyx_obj_5pysam_9csamtools_AlignedRead *__pyx_v_self); /* proto */
 static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get__(struct __pyx_obj_5pysam_9csamtools_AlignedRead *__pyx_v_self); /* proto */
 static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx_obj_5pysam_9csamtools_AlignedRead *__pyx_v_self, uint32_t __pyx_v_start, uint32_t __pyx_v_end); /* proto */
 static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj_5pysam_9csamtools_AlignedRead *__pyx_v_self, PyObject *__pyx_v_tag); /* proto */
@@ -1704,42 +1768,45 @@ static char __pyx_k_16[] = "";
 static char __pyx_k_17[] = "start out of range (%i)";
 static char __pyx_k_18[] = "end out of range (%i)";
 static char __pyx_k_19[] = "%s:%i-%i";
-static char __pyx_k_24[] = "invalid file opening mode `%s`";
-static char __pyx_k_26[] = "-";
-static char __pyx_k_27[] = "http:";
-static char __pyx_k_28[] = "ftp:";
-static char __pyx_k_29[] = "either supply options `template`, `header` or  both `referencenames` and `referencelengths` for writing";
-static char __pyx_k_30[] = "unequal names and lengths of reference sequences";
-static char __pyx_k_31[] = "@SQ\tSN:%s\tLN:%s\n";
-static char __pyx_k_32[] = "file `%s` not found";
-static char __pyx_k_33[] = "could not open file (mode='%s') - is it SAM/BAM format?";
-static char __pyx_k_34[] = "file does not have valid header (mode='%s') - is it BAM format?";
-static char __pyx_k_35[] = "file does not have valid header (mode='%s') - is it SAM format?";
-static char __pyx_k_36[] = "file header is empty (mode='%s') - is it SAM/BAM format?";
-static char __pyx_k_37[] = ".bai";
-static char __pyx_k_38[] = "error while opening index `%s` ";
-static char __pyx_k_41[] = "tid %i out of range 0<=tid<%i";
-static char __pyx_k_43[] = "[:-]";
-static char __pyx_k_45[] = "invalid reference `%s`";
-static char __pyx_k_46[] = "invalid coordinates: start (%i) > end (%i)";
-static char __pyx_k_48[] = "seek only available in bam files";
-static char __pyx_k_50[] = "seek no available in streams";
-static char __pyx_k_56[] = "fetch called on bamfile without index";
-static char __pyx_k_58[] = "callback functionality requires a region/reference";
-static char __pyx_k_60[] = "no index available for fetch";
-static char __pyx_k_62[] = "fetching by region is not available for sam files";
-static char __pyx_k_64[] = "callback not implemented yet";
-static char __pyx_k_66[] = "fetch called for samfile without header";
-static char __pyx_k_69[] = "read %s: is unpaired";
-static char __pyx_k_70[] = "mate %s: is unmapped";
-static char __pyx_k_71[] = "mate not found";
-static char __pyx_k_76[] = "counting functionality requires a region/reference";
-static char __pyx_k_79[] = "count for a region is not available for sam files";
-static char __pyx_k_82[] = "no index available for pileup";
-static char __pyx_k_85[] = "pileup of samfiles not implemented yet";
-static char __pyx_k_92[] = "Samfile.mapped only available in bam files";
-static char __pyx_k_94[] = "mapping information not recorded in index or index not available";
-static char __pyx_k_97[] = "Samfile.unmapped only available in bam files";
+static char __pyx_k_21[] = "No such file or directory: %s";
+static char __pyx_k_24[] = "name: %s\n";
+static char __pyx_k_25[] = "comment: %s\n";
+static char __pyx_k_26[] = "seq: %s\n";
+static char __pyx_k_27[] = "qual: %s\n";
+static char __pyx_k_28[] = "return value: %d\n";
+static char __pyx_k_32[] = "invalid file opening mode `%s`";
+static char __pyx_k_34[] = "-";
+static char __pyx_k_35[] = "http:";
+static char __pyx_k_36[] = "ftp:";
+static char __pyx_k_37[] = "either supply options `template`, `header` or  both `referencenames` and `referencelengths` for writing";
+static char __pyx_k_38[] = "unequal names and lengths of reference sequences";
+static char __pyx_k_39[] = "@SQ\tSN:%s\tLN:%s\n";
+static char __pyx_k_40[] = "file `%s` not found";
+static char __pyx_k_41[] = "could not open file (mode='%s') - is it SAM/BAM format?";
+static char __pyx_k_42[] = "file does not have valid header (mode='%s') - is it BAM format?";
+static char __pyx_k_43[] = "file does not have valid header (mode='%s') - is it SAM format?";
+static char __pyx_k_44[] = "file header is empty (mode='%s') - is it SAM/BAM format?";
+static char __pyx_k_45[] = ".bai";
+static char __pyx_k_46[] = "error while opening index `%s` ";
+static char __pyx_k_49[] = "tid %i out of range 0<=tid<%i";
+static char __pyx_k_51[] = "[:-]";
+static char __pyx_k_53[] = "invalid reference `%s`";
+static char __pyx_k_54[] = "invalid coordinates: start (%i) > end (%i)";
+static char __pyx_k_56[] = "seek only available in bam files";
+static char __pyx_k_58[] = "seek no available in streams";
+static char __pyx_k_64[] = "fetch called on bamfile without index";
+static char __pyx_k_66[] = "callback functionality requires a region/reference";
+static char __pyx_k_68[] = "no index available for fetch";
+static char __pyx_k_70[] = "fetching by region is not available for sam files";
+static char __pyx_k_72[] = "callback not implemented yet";
+static char __pyx_k_74[] = "fetch called for samfile without header";
+static char __pyx_k_77[] = "read %s: is unpaired";
+static char __pyx_k_78[] = "mate %s: is unmapped";
+static char __pyx_k_79[] = "mate not found";
+static char __pyx_k_84[] = "counting functionality requires a region/reference";
+static char __pyx_k_87[] = "count for a region is not available for sam files";
+static char __pyx_k_90[] = "no index available for pileup";
+static char __pyx_k_93[] = "pileup of samfiles not implemented yet";
 static char __pyx_k__A[] = "A";
 static char __pyx_k__B[] = "B";
 static char __pyx_k__C[] = "C";
@@ -1760,147 +1827,151 @@ static char __pyx_k__n[] = "n";
 static char __pyx_k__r[] = "r";
 static char __pyx_k__s[] = "s";
 static char __pyx_k__w[] = "w";
-static char __pyx_k_102[] = "@";
-static char __pyx_k_104[] = "header line without '@': '%s'";
-static char __pyx_k_106[] = "header line with invalid type '%s': '%s'";
-static char __pyx_k_107[] = ":";
-static char __pyx_k_108[] = "malformatted header: no ':' in field";
-static char __pyx_k_111[] = "unknown field code '%s' in record '%s'";
-static char __pyx_k_112[] = "multiple '%s' lines are not permitted";
-static char __pyx_k_113[] = "@%s";
-static char __pyx_k_114[] = "%s:%s";
-static char __pyx_k_115[] = "invalid type for record %s: %s, expected %s";
-static char __pyx_k_117[] = "incomplete sequence information in '%s'";
-static char __pyx_k_120[] = "can not iterate over samfile without header";
-static char __pyx_k_123[] = "no index available for iteration";
-static char __pyx_k_129[] = "can only use this iterator on bam files";
-static char __pyx_k_130[] = "reference sequence for '%s' (tid=%i) not found";
-static char __pyx_k_131[] = "unknown stepper option `%s` in IteratorColumn";
-static char __pyx_k_133[] = "error during iteration";
-static char __pyx_k_136[] = "Invalid clipping in CIGAR string";
-static char __pyx_k_139[] = "%i%c";
-static char __pyx_k_140[] = "quality and sequence mismatch: %i != %i";
-static char __pyx_k_141[] = "%c";
-static char __pyx_k_142[] = "<";
-static char __pyx_k_144[] = "integer %i out of range of BAM/SAM specification";
-static char __pyx_k_145[] = "2sccI%i%s";
-static char __pyx_k_149[] = "2sc%is";
-static char __pyx_k_151[] = "create_string_buffer";
-static char __pyx_k_152[] = "tag '%s' not present";
-static char __pyx_k_153[] = "unknown auxilliary type '%s'";
-static char __pyx_k_154[] = "Contig index";
-static char __pyx_k_155[] = "Mapped position on contig";
-static char __pyx_k_156[] = "Contig index for mate pair";
-static char __pyx_k_157[] = "Position of mate pair";
-static char __pyx_k_158[] = "Insert size";
-static char __pyx_k_159[] = "Binary flag";
-static char __pyx_k_160[] = "Count of cigar entries";
-static char __pyx_k_161[] = "Cigar entries";
-static char __pyx_k_162[] = "Mapping quality";
-static char __pyx_k_163[] = "Bam index bin number";
-static char __pyx_k_164[] = "Length of query name";
-static char __pyx_k_165[] = "Query name";
-static char __pyx_k_166[] = "Length of query sequence";
-static char __pyx_k_167[] = "Query sequence";
-static char __pyx_k_168[] = "Quality scores";
-static char __pyx_k_169[] = "Length of auxilary data";
-static char __pyx_k_170[] = "Maximum data length";
-static char __pyx_k_171[] = "Current data length";
-static char __pyx_k_172[] = "%-30s %-10s= %s";
-static char __pyx_k_173[] = "(";
-static char __pyx_k_174[] = ")";
-static char __pyx_k_175[] = "This class cannot be instantiated from Python";
-static char __pyx_k_177[] = "PileupProxy accessed after iterator finished";
-static char __pyx_k_181[] = "No such file or directory: '%s'";
-static char __pyx_k_182[] = "-o";
-static char __pyx_k_183[] = "option -o is forbidden in samtools view";
-static char __pyx_k_189[] = "can only IndexReads on bam files";
-static char __pyx_k_190[] = "read %s not found";
-static char __pyx_k_191[] = "number of :term:`filename` associated with this object.";
-static char __pyx_k_192[] = "the query name (None if not present)";
-static char __pyx_k_193[] = "the :term:`cigar` alignment (None if not present). The alignment\n        is returned as a list of tuples of (operation, length). \n        The operations are:\n\n        +-----+--------------+-----+\n        |M    |BAM_CMATCH    |0    |\n        +-----+--------------+-----+\n        |I    |BAM_CINS      |1    |\n        +-----+--------------+-----+\n        |D    |BAM_CDEL      |2    |\n        +-----+--------------+-----+\n        |N    |BAM_CREF_SKIP |3    [...]
-static char __pyx_k_194[] = "the :term:`cigar` alignment as a string.\n        \n        The cigar string is a string of alternating integers\n        and characters denoting the length and the type of\n        an operation.\n\n        .. note::\n            The order length,operation is specified in the\n            SAM format. It is different from the order of\n            the :meth:`cigar` property.\n\n        Returns the empty string if not present.\n        ";
-static char __pyx_k_195[] = "read sequence bases, including :term:`soft clipped` bases (None if not present).\n\n        In Python 3, this property is of type bytes and assigning a unicode string to it consisting of ASCII characters only will work, but is inefficient.";
-static char __pyx_k_196[] = "read sequence base qualities, including :term:`soft clipped` bases (None if not present).\n\n        In Python 3, this property is of type bytes and assigning a unicode string to it consisting of ASCII characters only will work, but is inefficient.";
-static char __pyx_k_197[] = "aligned portion of the read and excludes any flanking bases that were :term:`soft clipped` (None if not present).\n\n        In Python 3, this property is of type bytes. Assigning a unicode string to it consisting of ASCII characters only will work, but is inefficient.\n\n        SAM/BAM files may included extra flanking bases sequences that were\n        not part of the alignment.  These bases may be the result of the\n        Smith-Waterman or other algorit [...]
-static char __pyx_k_198[] = "aligned query sequence quality values (None if not present). This property is read-only.\n\n        In Python 3, this property is of type bytes.";
-static char __pyx_k_199[] = "start index of the aligned query portion of the sequence (0-based, inclusive)";
-static char __pyx_k_200[] = "end index of the aligned query portion of the sequence (0-based, exclusive)";
-static char __pyx_k_201[] = "Length of the aligned query sequence";
-static char __pyx_k_202[] = "the tags in the AUX field.\n\n        This property permits convenience access to\n        the tags. Changes it the returned list will\n        not update the tags automatically. Instead,\n        the following is required for adding a\n        new tag::\n\n            read.tags = read.tags + [(\"RG\",0)]\n\n\n        This method will happily write the same tag\n        multiple times.\n        ";
-static char __pyx_k_203[] = "properties flag";
-static char __pyx_k_204[] = "\n        :term:`target` ID\n\n        DEPRECATED from pysam-0.4 - use tid in the future.\n        The rname field caused a lot of confusion as it returns\n        the :term:`target` ID instead of the reference sequence\n        name.\n\n        .. note::\n\n            This field contains the index of the reference sequence\n            in the sequence dictionary. To obtain the name\n            of the reference sequence, use :meth:`pysam.Samfile.getrname()` [...]
-static char __pyx_k_205[] = "\n        :term:`target` ID\n\n        .. note::\n\n            This field contains the index of the reference sequence\n            in the sequence dictionary. To obtain the name\n            of the reference sequence, use :meth:`pysam.Samfile.getrname()`\n\n        ";
-static char __pyx_k_206[] = "0-based leftmost coordinate";
-static char __pyx_k_207[] = "properties bin";
-static char __pyx_k_208[] = "length of the read (read only). Returns 0 if not given.";
-static char __pyx_k_209[] = "aligned reference position of the read on the reference genome.  \n        \n        aend points to one past the last aligned residue.\n        Returns None if not available.";
-static char __pyx_k_210[] = "aligned length of the read on the reference genome.  Returns None if\n        not available.";
-static char __pyx_k_211[] = "mapping quality";
-static char __pyx_k_212[] = "the :term:`reference` id of the mate\n        deprecated, use RNEXT instead.\n        ";
-static char __pyx_k_213[] = "the :term:`reference` id of the mate ";
-static char __pyx_k_214[] = "the position of the mate\n        deprecated, use PNEXT instead.";
-static char __pyx_k_215[] = "the position of the mate";
-static char __pyx_k_216[] = "the insert size\n        deprecated: use tlen instead";
-static char __pyx_k_217[] = "the insert size";
-static char __pyx_k_218[] = "true if read is paired in sequencing";
-static char __pyx_k_219[] = "true if read is mapped in a proper pair";
-static char __pyx_k_220[] = "true if read itself is unmapped";
-static char __pyx_k_221[] = "true if the mate is unmapped";
-static char __pyx_k_222[] = "true if read is mapped to reverse strand";
-static char __pyx_k_223[] = "true is read is mapped to reverse strand";
-static char __pyx_k_224[] = "true if this is read1";
-static char __pyx_k_225[] = "true if this is read2";
-static char __pyx_k_226[] = "true if not primary alignment";
-static char __pyx_k_227[] = "true if QC failure";
-static char __pyx_k_228[] = "true if optical or PCR duplicate";
-static char __pyx_k_229[] = "a list of reference positions that this read aligns to.";
-static char __pyx_k_230[] = "a list of aligned read and reference positions.\n\n       Unaligned position are marked by None.\n       ";
-static char __pyx_k_231[] = "number of :term:`reference` sequences in the file.";
-static char __pyx_k_232[] = "tuple with the names of :term:`reference` sequences.";
-static char __pyx_k_233[] = "tuple of the lengths of the :term:`reference` sequences. The lengths are in the same order as\n        :attr:`pysam.Samfile.references`\n        ";
-static char __pyx_k_234[] = "total number of mapped reads in file.\n        ";
-static char __pyx_k_235[] = "total number of unmapped reads in file.\n        ";
-static char __pyx_k_236[] = "full contents of the :term:`sam file` header as a string.";
-static char __pyx_k_237[] = "header information within the :term:`sam file`. The records and fields are returned as\n        a two-level dictionary.\n        ";
-static char __pyx_k_238[] = "the chromosome ID as is defined in the header";
-static char __pyx_k_239[] = "number of reads mapping to this column.";
-static char __pyx_k_240[] = "list of reads (:class:`pysam.PileupRead`) aligned to this column";
-static char __pyx_k_241[] = "a :class:`pysam.AlignedRead` object of the aligned read";
-static char __pyx_k_242[] = "position of the read base at the pileup site, 0-based";
-static char __pyx_k_243[] = "indel length; 0 for no indel, positive for ins and negative for del";
-static char __pyx_k_244[] = "1 iff the base on the padded read is a deletion";
-static char __pyx_k_245[] = "current sequence length.";
-static char __pyx_k_246[] = "nucleotide position of SNP.";
-static char __pyx_k_247[] = "reference base at pos. ``N`` if no reference sequence supplied.";
-static char __pyx_k_248[] = "the genotype called.";
-static char __pyx_k_249[] = "the genotype quality (Phred-scaled).";
-static char __pyx_k_250[] = "the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.";
-static char __pyx_k_251[] = "the root mean square (rms) of the mapping quality of all reads involved in the call.";
-static char __pyx_k_252[] = "coverage or read depth - the number of reads involved in the call.";
-static char __pyx_k_253[] = "getfilesystemencoding";
-static char __pyx_k_254[] = "MIDNSHP=X";
-static char __pyx_k_255[] = "(\\d+)([MIDNSHP=X])";
-static char __pyx_k_257[] = "=ACMGRSVTWYHKDBN";
-static char __pyx_k_260[] = "/home/andreas/devel/pysam/pysam/csamtools.pyx";
-static char __pyx_k_261[] = "PileupColumn.__str__";
-static char __pyx_k_262[] = "pysam.csamtools";
-static char __pyx_k_263[] = "A pileup column. A pileup column contains\n    all the reads that map to a certain target base.\n\n    tid\n        chromosome ID as is defined in the header\n    pos\n        the target base coordinate (0-based)\n    n\n        number of reads mapping to this column\n    pileups\n        list of reads (:class:`pysam.PileupRead`) aligned to this column\n    ";
-static char __pyx_k_266[] = "StderrStore.__init__";
-static char __pyx_k_269[] = "StderrStore.readAndRelease";
-static char __pyx_k_272[] = "StderrStore.release";
-static char __pyx_k_275[] = "StderrStore.__del__";
-static char __pyx_k_276[] = "\n    stderr is captured.\n    ";
-static char __pyx_k_279[] = "StderrStoreWindows.__init__";
-static char __pyx_k_282[] = "StderrStoreWindows.readAndRelease";
-static char __pyx_k_285[] = "StderrStoreWindows.release";
-static char __pyx_k_286[] = "does nothing. stderr can't be redirected on windows";
-static char __pyx_k_295[] = "Outs.__init__";
-static char __pyx_k_298[] = "Outs.setdevice";
-static char __pyx_k_301[] = "Outs.setfile";
-static char __pyx_k_304[] = "Outs.setfd";
-static char __pyx_k_307[] = "Outs.restore";
-static char __pyx_k_308[] = "http://mail.python.org/pipermail/python-list/2000-June/038406.html";
+static char __pyx_k_100[] = "Samfile.mapped only available in bam files";
+static char __pyx_k_102[] = "mapping information not recorded in index or index not available";
+static char __pyx_k_105[] = "Samfile.unmapped only available in bam files";
+static char __pyx_k_110[] = "@";
+static char __pyx_k_112[] = "header line without '@': '%s'";
+static char __pyx_k_114[] = "header line with invalid type '%s': '%s'";
+static char __pyx_k_115[] = ":";
+static char __pyx_k_116[] = "malformatted header: no ':' in field";
+static char __pyx_k_119[] = "unknown field code '%s' in record '%s'";
+static char __pyx_k_120[] = "multiple '%s' lines are not permitted";
+static char __pyx_k_121[] = "@%s";
+static char __pyx_k_122[] = "%s:%s";
+static char __pyx_k_123[] = "invalid type for record %s: %s, expected %s";
+static char __pyx_k_125[] = "incomplete sequence information in '%s'";
+static char __pyx_k_128[] = "can not iterate over samfile without header";
+static char __pyx_k_131[] = "no index available for iteration";
+static char __pyx_k_137[] = "can only use this iterator on bam files";
+static char __pyx_k_138[] = "reference sequence for '%s' (tid=%i) not found";
+static char __pyx_k_139[] = "unknown stepper option `%s` in IteratorColumn";
+static char __pyx_k_141[] = "error during iteration";
+static char __pyx_k_144[] = "Invalid clipping in CIGAR string";
+static char __pyx_k_147[] = "%i%c";
+static char __pyx_k_148[] = "quality and sequence mismatch: %i != %i";
+static char __pyx_k_149[] = "%c";
+static char __pyx_k_150[] = "<";
+static char __pyx_k_152[] = "integer %i out of range of BAM/SAM specification";
+static char __pyx_k_153[] = "2sccI%i%s";
+static char __pyx_k_157[] = "2sc%is";
+static char __pyx_k_159[] = "create_string_buffer";
+static char __pyx_k_160[] = "tag '%s' not present";
+static char __pyx_k_161[] = "unknown auxilliary type '%s'";
+static char __pyx_k_162[] = "Contig index";
+static char __pyx_k_163[] = "Mapped position on contig";
+static char __pyx_k_164[] = "Contig index for mate pair";
+static char __pyx_k_165[] = "Position of mate pair";
+static char __pyx_k_166[] = "Insert size";
+static char __pyx_k_167[] = "Binary flag";
+static char __pyx_k_168[] = "Count of cigar entries";
+static char __pyx_k_169[] = "Cigar entries";
+static char __pyx_k_170[] = "Mapping quality";
+static char __pyx_k_171[] = "Bam index bin number";
+static char __pyx_k_172[] = "Length of query name";
+static char __pyx_k_173[] = "Query name";
+static char __pyx_k_174[] = "Length of query sequence";
+static char __pyx_k_175[] = "Query sequence";
+static char __pyx_k_176[] = "Quality scores";
+static char __pyx_k_177[] = "Length of auxilary data";
+static char __pyx_k_178[] = "Maximum data length";
+static char __pyx_k_179[] = "Current data length";
+static char __pyx_k_180[] = "%-30s %-10s= %s";
+static char __pyx_k_181[] = "(";
+static char __pyx_k_182[] = ")";
+static char __pyx_k_183[] = "This class cannot be instantiated from Python";
+static char __pyx_k_185[] = "PileupProxy accessed after iterator finished";
+static char __pyx_k_189[] = "No such file or directory: '%s'";
+static char __pyx_k_190[] = "-o";
+static char __pyx_k_191[] = "option -o is forbidden in samtools view";
+static char __pyx_k_197[] = "can only IndexReads on bam files";
+static char __pyx_k_198[] = "read %s not found";
+static char __pyx_k_199[] = "number of :term:`filename` associated with this object.";
+static char __pyx_k_200[] = "the query name (None if not present)";
+static char __pyx_k_201[] = "the :term:`cigar` alignment (None if not present). The alignment\n        is returned as a list of tuples of (operation, length). \n        The operations are:\n\n        +-----+--------------+-----+\n        |M    |BAM_CMATCH    |0    |\n        +-----+--------------+-----+\n        |I    |BAM_CINS      |1    |\n        +-----+--------------+-----+\n        |D    |BAM_CDEL      |2    |\n        +-----+--------------+-----+\n        |N    |BAM_CREF_SKIP |3    [...]
+static char __pyx_k_202[] = "the :term:`cigar` alignment as a string.\n        \n        The cigar string is a string of alternating integers\n        and characters denoting the length and the type of\n        an operation.\n\n        .. note::\n            The order length,operation is specified in the\n            SAM format. It is different from the order of\n            the :meth:`cigar` property.\n\n        Returns the empty string if not present.\n        ";
+static char __pyx_k_203[] = "read sequence bases, including :term:`soft clipped` bases \n        (None if not present).\n\n        In Python 3, this property is of type bytes and assigning a\n        unicode string to it consisting of ASCII characters only will\n        work, but is inefficient.\n\n        Note that assigning to seq will invalidate any quality scores.\n        Thus, to in-place edit the sequence and quality scores, copies of\n        the quality scores need to be taken.  [...]
+static char __pyx_k_204[] = "read sequence base qualities, including :term:`soft\n        clipped` bases (None if not present).\n\n        In Python 3, this property is of type bytes and assigning a\n        unicode string to it consisting of ASCII characters only will\n        work, but is inefficient.\n\n        Note that to set quality scores the sequence has to be set\n        previously as this will determine the permitted length of\n        the quality score array.\n\n        This  [...]
+static char __pyx_k_205[] = "aligned portion of the read and excludes any flanking bases that were :term:`soft clipped` (None if not present).\n\n        In Python 3, this property is of type bytes. Assigning a unicode string to it consisting of ASCII characters only will work, but is inefficient.\n\n        SAM/BAM files may included extra flanking bases sequences that were\n        not part of the alignment.  These bases may be the result of the\n        Smith-Waterman or other algorit [...]
+static char __pyx_k_206[] = "aligned query sequence quality values (None if not present). This property is read-only.\n\n        In Python 3, this property is of type bytes.";
+static char __pyx_k_207[] = "start index of the aligned query portion of the sequence (0-based, inclusive)";
+static char __pyx_k_208[] = "end index of the aligned query portion of the sequence (0-based, exclusive)";
+static char __pyx_k_209[] = "Length of the aligned query sequence";
+static char __pyx_k_210[] = "the tags in the AUX field.\n\n        This property permits convenience access to\n        the tags. Changes it the returned list will\n        not update the tags automatically. Instead,\n        the following is required for adding a\n        new tag::\n\n            read.tags = read.tags + [(\"RG\",0)]\n\n\n        This method will happily write the same tag\n        multiple times.\n        ";
+static char __pyx_k_211[] = "properties flag";
+static char __pyx_k_212[] = "\n        :term:`target` ID\n\n        DEPRECATED from pysam-0.4 - use tid in the future.\n        The rname field caused a lot of confusion as it returns\n        the :term:`target` ID instead of the reference sequence\n        name.\n\n        .. note::\n\n            This field contains the index of the reference sequence\n            in the sequence dictionary. To obtain the name\n            of the reference sequence, use :meth:`pysam.Samfile.getrname()` [...]
+static char __pyx_k_213[] = "\n        :term:`target` ID\n\n        .. note::\n\n            This field contains the index of the reference sequence\n            in the sequence dictionary. To obtain the name\n            of the reference sequence, use :meth:`pysam.Samfile.getrname()`\n\n        ";
+static char __pyx_k_214[] = "0-based leftmost coordinate";
+static char __pyx_k_215[] = "properties bin";
+static char __pyx_k_216[] = "length of the read (read only). Returns 0 if not given.";
+static char __pyx_k_217[] = "aligned reference position of the read on the reference genome.  \n        \n        aend points to one past the last aligned residue.\n        Returns None if not available.";
+static char __pyx_k_218[] = "aligned length of the read on the reference genome.  Returns None if\n        not available.";
+static char __pyx_k_219[] = "mapping quality";
+static char __pyx_k_220[] = "the :term:`reference` id of the mate\n        deprecated, use RNEXT instead.\n        ";
+static char __pyx_k_221[] = "the :term:`reference` id of the mate ";
+static char __pyx_k_222[] = "the position of the mate\n        deprecated, use PNEXT instead.";
+static char __pyx_k_223[] = "the position of the mate";
+static char __pyx_k_224[] = "the insert size\n        deprecated: use tlen instead";
+static char __pyx_k_225[] = "the insert size";
+static char __pyx_k_226[] = "true if read is paired in sequencing";
+static char __pyx_k_227[] = "true if read is mapped in a proper pair";
+static char __pyx_k_228[] = "true if read itself is unmapped";
+static char __pyx_k_229[] = "true if the mate is unmapped";
+static char __pyx_k_230[] = "true if read is mapped to reverse strand";
+static char __pyx_k_231[] = "true is read is mapped to reverse strand";
+static char __pyx_k_232[] = "true if this is read1";
+static char __pyx_k_233[] = "true if this is read2";
+static char __pyx_k_234[] = "true if not primary alignment";
+static char __pyx_k_235[] = "true if QC failure";
+static char __pyx_k_236[] = "true if optical or PCR duplicate";
+static char __pyx_k_237[] = "a list of reference positions that this read aligns to.";
+static char __pyx_k_238[] = "inferred read length from CIGAR string.\n\n        Returns 0 if CIGAR string is not present.\n        ";
+static char __pyx_k_239[] = "a list of aligned read and reference positions.\n\n       Unaligned position are marked by None.\n       ";
+static char __pyx_k_240[] = "number of :term:`reference` sequences in the file.";
+static char __pyx_k_241[] = "tuple with the names of :term:`reference` sequences.";
+static char __pyx_k_242[] = "tuple of the lengths of the :term:`reference` sequences. The lengths are in the same order as\n        :attr:`pysam.Samfile.references`\n        ";
+static char __pyx_k_243[] = "total number of mapped reads in file.\n        ";
+static char __pyx_k_244[] = "total number of unmapped reads in file.\n        ";
+static char __pyx_k_245[] = "full contents of the :term:`sam file` header as a string.";
+static char __pyx_k_246[] = "header information within the :term:`sam file`. The records and fields are returned as\n        a two-level dictionary.\n        ";
+static char __pyx_k_247[] = "the chromosome ID as is defined in the header";
+static char __pyx_k_248[] = "number of reads mapping to this column.";
+static char __pyx_k_249[] = "list of reads (:class:`pysam.PileupRead`) aligned to this column";
+static char __pyx_k_250[] = "a :class:`pysam.AlignedRead` object of the aligned read";
+static char __pyx_k_251[] = "position of the read base at the pileup site, 0-based";
+static char __pyx_k_252[] = "indel length; 0 for no indel, positive for ins and negative for del";
+static char __pyx_k_253[] = "1 iff the base on the padded read is a deletion";
+static char __pyx_k_254[] = "current sequence length.";
+static char __pyx_k_255[] = "nucleotide position of SNP.";
+static char __pyx_k_256[] = "reference base at pos. ``N`` if no reference sequence supplied.";
+static char __pyx_k_257[] = "the genotype called.";
+static char __pyx_k_258[] = "the genotype quality (Phred-scaled).";
+static char __pyx_k_259[] = "the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.";
+static char __pyx_k_260[] = "the root mean square (rms) of the mapping quality of all reads involved in the call.";
+static char __pyx_k_261[] = "coverage or read depth - the number of reads involved in the call.";
+static char __pyx_k_262[] = "getfilesystemencoding";
+static char __pyx_k_263[] = "MIDNSHP=X";
+static char __pyx_k_264[] = "(\\d+)([MIDNSHP=X])";
+static char __pyx_k_266[] = "=ACMGRSVTWYHKDBN";
+static char __pyx_k_269[] = "/home/andreas/devel/pysam/pysam/csamtools.pyx";
+static char __pyx_k_270[] = "PileupColumn.__str__";
+static char __pyx_k_271[] = "pysam.csamtools";
+static char __pyx_k_272[] = "A pileup column. A pileup column contains\n    all the reads that map to a certain target base.\n\n    tid\n        chromosome ID as is defined in the header\n    pos\n        the target base coordinate (0-based)\n    n\n        number of reads mapping to this column\n    pileups\n        list of reads (:class:`pysam.PileupRead`) aligned to this column\n    ";
+static char __pyx_k_275[] = "StderrStore.__init__";
+static char __pyx_k_278[] = "StderrStore.readAndRelease";
+static char __pyx_k_281[] = "StderrStore.release";
+static char __pyx_k_284[] = "StderrStore.__del__";
+static char __pyx_k_285[] = "\n    stderr is captured.\n    ";
+static char __pyx_k_288[] = "StderrStoreWindows.__init__";
+static char __pyx_k_291[] = "StderrStoreWindows.readAndRelease";
+static char __pyx_k_294[] = "StderrStoreWindows.release";
+static char __pyx_k_295[] = "does nothing. stderr can't be redirected on windows";
+static char __pyx_k_304[] = "Outs.__init__";
+static char __pyx_k_307[] = "Outs.setdevice";
+static char __pyx_k_310[] = "Outs.setfile";
+static char __pyx_k_313[] = "Outs.setfd";
+static char __pyx_k_316[] = "Outs.restore";
+static char __pyx_k_317[] = "http://mail.python.org/pipermail/python-list/2000-June/038406.html";
 static char __pyx_k__AS[] = "AS";
 static char __pyx_k__CL[] = "CL";
 static char __pyx_k__CN[] = "CN";
@@ -2089,6 +2160,7 @@ static char __pyx_k__template[] = "template";
 static char __pyx_k__truncate[] = "truncate";
 static char __pyx_k__warnings[] = "warnings";
 static char __pyx_k__Fastafile[] = "Fastafile";
+static char __pyx_k__Fastqfile[] = "Fastqfile";
 static char __pyx_k__TypeError[] = "TypeError";
 static char __pyx_k____enter__[] = "__enter__";
 static char __pyx_k___hasIndex[] = "_hasIndex";
@@ -2153,41 +2225,36 @@ static char __pyx_k__NotImplementedError[] = "NotImplementedError";
 static char __pyx_k__VALID_HEADER_FIELDS[] = "VALID_HEADER_FIELDS";
 static PyObject *__pyx_kp_u_1;
 static PyObject *__pyx_kp_s_10;
+static PyObject *__pyx_kp_s_100;
 static PyObject *__pyx_kp_s_102;
-static PyObject *__pyx_kp_s_104;
-static PyObject *__pyx_kp_s_106;
-static PyObject *__pyx_kp_s_107;
-static PyObject *__pyx_kp_s_108;
-static PyObject *__pyx_kp_s_111;
+static PyObject *__pyx_kp_s_105;
+static PyObject *__pyx_kp_s_110;
 static PyObject *__pyx_kp_s_112;
-static PyObject *__pyx_kp_s_113;
 static PyObject *__pyx_kp_s_114;
 static PyObject *__pyx_kp_s_115;
-static PyObject *__pyx_kp_s_117;
+static PyObject *__pyx_kp_s_116;
+static PyObject *__pyx_kp_s_119;
 static PyObject *__pyx_kp_s_120;
+static PyObject *__pyx_kp_s_121;
+static PyObject *__pyx_kp_s_122;
 static PyObject *__pyx_kp_s_123;
-static PyObject *__pyx_kp_s_129;
+static PyObject *__pyx_kp_s_125;
+static PyObject *__pyx_kp_s_128;
 static PyObject *__pyx_kp_s_13;
-static PyObject *__pyx_kp_s_130;
 static PyObject *__pyx_kp_s_131;
-static PyObject *__pyx_kp_s_133;
+static PyObject *__pyx_kp_s_137;
+static PyObject *__pyx_kp_s_138;
 static PyObject *__pyx_kp_s_139;
-static PyObject *__pyx_kp_s_140;
 static PyObject *__pyx_kp_s_141;
-static PyObject *__pyx_kp_s_142;
-static PyObject *__pyx_kp_s_144;
-static PyObject *__pyx_kp_s_145;
+static PyObject *__pyx_kp_s_147;
+static PyObject *__pyx_kp_s_148;
 static PyObject *__pyx_kp_s_149;
 static PyObject *__pyx_kp_s_15;
-static PyObject *__pyx_n_s_151;
+static PyObject *__pyx_kp_s_150;
 static PyObject *__pyx_kp_s_152;
 static PyObject *__pyx_kp_s_153;
-static PyObject *__pyx_kp_s_154;
-static PyObject *__pyx_kp_s_155;
-static PyObject *__pyx_kp_s_156;
 static PyObject *__pyx_kp_s_157;
-static PyObject *__pyx_kp_s_158;
-static PyObject *__pyx_kp_s_159;
+static PyObject *__pyx_n_s_159;
 static PyObject *__pyx_kp_b_16;
 static PyObject *__pyx_kp_s_16;
 static PyObject *__pyx_kp_s_160;
@@ -2207,73 +2274,79 @@ static PyObject *__pyx_kp_s_172;
 static PyObject *__pyx_kp_s_173;
 static PyObject *__pyx_kp_s_174;
 static PyObject *__pyx_kp_s_175;
+static PyObject *__pyx_kp_s_176;
 static PyObject *__pyx_kp_s_177;
+static PyObject *__pyx_kp_s_178;
+static PyObject *__pyx_kp_s_179;
 static PyObject *__pyx_kp_s_18;
+static PyObject *__pyx_kp_s_180;
 static PyObject *__pyx_kp_s_181;
 static PyObject *__pyx_kp_s_182;
 static PyObject *__pyx_kp_s_183;
+static PyObject *__pyx_kp_s_185;
 static PyObject *__pyx_kp_s_189;
 static PyObject *__pyx_kp_s_19;
 static PyObject *__pyx_kp_s_190;
-static PyObject *__pyx_kp_s_24;
-static PyObject *__pyx_n_s_253;
-static PyObject *__pyx_kp_s_255;
-static PyObject *__pyx_kp_s_260;
-static PyObject *__pyx_n_s_261;
+static PyObject *__pyx_kp_s_191;
+static PyObject *__pyx_kp_s_197;
+static PyObject *__pyx_kp_s_198;
+static PyObject *__pyx_kp_s_21;
 static PyObject *__pyx_n_s_262;
-static PyObject *__pyx_kp_s_263;
-static PyObject *__pyx_n_s_266;
-static PyObject *__pyx_n_s_269;
-static PyObject *__pyx_n_s_272;
+static PyObject *__pyx_kp_s_264;
+static PyObject *__pyx_kp_s_269;
+static PyObject *__pyx_n_s_270;
+static PyObject *__pyx_n_s_271;
+static PyObject *__pyx_kp_s_272;
 static PyObject *__pyx_n_s_275;
-static PyObject *__pyx_kp_s_276;
-static PyObject *__pyx_n_s_279;
-static PyObject *__pyx_n_s_282;
-static PyObject *__pyx_n_s_285;
-static PyObject *__pyx_kp_s_286;
-static PyObject *__pyx_kp_s_29;
-static PyObject *__pyx_n_s_295;
-static PyObject *__pyx_n_s_298;
+static PyObject *__pyx_n_s_278;
+static PyObject *__pyx_n_s_281;
+static PyObject *__pyx_n_s_284;
+static PyObject *__pyx_kp_s_285;
+static PyObject *__pyx_n_s_288;
+static PyObject *__pyx_n_s_291;
+static PyObject *__pyx_n_s_294;
+static PyObject *__pyx_kp_s_295;
 static PyObject *__pyx_kp_u_3;
-static PyObject *__pyx_kp_s_30;
-static PyObject *__pyx_n_s_301;
 static PyObject *__pyx_n_s_304;
 static PyObject *__pyx_n_s_307;
-static PyObject *__pyx_kp_s_308;
-static PyObject *__pyx_kp_s_31;
+static PyObject *__pyx_n_s_310;
+static PyObject *__pyx_n_s_313;
+static PyObject *__pyx_n_s_316;
+static PyObject *__pyx_kp_s_317;
 static PyObject *__pyx_kp_s_32;
-static PyObject *__pyx_kp_s_33;
-static PyObject *__pyx_kp_s_34;
-static PyObject *__pyx_kp_s_35;
-static PyObject *__pyx_kp_s_36;
-static PyObject *__pyx_kp_b_37;
+static PyObject *__pyx_kp_s_37;
 static PyObject *__pyx_kp_s_38;
+static PyObject *__pyx_kp_s_39;
+static PyObject *__pyx_kp_s_40;
 static PyObject *__pyx_kp_s_41;
+static PyObject *__pyx_kp_s_42;
 static PyObject *__pyx_kp_s_43;
-static PyObject *__pyx_kp_s_45;
+static PyObject *__pyx_kp_s_44;
+static PyObject *__pyx_kp_b_45;
 static PyObject *__pyx_kp_s_46;
-static PyObject *__pyx_kp_s_48;
+static PyObject *__pyx_kp_s_49;
 static PyObject *__pyx_kp_s_5;
-static PyObject *__pyx_kp_s_50;
+static PyObject *__pyx_kp_s_51;
+static PyObject *__pyx_kp_s_53;
+static PyObject *__pyx_kp_s_54;
 static PyObject *__pyx_kp_s_56;
 static PyObject *__pyx_kp_s_58;
 static PyObject *__pyx_kp_s_6;
-static PyObject *__pyx_kp_s_60;
-static PyObject *__pyx_kp_s_62;
 static PyObject *__pyx_kp_s_64;
 static PyObject *__pyx_kp_s_66;
-static PyObject *__pyx_kp_s_69;
+static PyObject *__pyx_kp_s_68;
 static PyObject *__pyx_kp_s_7;
 static PyObject *__pyx_kp_s_70;
-static PyObject *__pyx_kp_s_71;
-static PyObject *__pyx_kp_s_76;
+static PyObject *__pyx_kp_s_72;
+static PyObject *__pyx_kp_s_74;
+static PyObject *__pyx_kp_s_77;
+static PyObject *__pyx_kp_s_78;
 static PyObject *__pyx_kp_s_79;
-static PyObject *__pyx_kp_s_82;
-static PyObject *__pyx_kp_s_85;
+static PyObject *__pyx_kp_s_84;
+static PyObject *__pyx_kp_s_87;
 static PyObject *__pyx_kp_s_9;
-static PyObject *__pyx_kp_s_92;
-static PyObject *__pyx_kp_s_94;
-static PyObject *__pyx_kp_s_97;
+static PyObject *__pyx_kp_s_90;
+static PyObject *__pyx_kp_s_93;
 static PyObject *__pyx_kp_s__2scB;
 static PyObject *__pyx_kp_s__2scH;
 static PyObject *__pyx_kp_s__2scI;
@@ -2299,6 +2372,7 @@ static PyObject *__pyx_n_s__DT;
 static PyObject *__pyx_n_s__F;
 static PyObject *__pyx_n_s__FO;
 static PyObject *__pyx_n_s__Fastafile;
+static PyObject *__pyx_n_s__Fastqfile;
 static PyObject *__pyx_n_s__GO;
 static PyObject *__pyx_n_s__H;
 static PyObject *__pyx_n_s__HD;
@@ -2568,13 +2642,13 @@ static PyObject *__pyx_int_neg_32767;
 static PyObject *__pyx_int_536870912;
 static PyObject *__pyx_int_4294967295;
 static PyObject *__pyx_int_neg_2147483648;
-static PyObject *__pyx_k_21;
-static PyObject *__pyx_k_22;
-static PyObject *__pyx_k_23;
-static PyObject *__pyx_k_54;
-static PyObject *__pyx_k_73;
-static int __pyx_k_132;
-static PyObject *__pyx_k_180;
+static PyObject *__pyx_k_29;
+static PyObject *__pyx_k_30;
+static PyObject *__pyx_k_31;
+static PyObject *__pyx_k_62;
+static PyObject *__pyx_k_81;
+static int __pyx_k_140;
+static PyObject *__pyx_k_188;
 static PyObject *__pyx_k_tuple_2;
 static PyObject *__pyx_k_tuple_4;
 static PyObject *__pyx_k_tuple_8;
@@ -2582,112 +2656,114 @@ static PyObject *__pyx_k_tuple_11;
 static PyObject *__pyx_k_tuple_12;
 static PyObject *__pyx_k_tuple_14;
 static PyObject *__pyx_k_tuple_20;
-static PyObject *__pyx_k_tuple_25;
-static PyObject *__pyx_k_tuple_39;
-static PyObject *__pyx_k_tuple_40;
-static PyObject *__pyx_k_tuple_42;
-static PyObject *__pyx_k_tuple_44;
+static PyObject *__pyx_k_tuple_22;
+static PyObject *__pyx_k_tuple_23;
+static PyObject *__pyx_k_tuple_33;
 static PyObject *__pyx_k_tuple_47;
-static PyObject *__pyx_k_tuple_49;
-static PyObject *__pyx_k_tuple_51;
+static PyObject *__pyx_k_tuple_48;
+static PyObject *__pyx_k_tuple_50;
 static PyObject *__pyx_k_tuple_52;
-static PyObject *__pyx_k_tuple_53;
 static PyObject *__pyx_k_tuple_55;
 static PyObject *__pyx_k_tuple_57;
 static PyObject *__pyx_k_tuple_59;
+static PyObject *__pyx_k_tuple_60;
 static PyObject *__pyx_k_tuple_61;
 static PyObject *__pyx_k_tuple_63;
 static PyObject *__pyx_k_tuple_65;
 static PyObject *__pyx_k_tuple_67;
-static PyObject *__pyx_k_tuple_68;
-static PyObject *__pyx_k_tuple_72;
-static PyObject *__pyx_k_tuple_74;
+static PyObject *__pyx_k_tuple_69;
+static PyObject *__pyx_k_tuple_71;
+static PyObject *__pyx_k_tuple_73;
 static PyObject *__pyx_k_tuple_75;
-static PyObject *__pyx_k_tuple_77;
-static PyObject *__pyx_k_tuple_78;
+static PyObject *__pyx_k_tuple_76;
 static PyObject *__pyx_k_tuple_80;
-static PyObject *__pyx_k_tuple_81;
+static PyObject *__pyx_k_tuple_82;
 static PyObject *__pyx_k_tuple_83;
-static PyObject *__pyx_k_tuple_84;
+static PyObject *__pyx_k_tuple_85;
 static PyObject *__pyx_k_tuple_86;
-static PyObject *__pyx_k_tuple_87;
 static PyObject *__pyx_k_tuple_88;
 static PyObject *__pyx_k_tuple_89;
-static PyObject *__pyx_k_tuple_90;
 static PyObject *__pyx_k_tuple_91;
-static PyObject *__pyx_k_tuple_93;
+static PyObject *__pyx_k_tuple_92;
+static PyObject *__pyx_k_tuple_94;
 static PyObject *__pyx_k_tuple_95;
 static PyObject *__pyx_k_tuple_96;
+static PyObject *__pyx_k_tuple_97;
 static PyObject *__pyx_k_tuple_98;
 static PyObject *__pyx_k_tuple_99;
-static PyObject *__pyx_k_tuple_100;
 static PyObject *__pyx_k_tuple_101;
 static PyObject *__pyx_k_tuple_103;
-static PyObject *__pyx_k_tuple_105;
+static PyObject *__pyx_k_tuple_104;
+static PyObject *__pyx_k_tuple_106;
+static PyObject *__pyx_k_tuple_107;
+static PyObject *__pyx_k_tuple_108;
 static PyObject *__pyx_k_tuple_109;
-static PyObject *__pyx_k_tuple_110;
-static PyObject *__pyx_k_tuple_116;
+static PyObject *__pyx_k_tuple_111;
+static PyObject *__pyx_k_tuple_113;
+static PyObject *__pyx_k_tuple_117;
 static PyObject *__pyx_k_tuple_118;
-static PyObject *__pyx_k_tuple_119;
-static PyObject *__pyx_k_tuple_121;
-static PyObject *__pyx_k_tuple_122;
 static PyObject *__pyx_k_tuple_124;
-static PyObject *__pyx_k_tuple_125;
 static PyObject *__pyx_k_tuple_126;
 static PyObject *__pyx_k_tuple_127;
-static PyObject *__pyx_k_tuple_128;
+static PyObject *__pyx_k_tuple_129;
+static PyObject *__pyx_k_tuple_130;
+static PyObject *__pyx_k_tuple_132;
+static PyObject *__pyx_k_tuple_133;
 static PyObject *__pyx_k_tuple_134;
 static PyObject *__pyx_k_tuple_135;
-static PyObject *__pyx_k_tuple_137;
-static PyObject *__pyx_k_tuple_138;
+static PyObject *__pyx_k_tuple_136;
+static PyObject *__pyx_k_tuple_142;
 static PyObject *__pyx_k_tuple_143;
+static PyObject *__pyx_k_tuple_145;
 static PyObject *__pyx_k_tuple_146;
-static PyObject *__pyx_k_tuple_147;
-static PyObject *__pyx_k_tuple_148;
-static PyObject *__pyx_k_tuple_150;
-static PyObject *__pyx_k_tuple_176;
-static PyObject *__pyx_k_tuple_178;
-static PyObject *__pyx_k_tuple_179;
+static PyObject *__pyx_k_tuple_151;
+static PyObject *__pyx_k_tuple_154;
+static PyObject *__pyx_k_tuple_155;
+static PyObject *__pyx_k_tuple_156;
+static PyObject *__pyx_k_tuple_158;
 static PyObject *__pyx_k_tuple_184;
-static PyObject *__pyx_k_tuple_185;
 static PyObject *__pyx_k_tuple_186;
 static PyObject *__pyx_k_tuple_187;
-static PyObject *__pyx_k_tuple_188;
-static PyObject *__pyx_k_tuple_256;
-static PyObject *__pyx_k_tuple_258;
-static PyObject *__pyx_k_tuple_264;
+static PyObject *__pyx_k_tuple_192;
+static PyObject *__pyx_k_tuple_193;
+static PyObject *__pyx_k_tuple_194;
+static PyObject *__pyx_k_tuple_195;
+static PyObject *__pyx_k_tuple_196;
+static PyObject *__pyx_k_tuple_265;
 static PyObject *__pyx_k_tuple_267;
-static PyObject *__pyx_k_tuple_270;
 static PyObject *__pyx_k_tuple_273;
-static PyObject *__pyx_k_tuple_277;
-static PyObject *__pyx_k_tuple_280;
-static PyObject *__pyx_k_tuple_283;
-static PyObject *__pyx_k_tuple_287;
-static PyObject *__pyx_k_tuple_288;
+static PyObject *__pyx_k_tuple_276;
+static PyObject *__pyx_k_tuple_279;
+static PyObject *__pyx_k_tuple_282;
+static PyObject *__pyx_k_tuple_286;
 static PyObject *__pyx_k_tuple_289;
-static PyObject *__pyx_k_tuple_290;
-static PyObject *__pyx_k_tuple_291;
 static PyObject *__pyx_k_tuple_292;
-static PyObject *__pyx_k_tuple_294;
 static PyObject *__pyx_k_tuple_296;
+static PyObject *__pyx_k_tuple_297;
+static PyObject *__pyx_k_tuple_298;
 static PyObject *__pyx_k_tuple_299;
-static PyObject *__pyx_k_tuple_302;
+static PyObject *__pyx_k_tuple_300;
+static PyObject *__pyx_k_tuple_301;
+static PyObject *__pyx_k_tuple_303;
 static PyObject *__pyx_k_tuple_305;
-static PyObject *__pyx_k_tuple_309;
-static PyObject *__pyx_k_codeobj_259;
-static PyObject *__pyx_k_codeobj_265;
+static PyObject *__pyx_k_tuple_308;
+static PyObject *__pyx_k_tuple_311;
+static PyObject *__pyx_k_tuple_314;
+static PyObject *__pyx_k_tuple_318;
 static PyObject *__pyx_k_codeobj_268;
-static PyObject *__pyx_k_codeobj_271;
 static PyObject *__pyx_k_codeobj_274;
-static PyObject *__pyx_k_codeobj_278;
-static PyObject *__pyx_k_codeobj_281;
-static PyObject *__pyx_k_codeobj_284;
+static PyObject *__pyx_k_codeobj_277;
+static PyObject *__pyx_k_codeobj_280;
+static PyObject *__pyx_k_codeobj_283;
+static PyObject *__pyx_k_codeobj_287;
+static PyObject *__pyx_k_codeobj_290;
 static PyObject *__pyx_k_codeobj_293;
-static PyObject *__pyx_k_codeobj_297;
-static PyObject *__pyx_k_codeobj_300;
-static PyObject *__pyx_k_codeobj_303;
+static PyObject *__pyx_k_codeobj_302;
 static PyObject *__pyx_k_codeobj_306;
-static PyObject *__pyx_k_codeobj_310;
+static PyObject *__pyx_k_codeobj_309;
+static PyObject *__pyx_k_codeobj_312;
+static PyObject *__pyx_k_codeobj_315;
+static PyObject *__pyx_k_codeobj_319;
 static PyObject *__pyx_gb_5pysam_9csamtools_4generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
 
 /* "pysam/csamtools.pyx":140
@@ -3887,7 +3963,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v
  *     dest._is_tail = src.is_tail
  *     return dest             # <<<<<<<<<<<<<<
  * 
- * cdef convertBinaryTagToList( uint8_t * s ):
+ * cdef class FastqProxy
  */
   __Pyx_XDECREF(__pyx_r);
   __Pyx_INCREF(((PyObject *)__pyx_v_dest));
@@ -3908,7 +3984,75 @@ static PyObject *__pyx_f_5pysam_9csamtools_makePileupRead(bam_pileup1_t *__pyx_v
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":188
+/* "pysam/csamtools.pyx":189
+ * 
+ * cdef class FastqProxy
+ * cdef makeFastqProxy( kseq_t * src):             # <<<<<<<<<<<<<<
+ *     '''enter src into AlignedRead.'''
+ *     cdef FastqProxy dest = FastqProxy.__new__(FastqProxy)
+ */
+
+static PyObject *__pyx_f_5pysam_9csamtools_makeFastqProxy(kseq_t *__pyx_v_src) {
+  struct __pyx_obj_5pysam_9csamtools_FastqProxy *__pyx_v_dest = 0;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("makeFastqProxy", 0);
+  __Pyx_TraceCall("makeFastqProxy", __pyx_f[0], 189);
+
+  /* "pysam/csamtools.pyx":191
+ * cdef makeFastqProxy( kseq_t * src):
+ *     '''enter src into AlignedRead.'''
+ *     cdef FastqProxy dest = FastqProxy.__new__(FastqProxy)             # <<<<<<<<<<<<<<
+ *     dest._delegate = src
+ *     return dest
+ */
+  __pyx_t_1 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5pysam_9csamtools_FastqProxy)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (!(likely(__Pyx_TypeTest(__pyx_t_1, __pyx_ptype_5pysam_9csamtools_FastqProxy)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_dest = ((struct __pyx_obj_5pysam_9csamtools_FastqProxy *)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "pysam/csamtools.pyx":192
+ *     '''enter src into AlignedRead.'''
+ *     cdef FastqProxy dest = FastqProxy.__new__(FastqProxy)
+ *     dest._delegate = src             # <<<<<<<<<<<<<<
+ *     return dest
+ * 
+ */
+  __pyx_v_dest->_delegate = __pyx_v_src;
+
+  /* "pysam/csamtools.pyx":193
+ *     cdef FastqProxy dest = FastqProxy.__new__(FastqProxy)
+ *     dest._delegate = src
+ *     return dest             # <<<<<<<<<<<<<<
+ * 
+ * cdef convertBinaryTagToList( uint8_t * s ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_dest));
+  __pyx_r = ((PyObject *)__pyx_v_dest);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("pysam.csamtools.makeFastqProxy", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_dest);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":195
  *     return dest
  * 
  * cdef convertBinaryTagToList( uint8_t * s ):             # <<<<<<<<<<<<<<
@@ -3935,9 +4079,9 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("convertBinaryTagToList", 0);
-  __Pyx_TraceCall("convertBinaryTagToList", __pyx_f[0], 188);
+  __Pyx_TraceCall("convertBinaryTagToList", __pyx_f[0], 195);
 
-  /* "pysam/csamtools.pyx":195
+  /* "pysam/csamtools.pyx":202
  * 
  *     # get byte size
  *     auxtype = s[0]             # <<<<<<<<<<<<<<
@@ -3946,7 +4090,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
  */
   __pyx_v_auxtype = (__pyx_v_s[0]);
 
-  /* "pysam/csamtools.pyx":196
+  /* "pysam/csamtools.pyx":203
  *     # get byte size
  *     auxtype = s[0]
  *     byte_size = bam_aux_type2size( auxtype )             # <<<<<<<<<<<<<<
@@ -3955,7 +4099,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
  */
   __pyx_v_byte_size = bam_aux_type2size(__pyx_v_auxtype);
 
-  /* "pysam/csamtools.pyx":197
+  /* "pysam/csamtools.pyx":204
  *     auxtype = s[0]
  *     byte_size = bam_aux_type2size( auxtype )
  *     s += 1             # <<<<<<<<<<<<<<
@@ -3964,7 +4108,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
  */
   __pyx_v_s = (__pyx_v_s + 1);
 
-  /* "pysam/csamtools.pyx":199
+  /* "pysam/csamtools.pyx":206
  *     s += 1
  *     # get number of values in array
  *     nvalues = (<int32_t*>s)[0]             # <<<<<<<<<<<<<<
@@ -3973,7 +4117,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
  */
   __pyx_v_nvalues = (((int32_t *)__pyx_v_s)[0]);
 
-  /* "pysam/csamtools.pyx":200
+  /* "pysam/csamtools.pyx":207
  *     # get number of values in array
  *     nvalues = (<int32_t*>s)[0]
  *     s += 4             # <<<<<<<<<<<<<<
@@ -3982,19 +4126,19 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
  */
   __pyx_v_s = (__pyx_v_s + 4);
 
-  /* "pysam/csamtools.pyx":202
+  /* "pysam/csamtools.pyx":209
  *     s += 4
  *     # get values
  *     values = []             # <<<<<<<<<<<<<<
  *     if auxtype == 'c':
  *         for x from 0 <= x < nvalues:
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_v_values = ((PyObject*)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":203
+  /* "pysam/csamtools.pyx":210
  *     # get values
  *     values = []
  *     if auxtype == 'c':             # <<<<<<<<<<<<<<
@@ -4004,7 +4148,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
   __pyx_t_2 = (__pyx_v_auxtype == 'c');
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":204
+    /* "pysam/csamtools.pyx":211
  *     values = []
  *     if auxtype == 'c':
  *         for x from 0 <= x < nvalues:             # <<<<<<<<<<<<<<
@@ -4014,19 +4158,19 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     __pyx_t_3 = __pyx_v_nvalues;
     for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
 
-      /* "pysam/csamtools.pyx":205
+      /* "pysam/csamtools.pyx":212
  *     if auxtype == 'c':
  *         for x from 0 <= x < nvalues:
  *             values.append((<int8_t*>s)[0])             # <<<<<<<<<<<<<<
  *             s += 1
  *     elif auxtype == 'C':
  */
-      __pyx_t_1 = __Pyx_PyInt_to_py_int8_t((((int8_t *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PyInt_to_py_int8_t((((int8_t *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-      /* "pysam/csamtools.pyx":206
+      /* "pysam/csamtools.pyx":213
  *         for x from 0 <= x < nvalues:
  *             values.append((<int8_t*>s)[0])
  *             s += 1             # <<<<<<<<<<<<<<
@@ -4038,7 +4182,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     goto __pyx_L3;
   }
 
-  /* "pysam/csamtools.pyx":207
+  /* "pysam/csamtools.pyx":214
  *             values.append((<int8_t*>s)[0])
  *             s += 1
  *     elif auxtype == 'C':             # <<<<<<<<<<<<<<
@@ -4048,7 +4192,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
   __pyx_t_2 = (__pyx_v_auxtype == 'C');
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":208
+    /* "pysam/csamtools.pyx":215
  *             s += 1
  *     elif auxtype == 'C':
  *         for x from 0 <= x < nvalues:             # <<<<<<<<<<<<<<
@@ -4058,19 +4202,19 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     __pyx_t_3 = __pyx_v_nvalues;
     for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
 
-      /* "pysam/csamtools.pyx":209
+      /* "pysam/csamtools.pyx":216
  *     elif auxtype == 'C':
  *         for x from 0 <= x < nvalues:
  *             values.append((<uint8_t*>s)[0])             # <<<<<<<<<<<<<<
  *             s += 1
  *     elif auxtype == 's':
  */
-      __pyx_t_1 = __Pyx_PyInt_to_py_uint8_t((((uint8_t *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PyInt_to_py_uint8_t((((uint8_t *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 209; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-      /* "pysam/csamtools.pyx":210
+      /* "pysam/csamtools.pyx":217
  *         for x from 0 <= x < nvalues:
  *             values.append((<uint8_t*>s)[0])
  *             s += 1             # <<<<<<<<<<<<<<
@@ -4082,7 +4226,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     goto __pyx_L3;
   }
 
-  /* "pysam/csamtools.pyx":211
+  /* "pysam/csamtools.pyx":218
  *             values.append((<uint8_t*>s)[0])
  *             s += 1
  *     elif auxtype == 's':             # <<<<<<<<<<<<<<
@@ -4092,7 +4236,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
   __pyx_t_2 = (__pyx_v_auxtype == 's');
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":212
+    /* "pysam/csamtools.pyx":219
  *             s += 1
  *     elif auxtype == 's':
  *         for x from 0 <= x < nvalues:             # <<<<<<<<<<<<<<
@@ -4102,19 +4246,19 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     __pyx_t_3 = __pyx_v_nvalues;
     for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
 
-      /* "pysam/csamtools.pyx":213
+      /* "pysam/csamtools.pyx":220
  *     elif auxtype == 's':
  *         for x from 0 <= x < nvalues:
  *             values.append((<int16_t*>s)[0])             # <<<<<<<<<<<<<<
  *             s += 2
  *     elif auxtype == 'S':
  */
-      __pyx_t_1 = __Pyx_PyInt_to_py_int16_t((((int16_t *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PyInt_to_py_int16_t((((int16_t *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-      /* "pysam/csamtools.pyx":214
+      /* "pysam/csamtools.pyx":221
  *         for x from 0 <= x < nvalues:
  *             values.append((<int16_t*>s)[0])
  *             s += 2             # <<<<<<<<<<<<<<
@@ -4126,7 +4270,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     goto __pyx_L3;
   }
 
-  /* "pysam/csamtools.pyx":215
+  /* "pysam/csamtools.pyx":222
  *             values.append((<int16_t*>s)[0])
  *             s += 2
  *     elif auxtype == 'S':             # <<<<<<<<<<<<<<
@@ -4136,7 +4280,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
   __pyx_t_2 = (__pyx_v_auxtype == 'S');
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":216
+    /* "pysam/csamtools.pyx":223
  *             s += 2
  *     elif auxtype == 'S':
  *         for x from 0 <= x < nvalues:             # <<<<<<<<<<<<<<
@@ -4146,19 +4290,19 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     __pyx_t_3 = __pyx_v_nvalues;
     for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
 
-      /* "pysam/csamtools.pyx":217
+      /* "pysam/csamtools.pyx":224
  *     elif auxtype == 'S':
  *         for x from 0 <= x < nvalues:
  *             values.append((<uint16_t*>s)[0])             # <<<<<<<<<<<<<<
  *             s += 2
  *     elif auxtype == 'i':
  */
-      __pyx_t_1 = __Pyx_PyInt_to_py_uint16_t((((uint16_t *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PyInt_to_py_uint16_t((((uint16_t *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-      /* "pysam/csamtools.pyx":218
+      /* "pysam/csamtools.pyx":225
  *         for x from 0 <= x < nvalues:
  *             values.append((<uint16_t*>s)[0])
  *             s += 2             # <<<<<<<<<<<<<<
@@ -4170,7 +4314,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     goto __pyx_L3;
   }
 
-  /* "pysam/csamtools.pyx":219
+  /* "pysam/csamtools.pyx":226
  *             values.append((<uint16_t*>s)[0])
  *             s += 2
  *     elif auxtype == 'i':             # <<<<<<<<<<<<<<
@@ -4180,7 +4324,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
   __pyx_t_2 = (__pyx_v_auxtype == 'i');
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":220
+    /* "pysam/csamtools.pyx":227
  *             s += 2
  *     elif auxtype == 'i':
  *         for x from 0 <= x < nvalues:             # <<<<<<<<<<<<<<
@@ -4190,19 +4334,19 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     __pyx_t_3 = __pyx_v_nvalues;
     for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
 
-      /* "pysam/csamtools.pyx":221
+      /* "pysam/csamtools.pyx":228
  *     elif auxtype == 'i':
  *         for x from 0 <= x < nvalues:
  *             values.append((<int32_t*>s)[0])             # <<<<<<<<<<<<<<
  *             s += 4
  *     elif auxtype == 'I':
  */
-      __pyx_t_1 = __Pyx_PyInt_to_py_int32_t((((int32_t *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PyInt_to_py_int32_t((((int32_t *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 228; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-      /* "pysam/csamtools.pyx":222
+      /* "pysam/csamtools.pyx":229
  *         for x from 0 <= x < nvalues:
  *             values.append((<int32_t*>s)[0])
  *             s += 4             # <<<<<<<<<<<<<<
@@ -4214,7 +4358,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     goto __pyx_L3;
   }
 
-  /* "pysam/csamtools.pyx":223
+  /* "pysam/csamtools.pyx":230
  *             values.append((<int32_t*>s)[0])
  *             s += 4
  *     elif auxtype == 'I':             # <<<<<<<<<<<<<<
@@ -4224,7 +4368,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
   __pyx_t_2 = (__pyx_v_auxtype == 'I');
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":224
+    /* "pysam/csamtools.pyx":231
  *             s += 4
  *     elif auxtype == 'I':
  *         for x from 0 <= x < nvalues:             # <<<<<<<<<<<<<<
@@ -4234,19 +4378,19 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     __pyx_t_3 = __pyx_v_nvalues;
     for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
 
-      /* "pysam/csamtools.pyx":225
+      /* "pysam/csamtools.pyx":232
  *     elif auxtype == 'I':
  *         for x from 0 <= x < nvalues:
  *             values.append((<uint32_t*>s)[0])             # <<<<<<<<<<<<<<
  *             s += 4
  *     elif auxtype == 'f':
  */
-      __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t((((uint32_t *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t((((uint32_t *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-      /* "pysam/csamtools.pyx":226
+      /* "pysam/csamtools.pyx":233
  *         for x from 0 <= x < nvalues:
  *             values.append((<uint32_t*>s)[0])
  *             s += 4             # <<<<<<<<<<<<<<
@@ -4258,7 +4402,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     goto __pyx_L3;
   }
 
-  /* "pysam/csamtools.pyx":227
+  /* "pysam/csamtools.pyx":234
  *             values.append((<uint32_t*>s)[0])
  *             s += 4
  *     elif auxtype == 'f':             # <<<<<<<<<<<<<<
@@ -4268,7 +4412,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
   __pyx_t_2 = (__pyx_v_auxtype == 'f');
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":228
+    /* "pysam/csamtools.pyx":235
  *             s += 4
  *     elif auxtype == 'f':
  *         for x from 0 <= x < nvalues:             # <<<<<<<<<<<<<<
@@ -4278,19 +4422,19 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
     __pyx_t_3 = __pyx_v_nvalues;
     for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
 
-      /* "pysam/csamtools.pyx":229
+      /* "pysam/csamtools.pyx":236
  *     elif auxtype == 'f':
  *         for x from 0 <= x < nvalues:
  *             values.append((<float*>s)[0])             # <<<<<<<<<<<<<<
  *             s += 4
  * 
  */
-      __pyx_t_1 = PyFloat_FromDouble((((float *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyFloat_FromDouble((((float *)__pyx_v_s)[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 229; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyList_Append(__pyx_v_values, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-      /* "pysam/csamtools.pyx":230
+      /* "pysam/csamtools.pyx":237
  *         for x from 0 <= x < nvalues:
  *             values.append((<float*>s)[0])
  *             s += 4             # <<<<<<<<<<<<<<
@@ -4303,7 +4447,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":232
+  /* "pysam/csamtools.pyx":239
  *             s += 4
  * 
  *     return byte_size, nvalues, values             # <<<<<<<<<<<<<<
@@ -4311,11 +4455,11 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
  * #####################################################################
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint8_t(__pyx_v_byte_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint8_t(__pyx_v_byte_size); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_5 = __Pyx_PyInt_to_py_int32_t(__pyx_v_nvalues); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyInt_to_py_int32_t(__pyx_v_nvalues); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
   PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
@@ -4346,7 +4490,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_convertBinaryTagToList(uint8_t *__pyx
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":239
+/* "pysam/csamtools.pyx":246
  * ## Generic callbacks for inserting python callbacks.
  * #####################################################################
  * cdef int fetch_callback( bam1_t *alignment, void *f):             # <<<<<<<<<<<<<<
@@ -4365,33 +4509,33 @@ static int __pyx_f_5pysam_9csamtools_fetch_callback(bam1_t *__pyx_v_alignment, v
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("fetch_callback", 0);
-  __Pyx_TraceCall("fetch_callback", __pyx_f[0], 239);
+  __Pyx_TraceCall("fetch_callback", __pyx_f[0], 246);
 
-  /* "pysam/csamtools.pyx":244
+  /* "pysam/csamtools.pyx":251
  *     calls function in *f* with a new :class:`AlignedRead` object as parameter.
  *     '''
  *     a = makeAlignedRead( alignment )             # <<<<<<<<<<<<<<
  *     (<object>f)(a)
  * 
  */
-  __pyx_t_1 = __pyx_f_5pysam_9csamtools_makeAlignedRead(__pyx_v_alignment); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_5pysam_9csamtools_makeAlignedRead(__pyx_v_alignment); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_v_a = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":245
+  /* "pysam/csamtools.pyx":252
  *     '''
  *     a = makeAlignedRead( alignment )
  *     (<object>f)(a)             # <<<<<<<<<<<<<<
  * 
  * class PileupColumn(object):
  */
-  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(__pyx_v_a);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_a);
   __Pyx_GIVEREF(__pyx_v_a);
-  __pyx_t_2 = PyObject_Call(((PyObject *)__pyx_v_f), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 245; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(((PyObject *)__pyx_v_f), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
@@ -4423,7 +4567,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_12PileupColumn_1__str__(PyObject *__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":260
+/* "pysam/csamtools.pyx":267
  *         list of reads (:class:`pysam.PileupRead`) aligned to this column
  *     '''
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -4444,9 +4588,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12PileupColumn___str__(CYTHON_UNUSED
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__", 0);
-  __Pyx_TraceCall("__str__", __pyx_f[0], 260);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 267);
 
-  /* "pysam/csamtools.pyx":261
+  /* "pysam/csamtools.pyx":268
  *     '''
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
@@ -4455,30 +4599,30 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12PileupColumn___str__(CYTHON_UNUSED
  */
   __Pyx_XDECREF(__pyx_r);
 
-  /* "pysam/csamtools.pyx":262
+  /* "pysam/csamtools.pyx":269
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
  *             "\n" + "\n".join( map(str, self.pileups) )             # <<<<<<<<<<<<<<
  * 
  * cdef int pileup_callback( uint32_t tid, uint32_t pos, int n, bam_pileup1_t *pl, void *f):
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
 
-  /* "pysam/csamtools.pyx":261
+  /* "pysam/csamtools.pyx":268
  *     '''
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
  *             "\n" + "\n".join( map(str, self.pileups) )
  * 
  */
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
@@ -4489,7 +4633,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12PileupColumn___str__(CYTHON_UNUSED
   __pyx_t_2 = 0;
   __pyx_t_3 = 0;
   __pyx_t_4 = 0;
-  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
   PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
@@ -4497,34 +4641,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12PileupColumn___str__(CYTHON_UNUSED
   PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_5));
   __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
   __pyx_t_5 = 0;
-  __pyx_t_5 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
   __Pyx_GIVEREF(__pyx_t_5);
   __pyx_t_5 = 0;
-  __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-  __pyx_t_4 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_6)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_6)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-  /* "pysam/csamtools.pyx":262
+  /* "pysam/csamtools.pyx":269
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
  *             "\n" + "\n".join( map(str, self.pileups) )             # <<<<<<<<<<<<<<
  * 
  * cdef int pileup_callback( uint32_t tid, uint32_t pos, int n, bam_pileup1_t *pl, void *f):
  */
-  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_6), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_6), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pileups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__pileups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
   PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
@@ -4532,19 +4676,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12PileupColumn___str__(CYTHON_UNUSED
   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-  __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -4569,7 +4713,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12PileupColumn___str__(CYTHON_UNUSED
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":264
+/* "pysam/csamtools.pyx":271
  *             "\n" + "\n".join( map(str, self.pileups) )
  * 
  * cdef int pileup_callback( uint32_t tid, uint32_t pos, int n, bam_pileup1_t *pl, void *f):             # <<<<<<<<<<<<<<
@@ -4592,72 +4736,72 @@ static int __pyx_f_5pysam_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint3
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("pileup_callback", 0);
-  __Pyx_TraceCall("pileup_callback", __pyx_f[0], 264);
+  __Pyx_TraceCall("pileup_callback", __pyx_f[0], 271);
 
-  /* "pysam/csamtools.pyx":281
+  /* "pysam/csamtools.pyx":288
  *     '''
  * 
  *     p = PileupColumn()             # <<<<<<<<<<<<<<
  *     p.tid = tid
  *     p.pos = pos
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__PileupColumn); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__PileupColumn); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_v_p = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":282
+  /* "pysam/csamtools.pyx":289
  * 
  *     p = PileupColumn()
  *     p.tid = tid             # <<<<<<<<<<<<<<
  *     p.pos = pos
  *     p.n = n
  */
-  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  if (PyObject_SetAttr(__pyx_v_p, __pyx_n_s__tid, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_v_p, __pyx_n_s__tid, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":283
+  /* "pysam/csamtools.pyx":290
  *     p = PileupColumn()
  *     p.tid = tid
  *     p.pos = pos             # <<<<<<<<<<<<<<
  *     p.n = n
  *     pileups = []
  */
-  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  if (PyObject_SetAttr(__pyx_v_p, __pyx_n_s__pos, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_v_p, __pyx_n_s__pos, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":284
+  /* "pysam/csamtools.pyx":291
  *     p.tid = tid
  *     p.pos = pos
  *     p.n = n             # <<<<<<<<<<<<<<
  *     pileups = []
  * 
  */
-  __pyx_t_2 = PyInt_FromLong(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_n); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  if (PyObject_SetAttr(__pyx_v_p, __pyx_n_s__n, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_v_p, __pyx_n_s__n, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":285
+  /* "pysam/csamtools.pyx":292
  *     p.pos = pos
  *     p.n = n
  *     pileups = []             # <<<<<<<<<<<<<<
  * 
  *     cdef int x
  */
-  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_v_pileups = ((PyObject*)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":288
+  /* "pysam/csamtools.pyx":295
  * 
  *     cdef int x
  *     for x from 0 <= x < n:             # <<<<<<<<<<<<<<
@@ -4667,41 +4811,41 @@ static int __pyx_f_5pysam_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint3
   __pyx_t_3 = __pyx_v_n;
   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
 
-    /* "pysam/csamtools.pyx":289
+    /* "pysam/csamtools.pyx":296
  *     cdef int x
  *     for x from 0 <= x < n:
  *         pileups.append( makePileupRead( &(pl[x]) ) )             # <<<<<<<<<<<<<<
  *     p.pileups = pileups
  * 
  */
-    __pyx_t_2 = __pyx_f_5pysam_9csamtools_makePileupRead((&(__pyx_v_pl[__pyx_v_x]))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __pyx_f_5pysam_9csamtools_makePileupRead((&(__pyx_v_pl[__pyx_v_x]))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_4 = PyList_Append(__pyx_v_pileups, __pyx_t_2); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyList_Append(__pyx_v_pileups, __pyx_t_2); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   }
 
-  /* "pysam/csamtools.pyx":290
+  /* "pysam/csamtools.pyx":297
  *     for x from 0 <= x < n:
  *         pileups.append( makePileupRead( &(pl[x]) ) )
  *     p.pileups = pileups             # <<<<<<<<<<<<<<
  * 
  *     (<object>f)(p)
  */
-  if (PyObject_SetAttr(__pyx_v_p, __pyx_n_s__pileups, ((PyObject *)__pyx_v_pileups)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_v_p, __pyx_n_s__pileups, ((PyObject *)__pyx_v_pileups)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":292
+  /* "pysam/csamtools.pyx":299
  *     p.pileups = pileups
  * 
  *     (<object>f)(p)             # <<<<<<<<<<<<<<
  * 
  * cdef int pileup_fetch_callback( bam1_t *b, void *data):
  */
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_INCREF(__pyx_v_p);
   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_p);
   __Pyx_GIVEREF(__pyx_v_p);
-  __pyx_t_1 = PyObject_Call(((PyObject *)__pyx_v_f), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(((PyObject *)__pyx_v_f), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -4721,7 +4865,7 @@ static int __pyx_f_5pysam_9csamtools_pileup_callback(uint32_t __pyx_v_tid, uint3
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":294
+/* "pysam/csamtools.pyx":301
  *     (<object>f)(p)
  * 
  * cdef int pileup_fetch_callback( bam1_t *b, void *data):             # <<<<<<<<<<<<<<
@@ -4735,9 +4879,9 @@ static int __pyx_f_5pysam_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, vo
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("pileup_fetch_callback", 0);
-  __Pyx_TraceCall("pileup_fetch_callback", __pyx_f[0], 294);
+  __Pyx_TraceCall("pileup_fetch_callback", __pyx_f[0], 301);
 
-  /* "pysam/csamtools.pyx":300
+  /* "pysam/csamtools.pyx":307
  *     '''
  *     cdef bam_plbuf_t * buf
  *     buf = <bam_plbuf_t*>data             # <<<<<<<<<<<<<<
@@ -4746,7 +4890,7 @@ static int __pyx_f_5pysam_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, vo
  */
   __pyx_v_buf = ((bam_plbuf_t *)__pyx_v_data);
 
-  /* "pysam/csamtools.pyx":301
+  /* "pysam/csamtools.pyx":308
  *     cdef bam_plbuf_t * buf
  *     buf = <bam_plbuf_t*>data
  *     bam_plbuf_push(b, buf)             # <<<<<<<<<<<<<<
@@ -4755,7 +4899,7 @@ static int __pyx_f_5pysam_9csamtools_pileup_fetch_callback(bam1_t *__pyx_v_b, vo
  */
   bam_plbuf_push(__pyx_v_b, __pyx_v_buf);
 
-  /* "pysam/csamtools.pyx":302
+  /* "pysam/csamtools.pyx":309
  *     buf = <bam_plbuf_t*>data
  *     bam_plbuf_push(b, buf)
  *     return 0             # <<<<<<<<<<<<<<
@@ -4785,7 +4929,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11StderrStore_1__init__(PyObject *__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":308
+/* "pysam/csamtools.pyx":315
  *     stderr is captured.
  *     '''
  *     def __init__(self):             # <<<<<<<<<<<<<<
@@ -4798,9 +4942,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11StderrStore___init__(CYTHON_UNUSED
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__", 0);
-  __Pyx_TraceCall("__init__", __pyx_f[0], 308);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 315);
 
-  /* "pysam/csamtools.pyx":309
+  /* "pysam/csamtools.pyx":316
  *     '''
  *     def __init__(self):
  *         return             # <<<<<<<<<<<<<<
@@ -4832,7 +4976,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11StderrStore_3readAndRelease(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":314
+/* "pysam/csamtools.pyx":321
  *         self.stderr_save.setfd( self.stderr_h )
  * 
  *     def readAndRelease( self ):             # <<<<<<<<<<<<<<
@@ -4849,9 +4993,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11StderrStore_2readAndRelease(CYTHON
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("readAndRelease", 0);
-  __Pyx_TraceCall("readAndRelease", __pyx_f[0], 314);
+  __Pyx_TraceCall("readAndRelease", __pyx_f[0], 321);
 
-  /* "pysam/csamtools.pyx":315
+  /* "pysam/csamtools.pyx":322
  * 
  *     def readAndRelease( self ):
  *         return []             # <<<<<<<<<<<<<<
@@ -4859,7 +5003,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11StderrStore_2readAndRelease(CYTHON
  *         lines = []
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = ((PyObject *)__pyx_t_1);
   __pyx_t_1 = 0;
@@ -4891,7 +5035,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11StderrStore_5release(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":323
+/* "pysam/csamtools.pyx":330
  *         return lines
  * 
  *     def release(self):             # <<<<<<<<<<<<<<
@@ -4904,9 +5048,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11StderrStore_4release(CYTHON_UNUSED
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("release", 0);
-  __Pyx_TraceCall("release", __pyx_f[0], 323);
+  __Pyx_TraceCall("release", __pyx_f[0], 330);
 
-  /* "pysam/csamtools.pyx":324
+  /* "pysam/csamtools.pyx":331
  * 
  *     def release(self):
  *         return             # <<<<<<<<<<<<<<
@@ -4938,7 +5082,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11StderrStore_7__del__(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":329
+/* "pysam/csamtools.pyx":336
  *             os.remove( self.stderr_f )
  * 
  *     def __del__(self):             # <<<<<<<<<<<<<<
@@ -4956,18 +5100,18 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11StderrStore_6__del__(CYTHON_UNUSED
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__del__", 0);
-  __Pyx_TraceCall("__del__", __pyx_f[0], 329);
+  __Pyx_TraceCall("__del__", __pyx_f[0], 336);
 
-  /* "pysam/csamtools.pyx":330
+  /* "pysam/csamtools.pyx":337
  * 
  *     def __del__(self):
  *         self.release()             # <<<<<<<<<<<<<<
  * 
  * class StderrStoreWindows():
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__release); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__release); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
@@ -4999,7 +5143,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_18StderrStoreWindows_1__init__(PyObj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":334
+/* "pysam/csamtools.pyx":341
  * class StderrStoreWindows():
  *     '''does nothing. stderr can't be redirected on windows'''
  *     def __init__(self): pass             # <<<<<<<<<<<<<<
@@ -5012,7 +5156,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18StderrStoreWindows___init__(CYTHON
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__", 0);
-  __Pyx_TraceCall("__init__", __pyx_f[0], 334);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 341);
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   __Pyx_XGIVEREF(__pyx_r);
@@ -5034,7 +5178,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_18StderrStoreWindows_3readAndRelease
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":335
+/* "pysam/csamtools.pyx":342
  *     '''does nothing. stderr can't be redirected on windows'''
  *     def __init__(self): pass
  *     def readAndRelease(self): return []             # <<<<<<<<<<<<<<
@@ -5051,9 +5195,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18StderrStoreWindows_2readAndRelease
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("readAndRelease", 0);
-  __Pyx_TraceCall("readAndRelease", __pyx_f[0], 335);
+  __Pyx_TraceCall("readAndRelease", __pyx_f[0], 342);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = ((PyObject *)__pyx_t_1);
   __pyx_t_1 = 0;
@@ -5085,7 +5229,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_18StderrStoreWindows_5release(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":336
+/* "pysam/csamtools.pyx":343
  *     def __init__(self): pass
  *     def readAndRelease(self): return []
  *     def release(self): pass             # <<<<<<<<<<<<<<
@@ -5098,7 +5242,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18StderrStoreWindows_4release(CYTHON
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("release", 0);
-  __Pyx_TraceCall("release", __pyx_f[0], 336);
+  __Pyx_TraceCall("release", __pyx_f[0], 343);
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   __Pyx_XGIVEREF(__pyx_r);
@@ -5128,7 +5272,7 @@ static int __pyx_pw_5pysam_9csamtools_9Fastafile_1__cinit__(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":387
+/* "pysam/csamtools.pyx":394
  *     '''
  * 
  *     def __cinit__(self, *args, **kwargs ):             # <<<<<<<<<<<<<<
@@ -5148,9 +5292,9 @@ static int __pyx_pf_5pysam_9csamtools_9Fastafile___cinit__(struct __pyx_obj_5pys
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__", 0);
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 387);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 394);
 
-  /* "pysam/csamtools.pyx":388
+  /* "pysam/csamtools.pyx":395
  * 
  *     def __cinit__(self, *args, **kwargs ):
  *         self.fastafile = NULL             # <<<<<<<<<<<<<<
@@ -5159,7 +5303,7 @@ static int __pyx_pf_5pysam_9csamtools_9Fastafile___cinit__(struct __pyx_obj_5pys
  */
   __pyx_v_self->fastafile = NULL;
 
-  /* "pysam/csamtools.pyx":389
+  /* "pysam/csamtools.pyx":396
  *     def __cinit__(self, *args, **kwargs ):
  *         self.fastafile = NULL
  *         self._filename = NULL             # <<<<<<<<<<<<<<
@@ -5168,20 +5312,20 @@ static int __pyx_pf_5pysam_9csamtools_9Fastafile___cinit__(struct __pyx_obj_5pys
  */
   __pyx_v_self->_filename = NULL;
 
-  /* "pysam/csamtools.pyx":390
+  /* "pysam/csamtools.pyx":397
  *         self.fastafile = NULL
  *         self._filename = NULL
  *         self._open( *args, **kwargs )             # <<<<<<<<<<<<<<
  * 
  *     def _isOpen( self ):
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __pyx_t_3 = ((PyObject *)__pyx_v_kwargs);
   __Pyx_INCREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
@@ -5215,7 +5359,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_9Fastafile_3_isOpen(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":392
+/* "pysam/csamtools.pyx":399
  *         self._open( *args, **kwargs )
  * 
  *     def _isOpen( self ):             # <<<<<<<<<<<<<<
@@ -5232,9 +5376,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_2_isOpen(struct __pyx_obj
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_isOpen", 0);
-  __Pyx_TraceCall("_isOpen", __pyx_f[0], 392);
+  __Pyx_TraceCall("_isOpen", __pyx_f[0], 399);
 
-  /* "pysam/csamtools.pyx":394
+  /* "pysam/csamtools.pyx":401
  *     def _isOpen( self ):
  *         '''return true if samfile has been opened.'''
  *         return self.fastafile != NULL             # <<<<<<<<<<<<<<
@@ -5242,7 +5386,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_2_isOpen(struct __pyx_obj
  *     def __len__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->fastafile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->fastafile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -5272,7 +5416,7 @@ static Py_ssize_t __pyx_pw_5pysam_9csamtools_9Fastafile_5__len__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":396
+/* "pysam/csamtools.pyx":403
  *         return self.fastafile != NULL
  * 
  *     def __len__(self):             # <<<<<<<<<<<<<<
@@ -5290,9 +5434,9 @@ static Py_ssize_t __pyx_pf_5pysam_9csamtools_9Fastafile_4__len__(struct __pyx_ob
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__len__", 0);
-  __Pyx_TraceCall("__len__", __pyx_f[0], 396);
+  __Pyx_TraceCall("__len__", __pyx_f[0], 403);
 
-  /* "pysam/csamtools.pyx":397
+  /* "pysam/csamtools.pyx":404
  * 
  *     def __len__(self):
  *         if self.fastafile == NULL:             # <<<<<<<<<<<<<<
@@ -5302,23 +5446,23 @@ static Py_ssize_t __pyx_pf_5pysam_9csamtools_9Fastafile_4__len__(struct __pyx_ob
   __pyx_t_1 = (__pyx_v_self->fastafile == NULL);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":398
+    /* "pysam/csamtools.pyx":405
  *     def __len__(self):
  *         if self.fastafile == NULL:
  *             raise ValueError( "calling len() on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         return faidx_fetch_nseq(self.fastafile)
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_8), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":400
+  /* "pysam/csamtools.pyx":407
  *             raise ValueError( "calling len() on closed file" )
  * 
  *         return faidx_fetch_nseq(self.fastafile)             # <<<<<<<<<<<<<<
@@ -5352,7 +5496,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_9Fastafile_7_open(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":402
+/* "pysam/csamtools.pyx":409
  *         return faidx_fetch_nseq(self.fastafile)
  * 
  *     def _open( self,             # <<<<<<<<<<<<<<
@@ -5372,10 +5516,10 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_6_open(struct __pyx_obj_5
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_open", 0);
-  __Pyx_TraceCall("_open", __pyx_f[0], 402);
+  __Pyx_TraceCall("_open", __pyx_f[0], 409);
   __Pyx_INCREF(__pyx_v_filename);
 
-  /* "pysam/csamtools.pyx":410
+  /* "pysam/csamtools.pyx":417
  * 
  *         # close a previously opened file
  *         if self.fastafile != NULL: self.close()             # <<<<<<<<<<<<<<
@@ -5384,9 +5528,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_6_open(struct __pyx_obj_5
  */
   __pyx_t_1 = (__pyx_v_self->fastafile != NULL);
   if (__pyx_t_1) {
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
@@ -5394,7 +5538,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_6_open(struct __pyx_obj_5
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":411
+  /* "pysam/csamtools.pyx":418
  *         # close a previously opened file
  *         if self.fastafile != NULL: self.close()
  *         if self._filename != NULL: free(self._filename)             # <<<<<<<<<<<<<<
@@ -5408,40 +5552,40 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_6_open(struct __pyx_obj_5
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":412
+  /* "pysam/csamtools.pyx":419
  *         if self.fastafile != NULL: self.close()
  *         if self._filename != NULL: free(self._filename)
  *         filename = _my_encodeFilename(filename)             # <<<<<<<<<<<<<<
  *         self._filename = strdup(filename)
  *         self.fastafile = fai_load( filename )
  */
-  __pyx_t_3 = ((PyObject *)__pyx_f_5pysam_9csamtools__my_encodeFilename(__pyx_v_filename)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 412; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = ((PyObject *)__pyx_f_5pysam_9csamtools__my_encodeFilename(__pyx_v_filename)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_v_filename);
   __pyx_v_filename = __pyx_t_3;
   __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":413
+  /* "pysam/csamtools.pyx":420
  *         if self._filename != NULL: free(self._filename)
  *         filename = _my_encodeFilename(filename)
  *         self._filename = strdup(filename)             # <<<<<<<<<<<<<<
  *         self.fastafile = fai_load( filename )
  * 
  */
-  __pyx_t_4 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_filename = strdup(__pyx_t_4);
 
-  /* "pysam/csamtools.pyx":414
+  /* "pysam/csamtools.pyx":421
  *         filename = _my_encodeFilename(filename)
  *         self._filename = strdup(filename)
  *         self.fastafile = fai_load( filename )             # <<<<<<<<<<<<<<
  * 
  *         if self.fastafile == NULL:
  */
-  __pyx_t_4 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_4) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->fastafile = fai_load(__pyx_t_4);
 
-  /* "pysam/csamtools.pyx":416
+  /* "pysam/csamtools.pyx":423
  *         self.fastafile = fai_load( filename )
  * 
  *         if self.fastafile == NULL:             # <<<<<<<<<<<<<<
@@ -5451,26 +5595,26 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_6_open(struct __pyx_obj_5
   __pyx_t_1 = (__pyx_v_self->fastafile == NULL);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":417
+    /* "pysam/csamtools.pyx":424
  * 
  *         if self.fastafile == NULL:
  *             raise IOError("could not open file `%s`" % filename )             # <<<<<<<<<<<<<<
  * 
  *     def close( self ):
  */
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
     __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
@@ -5502,7 +5646,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_9Fastafile_9close(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":419
+/* "pysam/csamtools.pyx":426
  *             raise IOError("could not open file `%s`" % filename )
  * 
  *     def close( self ):             # <<<<<<<<<<<<<<
@@ -5516,9 +5660,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_8close(struct __pyx_obj_5
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("close", 0);
-  __Pyx_TraceCall("close", __pyx_f[0], 419);
+  __Pyx_TraceCall("close", __pyx_f[0], 426);
 
-  /* "pysam/csamtools.pyx":420
+  /* "pysam/csamtools.pyx":427
  * 
  *     def close( self ):
  *         if self.fastafile != NULL:             # <<<<<<<<<<<<<<
@@ -5528,7 +5672,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_8close(struct __pyx_obj_5
   __pyx_t_1 = (__pyx_v_self->fastafile != NULL);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":421
+    /* "pysam/csamtools.pyx":428
  *     def close( self ):
  *         if self.fastafile != NULL:
  *             fai_destroy( self.fastafile )             # <<<<<<<<<<<<<<
@@ -5537,7 +5681,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_8close(struct __pyx_obj_5
  */
     fai_destroy(__pyx_v_self->fastafile);
 
-    /* "pysam/csamtools.pyx":422
+    /* "pysam/csamtools.pyx":429
  *         if self.fastafile != NULL:
  *             fai_destroy( self.fastafile )
  *             self.fastafile = NULL             # <<<<<<<<<<<<<<
@@ -5565,7 +5709,7 @@ static void __pyx_pw_5pysam_9csamtools_9Fastafile_11__dealloc__(PyObject *__pyx_
   __Pyx_RefNannyFinishContext();
 }
 
-/* "pysam/csamtools.pyx":424
+/* "pysam/csamtools.pyx":431
  *             self.fastafile = NULL
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -5583,23 +5727,23 @@ static void __pyx_pf_5pysam_9csamtools_9Fastafile_10__dealloc__(struct __pyx_obj
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__", 0);
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 424);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 431);
 
-  /* "pysam/csamtools.pyx":425
+  /* "pysam/csamtools.pyx":432
  * 
  *     def __dealloc__(self):
  *         self.close()             # <<<<<<<<<<<<<<
  *         if self._filename != NULL: free(self._filename)
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":426
+  /* "pysam/csamtools.pyx":433
  *     def __dealloc__(self):
  *         self.close()
  *         if self._filename != NULL: free(self._filename)             # <<<<<<<<<<<<<<
@@ -5634,7 +5778,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_9Fastafile_8filename_1__get__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":430
+/* "pysam/csamtools.pyx":437
  *     property filename:
  *         '''number of :term:`filename` associated with this object.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -5654,34 +5798,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_8filename___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 430);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 437);
 
-  /* "pysam/csamtools.pyx":431
+  /* "pysam/csamtools.pyx":438
  *         '''number of :term:`filename` associated with this object.'''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             return self._filename
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_11), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":432
+  /* "pysam/csamtools.pyx":439
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             return self._filename             # <<<<<<<<<<<<<<
@@ -5689,7 +5833,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_8filename___get__(struct
  *     def fetch( self,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyBytes_FromString(__pyx_v_self->_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyBytes_FromString(__pyx_v_self->_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __pyx_r = ((PyObject *)__pyx_t_2);
   __pyx_t_2 = 0;
@@ -5724,7 +5868,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_9Fastafile_13fetch(PyObject *__pyx_v
     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,0};
     PyObject* values[4] = {0,0,0,0};
 
-    /* "pysam/csamtools.pyx":435
+    /* "pysam/csamtools.pyx":442
  * 
  *     def fetch( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -5733,7 +5877,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_9Fastafile_13fetch(PyObject *__pyx_v
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":436
+    /* "pysam/csamtools.pyx":443
  *     def fetch( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -5742,7 +5886,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_9Fastafile_13fetch(PyObject *__pyx_v
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":437
+    /* "pysam/csamtools.pyx":444
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -5751,7 +5895,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_9Fastafile_13fetch(PyObject *__pyx_v
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":438
+    /* "pysam/csamtools.pyx":445
  *                start = None,
  *                end = None,
  *                region = None):             # <<<<<<<<<<<<<<
@@ -5794,7 +5938,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_9Fastafile_13fetch(PyObject *__pyx_v
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -5813,7 +5957,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_9Fastafile_13fetch(PyObject *__pyx_v
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("fetch", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("fetch", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.Fastafile.fetch", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -5824,7 +5968,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_9Fastafile_13fetch(PyObject *__pyx_v
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":434
+/* "pysam/csamtools.pyx":441
  *             return self._filename
  * 
  *     def fetch( self,             # <<<<<<<<<<<<<<
@@ -5848,56 +5992,56 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_12fetch(struct __pyx_obj_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("fetch", 0);
-  __Pyx_TraceCall("fetch", __pyx_f[0], 434);
+  __Pyx_TraceCall("fetch", __pyx_f[0], 441);
   __Pyx_INCREF(__pyx_v_start);
   __Pyx_INCREF(__pyx_v_end);
   __Pyx_INCREF(__pyx_v_region);
 
-  /* "pysam/csamtools.pyx":455
+  /* "pysam/csamtools.pyx":462
  *         '''
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 455; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":456
+    /* "pysam/csamtools.pyx":463
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         cdef int length
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_12), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":461
+  /* "pysam/csamtools.pyx":468
  *         cdef char * seq
  * 
  *         if not region:             # <<<<<<<<<<<<<<
  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )
  *             if start is None: start = 0
  */
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_t_3 = (!__pyx_t_4);
   if (__pyx_t_3) {
 
-    /* "pysam/csamtools.pyx":462
+    /* "pysam/csamtools.pyx":469
  * 
  *         if not region:
  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )             # <<<<<<<<<<<<<<
@@ -5906,16 +6050,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_12fetch(struct __pyx_obj_
  */
     __pyx_t_3 = (__pyx_v_reference == Py_None);
     if (__pyx_t_3) {
-      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_14), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_Raise(__pyx_t_2, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L5;
     }
     __pyx_L5:;
 
-    /* "pysam/csamtools.pyx":463
+    /* "pysam/csamtools.pyx":470
  *         if not region:
  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )
  *             if start is None: start = 0             # <<<<<<<<<<<<<<
@@ -5931,7 +6075,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_12fetch(struct __pyx_obj_
     }
     __pyx_L6:;
 
-    /* "pysam/csamtools.pyx":464
+    /* "pysam/csamtools.pyx":471
  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )
  *             if start is None: start = 0
  *             if end is None: end = max_pos -1             # <<<<<<<<<<<<<<
@@ -5940,7 +6084,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_12fetch(struct __pyx_obj_
  */
     __pyx_t_3 = (__pyx_v_end == Py_None);
     if (__pyx_t_3) {
-      __pyx_t_2 = PyInt_FromLong((__pyx_v_5pysam_9csamtools_max_pos - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong((__pyx_v_5pysam_9csamtools_max_pos - 1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 471; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_v_end);
       __pyx_v_end = __pyx_t_2;
@@ -5949,18 +6093,18 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_12fetch(struct __pyx_obj_
     }
     __pyx_L7:;
 
-    /* "pysam/csamtools.pyx":466
+    /* "pysam/csamtools.pyx":473
  *             if end is None: end = max_pos -1
  * 
  *             if start > end: raise ValueError( 'invalid region: start (%i) > end (%i)' % (start, end) )             # <<<<<<<<<<<<<<
  *             if start == end: return b""
  *             # valid ranges are from 0 to 2^29-1
  */
-    __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, __pyx_v_end, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_RichCompare(__pyx_v_start, __pyx_v_end, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     if (__pyx_t_3) {
-      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_INCREF(__pyx_v_start);
       PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_start);
@@ -5968,33 +6112,33 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_12fetch(struct __pyx_obj_
       __Pyx_INCREF(__pyx_v_end);
       PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_end);
       __Pyx_GIVEREF(__pyx_v_end);
-      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_15), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_1));
       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
       __pyx_t_1 = 0;
-      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "pysam/csamtools.pyx":467
+    /* "pysam/csamtools.pyx":474
  * 
  *             if start > end: raise ValueError( 'invalid region: start (%i) > end (%i)' % (start, end) )
  *             if start == end: return b""             # <<<<<<<<<<<<<<
  *             # valid ranges are from 0 to 2^29-1
  *             if not 0 <= start < max_pos: raise ValueError( 'start out of range (%i)' % start )
  */
-    __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, __pyx_v_end, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, __pyx_v_end, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 474; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     if (__pyx_t_3) {
       __Pyx_XDECREF(__pyx_r);
@@ -6005,88 +6149,88 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_12fetch(struct __pyx_obj_
     }
     __pyx_L9:;
 
-    /* "pysam/csamtools.pyx":469
+    /* "pysam/csamtools.pyx":476
  *             if start == end: return b""
  *             # valid ranges are from 0 to 2^29-1
  *             if not 0 <= start < max_pos: raise ValueError( 'start out of range (%i)' % start )             # <<<<<<<<<<<<<<
  *             if not 0 <= end < max_pos: raise ValueError( 'end out of range (%i)' % end )
  *             # note: faidx_fetch_seq has a bug such that out-of-range access
  */
-    __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_start, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_start, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
       __Pyx_DECREF(__pyx_t_1);
-      __pyx_t_2 = PyInt_FromLong(__pyx_v_5pysam_9csamtools_max_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong(__pyx_v_5pysam_9csamtools_max_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     }
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_4 = (!__pyx_t_3);
     if (__pyx_t_4) {
-      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_v_start); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
       __pyx_t_1 = 0;
-      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 476; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L10;
     }
     __pyx_L10:;
 
-    /* "pysam/csamtools.pyx":470
+    /* "pysam/csamtools.pyx":477
  *             # valid ranges are from 0 to 2^29-1
  *             if not 0 <= start < max_pos: raise ValueError( 'start out of range (%i)' % start )
  *             if not 0 <= end < max_pos: raise ValueError( 'end out of range (%i)' % end )             # <<<<<<<<<<<<<<
  *             # note: faidx_fetch_seq has a bug such that out-of-range access
  *             # always returns the last residue. Hence do not use faidx_fetch_seq,
  */
-    __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_end, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_int_0, __pyx_v_end, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__Pyx_PyObject_IsTrue(__pyx_t_1)) {
       __Pyx_DECREF(__pyx_t_1);
-      __pyx_t_2 = PyInt_FromLong(__pyx_v_5pysam_9csamtools_max_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyInt_FromLong(__pyx_v_5pysam_9csamtools_max_pos); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_1 = PyObject_RichCompare(__pyx_v_end, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_RichCompare(__pyx_v_end, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     }
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_3 = (!__pyx_t_4);
     if (__pyx_t_3) {
-      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), __pyx_v_end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), __pyx_v_end); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
       __pyx_t_1 = 0;
-      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
       __Pyx_Raise(__pyx_t_1, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 470; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 477; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L11;
     }
     __pyx_L11:;
 
-    /* "pysam/csamtools.pyx":479
+    /* "pysam/csamtools.pyx":486
  *             #                       end-1,
  *             #                       &length)
  *             region = "%s:%i-%i" % (reference, start+1, end)             # <<<<<<<<<<<<<<
  *             if PY_MAJOR_VERSION >= 3:
  *                 region = region.encode('ascii')
  */
-    __pyx_t_1 = PyNumber_Add(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyNumber_Add(__pyx_v_start, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_INCREF(__pyx_v_reference);
     PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_reference);
@@ -6097,14 +6241,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_12fetch(struct __pyx_obj_
     PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_end);
     __Pyx_GIVEREF(__pyx_v_end);
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_19), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 479; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_19), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_v_region);
     __pyx_v_region = ((PyObject *)__pyx_t_1);
     __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":480
+    /* "pysam/csamtools.pyx":487
  *             #                       &length)
  *             region = "%s:%i-%i" % (reference, start+1, end)
  *             if PY_MAJOR_VERSION >= 3:             # <<<<<<<<<<<<<<
@@ -6114,205 +6258,1425 @@ static PyObject *__pyx_pf_5pysam_9csamtools_9Fastafile_12fetch(struct __pyx_obj_
     __pyx_t_3 = (PY_MAJOR_VERSION >= 3);
     if (__pyx_t_3) {
 
-      /* "pysam/csamtools.pyx":481
- *             region = "%s:%i-%i" % (reference, start+1, end)
- *             if PY_MAJOR_VERSION >= 3:
- *                 region = region.encode('ascii')             # <<<<<<<<<<<<<<
- *             seq = fai_fetch( self.fastafile,
- *                              region,
+      /* "pysam/csamtools.pyx":488
+ *             region = "%s:%i-%i" % (reference, start+1, end)
+ *             if PY_MAJOR_VERSION >= 3:
+ *                 region = region.encode('ascii')             # <<<<<<<<<<<<<<
+ *             seq = fai_fetch( self.fastafile,
+ *                              region,
+ */
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_region, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __Pyx_DECREF(__pyx_v_region);
+      __pyx_v_region = __pyx_t_2;
+      __pyx_t_2 = 0;
+      goto __pyx_L12;
+    }
+    __pyx_L12:;
+
+    /* "pysam/csamtools.pyx":490
+ *                 region = region.encode('ascii')
+ *             seq = fai_fetch( self.fastafile,
+ *                              region,             # <<<<<<<<<<<<<<
+ *                              &length )
+ *         else:
+ */
+    __pyx_t_5 = PyBytes_AsString(__pyx_v_region); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+    /* "pysam/csamtools.pyx":491
+ *             seq = fai_fetch( self.fastafile,
+ *                              region,
+ *                              &length )             # <<<<<<<<<<<<<<
+ *         else:
+ *             # samtools adds a '\0' at the end
+ */
+    __pyx_v_seq = fai_fetch(__pyx_v_self->fastafile, __pyx_t_5, (&__pyx_v_length));
+    goto __pyx_L4;
+  }
+  /*else*/ {
+
+    /* "pysam/csamtools.pyx":494
+ *         else:
+ *             # samtools adds a '\0' at the end
+ *             seq = fai_fetch( self.fastafile, region, &length )             # <<<<<<<<<<<<<<
+ * 
+ *         # copy to python
+ */
+    __pyx_t_5 = PyBytes_AsString(__pyx_v_region); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_v_seq = fai_fetch(__pyx_v_self->fastafile, __pyx_t_5, (&__pyx_v_length));
+  }
+  __pyx_L4:;
+
+  /* "pysam/csamtools.pyx":497
+ * 
+ *         # copy to python
+ *         if seq == NULL:             # <<<<<<<<<<<<<<
+ *             return b""
+ *         else:
+ */
+  __pyx_t_3 = (__pyx_v_seq == NULL);
+  if (__pyx_t_3) {
+
+    /* "pysam/csamtools.pyx":498
+ *         # copy to python
+ *         if seq == NULL:
+ *             return b""             # <<<<<<<<<<<<<<
+ *         else:
+ *             try:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(((PyObject *)__pyx_kp_b_16));
+    __pyx_r = ((PyObject *)__pyx_kp_b_16);
+    goto __pyx_L0;
+    goto __pyx_L13;
+  }
+  /*else*/ {
+
+    /* "pysam/csamtools.pyx":500
+ *             return b""
+ *         else:
+ *             try:             # <<<<<<<<<<<<<<
+ *                 py_seq = seq[:length]
+ *             finally:
+ */
+    /*try:*/ {
+
+      /* "pysam/csamtools.pyx":501
+ *         else:
+ *             try:
+ *                 py_seq = seq[:length]             # <<<<<<<<<<<<<<
+ *             finally:
+ *                 free(seq)
+ */
+      __pyx_t_2 = PyBytes_FromStringAndSize(__pyx_v_seq + 0, __pyx_v_length - 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 501; __pyx_clineno = __LINE__; goto __pyx_L15;}
+      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+      __pyx_v_py_seq = ((PyObject*)__pyx_t_2);
+      __pyx_t_2 = 0;
+    }
+
+    /* "pysam/csamtools.pyx":503
+ *                 py_seq = seq[:length]
+ *             finally:
+ *                 free(seq)             # <<<<<<<<<<<<<<
+ * 
+ *         return py_seq
+ */
+    /*finally:*/ {
+      int __pyx_why;
+      PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
+      int __pyx_exc_lineno;
+      __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
+      __pyx_why = 0; goto __pyx_L16;
+      __pyx_L15: {
+        __pyx_why = 4;
+        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
+        __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
+        __pyx_exc_lineno = __pyx_lineno;
+        goto __pyx_L16;
+      }
+      __pyx_L16:;
+      free(__pyx_v_seq);
+      switch (__pyx_why) {
+        case 4: {
+          __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
+          __pyx_lineno = __pyx_exc_lineno;
+          __pyx_exc_type = 0;
+          __pyx_exc_value = 0;
+          __pyx_exc_tb = 0;
+          goto __pyx_L1_error;
+        }
+      }
+    }
+  }
+  __pyx_L13:;
+
+  /* "pysam/csamtools.pyx":505
+ *                 free(seq)
+ * 
+ *         return py_seq             # <<<<<<<<<<<<<<
+ * 
+ *     cdef char * _fetch( self, char * reference, int start, int end, int * length ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_py_seq));
+  __pyx_r = ((PyObject *)__pyx_v_py_seq);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("pysam.csamtools.Fastafile.fetch", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_py_seq);
+  __Pyx_XDECREF(__pyx_v_start);
+  __Pyx_XDECREF(__pyx_v_end);
+  __Pyx_XDECREF(__pyx_v_region);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":507
+ *         return py_seq
+ * 
+ *     cdef char * _fetch( self, char * reference, int start, int end, int * length ):             # <<<<<<<<<<<<<<
+ *         '''fetch sequence for reference, start and end'''
+ * 
+ */
+
+static char *__pyx_f_5pysam_9csamtools_9Fastafile__fetch(struct __pyx_obj_5pysam_9csamtools_Fastafile *__pyx_v_self, char *__pyx_v_reference, int __pyx_v_start, int __pyx_v_end, int *__pyx_v_length) {
+  char *__pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("_fetch", 0);
+  __Pyx_TraceCall("_fetch", __pyx_f[0], 507);
+
+  /* "pysam/csamtools.pyx":514
+ *                                start,
+ *                                end-1,
+ *                                length )             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_r = faidx_fetch_seq(__pyx_v_self->fastafile, __pyx_v_reference, __pyx_v_start, (__pyx_v_end - 1), __pyx_v_length);
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5pysam_9csamtools_10FastqProxy_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5pysam_9csamtools_10FastqProxy_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
+    __Pyx_RaiseArgtupleInvalid("__init__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
+  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__init__", 0))) return -1;
+  __pyx_r = __pyx_pf_5pysam_9csamtools_10FastqProxy___init__(((struct __pyx_obj_5pysam_9csamtools_FastqProxy *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":524
+ * 
+ * cdef class FastqProxy:
+ *     def __init__(self): pass             # <<<<<<<<<<<<<<
+ * 
+ *     property name:
+ */
+
+static int __pyx_pf_5pysam_9csamtools_10FastqProxy___init__(CYTHON_UNUSED struct __pyx_obj_5pysam_9csamtools_FastqProxy *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__init__", 0);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 524);
+
+  __pyx_r = 0;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5pysam_9csamtools_10FastqProxy_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5pysam_9csamtools_10FastqProxy_4name_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_5pysam_9csamtools_10FastqProxy_4name___get__(((struct __pyx_obj_5pysam_9csamtools_FastqProxy *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":527
+ * 
+ *     property name:
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             return self._delegate.name.s
+ * 
+ */
+
+static PyObject *__pyx_pf_5pysam_9csamtools_10FastqProxy_4name___get__(struct __pyx_obj_5pysam_9csamtools_FastqProxy *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 527);
+
+  /* "pysam/csamtools.pyx":528
+ *     property name:
+ *         def __get__(self):
+ *             return self._delegate.name.s             # <<<<<<<<<<<<<<
+ * 
+ *     property sequence:
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromString(__pyx_v_self->_delegate->name.s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_r = ((PyObject *)__pyx_t_1);
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("pysam.csamtools.FastqProxy.name.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5pysam_9csamtools_10FastqProxy_8sequence_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5pysam_9csamtools_10FastqProxy_8sequence_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_5pysam_9csamtools_10FastqProxy_8sequence___get__(((struct __pyx_obj_5pysam_9csamtools_FastqProxy *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":531
+ * 
+ *     property sequence:
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             return self._delegate.seq.s
+ * 
+ */
+
+static PyObject *__pyx_pf_5pysam_9csamtools_10FastqProxy_8sequence___get__(struct __pyx_obj_5pysam_9csamtools_FastqProxy *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 531);
+
+  /* "pysam/csamtools.pyx":532
+ *     property sequence:
+ *         def __get__(self):
+ *             return self._delegate.seq.s             # <<<<<<<<<<<<<<
+ * 
+ *     property comment:
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyBytes_FromString(__pyx_v_self->_delegate->seq.s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 532; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+  __pyx_r = ((PyObject *)__pyx_t_1);
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("pysam.csamtools.FastqProxy.sequence.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5pysam_9csamtools_10FastqProxy_7comment_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5pysam_9csamtools_10FastqProxy_7comment_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_5pysam_9csamtools_10FastqProxy_7comment___get__(((struct __pyx_obj_5pysam_9csamtools_FastqProxy *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":535
+ * 
+ *     property comment:
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             if self._delegate.comment.l:
+ *                 return self._delegate.comment.s
+ */
+
+static PyObject *__pyx_pf_5pysam_9csamtools_10FastqProxy_7comment___get__(struct __pyx_obj_5pysam_9csamtools_FastqProxy *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 535);
+
+  /* "pysam/csamtools.pyx":536
+ *     property comment:
+ *         def __get__(self):
+ *             if self._delegate.comment.l:             # <<<<<<<<<<<<<<
+ *                 return self._delegate.comment.s
+ *             else: return None
+ */
+  if (__pyx_v_self->_delegate->comment.l) {
+
+    /* "pysam/csamtools.pyx":537
+ *         def __get__(self):
+ *             if self._delegate.comment.l:
+ *                 return self._delegate.comment.s             # <<<<<<<<<<<<<<
+ *             else: return None
+ * 
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = PyBytes_FromString(__pyx_v_self->_delegate->comment.s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __pyx_r = ((PyObject *)__pyx_t_1);
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+    goto __pyx_L3;
+  }
+  /*else*/ {
+
+    /* "pysam/csamtools.pyx":538
+ *             if self._delegate.comment.l:
+ *                 return self._delegate.comment.s
+ *             else: return None             # <<<<<<<<<<<<<<
+ * 
+ *     property quality:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_None);
+    __pyx_r = Py_None;
+    goto __pyx_L0;
+  }
+  __pyx_L3:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("pysam.csamtools.FastqProxy.comment.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5pysam_9csamtools_10FastqProxy_7quality_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5pysam_9csamtools_10FastqProxy_7quality_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_5pysam_9csamtools_10FastqProxy_7quality___get__(((struct __pyx_obj_5pysam_9csamtools_FastqProxy *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":541
+ * 
+ *     property quality:
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             if self._delegate.qual.l:
+ *                 return self._delegate.qual.s
+ */
+
+static PyObject *__pyx_pf_5pysam_9csamtools_10FastqProxy_7quality___get__(struct __pyx_obj_5pysam_9csamtools_FastqProxy *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 541);
+
+  /* "pysam/csamtools.pyx":542
+ *     property quality:
+ *         def __get__(self):
+ *             if self._delegate.qual.l:             # <<<<<<<<<<<<<<
+ *                 return self._delegate.qual.s
+ *             else: return None
+ */
+  if (__pyx_v_self->_delegate->qual.l) {
+
+    /* "pysam/csamtools.pyx":543
+ *         def __get__(self):
+ *             if self._delegate.qual.l:
+ *                 return self._delegate.qual.s             # <<<<<<<<<<<<<<
+ *             else: return None
+ * 
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __pyx_t_1 = PyBytes_FromString(__pyx_v_self->_delegate->qual.s); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_1));
+    __pyx_r = ((PyObject *)__pyx_t_1);
+    __pyx_t_1 = 0;
+    goto __pyx_L0;
+    goto __pyx_L3;
+  }
+  /*else*/ {
+
+    /* "pysam/csamtools.pyx":544
+ *             if self._delegate.qual.l:
+ *                 return self._delegate.qual.s
+ *             else: return None             # <<<<<<<<<<<<<<
+ * 
+ * cdef class Fastqfile:
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_None);
+    __pyx_r = Py_None;
+    goto __pyx_L0;
+  }
+  __pyx_L3:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("pysam.csamtools.FastqProxy.quality.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_5pysam_9csamtools_9Fastqfile_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_5pysam_9csamtools_9Fastqfile_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_args = 0;
+  PyObject *__pyx_v_kwargs = 0;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
+  if (unlikely(__pyx_kwds) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 1))) return -1;
+  __pyx_v_kwargs = (__pyx_kwds) ? PyDict_Copy(__pyx_kwds) : PyDict_New();
+  if (unlikely(!__pyx_v_kwargs)) return -1;
+  __Pyx_GOTREF(__pyx_v_kwargs);
+  __Pyx_INCREF(__pyx_args);
+  __pyx_v_args = __pyx_args;
+  __pyx_r = __pyx_pf_5pysam_9csamtools_9Fastqfile___cinit__(((struct __pyx_obj_5pysam_9csamtools_Fastqfile *)__pyx_v_self), __pyx_v_args, __pyx_v_kwargs);
+  __Pyx_XDECREF(__pyx_v_args);
+  __Pyx_XDECREF(__pyx_v_kwargs);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":553
+ *     '''
+ * 
+ *     def __cinit__(self, *args, **kwargs ):             # <<<<<<<<<<<<<<
+ *         # self.fastqfile = NULL
+ *         self._filename = NULL
+ */
+
+static int __pyx_pf_5pysam_9csamtools_9Fastqfile___cinit__(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self, PyObject *__pyx_v_args, PyObject *__pyx_v_kwargs) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__cinit__", 0);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 553);
+
+  /* "pysam/csamtools.pyx":555
+ *     def __cinit__(self, *args, **kwargs ):
+ *         # self.fastqfile = NULL
+ *         self._filename = NULL             # <<<<<<<<<<<<<<
+ *         self._open( *args, **kwargs )
+ * 
+ */
+  __pyx_v_self->_filename = NULL;
+
+  /* "pysam/csamtools.pyx":556
+ *         # self.fastqfile = NULL
+ *         self._filename = NULL
+ *         self._open( *args, **kwargs )             # <<<<<<<<<<<<<<
+ * 
+ *     def _isOpen( self ):
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_t_3 = ((PyObject *)__pyx_v_kwargs);
+  __Pyx_INCREF(__pyx_t_3);
+  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 556; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("pysam.csamtools.Fastqfile.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_3_isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_5pysam_9csamtools_9Fastqfile_2_isOpen[] = "Fastqfile._isOpen(self)\nreturn true if samfile has been opened.";
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_3_isOpen(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_isOpen (wrapper)", 0);
+  __pyx_r = __pyx_pf_5pysam_9csamtools_9Fastqfile_2_isOpen(((struct __pyx_obj_5pysam_9csamtools_Fastqfile *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":558
+ *         self._open( *args, **kwargs )
+ * 
+ *     def _isOpen( self ):             # <<<<<<<<<<<<<<
+ *         '''return true if samfile has been opened.'''
+ *         return self._filename != NULL
+ */
+
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_2_isOpen(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("_isOpen", 0);
+  __Pyx_TraceCall("_isOpen", __pyx_f[0], 558);
+
+  /* "pysam/csamtools.pyx":560
+ *     def _isOpen( self ):
+ *         '''return true if samfile has been opened.'''
+ *         return self._filename != NULL             # <<<<<<<<<<<<<<
+ * 
+ *     def _open( self,
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->_filename != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 560; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("pysam.csamtools.Fastqfile._isOpen", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_5_open(PyObject *__pyx_v_self, PyObject *__pyx_v_filename); /*proto*/
+static char __pyx_doc_5pysam_9csamtools_9Fastqfile_4_open[] = "Fastqfile._open(self, filename)\nopen an indexed fasta file.\n\n        This method expects an indexed fasta file.\n        ";
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_5_open(PyObject *__pyx_v_self, PyObject *__pyx_v_filename) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_open (wrapper)", 0);
+  __pyx_r = __pyx_pf_5pysam_9csamtools_9Fastqfile_4_open(((struct __pyx_obj_5pysam_9csamtools_Fastqfile *)__pyx_v_self), ((PyObject *)__pyx_v_filename));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":562
+ *         return self._filename != NULL
+ * 
+ *     def _open( self,             # <<<<<<<<<<<<<<
+ *                filename ):
+ *         '''open an indexed fasta file.
+ */
+
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_4_open(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self, PyObject *__pyx_v_filename) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  int __pyx_t_5;
+  char *__pyx_t_6;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("_open", 0);
+  __Pyx_TraceCall("_open", __pyx_f[0], 562);
+  __Pyx_INCREF(__pyx_v_filename);
+
+  /* "pysam/csamtools.pyx":569
+ *         '''
+ * 
+ *         if not os.path.exists( filename ):             # <<<<<<<<<<<<<<
+ *             raise IOError( "No such file or directory: %s" % filename )
+ * 
+ */
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_filename);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_filename);
+  __Pyx_GIVEREF(__pyx_v_filename);
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 569; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __pyx_t_5 = (!__pyx_t_4);
+  if (__pyx_t_5) {
+
+    /* "pysam/csamtools.pyx":570
+ * 
+ *         if not os.path.exists( filename ):
+ *             raise IOError( "No such file or directory: %s" % filename )             # <<<<<<<<<<<<<<
+ * 
+ *         # close a previously opened file
+ */
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_21), __pyx_v_filename); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(((PyObject *)__pyx_t_3));
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_3));
+    __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
+    __pyx_t_3 = 0;
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 570; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "pysam/csamtools.pyx":574
+ *         # close a previously opened file
+ *         # if self.fastqfile != NULL: self.close()
+ *         if self._filename != NULL: free(self._filename)             # <<<<<<<<<<<<<<
+ *         filename = _my_encodeFilename(filename)
+ *         self._filename = strdup(filename)
+ */
+  __pyx_t_5 = (__pyx_v_self->_filename != NULL);
+  if (__pyx_t_5) {
+    free(__pyx_v_self->_filename);
+    goto __pyx_L4;
+  }
+  __pyx_L4:;
+
+  /* "pysam/csamtools.pyx":575
+ *         # if self.fastqfile != NULL: self.close()
+ *         if self._filename != NULL: free(self._filename)
+ *         filename = _my_encodeFilename(filename)             # <<<<<<<<<<<<<<
+ *         self._filename = strdup(filename)
+ *         self.fastqfile = gzopen( filename, "r" )
+ */
+  __pyx_t_3 = ((PyObject *)__pyx_f_5pysam_9csamtools__my_encodeFilename(__pyx_v_filename)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 575; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_v_filename);
+  __pyx_v_filename = __pyx_t_3;
+  __pyx_t_3 = 0;
+
+  /* "pysam/csamtools.pyx":576
+ *         if self._filename != NULL: free(self._filename)
+ *         filename = _my_encodeFilename(filename)
+ *         self._filename = strdup(filename)             # <<<<<<<<<<<<<<
+ *         self.fastqfile = gzopen( filename, "r" )
+ *         self.entry = kseq_init( self.fastqfile )
+ */
+  __pyx_t_6 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 576; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_self->_filename = strdup(__pyx_t_6);
+
+  /* "pysam/csamtools.pyx":577
+ *         filename = _my_encodeFilename(filename)
+ *         self._filename = strdup(filename)
+ *         self.fastqfile = gzopen( filename, "r" )             # <<<<<<<<<<<<<<
+ *         self.entry = kseq_init( self.fastqfile )
+ * 
+ */
+  __pyx_t_6 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 577; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_self->fastqfile = gzopen(__pyx_t_6, __pyx_k__r);
+
+  /* "pysam/csamtools.pyx":578
+ *         self._filename = strdup(filename)
+ *         self.fastqfile = gzopen( filename, "r" )
+ *         self.entry = kseq_init( self.fastqfile )             # <<<<<<<<<<<<<<
+ * 
+ *     def close( self ):
+ */
+  __pyx_v_self->entry = kseq_init(__pyx_v_self->fastqfile);
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("pysam.csamtools.Fastqfile._open", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_filename);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_7close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_5pysam_9csamtools_9Fastqfile_6close[] = "Fastqfile.close(self)\nclose file.";
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_7close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("close (wrapper)", 0);
+  __pyx_r = __pyx_pf_5pysam_9csamtools_9Fastqfile_6close(((struct __pyx_obj_5pysam_9csamtools_Fastqfile *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":580
+ *         self.entry = kseq_init( self.fastqfile )
+ * 
+ *     def close( self ):             # <<<<<<<<<<<<<<
+ *         '''close file.'''
+ *         if self._filename != NULL:
+ */
+
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_6close(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("close", 0);
+  __Pyx_TraceCall("close", __pyx_f[0], 580);
+
+  /* "pysam/csamtools.pyx":582
+ *     def close( self ):
+ *         '''close file.'''
+ *         if self._filename != NULL:             # <<<<<<<<<<<<<<
+ *             gzclose( self.fastqfile )
+ *             free(self._filename)
+ */
+  __pyx_t_1 = (__pyx_v_self->_filename != NULL);
+  if (__pyx_t_1) {
+
+    /* "pysam/csamtools.pyx":583
+ *         '''close file.'''
+ *         if self._filename != NULL:
+ *             gzclose( self.fastqfile )             # <<<<<<<<<<<<<<
+ *             free(self._filename)
+ * 
+ */
+    gzclose(__pyx_v_self->fastqfile);
+
+    /* "pysam/csamtools.pyx":584
+ *         if self._filename != NULL:
+ *             gzclose( self.fastqfile )
+ *             free(self._filename)             # <<<<<<<<<<<<<<
+ * 
+ *     def __dealloc__(self):
+ */
+    free(__pyx_v_self->_filename);
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static void __pyx_pw_5pysam_9csamtools_9Fastqfile_9__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_5pysam_9csamtools_9Fastqfile_9__dealloc__(PyObject *__pyx_v_self) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+  __pyx_pf_5pysam_9csamtools_9Fastqfile_8__dealloc__(((struct __pyx_obj_5pysam_9csamtools_Fastqfile *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+}
+
+/* "pysam/csamtools.pyx":586
+ *             free(self._filename)
+ * 
+ *     def __dealloc__(self):             # <<<<<<<<<<<<<<
+ *         kseq_destroy(self.entry)
+ *         self.close()
+ */
+
+static void __pyx_pf_5pysam_9csamtools_9Fastqfile_8__dealloc__(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self) {
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__dealloc__", 0);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 586);
+
+  /* "pysam/csamtools.pyx":587
+ * 
+ *     def __dealloc__(self):
+ *         kseq_destroy(self.entry)             # <<<<<<<<<<<<<<
+ *         self.close()
+ * 
+ */
+  kseq_destroy(__pyx_v_self->entry);
+
+  /* "pysam/csamtools.pyx":588
+ *     def __dealloc__(self):
+ *         kseq_destroy(self.entry)
+ *         self.close()             # <<<<<<<<<<<<<<
+ * 
+ *     property filename:
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 588; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("pysam.csamtools.Fastqfile.__dealloc__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_L0:;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_8filename_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_8filename_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_5pysam_9csamtools_9Fastqfile_8filename___get__(((struct __pyx_obj_5pysam_9csamtools_Fastqfile *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":592
+ *     property filename:
+ *         '''number of :term:`filename` associated with this object.'''
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
+ *             return self._filename
+ */
+
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_8filename___get__(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 592);
+
+  /* "pysam/csamtools.pyx":593
+ *         '''number of :term:`filename` associated with this object.'''
+ *         def __get__(self):
+ *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
+ *             return self._filename
+ * 
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = (!__pyx_t_3);
+  if (__pyx_t_4) {
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_22), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "pysam/csamtools.pyx":594
+ *         def __get__(self):
+ *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
+ *             return self._filename             # <<<<<<<<<<<<<<
+ * 
+ *     def __iter__(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = PyBytes_FromString(__pyx_v_self->_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(((PyObject *)__pyx_t_2));
+  __pyx_r = ((PyObject *)__pyx_t_2);
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("pysam.csamtools.Fastqfile.filename.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_11__iter__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_11__iter__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_5pysam_9csamtools_9Fastqfile_10__iter__(((struct __pyx_obj_5pysam_9csamtools_Fastqfile *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":596
+ *             return self._filename
+ * 
+ *     def __iter__(self):             # <<<<<<<<<<<<<<
+ *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
+ *         return self
+ */
+
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_10__iter__(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__iter__", 0);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 596);
+
+  /* "pysam/csamtools.pyx":597
+ * 
+ *     def __iter__(self):
+ *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
+ *         return self
+ * 
+ */
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = (!__pyx_t_3);
+  if (__pyx_t_4) {
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_23), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "pysam/csamtools.pyx":598
+ *     def __iter__(self):
+ *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
+ *         return self             # <<<<<<<<<<<<<<
+ * 
+ *     cdef kseq_t * getCurrent( self ):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(((PyObject *)__pyx_v_self));
+  __pyx_r = ((PyObject *)__pyx_v_self);
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("pysam.csamtools.Fastqfile.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":600
+ *         return self
+ * 
+ *     cdef kseq_t * getCurrent( self ):             # <<<<<<<<<<<<<<
+ *         return self.entry
+ * 
  */
-      __pyx_t_1 = PyObject_GetAttr(__pyx_v_region, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_20), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __Pyx_GOTREF(__pyx_t_2);
-      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __Pyx_DECREF(__pyx_v_region);
-      __pyx_v_region = __pyx_t_2;
-      __pyx_t_2 = 0;
-      goto __pyx_L12;
-    }
-    __pyx_L12:;
 
-    /* "pysam/csamtools.pyx":483
- *                 region = region.encode('ascii')
- *             seq = fai_fetch( self.fastafile,
- *                              region,             # <<<<<<<<<<<<<<
- *                              &length )
- *         else:
+static kseq_t *__pyx_f_5pysam_9csamtools_9Fastqfile_getCurrent(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self) {
+  kseq_t *__pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("getCurrent", 0);
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 600);
+
+  /* "pysam/csamtools.pyx":601
+ * 
+ *     cdef kseq_t * getCurrent( self ):
+ *         return self.entry             # <<<<<<<<<<<<<<
+ * 
+ *     cdef int cnext(self):
  */
-    __pyx_t_5 = PyBytes_AsString(__pyx_v_region); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_r = __pyx_v_self->entry;
+  goto __pyx_L0;
 
-    /* "pysam/csamtools.pyx":484
- *             seq = fai_fetch( self.fastafile,
- *                              region,
- *                              &length )             # <<<<<<<<<<<<<<
- *         else:
- *             # samtools adds a '\0' at the end
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":603
+ *         return self.entry
+ * 
+ *     cdef int cnext(self):             # <<<<<<<<<<<<<<
+ *         '''C version of iterator
+ *         '''
  */
-    __pyx_v_seq = fai_fetch(__pyx_v_self->fastafile, __pyx_t_5, (&__pyx_v_length));
-    goto __pyx_L4;
-  }
-  /*else*/ {
 
-    /* "pysam/csamtools.pyx":487
- *         else:
- *             # samtools adds a '\0' at the end
- *             seq = fai_fetch( self.fastafile, region, &length )             # <<<<<<<<<<<<<<
+static int __pyx_f_5pysam_9csamtools_9Fastqfile_cnext(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("cnext", 0);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 603);
+
+  /* "pysam/csamtools.pyx":606
+ *         '''C version of iterator
+ *         '''
+ *         return kseq_read(self.entry)             # <<<<<<<<<<<<<<
  * 
- *         # copy to python
+ *     def __next__(self):
  */
-    __pyx_t_5 = PyBytes_AsString(__pyx_v_region); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_v_seq = fai_fetch(__pyx_v_self->fastafile, __pyx_t_5, (&__pyx_v_length));
-  }
-  __pyx_L4:;
+  __pyx_r = kseq_read(__pyx_v_self->entry);
+  goto __pyx_L0;
+
+  __pyx_r = 0;
+  __pyx_L0:;
+  __Pyx_TraceReturn(Py_None);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_13__next__(PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_5pysam_9csamtools_9Fastqfile_12__next__[] = "\n        python version of next().\n        ";
+#if CYTHON_COMPILING_IN_CPYTHON
+struct wrapperbase __pyx_wrapperbase_5pysam_9csamtools_9Fastqfile_12__next__;
+#endif
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_13__next__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__next__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_5pysam_9csamtools_9Fastqfile_12__next__(((struct __pyx_obj_5pysam_9csamtools_Fastqfile *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
 
-  /* "pysam/csamtools.pyx":490
+/* "pysam/csamtools.pyx":608
+ *         return kseq_read(self.entry)
  * 
- *         # copy to python
- *         if seq == NULL:             # <<<<<<<<<<<<<<
- *             return b""
+ *     def __next__(self):             # <<<<<<<<<<<<<<
+ *         """
+ *         python version of next().
+ */
+
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_12__next__(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self) {
+  int __pyx_v_l;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__next__", 0);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 608);
+
+  /* "pysam/csamtools.pyx":613
+ *         """
+ *         cdef int l
+ *         l = kseq_read( self.entry)             # <<<<<<<<<<<<<<
+ *         if (l > 0):
+ *             return makeFastqProxy( self.entry )
+ */
+  __pyx_v_l = kseq_read(__pyx_v_self->entry);
+
+  /* "pysam/csamtools.pyx":614
+ *         cdef int l
+ *         l = kseq_read( self.entry)
+ *         if (l > 0):             # <<<<<<<<<<<<<<
+ *             return makeFastqProxy( self.entry )
  *         else:
  */
-  __pyx_t_3 = (__pyx_v_seq == NULL);
-  if (__pyx_t_3) {
+  __pyx_t_1 = (__pyx_v_l > 0);
+  if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":491
- *         # copy to python
- *         if seq == NULL:
- *             return b""             # <<<<<<<<<<<<<<
+    /* "pysam/csamtools.pyx":615
+ *         l = kseq_read( self.entry)
+ *         if (l > 0):
+ *             return makeFastqProxy( self.entry )             # <<<<<<<<<<<<<<
  *         else:
- *             try:
+ *             raise StopIteration
  */
     __Pyx_XDECREF(__pyx_r);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_b_16));
-    __pyx_r = ((PyObject *)__pyx_kp_b_16);
+    __pyx_t_2 = __pyx_f_5pysam_9csamtools_makeFastqProxy(__pyx_v_self->entry); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_r = __pyx_t_2;
+    __pyx_t_2 = 0;
     goto __pyx_L0;
-    goto __pyx_L13;
+    goto __pyx_L3;
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":493
- *             return b""
- *         else:
- *             try:             # <<<<<<<<<<<<<<
- *                 py_seq = seq[:length]
- *             finally:
- */
-    /*try:*/ {
-
-      /* "pysam/csamtools.pyx":494
+    /* "pysam/csamtools.pyx":617
+ *             return makeFastqProxy( self.entry )
  *         else:
- *             try:
- *                 py_seq = seq[:length]             # <<<<<<<<<<<<<<
- *             finally:
- *                 free(seq)
- */
-      __pyx_t_2 = PyBytes_FromStringAndSize(__pyx_v_seq + 0, __pyx_v_length - 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 494; __pyx_clineno = __LINE__; goto __pyx_L15;}
-      __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-      __pyx_v_py_seq = ((PyObject*)__pyx_t_2);
-      __pyx_t_2 = 0;
-    }
-
-    /* "pysam/csamtools.pyx":496
- *                 py_seq = seq[:length]
- *             finally:
- *                 free(seq)             # <<<<<<<<<<<<<<
+ *             raise StopIteration             # <<<<<<<<<<<<<<
  * 
- *         return py_seq
+ *     def test( self ):
  */
-    /*finally:*/ {
-      int __pyx_why;
-      PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb;
-      int __pyx_exc_lineno;
-      __pyx_exc_type = 0; __pyx_exc_value = 0; __pyx_exc_tb = 0; __pyx_exc_lineno = 0;
-      __pyx_why = 0; goto __pyx_L16;
-      __pyx_L15: {
-        __pyx_why = 4;
-        __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
-        __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
-        __Pyx_ErrFetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb);
-        __pyx_exc_lineno = __pyx_lineno;
-        goto __pyx_L16;
-      }
-      __pyx_L16:;
-      free(__pyx_v_seq);
-      switch (__pyx_why) {
-        case 4: {
-          __Pyx_ErrRestore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb);
-          __pyx_lineno = __pyx_exc_lineno;
-          __pyx_exc_type = 0;
-          __pyx_exc_value = 0;
-          __pyx_exc_tb = 0;
-          goto __pyx_L1_error;
-        }
-      }
-    }
+    __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
-  __pyx_L13:;
-
-  /* "pysam/csamtools.pyx":498
- *                 free(seq)
- * 
- *         return py_seq             # <<<<<<<<<<<<<<
- * 
- *     cdef char * _fetch( self, char * reference, int start, int end, int * length ):
- */
-  __Pyx_XDECREF(__pyx_r);
-  __Pyx_INCREF(((PyObject *)__pyx_v_py_seq));
-  __pyx_r = ((PyObject *)__pyx_v_py_seq);
-  goto __pyx_L0;
+  __pyx_L3:;
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
   __pyx_L1_error:;
-  __Pyx_XDECREF(__pyx_t_1);
   __Pyx_XDECREF(__pyx_t_2);
-  __Pyx_AddTraceback("pysam.csamtools.Fastafile.fetch", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_AddTraceback("pysam.csamtools.Fastqfile.__next__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __pyx_r = NULL;
   __pyx_L0:;
-  __Pyx_XDECREF(__pyx_v_py_seq);
-  __Pyx_XDECREF(__pyx_v_start);
-  __Pyx_XDECREF(__pyx_v_end);
-  __Pyx_XDECREF(__pyx_v_region);
   __Pyx_XGIVEREF(__pyx_r);
   __Pyx_TraceReturn(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":500
- *         return py_seq
+/* Python wrapper */
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_15test(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_5pysam_9csamtools_9Fastqfile_14test[] = "Fastqfile.test(self)";
+static PyObject *__pyx_pw_5pysam_9csamtools_9Fastqfile_15test(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("test (wrapper)", 0);
+  __pyx_r = __pyx_pf_5pysam_9csamtools_9Fastqfile_14test(((struct __pyx_obj_5pysam_9csamtools_Fastqfile *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":619
+ *             raise StopIteration
  * 
- *     cdef char * _fetch( self, char * reference, int start, int end, int * length ):             # <<<<<<<<<<<<<<
- *         '''fetch sequence for reference, start and end'''
+ *     def test( self ):             # <<<<<<<<<<<<<<
  * 
+ *         cdef int l
  */
 
-static char *__pyx_f_5pysam_9csamtools_9Fastafile__fetch(struct __pyx_obj_5pysam_9csamtools_Fastafile *__pyx_v_self, char *__pyx_v_reference, int __pyx_v_start, int __pyx_v_end, int *__pyx_v_length) {
-  char *__pyx_r;
+static PyObject *__pyx_pf_5pysam_9csamtools_9Fastqfile_14test(struct __pyx_obj_5pysam_9csamtools_Fastqfile *__pyx_v_self) {
+  int __pyx_v_l;
+  PyObject *__pyx_r = NULL;
   __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
   __Pyx_TraceDeclarations
-  __Pyx_RefNannySetupContext("_fetch", 0);
-  __Pyx_TraceCall("_fetch", __pyx_f[0], 500);
+  __Pyx_RefNannySetupContext("test", 0);
+  __Pyx_TraceCall("test", __pyx_f[0], 619);
 
-  /* "pysam/csamtools.pyx":507
- *                                start,
- *                                end-1,
- *                                length )             # <<<<<<<<<<<<<<
+  /* "pysam/csamtools.pyx":623
+ *         cdef int l
+ * 
+ *         while 1:             # <<<<<<<<<<<<<<
+ *             l = kseq_read(self.entry)
+ *             if l <= 0: break
+ */
+  while (1) {
+    if (!1) break;
+
+    /* "pysam/csamtools.pyx":624
+ * 
+ *         while 1:
+ *             l = kseq_read(self.entry)             # <<<<<<<<<<<<<<
+ *             if l <= 0: break
+ *             printf( "name: %s\n", self.entry.name.s)
+ */
+    __pyx_v_l = kseq_read(__pyx_v_self->entry);
+
+    /* "pysam/csamtools.pyx":625
+ *         while 1:
+ *             l = kseq_read(self.entry)
+ *             if l <= 0: break             # <<<<<<<<<<<<<<
+ *             printf( "name: %s\n", self.entry.name.s)
+ *             if self.entry.comment.l:
+ */
+    __pyx_t_1 = (__pyx_v_l <= 0);
+    if (__pyx_t_1) {
+      goto __pyx_L4_break;
+      goto __pyx_L5;
+    }
+    __pyx_L5:;
+
+    /* "pysam/csamtools.pyx":626
+ *             l = kseq_read(self.entry)
+ *             if l <= 0: break
+ *             printf( "name: %s\n", self.entry.name.s)             # <<<<<<<<<<<<<<
+ *             if self.entry.comment.l:
+ *                 printf("comment: %s\n", self.entry.comment.s)
+ */
+    printf(__pyx_k_24, __pyx_v_self->entry->name.s);
+
+    /* "pysam/csamtools.pyx":627
+ *             if l <= 0: break
+ *             printf( "name: %s\n", self.entry.name.s)
+ *             if self.entry.comment.l:             # <<<<<<<<<<<<<<
+ *                 printf("comment: %s\n", self.entry.comment.s)
+ *             printf("seq: %s\n", self.entry.seq.s)
+ */
+    if (__pyx_v_self->entry->comment.l) {
+
+      /* "pysam/csamtools.pyx":628
+ *             printf( "name: %s\n", self.entry.name.s)
+ *             if self.entry.comment.l:
+ *                 printf("comment: %s\n", self.entry.comment.s)             # <<<<<<<<<<<<<<
+ *             printf("seq: %s\n", self.entry.seq.s)
+ *             if (self.entry.qual.l):
+ */
+      printf(__pyx_k_25, __pyx_v_self->entry->comment.s);
+      goto __pyx_L6;
+    }
+    __pyx_L6:;
+
+    /* "pysam/csamtools.pyx":629
+ *             if self.entry.comment.l:
+ *                 printf("comment: %s\n", self.entry.comment.s)
+ *             printf("seq: %s\n", self.entry.seq.s)             # <<<<<<<<<<<<<<
+ *             if (self.entry.qual.l):
+ *                 printf("qual: %s\n", self.entry.qual.s);
+ */
+    printf(__pyx_k_26, __pyx_v_self->entry->seq.s);
+
+    /* "pysam/csamtools.pyx":630
+ *                 printf("comment: %s\n", self.entry.comment.s)
+ *             printf("seq: %s\n", self.entry.seq.s)
+ *             if (self.entry.qual.l):             # <<<<<<<<<<<<<<
+ *                 printf("qual: %s\n", self.entry.qual.s);
+ * 
+ */
+    if (__pyx_v_self->entry->qual.l) {
+
+      /* "pysam/csamtools.pyx":631
+ *             printf("seq: %s\n", self.entry.seq.s)
+ *             if (self.entry.qual.l):
+ *                 printf("qual: %s\n", self.entry.qual.s);             # <<<<<<<<<<<<<<
+ * 
+ *         printf("return value: %d\n", l);
+ */
+      printf(__pyx_k_27, __pyx_v_self->entry->qual.s);
+      goto __pyx_L7;
+    }
+    __pyx_L7:;
+  }
+  __pyx_L4_break:;
+
+  /* "pysam/csamtools.pyx":633
+ *                 printf("qual: %s\n", self.entry.qual.s);
+ * 
+ *         printf("return value: %d\n", l);             # <<<<<<<<<<<<<<
  * 
  * #------------------------------------------------------------------------
  */
-  __pyx_r = faidx_fetch_seq(__pyx_v_self->fastafile, __pyx_v_reference, __pyx_v_start, (__pyx_v_end - 1), __pyx_v_length);
-  goto __pyx_L0;
+  printf(__pyx_k_28, __pyx_v_l);
 
-  __pyx_r = 0;
-  __pyx_L0:;
-  __Pyx_TraceReturn(Py_None);
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
   __Pyx_RefNannyFinishContext();
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":512
+/* "pysam/csamtools.pyx":638
  * #------------------------------------------------------------------------
  * #------------------------------------------------------------------------
  * cdef int count_callback( bam1_t *alignment, void *f):             # <<<<<<<<<<<<<<
@@ -6327,9 +7691,9 @@ static int __pyx_f_5pysam_9csamtools_count_callback(CYTHON_UNUSED bam1_t *__pyx_
   long __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("count_callback", 0);
-  __Pyx_TraceCall("count_callback", __pyx_f[0], 512);
+  __Pyx_TraceCall("count_callback", __pyx_f[0], 638);
 
-  /* "pysam/csamtools.pyx":515
+  /* "pysam/csamtools.pyx":641
  *      '''callback for bam_fetch - count number of reads.
  *      '''
  *      cdef int* counter = (<int*>f)             # <<<<<<<<<<<<<<
@@ -6338,7 +7702,7 @@ static int __pyx_f_5pysam_9csamtools_count_callback(CYTHON_UNUSED bam1_t *__pyx_
  */
   __pyx_v_counter = ((int *)__pyx_v_f);
 
-  /* "pysam/csamtools.pyx":516
+  /* "pysam/csamtools.pyx":642
  *      '''
  *      cdef int* counter = (<int*>f)
  *      counter[0] += 1;             # <<<<<<<<<<<<<<
@@ -6354,7 +7718,7 @@ static int __pyx_f_5pysam_9csamtools_count_callback(CYTHON_UNUSED bam1_t *__pyx_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":526
+/* "pysam/csamtools.pyx":652
  * #------------------------------------------------------------------------
  * #------------------------------------------------------------------------
  * cdef int mate_callback( bam1_t *alignment, void *f):             # <<<<<<<<<<<<<<
@@ -6371,9 +7735,9 @@ static int __pyx_f_5pysam_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, vo
   int __pyx_t_3;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("mate_callback", 0);
-  __Pyx_TraceCall("mate_callback", __pyx_f[0], 526);
+  __Pyx_TraceCall("mate_callback", __pyx_f[0], 652);
 
-  /* "pysam/csamtools.pyx":529
+  /* "pysam/csamtools.pyx":655
  *      '''callback for bam_fetch = filter mate
  *      '''
  *      cdef MateData * d = (<MateData*>f)             # <<<<<<<<<<<<<<
@@ -6382,7 +7746,7 @@ static int __pyx_f_5pysam_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, vo
  */
   __pyx_v_d = ((__pyx_t_5pysam_9csamtools_MateData *)__pyx_v_f);
 
-  /* "pysam/csamtools.pyx":534
+  /* "pysam/csamtools.pyx":660
  *      #        d.flag, alignment.core.flag, alignment.core.flag & d.flag)
  * 
  *      if d.mate == NULL:             # <<<<<<<<<<<<<<
@@ -6392,7 +7756,7 @@ static int __pyx_f_5pysam_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, vo
   __pyx_t_1 = (__pyx_v_d->mate == NULL);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":540
+    /* "pysam/csamtools.pyx":666
  *          # also, make sure that we get the other read by comparing
  *          # the flags
  *          if alignment.core.flag & d.flag != 0 and \             # <<<<<<<<<<<<<<
@@ -6402,7 +7766,7 @@ static int __pyx_f_5pysam_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, vo
     __pyx_t_1 = ((__pyx_v_alignment->core.flag & __pyx_v_d->flag) != 0);
     if (__pyx_t_1) {
 
-      /* "pysam/csamtools.pyx":541
+      /* "pysam/csamtools.pyx":667
  *          # the flags
  *          if alignment.core.flag & d.flag != 0 and \
  *                  strcmp( bam1_qname( alignment ), d.name ) == 0:             # <<<<<<<<<<<<<<
@@ -6416,7 +7780,7 @@ static int __pyx_f_5pysam_9csamtools_mate_callback(bam1_t *__pyx_v_alignment, vo
     }
     if (__pyx_t_3) {
 
-      /* "pysam/csamtools.pyx":542
+      /* "pysam/csamtools.pyx":668
  *          if alignment.core.flag & d.flag != 0 and \
  *                  strcmp( bam1_qname( alignment ), d.name ) == 0:
  *              d.mate = bam_dup1( alignment )             # <<<<<<<<<<<<<<
@@ -6458,7 +7822,7 @@ static int __pyx_pw_5pysam_9csamtools_7Samfile_1__cinit__(PyObject *__pyx_v_self
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":592
+/* "pysam/csamtools.pyx":718
  *     '''
  * 
  *     def __cinit__(self, *args, **kwargs ):             # <<<<<<<<<<<<<<
@@ -6478,9 +7842,9 @@ static int __pyx_pf_5pysam_9csamtools_7Samfile___cinit__(struct __pyx_obj_5pysam
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__", 0);
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 592);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 718);
 
-  /* "pysam/csamtools.pyx":593
+  /* "pysam/csamtools.pyx":719
  * 
  *     def __cinit__(self, *args, **kwargs ):
  *         self.samfile = NULL             # <<<<<<<<<<<<<<
@@ -6489,7 +7853,7 @@ static int __pyx_pf_5pysam_9csamtools_7Samfile___cinit__(struct __pyx_obj_5pysam
  */
   __pyx_v_self->samfile = NULL;
 
-  /* "pysam/csamtools.pyx":594
+  /* "pysam/csamtools.pyx":720
  *     def __cinit__(self, *args, **kwargs ):
  *         self.samfile = NULL
  *         self._filename = NULL             # <<<<<<<<<<<<<<
@@ -6498,7 +7862,7 @@ static int __pyx_pf_5pysam_9csamtools_7Samfile___cinit__(struct __pyx_obj_5pysam
  */
   __pyx_v_self->_filename = NULL;
 
-  /* "pysam/csamtools.pyx":595
+  /* "pysam/csamtools.pyx":721
  *         self.samfile = NULL
  *         self._filename = NULL
  *         self.isbam = False             # <<<<<<<<<<<<<<
@@ -6507,7 +7871,7 @@ static int __pyx_pf_5pysam_9csamtools_7Samfile___cinit__(struct __pyx_obj_5pysam
  */
   __pyx_v_self->isbam = 0;
 
-  /* "pysam/csamtools.pyx":596
+  /* "pysam/csamtools.pyx":722
  *         self._filename = NULL
  *         self.isbam = False
  *         self.isstream = False             # <<<<<<<<<<<<<<
@@ -6516,27 +7880,27 @@ static int __pyx_pf_5pysam_9csamtools_7Samfile___cinit__(struct __pyx_obj_5pysam
  */
   __pyx_v_self->isstream = 0;
 
-  /* "pysam/csamtools.pyx":597
+  /* "pysam/csamtools.pyx":723
  *         self.isbam = False
  *         self.isstream = False
  *         self._open( *args, **kwargs )             # <<<<<<<<<<<<<<
  * 
  *         # allocate memory for iterator
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___open); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __pyx_t_3 = ((PyObject *)__pyx_v_kwargs);
   __Pyx_INCREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 723; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":600
+  /* "pysam/csamtools.pyx":726
  * 
  *         # allocate memory for iterator
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))             # <<<<<<<<<<<<<<
@@ -6572,7 +7936,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_3_isOpen(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":602
+/* "pysam/csamtools.pyx":728
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
  * 
  *     def _isOpen( self ):             # <<<<<<<<<<<<<<
@@ -6589,9 +7953,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_2_isOpen(struct __pyx_obj_5
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_isOpen", 0);
-  __Pyx_TraceCall("_isOpen", __pyx_f[0], 602);
+  __Pyx_TraceCall("_isOpen", __pyx_f[0], 728);
 
-  /* "pysam/csamtools.pyx":604
+  /* "pysam/csamtools.pyx":730
  *     def _isOpen( self ):
  *         '''return true if samfile has been opened.'''
  *         return self.samfile != NULL             # <<<<<<<<<<<<<<
@@ -6599,7 +7963,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_2_isOpen(struct __pyx_obj_5
  *     def _hasIndex( self ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->samfile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 604; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->samfile != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -6630,7 +7994,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_5_hasIndex(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":606
+/* "pysam/csamtools.pyx":732
  *         return self.samfile != NULL
  * 
  *     def _hasIndex( self ):             # <<<<<<<<<<<<<<
@@ -6647,9 +8011,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_4_hasIndex(struct __pyx_obj
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_hasIndex", 0);
-  __Pyx_TraceCall("_hasIndex", __pyx_f[0], 606);
+  __Pyx_TraceCall("_hasIndex", __pyx_f[0], 732);
 
-  /* "pysam/csamtools.pyx":608
+  /* "pysam/csamtools.pyx":734
  *     def _hasIndex( self ):
  *         '''return true if samfile has an existing (and opened) index.'''
  *         return self.index != NULL             # <<<<<<<<<<<<<<
@@ -6657,7 +8021,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_4_hasIndex(struct __pyx_obj
  *     def _open( self,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->index != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong((__pyx_v_self->index != NULL)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -6698,7 +8062,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_7_open(PyObject *__pyx_v_se
     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__filename,&__pyx_n_s__mode,&__pyx_n_s__template,&__pyx_n_s__referencenames,&__pyx_n_s__referencelengths,&__pyx_n_s__text,&__pyx_n_s__header,&__pyx_n_s__port,&__pyx_n_s__add_sq_text,&__pyx_n_s__check_header,&__pyx_n_s__check_sq,0};
     PyObject* values[11] = {0,0,0,0,0,0,0,0,0,0,0};
 
-    /* "pysam/csamtools.pyx":612
+    /* "pysam/csamtools.pyx":738
  *     def _open( self,
  *                filename,
  *                mode = None,             # <<<<<<<<<<<<<<
@@ -6707,7 +8071,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_7_open(PyObject *__pyx_v_se
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":613
+    /* "pysam/csamtools.pyx":739
  *                filename,
  *                mode = None,
  *                Samfile template = None,             # <<<<<<<<<<<<<<
@@ -6716,7 +8080,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_7_open(PyObject *__pyx_v_se
  */
     values[2] = (PyObject *)((struct __pyx_obj_5pysam_9csamtools_Samfile *)Py_None);
 
-    /* "pysam/csamtools.pyx":614
+    /* "pysam/csamtools.pyx":740
  *                mode = None,
  *                Samfile template = None,
  *                referencenames = None,             # <<<<<<<<<<<<<<
@@ -6725,7 +8089,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_7_open(PyObject *__pyx_v_se
  */
     values[3] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":615
+    /* "pysam/csamtools.pyx":741
  *                Samfile template = None,
  *                referencenames = None,
  *                referencelengths = None,             # <<<<<<<<<<<<<<
@@ -6734,7 +8098,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_7_open(PyObject *__pyx_v_se
  */
     values[4] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":616
+    /* "pysam/csamtools.pyx":742
  *                referencenames = None,
  *                referencelengths = None,
  *                text = None,             # <<<<<<<<<<<<<<
@@ -6743,7 +8107,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_7_open(PyObject *__pyx_v_se
  */
     values[5] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":617
+    /* "pysam/csamtools.pyx":743
  *                referencelengths = None,
  *                text = None,
  *                header = None,             # <<<<<<<<<<<<<<
@@ -6752,7 +8116,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_7_open(PyObject *__pyx_v_se
  */
     values[6] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":618
+    /* "pysam/csamtools.pyx":744
  *                text = None,
  *                header = None,
  *                port = None,             # <<<<<<<<<<<<<<
@@ -6760,9 +8124,9 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_7_open(PyObject *__pyx_v_se
  *                check_header = True,
  */
     values[7] = ((PyObject *)Py_None);
-    values[8] = __pyx_k_21;
-    values[9] = __pyx_k_22;
-    values[10] = __pyx_k_23;
+    values[8] = __pyx_k_29;
+    values[9] = __pyx_k_30;
+    values[10] = __pyx_k_31;
     if (unlikely(__pyx_kwds)) {
       Py_ssize_t kw_args;
       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
@@ -6838,7 +8202,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_7_open(PyObject *__pyx_v_se
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_open") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_open") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -6871,13 +8235,13 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_7_open(PyObject *__pyx_v_se
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("_open", 0, 1, 11, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 610; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("_open", 0, 1, 11, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.Samfile._open", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   return NULL;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_template), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "template", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_template), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "template", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_7Samfile_6_open(((struct __pyx_obj_5pysam_9csamtools_Samfile *)__pyx_v_self), __pyx_v_filename, __pyx_v_mode, __pyx_v_template, __pyx_v_referencenames, __pyx_v_referencelengths, __pyx_v_text, __pyx_v_header, __pyx_v_port, __pyx_v_add_sq_text, __pyx_v_check_header, __pyx_v_check_sq);
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -6887,7 +8251,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_7_open(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":610
+/* "pysam/csamtools.pyx":736
  *         return self.index != NULL
  * 
  *     def _open( self,             # <<<<<<<<<<<<<<
@@ -6934,12 +8298,12 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_open", 0);
-  __Pyx_TraceCall("_open", __pyx_f[0], 610);
+  __Pyx_TraceCall("_open", __pyx_f[0], 736);
   __Pyx_INCREF(__pyx_v_filename);
   __Pyx_INCREF(__pyx_v_referencenames);
   __Pyx_INCREF(__pyx_v_text);
 
-  /* "pysam/csamtools.pyx":630
+  /* "pysam/csamtools.pyx":756
  * 
  *         # read mode autodetection
  *         if mode is None:             # <<<<<<<<<<<<<<
@@ -6949,7 +8313,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
   __pyx_t_1 = (__pyx_v_mode == Py_None);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":631
+    /* "pysam/csamtools.pyx":757
  *         # read mode autodetection
  *         if mode is None:
  *             try:             # <<<<<<<<<<<<<<
@@ -6963,16 +8327,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       __Pyx_XGOTREF(__pyx_t_4);
       /*try:*/ {
 
-        /* "pysam/csamtools.pyx":632
+        /* "pysam/csamtools.pyx":758
  *         if mode is None:
  *             try:
  *                 self._open(filename, 'rb', template=template,             # <<<<<<<<<<<<<<
  *                            referencenames=referencenames,
  *                            referencelengths=referencelengths,
  */
-        __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___open); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___open); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_INCREF(__pyx_v_filename);
         PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_filename);
@@ -6980,64 +8344,64 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
         __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
         PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_n_s__rb));
         __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rb));
-        __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        __pyx_t_7 = PyDict_New(); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__template), ((PyObject *)__pyx_v_template)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__template), ((PyObject *)__pyx_v_template)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
 
-        /* "pysam/csamtools.pyx":633
+        /* "pysam/csamtools.pyx":759
  *             try:
  *                 self._open(filename, 'rb', template=template,
  *                            referencenames=referencenames,             # <<<<<<<<<<<<<<
  *                            referencelengths=referencelengths,
  *                            text=text, header=header, port=port,
  */
-        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__referencenames), __pyx_v_referencenames) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__referencenames), __pyx_v_referencenames) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
 
-        /* "pysam/csamtools.pyx":634
+        /* "pysam/csamtools.pyx":760
  *                 self._open(filename, 'rb', template=template,
  *                            referencenames=referencenames,
  *                            referencelengths=referencelengths,             # <<<<<<<<<<<<<<
  *                            text=text, header=header, port=port,
  *                            check_header=check_header,
  */
-        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__referencelengths), __pyx_v_referencelengths) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__referencelengths), __pyx_v_referencelengths) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
 
-        /* "pysam/csamtools.pyx":635
+        /* "pysam/csamtools.pyx":761
  *                            referencenames=referencenames,
  *                            referencelengths=referencelengths,
  *                            text=text, header=header, port=port,             # <<<<<<<<<<<<<<
  *                            check_header=check_header,
  *                            check_sq=check_sq)
  */
-        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__text), __pyx_v_text) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
-        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__header), __pyx_v_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
-        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__port), __pyx_v_port) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__text), __pyx_v_text) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__header), __pyx_v_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__port), __pyx_v_port) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
 
-        /* "pysam/csamtools.pyx":636
+        /* "pysam/csamtools.pyx":762
  *                            referencelengths=referencelengths,
  *                            text=text, header=header, port=port,
  *                            check_header=check_header,             # <<<<<<<<<<<<<<
  *                            check_sq=check_sq)
  *                 return
  */
-        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__check_header), __pyx_v_check_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__check_header), __pyx_v_check_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
 
-        /* "pysam/csamtools.pyx":637
+        /* "pysam/csamtools.pyx":763
  *                            text=text, header=header, port=port,
  *                            check_header=check_header,
  *                            check_sq=check_sq)             # <<<<<<<<<<<<<<
  *                 return
  *             except ValueError, msg:
  */
-        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__check_sq), __pyx_v_check_sq) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
-        __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 632; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        if (PyDict_SetItem(__pyx_t_7, ((PyObject *)__pyx_n_s__check_sq), __pyx_v_check_sq) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 758; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
-        /* "pysam/csamtools.pyx":638
+        /* "pysam/csamtools.pyx":764
  *                            check_header=check_header,
  *                            check_sq=check_sq)
  *                 return             # <<<<<<<<<<<<<<
@@ -7064,7 +8428,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
 
-      /* "pysam/csamtools.pyx":639
+      /* "pysam/csamtools.pyx":765
  *                            check_sq=check_sq)
  *                 return
  *             except ValueError, msg:             # <<<<<<<<<<<<<<
@@ -7074,7 +8438,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       __pyx_t_9 = PyErr_ExceptionMatches(__pyx_builtin_ValueError);
       if (__pyx_t_9) {
         __Pyx_AddTraceback("pysam.csamtools.Samfile._open", __pyx_clineno, __pyx_lineno, __pyx_filename);
-        if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 639; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
+        if (__Pyx_GetException(&__pyx_t_8, &__pyx_t_7, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 765; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_GOTREF(__pyx_t_6);
@@ -7099,16 +8463,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       __pyx_L11_try_end:;
     }
 
-    /* "pysam/csamtools.pyx":642
+    /* "pysam/csamtools.pyx":768
  *                 pass
  * 
  *             self._open(filename, 'r', template=template,             # <<<<<<<<<<<<<<
  *                        referencenames=referencenames,
  *                        referencelengths=referencelengths,
  */
-    __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___open); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___open); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_INCREF(__pyx_v_filename);
     PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_filename);
@@ -7116,64 +8480,64 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
     PyTuple_SET_ITEM(__pyx_t_7, 1, ((PyObject *)__pyx_n_s__r));
     __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
-    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyDict_New(); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_8));
-    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__template), ((PyObject *)__pyx_v_template)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__template), ((PyObject *)__pyx_v_template)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "pysam/csamtools.pyx":643
+    /* "pysam/csamtools.pyx":769
  * 
  *             self._open(filename, 'r', template=template,
  *                        referencenames=referencenames,             # <<<<<<<<<<<<<<
  *                        referencelengths=referencelengths,
  *                        text=text, header=header, port=port,
  */
-    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__referencenames), __pyx_v_referencenames) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__referencenames), __pyx_v_referencenames) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "pysam/csamtools.pyx":644
+    /* "pysam/csamtools.pyx":770
  *             self._open(filename, 'r', template=template,
  *                        referencenames=referencenames,
  *                        referencelengths=referencelengths,             # <<<<<<<<<<<<<<
  *                        text=text, header=header, port=port,
  *                        check_header=check_header,
  */
-    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__referencelengths), __pyx_v_referencelengths) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__referencelengths), __pyx_v_referencelengths) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "pysam/csamtools.pyx":645
+    /* "pysam/csamtools.pyx":771
  *                        referencenames=referencenames,
  *                        referencelengths=referencelengths,
  *                        text=text, header=header, port=port,             # <<<<<<<<<<<<<<
  *                        check_header=check_header,
  *                        check_sq=check_sq)
  */
-    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__text), __pyx_v_text) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__header), __pyx_v_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__port), __pyx_v_port) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__text), __pyx_v_text) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__header), __pyx_v_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__port), __pyx_v_port) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "pysam/csamtools.pyx":646
+    /* "pysam/csamtools.pyx":772
  *                        referencelengths=referencelengths,
  *                        text=text, header=header, port=port,
  *                        check_header=check_header,             # <<<<<<<<<<<<<<
  *                        check_sq=check_sq)
  *             return
  */
-    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__check_header), __pyx_v_check_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__check_header), __pyx_v_check_header) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "pysam/csamtools.pyx":647
+    /* "pysam/csamtools.pyx":773
  *                        text=text, header=header, port=port,
  *                        check_header=check_header,
  *                        check_sq=check_sq)             # <<<<<<<<<<<<<<
  *             return
  * 
  */
-    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__check_sq), __pyx_v_check_sq) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_8, ((PyObject *)__pyx_n_s__check_sq), __pyx_v_check_sq) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 768; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-    /* "pysam/csamtools.pyx":648
+    /* "pysam/csamtools.pyx":774
  *                        check_header=check_header,
  *                        check_sq=check_sq)
  *             return             # <<<<<<<<<<<<<<
@@ -7187,7 +8551,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":650
+  /* "pysam/csamtools.pyx":776
  *             return
  * 
  *         assert mode in ( "r","w","rb","wb", "wh", "wbu", "rU" ), "invalid file opening mode `%s`" % mode             # <<<<<<<<<<<<<<
@@ -7197,52 +8561,52 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
   #ifndef CYTHON_WITHOUT_ASSERTIONS
   __Pyx_INCREF(__pyx_v_mode);
   __pyx_t_5 = __pyx_v_mode;
-  __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__r), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__r), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
   if (!((int)__pyx_t_1)) {
-    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__w), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__w), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __pyx_t_11 = ((int)__pyx_t_10);
   } else {
     __pyx_t_11 = ((int)__pyx_t_1);
   }
   if (!__pyx_t_11) {
-    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__rb), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__rb), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __pyx_t_10 = ((int)__pyx_t_1);
   } else {
     __pyx_t_10 = __pyx_t_11;
   }
   if (!__pyx_t_10) {
-    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__wb), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__wb), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __pyx_t_1 = ((int)__pyx_t_11);
   } else {
     __pyx_t_1 = __pyx_t_10;
   }
   if (!__pyx_t_1) {
-    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__wh), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__wh), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __pyx_t_11 = ((int)__pyx_t_10);
   } else {
     __pyx_t_11 = __pyx_t_1;
   }
   if (!__pyx_t_11) {
-    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__wbu), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__wbu), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __pyx_t_10 = ((int)__pyx_t_1);
   } else {
     __pyx_t_10 = __pyx_t_11;
   }
   if (!__pyx_t_10) {
-    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__rU), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__rU), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __pyx_t_1 = ((int)__pyx_t_11);
   } else {
@@ -7250,15 +8614,15 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
   }
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   if (unlikely(!__pyx_t_1)) {
-    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_24), __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_32), __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_5));
     PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_5));
     __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 650; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "pysam/csamtools.pyx":655
+  /* "pysam/csamtools.pyx":781
  * 
  *         # close a previously opened file
  *         if self.samfile != NULL: self.close()             # <<<<<<<<<<<<<<
@@ -7267,9 +8631,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
   __pyx_t_1 = (__pyx_v_self->samfile != NULL);
   if (__pyx_t_1) {
-    __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
@@ -7277,7 +8641,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
   }
   __pyx_L14:;
 
-  /* "pysam/csamtools.pyx":656
+  /* "pysam/csamtools.pyx":782
  *         # close a previously opened file
  *         if self.samfile != NULL: self.close()
  *         self.samfile = NULL             # <<<<<<<<<<<<<<
@@ -7286,7 +8650,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
   __pyx_v_self->samfile = NULL;
 
-  /* "pysam/csamtools.pyx":659
+  /* "pysam/csamtools.pyx":785
  * 
  *         cdef bam_header_t * header_to_write
  *         header_to_write = NULL             # <<<<<<<<<<<<<<
@@ -7295,7 +8659,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
   __pyx_v_header_to_write = NULL;
 
-  /* "pysam/csamtools.pyx":661
+  /* "pysam/csamtools.pyx":787
  *         header_to_write = NULL
  * 
  *         if self._filename != NULL: free(self._filename )             # <<<<<<<<<<<<<<
@@ -7309,71 +8673,71 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
   }
   __pyx_L15:;
 
-  /* "pysam/csamtools.pyx":662
+  /* "pysam/csamtools.pyx":788
  * 
  *         if self._filename != NULL: free(self._filename )
  *         filename = _my_encodeFilename(filename)             # <<<<<<<<<<<<<<
  *         cdef bytes bmode = mode.encode('ascii')
  *         #cdef char* cfilename
  */
-  __pyx_t_8 = ((PyObject *)__pyx_f_5pysam_9csamtools__my_encodeFilename(__pyx_v_filename)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 662; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = ((PyObject *)__pyx_f_5pysam_9csamtools__my_encodeFilename(__pyx_v_filename)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
   __Pyx_DECREF(__pyx_v_filename);
   __pyx_v_filename = __pyx_t_8;
   __pyx_t_8 = 0;
 
-  /* "pysam/csamtools.pyx":663
+  /* "pysam/csamtools.pyx":789
  *         if self._filename != NULL: free(self._filename )
  *         filename = _my_encodeFilename(filename)
  *         cdef bytes bmode = mode.encode('ascii')             # <<<<<<<<<<<<<<
  *         #cdef char* cfilename
  *         #cfilename = filename.encode(_FILENAME_ENCODING)
  */
-  __pyx_t_8 = PyObject_GetAttr(__pyx_v_mode, __pyx_n_s__encode); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_GetAttr(__pyx_v_mode, __pyx_n_s__encode); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
-  __pyx_t_5 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_k_tuple_25), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_k_tuple_33), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-  if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(PyBytes_CheckExact(__pyx_t_5))||((__pyx_t_5) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_5)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_bmode = ((PyObject*)__pyx_t_5);
   __pyx_t_5 = 0;
 
-  /* "pysam/csamtools.pyx":666
+  /* "pysam/csamtools.pyx":792
  *         #cdef char* cfilename
  *         #cfilename = filename.encode(_FILENAME_ENCODING)
  *         self._filename = strdup(filename)             # <<<<<<<<<<<<<<
  *         self.isstream = strcmp( filename, "-" ) == 0
  * 
  */
-  __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_filename = strdup(__pyx_t_12);
 
-  /* "pysam/csamtools.pyx":667
+  /* "pysam/csamtools.pyx":793
  *         #cfilename = filename.encode(_FILENAME_ENCODING)
  *         self._filename = strdup(filename)
  *         self.isstream = strcmp( filename, "-" ) == 0             # <<<<<<<<<<<<<<
  * 
  *         self.isbam = len(mode) > 1 and mode[1] == 'b'
  */
-  __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_self->isstream = (strcmp(__pyx_t_12, __pyx_k_26) == 0);
+  __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_self->isstream = (strcmp(__pyx_t_12, __pyx_k_34) == 0);
 
-  /* "pysam/csamtools.pyx":669
+  /* "pysam/csamtools.pyx":795
  *         self.isstream = strcmp( filename, "-" ) == 0
  * 
  *         self.isbam = len(mode) > 1 and mode[1] == 'b'             # <<<<<<<<<<<<<<
  * 
  *         self.isremote = strncmp(filename,"http:",5) == 0 or \
  */
-  __pyx_t_13 = PyObject_Length(__pyx_v_mode); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_5 = __Pyx_PyBool_FromLong((__pyx_t_13 > 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_13 = PyObject_Length(__pyx_v_mode); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyBool_FromLong((__pyx_t_13 > 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_mode, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_mode, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
-    __pyx_t_7 = PyObject_RichCompare(__pyx_t_8, ((PyObject *)__pyx_n_s__b), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_RichCompare(__pyx_t_8, ((PyObject *)__pyx_n_s__b), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __pyx_t_8 = __pyx_t_7;
     __pyx_t_7 = 0;
@@ -7381,36 +8745,36 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     __pyx_t_8 = __pyx_t_5;
     __pyx_t_5 = 0;
   }
-  __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_8); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 669; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = __Pyx_PyInt_AsInt(__pyx_t_8); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
   __pyx_v_self->isbam = __pyx_t_9;
 
-  /* "pysam/csamtools.pyx":671
+  /* "pysam/csamtools.pyx":797
  *         self.isbam = len(mode) > 1 and mode[1] == 'b'
  * 
  *         self.isremote = strncmp(filename,"http:",5) == 0 or \             # <<<<<<<<<<<<<<
  *             strncmp(filename,"ftp:",4) == 0
  * 
  */
-  __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_1 = (strncmp(__pyx_t_12, __pyx_k_27, 5) == 0);
+  __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = (strncmp(__pyx_t_12, __pyx_k_35, 5) == 0);
   if (!__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":672
+    /* "pysam/csamtools.pyx":798
  * 
  *         self.isremote = strncmp(filename,"http:",5) == 0 or \
  *             strncmp(filename,"ftp:",4) == 0             # <<<<<<<<<<<<<<
  * 
  *         cdef char * ctext
  */
-    __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 672; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_10 = (strncmp(__pyx_t_12, __pyx_k_28, 4) == 0);
+    __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = (strncmp(__pyx_t_12, __pyx_k_36, 4) == 0);
     __pyx_t_11 = __pyx_t_10;
   } else {
     __pyx_t_11 = __pyx_t_1;
   }
 
-  /* "pysam/csamtools.pyx":671
+  /* "pysam/csamtools.pyx":797
  *         self.isbam = len(mode) > 1 and mode[1] == 'b'
  * 
  *         self.isremote = strncmp(filename,"http:",5) == 0 or \             # <<<<<<<<<<<<<<
@@ -7419,7 +8783,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
   __pyx_v_self->isremote = __pyx_t_11;
 
-  /* "pysam/csamtools.pyx":675
+  /* "pysam/csamtools.pyx":801
  * 
  *         cdef char * ctext
  *         ctext = NULL             # <<<<<<<<<<<<<<
@@ -7428,32 +8792,32 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
   __pyx_v_ctext = NULL;
 
-  /* "pysam/csamtools.pyx":677
+  /* "pysam/csamtools.pyx":803
  *         ctext = NULL
  * 
  *         if mode[0] == 'w':             # <<<<<<<<<<<<<<
  *             # open file for writing
  * 
  */
-  __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
-  __pyx_t_5 = PyObject_RichCompare(__pyx_t_8, ((PyObject *)__pyx_n_s__w), Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_RichCompare(__pyx_t_8, ((PyObject *)__pyx_n_s__w), Py_EQ); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 677; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 803; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   if (__pyx_t_11) {
 
-    /* "pysam/csamtools.pyx":681
+    /* "pysam/csamtools.pyx":807
  * 
  *             # header structure (used for writing)
  *             if template:             # <<<<<<<<<<<<<<
  *                 # copy header from another file
  *                 header_to_write = template.samfile.header
  */
-    __pyx_t_11 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_template)); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_template)); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_11) {
 
-      /* "pysam/csamtools.pyx":683
+      /* "pysam/csamtools.pyx":809
  *             if template:
  *                 # copy header from another file
  *                 header_to_write = template.samfile.header             # <<<<<<<<<<<<<<
@@ -7465,17 +8829,17 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       goto __pyx_L17;
     }
 
-    /* "pysam/csamtools.pyx":685
+    /* "pysam/csamtools.pyx":811
  *                 header_to_write = template.samfile.header
  * 
  *             elif header:             # <<<<<<<<<<<<<<
  *                 header_to_write = self._buildHeader( header )
  * 
  */
-    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_header); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_header); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_11) {
 
-      /* "pysam/csamtools.pyx":686
+      /* "pysam/csamtools.pyx":812
  * 
  *             elif header:
  *                 header_to_write = self._buildHeader( header )             # <<<<<<<<<<<<<<
@@ -7487,7 +8851,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     }
     /*else*/ {
 
-      /* "pysam/csamtools.pyx":690
+      /* "pysam/csamtools.pyx":816
  *             else:
  *                 # build header from a target names and lengths
  *                 assert referencenames and referencelengths, "either supply options `template`, `header` or  both `referencenames` and `referencelengths` for writing"             # <<<<<<<<<<<<<<
@@ -7495,20 +8859,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  * 
  */
       #ifndef CYTHON_WITHOUT_ASSERTIONS
-      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_referencenames); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_referencenames); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       if (__pyx_t_11) {
-        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_referencelengths); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_referencelengths); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_t_10 = __pyx_t_1;
       } else {
         __pyx_t_10 = __pyx_t_11;
       }
       if (unlikely(!__pyx_t_10)) {
-        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_29));
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_37));
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #endif
 
-      /* "pysam/csamtools.pyx":691
+      /* "pysam/csamtools.pyx":817
  *                 # build header from a target names and lengths
  *                 assert referencenames and referencelengths, "either supply options `template`, `header` or  both `referencenames` and `referencelengths` for writing"
  *                 assert len(referencenames) == len(referencelengths), "unequal names and lengths of reference sequences"             # <<<<<<<<<<<<<<
@@ -7516,28 +8880,28 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  *                 # allocate and fill header
  */
       #ifndef CYTHON_WITHOUT_ASSERTIONS
-      __pyx_t_13 = PyObject_Length(__pyx_v_referencenames); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_t_15 = PyObject_Length(__pyx_v_referencelengths); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_13 = PyObject_Length(__pyx_v_referencenames); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_15 = PyObject_Length(__pyx_v_referencelengths); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       if (unlikely(!(__pyx_t_13 == __pyx_t_15))) {
-        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_30));
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 691; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_38));
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #endif
 
-      /* "pysam/csamtools.pyx":694
+      /* "pysam/csamtools.pyx":820
  * 
  *                 # allocate and fill header
  *                 referencenames = [ _force_bytes(ref) for ref in referencenames ]             # <<<<<<<<<<<<<<
  *                 header_to_write = bam_header_init()
  *                 header_to_write.n_targets = len(referencenames)
  */
-      __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       if (PyList_CheckExact(__pyx_v_referencenames) || PyTuple_CheckExact(__pyx_v_referencenames)) {
         __pyx_t_8 = __pyx_v_referencenames; __Pyx_INCREF(__pyx_t_8); __pyx_t_15 = 0;
         __pyx_t_16 = NULL;
       } else {
-        __pyx_t_15 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_referencenames); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_15 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_referencenames); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __pyx_t_16 = Py_TYPE(__pyx_t_8)->tp_iternext;
       }
@@ -7545,23 +8909,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
         if (!__pyx_t_16 && PyList_CheckExact(__pyx_t_8)) {
           if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_8)) break;
           #if CYTHON_COMPILING_IN_CPYTHON
-          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_15); __Pyx_INCREF(__pyx_t_7); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_15); __Pyx_INCREF(__pyx_t_7); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #else
-          __pyx_t_7 = PySequence_ITEM(__pyx_t_8, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PySequence_ITEM(__pyx_t_8, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #endif
         } else if (!__pyx_t_16 && PyTuple_CheckExact(__pyx_t_8)) {
           if (__pyx_t_15 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
           #if CYTHON_COMPILING_IN_CPYTHON
-          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_15); __Pyx_INCREF(__pyx_t_7); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_15); __Pyx_INCREF(__pyx_t_7); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #else
-          __pyx_t_7 = PySequence_ITEM(__pyx_t_8, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PySequence_ITEM(__pyx_t_8, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #endif
         } else {
           __pyx_t_7 = __pyx_t_16(__pyx_t_8);
           if (unlikely(!__pyx_t_7)) {
             if (PyErr_Occurred()) {
               if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             }
             break;
           }
@@ -7570,9 +8934,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
         __Pyx_XDECREF(__pyx_v_ref);
         __pyx_v_ref = __pyx_t_7;
         __pyx_t_7 = 0;
-        __pyx_t_7 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_ref)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_ref)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        if (unlikely(__Pyx_PyList_Append(__pyx_t_5, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 694; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (unlikely(__Pyx_PyList_Append(__pyx_t_5, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       }
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
@@ -7583,7 +8947,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       __pyx_v_referencenames = __pyx_t_8;
       __pyx_t_8 = 0;
 
-      /* "pysam/csamtools.pyx":695
+      /* "pysam/csamtools.pyx":821
  *                 # allocate and fill header
  *                 referencenames = [ _force_bytes(ref) for ref in referencenames ]
  *                 header_to_write = bam_header_init()             # <<<<<<<<<<<<<<
@@ -7592,17 +8956,17 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
       __pyx_v_header_to_write = bam_header_init();
 
-      /* "pysam/csamtools.pyx":696
+      /* "pysam/csamtools.pyx":822
  *                 referencenames = [ _force_bytes(ref) for ref in referencenames ]
  *                 header_to_write = bam_header_init()
  *                 header_to_write.n_targets = len(referencenames)             # <<<<<<<<<<<<<<
  *                 n = 0
  *                 for x in referencenames: n += len(x) + 1
  */
-      __pyx_t_15 = PyObject_Length(__pyx_v_referencenames); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 696; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_15 = PyObject_Length(__pyx_v_referencenames); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_v_header_to_write->n_targets = __pyx_t_15;
 
-      /* "pysam/csamtools.pyx":697
+      /* "pysam/csamtools.pyx":823
  *                 header_to_write = bam_header_init()
  *                 header_to_write.n_targets = len(referencenames)
  *                 n = 0             # <<<<<<<<<<<<<<
@@ -7612,7 +8976,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       __Pyx_INCREF(__pyx_int_0);
       __pyx_v_n = __pyx_int_0;
 
-      /* "pysam/csamtools.pyx":698
+      /* "pysam/csamtools.pyx":824
  *                 header_to_write.n_targets = len(referencenames)
  *                 n = 0
  *                 for x in referencenames: n += len(x) + 1             # <<<<<<<<<<<<<<
@@ -7623,7 +8987,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
         __pyx_t_8 = __pyx_v_referencenames; __Pyx_INCREF(__pyx_t_8); __pyx_t_15 = 0;
         __pyx_t_16 = NULL;
       } else {
-        __pyx_t_15 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_referencenames); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_15 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_v_referencenames); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __pyx_t_16 = Py_TYPE(__pyx_t_8)->tp_iternext;
       }
@@ -7631,23 +8995,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
         if (!__pyx_t_16 && PyList_CheckExact(__pyx_t_8)) {
           if (__pyx_t_15 >= PyList_GET_SIZE(__pyx_t_8)) break;
           #if CYTHON_COMPILING_IN_CPYTHON
-          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_15); __Pyx_INCREF(__pyx_t_5); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_5 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_15); __Pyx_INCREF(__pyx_t_5); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #else
-          __pyx_t_5 = PySequence_ITEM(__pyx_t_8, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_5 = PySequence_ITEM(__pyx_t_8, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #endif
         } else if (!__pyx_t_16 && PyTuple_CheckExact(__pyx_t_8)) {
           if (__pyx_t_15 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
           #if CYTHON_COMPILING_IN_CPYTHON
-          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_15); __Pyx_INCREF(__pyx_t_5); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_5 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_15); __Pyx_INCREF(__pyx_t_5); __pyx_t_15++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #else
-          __pyx_t_5 = PySequence_ITEM(__pyx_t_8, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_5 = PySequence_ITEM(__pyx_t_8, __pyx_t_15); __pyx_t_15++; if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #endif
         } else {
           __pyx_t_5 = __pyx_t_16(__pyx_t_8);
           if (unlikely(!__pyx_t_5)) {
             if (PyErr_Occurred()) {
               if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             }
             break;
           }
@@ -7656,10 +9020,10 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
         __Pyx_XDECREF(__pyx_v_x);
         __pyx_v_x = __pyx_t_5;
         __pyx_t_5 = 0;
-        __pyx_t_13 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_5 = PyInt_FromSsize_t((__pyx_t_13 + 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_13 = PyObject_Length(__pyx_v_x); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyInt_FromSsize_t((__pyx_t_13 + 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_n, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 698; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_v_n, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_DECREF(__pyx_v_n);
@@ -7668,27 +9032,27 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       }
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
-      /* "pysam/csamtools.pyx":699
+      /* "pysam/csamtools.pyx":825
  *                 n = 0
  *                 for x in referencenames: n += len(x) + 1
  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))             # <<<<<<<<<<<<<<
  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
  *                 for x from 0 <= x < header_to_write.n_targets:
  */
-      __pyx_t_17 = __Pyx_PyInt_AsSize_t(__pyx_v_n); if (unlikely((__pyx_t_17 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_17 = __Pyx_PyInt_AsSize_t(__pyx_v_n); if (unlikely((__pyx_t_17 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_v_header_to_write->target_name = ((char **)calloc(__pyx_t_17, (sizeof(char *))));
 
-      /* "pysam/csamtools.pyx":700
+      /* "pysam/csamtools.pyx":826
  *                 for x in referencenames: n += len(x) + 1
  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))
  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))             # <<<<<<<<<<<<<<
  *                 for x from 0 <= x < header_to_write.n_targets:
  *                     header_to_write.target_len[x] = referencelengths[x]
  */
-      __pyx_t_17 = __Pyx_PyInt_AsSize_t(__pyx_v_n); if (unlikely((__pyx_t_17 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_17 = __Pyx_PyInt_AsSize_t(__pyx_v_n); if (unlikely((__pyx_t_17 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_v_header_to_write->target_len = ((uint32_t *)calloc(__pyx_t_17, (sizeof(uint32_t))));
 
-      /* "pysam/csamtools.pyx":701
+      /* "pysam/csamtools.pyx":827
  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))
  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
  *                 for x from 0 <= x < header_to_write.n_targets:             # <<<<<<<<<<<<<<
@@ -7697,78 +9061,78 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
       __pyx_t_18 = __pyx_v_header_to_write->n_targets;
       for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19++) {
-        __pyx_t_8 = PyInt_FromLong(__pyx_t_19); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyInt_FromLong(__pyx_t_19); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_XDECREF(__pyx_v_x);
         __pyx_v_x = __pyx_t_8;
         __pyx_t_8 = 0;
 
-        /* "pysam/csamtools.pyx":702
+        /* "pysam/csamtools.pyx":828
  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
  *                 for x from 0 <= x < header_to_write.n_targets:
  *                     header_to_write.target_len[x] = referencelengths[x]             # <<<<<<<<<<<<<<
  *                     name = referencenames[x]
  *                     header_to_write.target_name[x] = <char*>calloc(len(name)+1, sizeof(char))
  */
-        __pyx_t_8 = PyObject_GetItem(__pyx_v_referencelengths, __pyx_v_x); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_GetItem(__pyx_v_referencelengths, __pyx_v_x); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
-        __pyx_t_20 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_20 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_20 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_20 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-        __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 702; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         (__pyx_v_header_to_write->target_len[__pyx_t_15]) = __pyx_t_20;
 
-        /* "pysam/csamtools.pyx":703
+        /* "pysam/csamtools.pyx":829
  *                 for x from 0 <= x < header_to_write.n_targets:
  *                     header_to_write.target_len[x] = referencelengths[x]
  *                     name = referencenames[x]             # <<<<<<<<<<<<<<
  *                     header_to_write.target_name[x] = <char*>calloc(len(name)+1, sizeof(char))
  *                     strncpy( header_to_write.target_name[x], name, len(name) )
  */
-        __pyx_t_8 = PyObject_GetItem(__pyx_v_referencenames, __pyx_v_x); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_GetItem(__pyx_v_referencenames, __pyx_v_x); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 829; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_XDECREF(__pyx_v_name);
         __pyx_v_name = __pyx_t_8;
         __pyx_t_8 = 0;
 
-        /* "pysam/csamtools.pyx":704
+        /* "pysam/csamtools.pyx":830
  *                     header_to_write.target_len[x] = referencelengths[x]
  *                     name = referencenames[x]
  *                     header_to_write.target_name[x] = <char*>calloc(len(name)+1, sizeof(char))             # <<<<<<<<<<<<<<
  *                     strncpy( header_to_write.target_name[x], name, len(name) )
  * 
  */
-        __pyx_t_15 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_15 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_13 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_13 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         (__pyx_v_header_to_write->target_name[__pyx_t_13]) = ((char *)calloc((__pyx_t_15 + 1), (sizeof(char))));
 
-        /* "pysam/csamtools.pyx":705
+        /* "pysam/csamtools.pyx":831
  *                     name = referencenames[x]
  *                     header_to_write.target_name[x] = <char*>calloc(len(name)+1, sizeof(char))
  *                     strncpy( header_to_write.target_name[x], name, len(name) )             # <<<<<<<<<<<<<<
  * 
  *                 # Optionally, if there is no text, add a SAM compatible header to output
  */
-        __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_12 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_13 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 705; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_15 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_15 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_12 = PyBytes_AsString(__pyx_v_name); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_13 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         strncpy((__pyx_v_header_to_write->target_name[__pyx_t_15]), __pyx_t_12, __pyx_t_13);
-        __pyx_t_19 = __Pyx_PyInt_AsLong(__pyx_v_x); if (unlikely((__pyx_t_19 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_19 = __Pyx_PyInt_AsLong(__pyx_v_x); if (unlikely((__pyx_t_19 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
 
-      /* "pysam/csamtools.pyx":701
+      /* "pysam/csamtools.pyx":827
  *                 header_to_write.target_name = <char**>calloc(n, sizeof(char*))
  *                 header_to_write.target_len = <uint32_t*>calloc(n, sizeof(uint32_t))
  *                 for x from 0 <= x < header_to_write.n_targets:             # <<<<<<<<<<<<<<
  *                     header_to_write.target_len[x] = referencelengths[x]
  *                     name = referencenames[x]
  */
-      __pyx_t_8 = PyInt_FromLong(__pyx_t_19); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 701; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyInt_FromLong(__pyx_t_19); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 827; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       __Pyx_XDECREF(__pyx_v_x);
       __pyx_v_x = __pyx_t_8;
       __pyx_t_8 = 0;
 
-      /* "pysam/csamtools.pyx":709
+      /* "pysam/csamtools.pyx":835
  *                 # Optionally, if there is no text, add a SAM compatible header to output
  *                 # file.
  *                 if text is None and add_sq_text:             # <<<<<<<<<<<<<<
@@ -7777,27 +9141,27 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
       __pyx_t_10 = (__pyx_v_text == Py_None);
       if (__pyx_t_10) {
-        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_add_sq_text); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_v_add_sq_text); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 835; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_t_1 = __pyx_t_11;
       } else {
         __pyx_t_1 = __pyx_t_10;
       }
       if (__pyx_t_1) {
 
-        /* "pysam/csamtools.pyx":710
+        /* "pysam/csamtools.pyx":836
  *                 # file.
  *                 if text is None and add_sq_text:
  *                     text = []             # <<<<<<<<<<<<<<
  *                     for x from 0 <= x < header_to_write.n_targets:
  *                         text.append( "@SQ\tSN:%s\tLN:%s\n" % (referencenames[x], referencelengths[x] ) )
  */
-        __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(__pyx_v_text);
         __pyx_v_text = ((PyObject *)__pyx_t_8);
         __pyx_t_8 = 0;
 
-        /* "pysam/csamtools.pyx":711
+        /* "pysam/csamtools.pyx":837
  *                 if text is None and add_sq_text:
  *                     text = []
  *                     for x from 0 <= x < header_to_write.n_targets:             # <<<<<<<<<<<<<<
@@ -7806,24 +9170,24 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
         __pyx_t_18 = __pyx_v_header_to_write->n_targets;
         for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19++) {
-          __pyx_t_8 = PyInt_FromLong(__pyx_t_19); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyInt_FromLong(__pyx_t_19); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_8);
           __Pyx_XDECREF(__pyx_v_x);
           __pyx_v_x = __pyx_t_8;
           __pyx_t_8 = 0;
 
-          /* "pysam/csamtools.pyx":712
+          /* "pysam/csamtools.pyx":838
  *                     text = []
  *                     for x from 0 <= x < header_to_write.n_targets:
  *                         text.append( "@SQ\tSN:%s\tLN:%s\n" % (referencenames[x], referencelengths[x] ) )             # <<<<<<<<<<<<<<
  *                     text = ''.join(text)
  * 
  */
-          __pyx_t_8 = PyObject_GetItem(__pyx_v_referencenames, __pyx_v_x); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyObject_GetItem(__pyx_v_referencenames, __pyx_v_x); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_8);
-          __pyx_t_7 = PyObject_GetItem(__pyx_v_referencelengths, __pyx_v_x); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyObject_GetItem(__pyx_v_referencelengths, __pyx_v_x); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
-          __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_5);
           PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8);
           __Pyx_GIVEREF(__pyx_t_8);
@@ -7831,44 +9195,44 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
           __Pyx_GIVEREF(__pyx_t_7);
           __pyx_t_8 = 0;
           __pyx_t_7 = 0;
-          __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_31), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_39), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_7));
           __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-          __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_text, ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 712; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_text, ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 838; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_5);
           __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
           __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-          __pyx_t_19 = __Pyx_PyInt_AsLong(__pyx_v_x); if (unlikely((__pyx_t_19 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_19 = __Pyx_PyInt_AsLong(__pyx_v_x); if (unlikely((__pyx_t_19 == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
 
-        /* "pysam/csamtools.pyx":711
+        /* "pysam/csamtools.pyx":837
  *                 if text is None and add_sq_text:
  *                     text = []
  *                     for x from 0 <= x < header_to_write.n_targets:             # <<<<<<<<<<<<<<
  *                         text.append( "@SQ\tSN:%s\tLN:%s\n" % (referencenames[x], referencelengths[x] ) )
  *                     text = ''.join(text)
  */
-        __pyx_t_5 = PyInt_FromLong(__pyx_t_19); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 711; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyInt_FromLong(__pyx_t_19); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_XDECREF(__pyx_v_x);
         __pyx_v_x = __pyx_t_5;
         __pyx_t_5 = 0;
 
-        /* "pysam/csamtools.pyx":713
+        /* "pysam/csamtools.pyx":839
  *                     for x from 0 <= x < header_to_write.n_targets:
  *                         text.append( "@SQ\tSN:%s\tLN:%s\n" % (referencenames[x], referencelengths[x] ) )
  *                     text = ''.join(text)             # <<<<<<<<<<<<<<
  * 
  *                 if text != None:
  */
-        __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_16), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_16), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_INCREF(__pyx_v_text);
         PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_text);
         __Pyx_GIVEREF(__pyx_v_text);
-        __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 713; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
@@ -7879,42 +9243,42 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       }
       __pyx_L24:;
 
-      /* "pysam/csamtools.pyx":715
+      /* "pysam/csamtools.pyx":841
  *                     text = ''.join(text)
  * 
  *                 if text != None:             # <<<<<<<<<<<<<<
  *                     # copy without \0
  *                     text = _force_bytes(text)
  */
-      __pyx_t_8 = PyObject_RichCompare(__pyx_v_text, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 715; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyObject_RichCompare(__pyx_v_text, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
       if (__pyx_t_1) {
 
-        /* "pysam/csamtools.pyx":717
+        /* "pysam/csamtools.pyx":843
  *                 if text != None:
  *                     # copy without \0
  *                     text = _force_bytes(text)             # <<<<<<<<<<<<<<
  *                     ctext = text
  *                     header_to_write.l_text = strlen(ctext)
  */
-        __pyx_t_8 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_text)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_text)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(__pyx_v_text);
         __pyx_v_text = __pyx_t_8;
         __pyx_t_8 = 0;
 
-        /* "pysam/csamtools.pyx":718
+        /* "pysam/csamtools.pyx":844
  *                     # copy without \0
  *                     text = _force_bytes(text)
  *                     ctext = text             # <<<<<<<<<<<<<<
  *                     header_to_write.l_text = strlen(ctext)
  *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )
  */
-        __pyx_t_12 = PyBytes_AsString(__pyx_v_text); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_12 = PyBytes_AsString(__pyx_v_text); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 844; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_v_ctext = __pyx_t_12;
 
-        /* "pysam/csamtools.pyx":719
+        /* "pysam/csamtools.pyx":845
  *                     text = _force_bytes(text)
  *                     ctext = text
  *                     header_to_write.l_text = strlen(ctext)             # <<<<<<<<<<<<<<
@@ -7923,7 +9287,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
         __pyx_v_header_to_write->l_text = strlen(__pyx_v_ctext);
 
-        /* "pysam/csamtools.pyx":720
+        /* "pysam/csamtools.pyx":846
  *                     ctext = text
  *                     header_to_write.l_text = strlen(ctext)
  *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )             # <<<<<<<<<<<<<<
@@ -7932,7 +9296,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
         __pyx_v_header_to_write->text = ((char *)calloc(strlen(__pyx_v_ctext), (sizeof(char))));
 
-        /* "pysam/csamtools.pyx":721
+        /* "pysam/csamtools.pyx":847
  *                     header_to_write.l_text = strlen(ctext)
  *                     header_to_write.text = <char*>calloc( strlen(ctext), sizeof(char) )
  *                     memcpy( header_to_write.text, ctext, strlen(ctext) )             # <<<<<<<<<<<<<<
@@ -7944,7 +9308,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       }
       __pyx_L27:;
 
-      /* "pysam/csamtools.pyx":723
+      /* "pysam/csamtools.pyx":849
  *                     memcpy( header_to_write.text, ctext, strlen(ctext) )
  * 
  *                 header_to_write.hash = NULL             # <<<<<<<<<<<<<<
@@ -7953,7 +9317,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
       __pyx_v_header_to_write->hash = NULL;
 
-      /* "pysam/csamtools.pyx":724
+      /* "pysam/csamtools.pyx":850
  * 
  *                 header_to_write.hash = NULL
  *                 header_to_write.rg2lib = NULL             # <<<<<<<<<<<<<<
@@ -7964,54 +9328,54 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     }
     __pyx_L17:;
 
-    /* "pysam/csamtools.pyx":728
+    /* "pysam/csamtools.pyx":854
  *             # open file. Header gets written to file at the same time for bam files
  *             # and sam files (in the latter case, the mode needs to be wh)
  *             store = StderrStore()             # <<<<<<<<<<<<<<
  *             self.samfile = samopen( filename, bmode, header_to_write )
  *             store.release()
  */
-    __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
-    __pyx_t_7 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 728; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __pyx_v_store = __pyx_t_7;
     __pyx_t_7 = 0;
 
-    /* "pysam/csamtools.pyx":729
+    /* "pysam/csamtools.pyx":855
  *             # and sam files (in the latter case, the mode needs to be wh)
  *             store = StderrStore()
  *             self.samfile = samopen( filename, bmode, header_to_write )             # <<<<<<<<<<<<<<
  *             store.release()
  * 
  */
-    __pyx_t_21 = PyBytes_AsString(__pyx_v_filename); if (unlikely((__pyx_t_21 == (const char*)NULL) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_12 = PyBytes_AsString(((PyObject *)__pyx_v_bmode)); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 729; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_21 = PyBytes_AsString(__pyx_v_filename); if (unlikely((__pyx_t_21 == (const char*)NULL) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = PyBytes_AsString(((PyObject *)__pyx_v_bmode)); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_v_self->samfile = samopen(__pyx_t_21, __pyx_t_12, __pyx_v_header_to_write);
 
-    /* "pysam/csamtools.pyx":730
+    /* "pysam/csamtools.pyx":856
  *             store = StderrStore()
  *             self.samfile = samopen( filename, bmode, header_to_write )
  *             store.release()             # <<<<<<<<<<<<<<
  * 
  *             # bam_header_destroy takes care of cleaning up of all the members
  */
-    __pyx_t_7 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
-    /* "pysam/csamtools.pyx":733
+    /* "pysam/csamtools.pyx":859
  * 
  *             # bam_header_destroy takes care of cleaning up of all the members
  *             if not template and header_to_write != NULL:             # <<<<<<<<<<<<<<
  *                 bam_header_destroy( header_to_write )
  * 
  */
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_template)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(((PyObject *)__pyx_v_template)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_10 = (!__pyx_t_1);
     if (__pyx_t_10) {
       __pyx_t_1 = (__pyx_v_header_to_write != NULL);
@@ -8021,7 +9385,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     }
     if (__pyx_t_11) {
 
-      /* "pysam/csamtools.pyx":734
+      /* "pysam/csamtools.pyx":860
  *             # bam_header_destroy takes care of cleaning up of all the members
  *             if not template and header_to_write != NULL:
  *                 bam_header_destroy( header_to_write )             # <<<<<<<<<<<<<<
@@ -8035,33 +9399,33 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     goto __pyx_L16;
   }
 
-  /* "pysam/csamtools.pyx":736
+  /* "pysam/csamtools.pyx":862
  *                 bam_header_destroy( header_to_write )
  * 
  *         elif mode[0] == "r":             # <<<<<<<<<<<<<<
  *             # open file for reading
  *             if strncmp( filename, "-", 1) != 0 and \
  */
-  __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
-  __pyx_t_7 = PyObject_RichCompare(__pyx_t_8, ((PyObject *)__pyx_n_s__r), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_RichCompare(__pyx_t_8, ((PyObject *)__pyx_n_s__r), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
   if (__pyx_t_11) {
 
-    /* "pysam/csamtools.pyx":738
+    /* "pysam/csamtools.pyx":864
  *         elif mode[0] == "r":
  *             # open file for reading
  *             if strncmp( filename, "-", 1) != 0 and \             # <<<<<<<<<<<<<<
  *                     not self.isremote and \
  *                     not os.path.exists( filename ):
  */
-    __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_11 = (strncmp(__pyx_t_12, __pyx_k_26, 1) != 0);
+    __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = (strncmp(__pyx_t_12, __pyx_k_34, 1) != 0);
     if (__pyx_t_11) {
 
-      /* "pysam/csamtools.pyx":739
+      /* "pysam/csamtools.pyx":865
  *             # open file for reading
  *             if strncmp( filename, "-", 1) != 0 and \
  *                     not self.isremote and \             # <<<<<<<<<<<<<<
@@ -8071,31 +9435,31 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       __pyx_t_10 = (!__pyx_v_self->isremote);
       if (__pyx_t_10) {
 
-        /* "pysam/csamtools.pyx":740
+        /* "pysam/csamtools.pyx":866
  *             if strncmp( filename, "-", 1) != 0 and \
  *                     not self.isremote and \
  *                     not os.path.exists( filename ):             # <<<<<<<<<<<<<<
  *                 raise IOError( "file `%s` not found" % filename)
  * 
  */
-        __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_8 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__path); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__path); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__exists); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__exists); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_INCREF(__pyx_v_filename);
         PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_filename);
         __Pyx_GIVEREF(__pyx_v_filename);
-        __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 740; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 866; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __pyx_t_22 = (!__pyx_t_1);
         __pyx_t_1 = __pyx_t_22;
@@ -8108,42 +9472,42 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     }
     if (__pyx_t_10) {
 
-      /* "pysam/csamtools.pyx":741
+      /* "pysam/csamtools.pyx":867
  *                     not self.isremote and \
  *                     not os.path.exists( filename ):
  *                 raise IOError( "file `%s` not found" % filename)             # <<<<<<<<<<<<<<
  * 
  *             # try to detect errors
  */
-      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_32), __pyx_v_filename); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_40), __pyx_v_filename); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_5));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
       __pyx_t_5 = 0;
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
       __Pyx_Raise(__pyx_t_5, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 867; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L29;
     }
     __pyx_L29:;
 
-    /* "pysam/csamtools.pyx":744
+    /* "pysam/csamtools.pyx":870
  * 
  *             # try to detect errors
  *             self.samfile = samopen( filename, bmode, NULL )             # <<<<<<<<<<<<<<
  *             if self.samfile == NULL:
  *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)
  */
-    __pyx_t_21 = PyBytes_AsString(__pyx_v_filename); if (unlikely((__pyx_t_21 == (const char*)NULL) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_12 = PyBytes_AsString(((PyObject *)__pyx_v_bmode)); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 744; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_21 = PyBytes_AsString(__pyx_v_filename); if (unlikely((__pyx_t_21 == (const char*)NULL) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = PyBytes_AsString(((PyObject *)__pyx_v_bmode)); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_v_self->samfile = samopen(__pyx_t_21, __pyx_t_12, NULL);
 
-    /* "pysam/csamtools.pyx":745
+    /* "pysam/csamtools.pyx":871
  *             # try to detect errors
  *             self.samfile = samopen( filename, bmode, NULL )
  *             if self.samfile == NULL:             # <<<<<<<<<<<<<<
@@ -8153,31 +9517,31 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     __pyx_t_10 = (__pyx_v_self->samfile == NULL);
     if (__pyx_t_10) {
 
-      /* "pysam/csamtools.pyx":746
+      /* "pysam/csamtools.pyx":872
  *             self.samfile = samopen( filename, bmode, NULL )
  *             if self.samfile == NULL:
  *                 raise ValueError( "could not open file (mode='%s') - is it SAM/BAM format?" % mode)             # <<<<<<<<<<<<<<
  * 
  *             # bam files require a valid header
  */
-      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_33), __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_41), __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_5));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
       __pyx_t_5 = 0;
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
       __Pyx_Raise(__pyx_t_5, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 872; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L30;
     }
     __pyx_L30:;
 
-    /* "pysam/csamtools.pyx":749
+    /* "pysam/csamtools.pyx":875
  * 
  *             # bam files require a valid header
  *             if self.isbam:             # <<<<<<<<<<<<<<
@@ -8186,7 +9550,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
  */
     if (__pyx_v_self->isbam) {
 
-      /* "pysam/csamtools.pyx":750
+      /* "pysam/csamtools.pyx":876
  *             # bam files require a valid header
  *             if self.isbam:
  *                 if self.samfile.header == NULL:             # <<<<<<<<<<<<<<
@@ -8196,26 +9560,26 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       __pyx_t_10 = (__pyx_v_self->samfile->header == NULL);
       if (__pyx_t_10) {
 
-        /* "pysam/csamtools.pyx":751
+        /* "pysam/csamtools.pyx":877
  *             if self.isbam:
  *                 if self.samfile.header == NULL:
  *                     raise ValueError( "file does not have valid header (mode='%s') - is it BAM format?" % mode )             # <<<<<<<<<<<<<<
  *             else:
  *                 # in sam files it is optional (samfile full of unmapped reads)
  */
-        __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_34), __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_42), __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_5));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
         __pyx_t_5 = 0;
-        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
         __Pyx_Raise(__pyx_t_5, 0, 0, 0);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 751; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 877; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L32;
       }
       __pyx_L32:;
@@ -8223,14 +9587,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     }
     /*else*/ {
 
-      /* "pysam/csamtools.pyx":754
+      /* "pysam/csamtools.pyx":880
  *             else:
  *                 # in sam files it is optional (samfile full of unmapped reads)
  *                 if check_header and self.samfile.header == NULL:             # <<<<<<<<<<<<<<
  *                     raise ValueError( "file does not have valid header (mode='%s') - is it SAM format?" % mode )
  * 
  */
-      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_check_header); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_check_header); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       if (__pyx_t_10) {
         __pyx_t_11 = (__pyx_v_self->samfile->header == NULL);
         __pyx_t_1 = __pyx_t_11;
@@ -8239,40 +9603,40 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       }
       if (__pyx_t_1) {
 
-        /* "pysam/csamtools.pyx":755
+        /* "pysam/csamtools.pyx":881
  *                 # in sam files it is optional (samfile full of unmapped reads)
  *                 if check_header and self.samfile.header == NULL:
  *                     raise ValueError( "file does not have valid header (mode='%s') - is it SAM format?" % mode )             # <<<<<<<<<<<<<<
  * 
  *             # disabled for autodetection to work
  */
-        __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_35), __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_43), __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_5));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
         __pyx_t_5 = 0;
-        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
         __Pyx_Raise(__pyx_t_5, 0, 0, 0);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L33;
       }
       __pyx_L33:;
     }
     __pyx_L31:;
 
-    /* "pysam/csamtools.pyx":759
+    /* "pysam/csamtools.pyx":885
  *             # disabled for autodetection to work
  *             # needs to be disabled so that reading from sam-files without headers works
  *             if check_sq and self.samfile.header.n_targets == 0:             # <<<<<<<<<<<<<<
  *                 raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)
  * 
  */
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_check_sq); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_check_sq); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_1) {
       __pyx_t_10 = (__pyx_v_self->samfile->header->n_targets == 0);
       __pyx_t_11 = __pyx_t_10;
@@ -8281,26 +9645,26 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     }
     if (__pyx_t_11) {
 
-      /* "pysam/csamtools.pyx":760
+      /* "pysam/csamtools.pyx":886
  *             # needs to be disabled so that reading from sam-files without headers works
  *             if check_sq and self.samfile.header.n_targets == 0:
  *                 raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)             # <<<<<<<<<<<<<<
  * 
  *         if self.samfile == NULL:
  */
-      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_36), __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_44), __pyx_v_mode); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_5));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
       __pyx_t_5 = 0;
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
       __Pyx_Raise(__pyx_t_5, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 886; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L34;
     }
     __pyx_L34:;
@@ -8308,7 +9672,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
   }
   __pyx_L16:;
 
-  /* "pysam/csamtools.pyx":762
+  /* "pysam/csamtools.pyx":888
  *                 raise ValueError( "file header is empty (mode='%s') - is it SAM/BAM format?" % mode)
  * 
  *         if self.samfile == NULL:             # <<<<<<<<<<<<<<
@@ -8318,42 +9682,42 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
   __pyx_t_11 = (__pyx_v_self->samfile == NULL);
   if (__pyx_t_11) {
 
-    /* "pysam/csamtools.pyx":763
+    /* "pysam/csamtools.pyx":889
  * 
  *         if self.samfile == NULL:
  *             raise IOError("could not open file `%s`" % filename )             # <<<<<<<<<<<<<<
  * 
  *         # check for index and open if present
  */
-    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_v_filename); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_9), __pyx_v_filename); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_5));
-    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_5));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
     __pyx_t_5 = 0;
-    __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
     __Pyx_Raise(__pyx_t_5, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 763; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L35;
   }
   __pyx_L35:;
 
-  /* "pysam/csamtools.pyx":766
+  /* "pysam/csamtools.pyx":892
  * 
  *         # check for index and open if present
  *         if mode[0] == "r" and self.isbam:             # <<<<<<<<<<<<<<
  * 
  *             if not self.isremote:
  */
-  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_mode, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_5) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__r), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_RichCompare(__pyx_t_5, ((PyObject *)__pyx_n_s__r), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 892; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
   if (__pyx_t_11) {
     __pyx_t_1 = __pyx_v_self->isbam;
@@ -8362,7 +9726,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
   }
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":768
+    /* "pysam/csamtools.pyx":894
  *         if mode[0] == "r" and self.isbam:
  * 
  *             if not self.isremote:             # <<<<<<<<<<<<<<
@@ -8372,67 +9736,67 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     __pyx_t_1 = (!__pyx_v_self->isremote);
     if (__pyx_t_1) {
 
-      /* "pysam/csamtools.pyx":769
+      /* "pysam/csamtools.pyx":895
  * 
  *             if not self.isremote:
  *                 if not os.path.exists(filename + b".bai") \             # <<<<<<<<<<<<<<
  *                         and not os.path.exists( filename[:-4] + b".bai"):
  *                     self.index = NULL
  */
-      __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
-      __pyx_t_5 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__path); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetAttr(__pyx_t_8, __pyx_n_s__path); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-      __pyx_t_8 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__exists); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__exists); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_5 = PyNumber_Add(__pyx_v_filename, ((PyObject *)__pyx_kp_b_37)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyNumber_Add(__pyx_v_filename, ((PyObject *)__pyx_kp_b_45)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
       __Pyx_GIVEREF(__pyx_t_5);
       __pyx_t_5 = 0;
-      __pyx_t_5 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
       __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 769; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __pyx_t_11 = (!__pyx_t_1);
       if (__pyx_t_11) {
 
-        /* "pysam/csamtools.pyx":770
+        /* "pysam/csamtools.pyx":896
  *             if not self.isremote:
  *                 if not os.path.exists(filename + b".bai") \
  *                         and not os.path.exists( filename[:-4] + b".bai"):             # <<<<<<<<<<<<<<
  *                     self.index = NULL
  *                 else:
  */
-        __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __pyx_t_7 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__path); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_GetAttr(__pyx_t_5, __pyx_n_s__path); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-        __pyx_t_5 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__exists); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__exists); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        __pyx_t_7 = __Pyx_PySequence_GetSlice(__pyx_v_filename, 0, -4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __Pyx_PySequence_GetSlice(__pyx_v_filename, 0, -4); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_8 = PyNumber_Add(__pyx_t_7, ((PyObject *)__pyx_kp_b_37)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyNumber_Add(__pyx_t_7, ((PyObject *)__pyx_kp_b_45)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
         __Pyx_GIVEREF(__pyx_t_8);
         __pyx_t_8 = 0;
-        __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 770; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
         __pyx_t_10 = (!__pyx_t_1);
         __pyx_t_1 = __pyx_t_10;
@@ -8441,7 +9805,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       }
       if (__pyx_t_1) {
 
-        /* "pysam/csamtools.pyx":771
+        /* "pysam/csamtools.pyx":897
  *                 if not os.path.exists(filename + b".bai") \
  *                         and not os.path.exists( filename[:-4] + b".bai"):
  *                     self.index = NULL             # <<<<<<<<<<<<<<
@@ -8453,17 +9817,17 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       }
       /*else*/ {
 
-        /* "pysam/csamtools.pyx":774
+        /* "pysam/csamtools.pyx":900
  *                 else:
  *                     # returns NULL if there is no index or index could not be opened
  *                     self.index = bam_index_load(filename)             # <<<<<<<<<<<<<<
  *                     if self.index == NULL:
  *                         raise IOError("error while opening index `%s` " % filename )
  */
-        __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 774; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 900; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_v_self->index = bam_index_load(__pyx_t_12);
 
-        /* "pysam/csamtools.pyx":775
+        /* "pysam/csamtools.pyx":901
  *                     # returns NULL if there is no index or index could not be opened
  *                     self.index = bam_index_load(filename)
  *                     if self.index == NULL:             # <<<<<<<<<<<<<<
@@ -8473,26 +9837,26 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
         __pyx_t_1 = (__pyx_v_self->index == NULL);
         if (__pyx_t_1) {
 
-          /* "pysam/csamtools.pyx":776
+          /* "pysam/csamtools.pyx":902
  *                     self.index = bam_index_load(filename)
  *                     if self.index == NULL:
  *                         raise IOError("error while opening index `%s` " % filename )             # <<<<<<<<<<<<<<
  *             else:
  *                 self.index = bam_index_load(filename)
  */
-          __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_38), __pyx_v_filename); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), __pyx_v_filename); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_8));
-          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
           PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_8));
           __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
           __pyx_t_8 = 0;
-          __pyx_t_8 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_8);
           __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
           __Pyx_Raise(__pyx_t_8, 0, 0, 0);
           __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 902; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           goto __pyx_L39;
         }
         __pyx_L39:;
@@ -8502,17 +9866,17 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     }
     /*else*/ {
 
-      /* "pysam/csamtools.pyx":778
+      /* "pysam/csamtools.pyx":904
  *                         raise IOError("error while opening index `%s` " % filename )
  *             else:
  *                 self.index = bam_index_load(filename)             # <<<<<<<<<<<<<<
  *                 if self.index == NULL:
  *                     raise IOError("error while opening index `%s` " % filename )
  */
-      __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 778; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_12 = PyBytes_AsString(__pyx_v_filename); if (unlikely((!__pyx_t_12) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 904; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_v_self->index = bam_index_load(__pyx_t_12);
 
-      /* "pysam/csamtools.pyx":779
+      /* "pysam/csamtools.pyx":905
  *             else:
  *                 self.index = bam_index_load(filename)
  *                 if self.index == NULL:             # <<<<<<<<<<<<<<
@@ -8522,33 +9886,33 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
       __pyx_t_1 = (__pyx_v_self->index == NULL);
       if (__pyx_t_1) {
 
-        /* "pysam/csamtools.pyx":780
+        /* "pysam/csamtools.pyx":906
  *                 self.index = bam_index_load(filename)
  *                 if self.index == NULL:
  *                     raise IOError("error while opening index `%s` " % filename )             # <<<<<<<<<<<<<<
  * 
  *             if not self.isstream:
  */
-        __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_38), __pyx_v_filename); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), __pyx_v_filename); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_8));
-        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_8));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
         __pyx_t_8 = 0;
-        __pyx_t_8 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
         __Pyx_Raise(__pyx_t_8, 0, 0, 0);
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 906; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L40;
       }
       __pyx_L40:;
     }
     __pyx_L37:;
 
-    /* "pysam/csamtools.pyx":782
+    /* "pysam/csamtools.pyx":908
  *                     raise IOError("error while opening index `%s` " % filename )
  * 
  *             if not self.isstream:             # <<<<<<<<<<<<<<
@@ -8558,7 +9922,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6_open(struct __pyx_obj_5py
     __pyx_t_1 = (!__pyx_v_self->isstream);
     if (__pyx_t_1) {
 
-      /* "pysam/csamtools.pyx":783
+      /* "pysam/csamtools.pyx":909
  * 
  *             if not self.isstream:
  *                 self.start_offset = bam_tell( self.samfile.x.bam )             # <<<<<<<<<<<<<<
@@ -8611,7 +9975,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_9gettid(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":785
+/* "pysam/csamtools.pyx":911
  *                 self.start_offset = bam_tell( self.samfile.x.bam )
  * 
  *     def gettid( self, reference ):             # <<<<<<<<<<<<<<
@@ -8632,48 +9996,48 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_8gettid(struct __pyx_obj_5p
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("gettid", 0);
-  __Pyx_TraceCall("gettid", __pyx_f[0], 785);
+  __Pyx_TraceCall("gettid", __pyx_f[0], 911);
   __Pyx_INCREF(__pyx_v_reference);
 
-  /* "pysam/csamtools.pyx":791
+  /* "pysam/csamtools.pyx":917
  *         returns -1 if reference is not known.
  *         '''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         reference = _force_bytes(reference)
  *         return pysam_reference2tid( self.samfile.header, reference )
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_39), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_47), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":792
+  /* "pysam/csamtools.pyx":918
  *         '''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         reference = _force_bytes(reference)             # <<<<<<<<<<<<<<
  *         return pysam_reference2tid( self.samfile.header, reference )
  * 
  */
-  __pyx_t_2 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_reference)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_reference)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 918; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_v_reference);
   __pyx_v_reference = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":793
+  /* "pysam/csamtools.pyx":919
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         reference = _force_bytes(reference)
  *         return pysam_reference2tid( self.samfile.header, reference )             # <<<<<<<<<<<<<<
@@ -8681,8 +10045,8 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_8gettid(struct __pyx_obj_5p
  *     def getrname( self, tid ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_5 = PyBytes_AsString(__pyx_v_reference); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = PyInt_FromLong(pysam_reference2tid(__pyx_v_self->samfile->header, __pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyBytes_AsString(__pyx_v_reference); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyInt_FromLong(pysam_reference2tid(__pyx_v_self->samfile->header, __pyx_t_5)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -8715,7 +10079,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_11getrname(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":795
+/* "pysam/csamtools.pyx":921
  *         return pysam_reference2tid( self.samfile.header, reference )
  * 
  *     def getrname( self, tid ):             # <<<<<<<<<<<<<<
@@ -8736,63 +10100,63 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_10getrname(struct __pyx_obj
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getrname", 0);
-  __Pyx_TraceCall("getrname", __pyx_f[0], 795);
+  __Pyx_TraceCall("getrname", __pyx_f[0], 921);
 
-  /* "pysam/csamtools.pyx":798
+  /* "pysam/csamtools.pyx":924
  *         '''
  *         convert numerical :term:`tid` into :term:`reference` name.'''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_40), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_48), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":799
+  /* "pysam/csamtools.pyx":925
  *         convert numerical :term:`tid` into :term:`reference` name.'''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         if not 0 <= tid < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
  *         return _charptr_to_str(self.samfile.header.target_name[tid])
  */
-  __pyx_t_2 = PyObject_RichCompare(__pyx_int_0, __pyx_v_tid, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_int_0, __pyx_v_tid, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__Pyx_PyObject_IsTrue(__pyx_t_2)) {
     __Pyx_DECREF(__pyx_t_2);
-    __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->samfile->header->n_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->samfile->header->n_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyObject_RichCompare(__pyx_v_tid, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_RichCompare(__pyx_v_tid, __pyx_t_1, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 799; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_3 = (!__pyx_t_4);
   if (__pyx_t_3) {
 
-    /* "pysam/csamtools.pyx":800
+    /* "pysam/csamtools.pyx":926
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )             # <<<<<<<<<<<<<<
  *         return _charptr_to_str(self.samfile.header.target_name[tid])
  * 
  */
-    __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->samfile->header->n_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->samfile->header->n_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_INCREF(__pyx_v_tid);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_tid);
@@ -8800,25 +10164,25 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_10getrname(struct __pyx_obj
     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
     __Pyx_GIVEREF(__pyx_t_2);
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_41), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_2));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L4;
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":801
+  /* "pysam/csamtools.pyx":927
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
  *         return _charptr_to_str(self.samfile.header.target_name[tid])             # <<<<<<<<<<<<<<
@@ -8826,8 +10190,8 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_10getrname(struct __pyx_obj
  *     cdef char * _getrname( self, int tid ): # TODO unused
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_tid); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __pyx_f_5pysam_9csamtools__charptr_to_str((__pyx_v_self->samfile->header->target_name[__pyx_t_5])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 801; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyIndex_AsSsize_t(__pyx_v_tid); if (unlikely((__pyx_t_5 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_5pysam_9csamtools__charptr_to_str((__pyx_v_self->samfile->header->target_name[__pyx_t_5])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 927; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -8847,7 +10211,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_10getrname(struct __pyx_obj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":803
+/* "pysam/csamtools.pyx":929
  *         return _charptr_to_str(self.samfile.header.target_name[tid])
  * 
  *     cdef char * _getrname( self, int tid ): # TODO unused             # <<<<<<<<<<<<<<
@@ -8868,34 +10232,34 @@ static char *__pyx_f_5pysam_9csamtools_7Samfile__getrname(struct __pyx_obj_5pysa
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_getrname", 0);
-  __Pyx_TraceCall("_getrname", __pyx_f[0], 803);
+  __Pyx_TraceCall("_getrname", __pyx_f[0], 929);
 
-  /* "pysam/csamtools.pyx":806
+  /* "pysam/csamtools.pyx":932
  *         '''
  *         convert numerical :term:`tid` into :term:`reference` name.'''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_42), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_50), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":807
+  /* "pysam/csamtools.pyx":933
  *         convert numerical :term:`tid` into :term:`reference` name.'''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         if not 0 <= tid < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
@@ -8909,18 +10273,18 @@ static char *__pyx_f_5pysam_9csamtools_7Samfile__getrname(struct __pyx_obj_5pysa
   __pyx_t_3 = (!__pyx_t_4);
   if (__pyx_t_3) {
 
-    /* "pysam/csamtools.pyx":808
+    /* "pysam/csamtools.pyx":934
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )             # <<<<<<<<<<<<<<
  *         return self.samfile.header.target_name[tid]
  * 
  */
-    __pyx_t_2 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->samfile->header->n_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->samfile->header->n_targets); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
     __Pyx_GIVEREF(__pyx_t_2);
@@ -8928,25 +10292,25 @@ static char *__pyx_f_5pysam_9csamtools_7Samfile__getrname(struct __pyx_obj_5pysa
     __Pyx_GIVEREF(__pyx_t_1);
     __pyx_t_2 = 0;
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_41), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_49), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
     __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
-    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_1));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L4;
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":809
+  /* "pysam/csamtools.pyx":935
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
  *         return self.samfile.header.target_name[tid]             # <<<<<<<<<<<<<<
@@ -8985,7 +10349,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_13_parseRegion(PyObject *__
     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,0};
     PyObject* values[4] = {0,0,0,0};
 
-    /* "pysam/csamtools.pyx":812
+    /* "pysam/csamtools.pyx":938
  * 
  *     def _parseRegion( self,
  *                       reference = None,             # <<<<<<<<<<<<<<
@@ -8994,7 +10358,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_13_parseRegion(PyObject *__
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":813
+    /* "pysam/csamtools.pyx":939
  *     def _parseRegion( self,
  *                       reference = None,
  *                       start = None,             # <<<<<<<<<<<<<<
@@ -9003,7 +10367,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_13_parseRegion(PyObject *__
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":814
+    /* "pysam/csamtools.pyx":940
  *                       reference = None,
  *                       start = None,
  *                       end = None,             # <<<<<<<<<<<<<<
@@ -9012,7 +10376,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_13_parseRegion(PyObject *__
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":815
+    /* "pysam/csamtools.pyx":941
  *                       start = None,
  *                       end = None,
  *                       region = None ):             # <<<<<<<<<<<<<<
@@ -9055,7 +10419,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_13_parseRegion(PyObject *__
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parseRegion") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_parseRegion") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -9074,7 +10438,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_13_parseRegion(PyObject *__
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("_parseRegion", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 811; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("_parseRegion", 0, 0, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.Samfile._parseRegion", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -9085,7 +10449,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_13_parseRegion(PyObject *__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":811
+/* "pysam/csamtools.pyx":937
  *         return self.samfile.header.target_name[tid]
  * 
  *     def _parseRegion( self,             # <<<<<<<<<<<<<<
@@ -9118,11 +10482,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_parseRegion", 0);
-  __Pyx_TraceCall("_parseRegion", __pyx_f[0], 811);
+  __Pyx_TraceCall("_parseRegion", __pyx_f[0], 937);
   __Pyx_INCREF(__pyx_v_reference);
   __Pyx_INCREF(__pyx_v_region);
 
-  /* "pysam/csamtools.pyx":834
+  /* "pysam/csamtools.pyx":960
  *         cdef long long rend
  * 
  *         rtid = -1             # <<<<<<<<<<<<<<
@@ -9131,7 +10495,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
  */
   __pyx_v_rtid = -1;
 
-  /* "pysam/csamtools.pyx":835
+  /* "pysam/csamtools.pyx":961
  * 
  *         rtid = -1
  *         rstart = 0             # <<<<<<<<<<<<<<
@@ -9140,7 +10504,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
  */
   __pyx_v_rstart = 0;
 
-  /* "pysam/csamtools.pyx":836
+  /* "pysam/csamtools.pyx":962
  *         rtid = -1
  *         rstart = 0
  *         rend = max_pos             # <<<<<<<<<<<<<<
@@ -9149,19 +10513,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
  */
   __pyx_v_rend = __pyx_v_5pysam_9csamtools_max_pos;
 
-  /* "pysam/csamtools.pyx":837
+  /* "pysam/csamtools.pyx":963
  *         rstart = 0
  *         rend = max_pos
  *         if start != None:             # <<<<<<<<<<<<<<
  *             try:
  *                 rstart = start
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_start, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 963; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":838
+    /* "pysam/csamtools.pyx":964
  *         rend = max_pos
  *         if start != None:
  *             try:             # <<<<<<<<<<<<<<
@@ -9175,14 +10539,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
       __Pyx_XGOTREF(__pyx_t_5);
       /*try:*/ {
 
-        /* "pysam/csamtools.pyx":839
+        /* "pysam/csamtools.pyx":965
  *         if start != None:
  *             try:
  *                 rstart = start             # <<<<<<<<<<<<<<
  *             except OverflowError:
  *                 raise ValueError( 'start out of range (%i)' % start )
  */
-        __pyx_t_6 = __Pyx_PyInt_AsLongLong(__pyx_v_start); if (unlikely((__pyx_t_6 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 839; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
+        __pyx_t_6 = __Pyx_PyInt_AsLongLong(__pyx_v_start); if (unlikely((__pyx_t_6 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L4_error;}
         __pyx_v_rstart = __pyx_t_6;
       }
       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
@@ -9192,7 +10556,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
       __pyx_L4_error:;
       __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-      /* "pysam/csamtools.pyx":840
+      /* "pysam/csamtools.pyx":966
  *             try:
  *                 rstart = start
  *             except OverflowError:             # <<<<<<<<<<<<<<
@@ -9202,31 +10566,31 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
       __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
       if (__pyx_t_7) {
         __Pyx_AddTraceback("pysam.csamtools.Samfile._parseRegion", __pyx_clineno, __pyx_lineno, __pyx_filename);
-        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_8, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
+        if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_8, &__pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_GOTREF(__pyx_t_9);
 
-        /* "pysam/csamtools.pyx":841
+        /* "pysam/csamtools.pyx":967
  *                 rstart = start
  *             except OverflowError:
  *                 raise ValueError( 'start out of range (%i)' % start )             # <<<<<<<<<<<<<<
  * 
  *         if end != None:
  */
-        __pyx_t_10 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_v_start); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
+        __pyx_t_10 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_v_start); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_10));
-        __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
+        __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
         __Pyx_GOTREF(__pyx_t_11);
         PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_t_10));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_10));
         __pyx_t_10 = 0;
-        __pyx_t_10 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
+        __pyx_t_10 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
         __Pyx_GOTREF(__pyx_t_10);
         __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
         __Pyx_Raise(__pyx_t_10, 0, 0, 0);
         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 841; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 967; __pyx_clineno = __LINE__; goto __pyx_L6_except_error;}
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
@@ -9249,19 +10613,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":843
+  /* "pysam/csamtools.pyx":969
  *                 raise ValueError( 'start out of range (%i)' % start )
  * 
  *         if end != None:             # <<<<<<<<<<<<<<
  *             try:
  *                 rend = end
  */
-  __pyx_t_9 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_RichCompare(__pyx_v_end, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":844
+    /* "pysam/csamtools.pyx":970
  * 
  *         if end != None:
  *             try:             # <<<<<<<<<<<<<<
@@ -9275,14 +10639,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
       __Pyx_XGOTREF(__pyx_t_3);
       /*try:*/ {
 
-        /* "pysam/csamtools.pyx":845
+        /* "pysam/csamtools.pyx":971
  *         if end != None:
  *             try:
  *                 rend = end             # <<<<<<<<<<<<<<
  *             except OverflowError:
  *                 raise ValueError( 'end out of range (%i)' % end )
  */
-        __pyx_t_6 = __Pyx_PyInt_AsLongLong(__pyx_v_end); if (unlikely((__pyx_t_6 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 845; __pyx_clineno = __LINE__; goto __pyx_L15_error;}
+        __pyx_t_6 = __Pyx_PyInt_AsLongLong(__pyx_v_end); if (unlikely((__pyx_t_6 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 971; __pyx_clineno = __LINE__; goto __pyx_L15_error;}
         __pyx_v_rend = __pyx_t_6;
       }
       __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
@@ -9296,7 +10660,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
       __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
       __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
 
-      /* "pysam/csamtools.pyx":846
+      /* "pysam/csamtools.pyx":972
  *             try:
  *                 rend = end
  *             except OverflowError:             # <<<<<<<<<<<<<<
@@ -9306,31 +10670,31 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
       __pyx_t_7 = PyErr_ExceptionMatches(__pyx_builtin_OverflowError);
       if (__pyx_t_7) {
         __Pyx_AddTraceback("pysam.csamtools.Samfile._parseRegion", __pyx_clineno, __pyx_lineno, __pyx_filename);
-        if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 846; __pyx_clineno = __LINE__; goto __pyx_L17_except_error;}
+        if (__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L17_except_error;}
         __Pyx_GOTREF(__pyx_t_9);
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_GOTREF(__pyx_t_1);
 
-        /* "pysam/csamtools.pyx":847
+        /* "pysam/csamtools.pyx":973
  *                 rend = end
  *             except OverflowError:
  *                 raise ValueError( 'end out of range (%i)' % end )             # <<<<<<<<<<<<<<
  * 
  *         if region:
  */
-        __pyx_t_10 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), __pyx_v_end); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L17_except_error;}
+        __pyx_t_10 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), __pyx_v_end); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L17_except_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_10));
-        __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L17_except_error;}
+        __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L17_except_error;}
         __Pyx_GOTREF(__pyx_t_11);
         PyTuple_SET_ITEM(__pyx_t_11, 0, ((PyObject *)__pyx_t_10));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_10));
         __pyx_t_10 = 0;
-        __pyx_t_10 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L17_except_error;}
+        __pyx_t_10 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L17_except_error;}
         __Pyx_GOTREF(__pyx_t_10);
         __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
         __Pyx_Raise(__pyx_t_10, 0, 0, 0);
         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 847; __pyx_clineno = __LINE__; goto __pyx_L17_except_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 973; __pyx_clineno = __LINE__; goto __pyx_L17_except_error;}
         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -9353,120 +10717,120 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
   }
   __pyx_L14:;
 
-  /* "pysam/csamtools.pyx":849
+  /* "pysam/csamtools.pyx":975
  *                 raise ValueError( 'end out of range (%i)' % end )
  * 
  *         if region:             # <<<<<<<<<<<<<<
  *             region = _force_str(region)
  *             parts = re.split( "[:-]", region )
  */
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":850
+    /* "pysam/csamtools.pyx":976
  * 
  *         if region:
  *             region = _force_str(region)             # <<<<<<<<<<<<<<
  *             parts = re.split( "[:-]", region )
  *             reference = parts[0]
  */
-    __pyx_t_1 = __pyx_f_5pysam_9csamtools__force_str(__pyx_v_region); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __pyx_f_5pysam_9csamtools__force_str(__pyx_v_region); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_v_region);
     __pyx_v_region = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":851
+    /* "pysam/csamtools.pyx":977
  *         if region:
  *             region = _force_str(region)
  *             parts = re.split( "[:-]", region )             # <<<<<<<<<<<<<<
  *             reference = parts[0]
  *             if len(parts) >= 2: rstart = int(parts[1]) - 1
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__re); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__re); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_8 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__split); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__split); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __Pyx_INCREF(((PyObject *)__pyx_kp_s_43));
-    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_43));
-    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_43));
+    __Pyx_INCREF(((PyObject *)__pyx_kp_s_51));
+    PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_51));
+    __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_51));
     __Pyx_INCREF(__pyx_v_region);
     PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_region);
     __Pyx_GIVEREF(__pyx_v_region);
-    __pyx_t_9 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
     __pyx_v_parts = __pyx_t_9;
     __pyx_t_9 = 0;
 
-    /* "pysam/csamtools.pyx":852
+    /* "pysam/csamtools.pyx":978
  *             region = _force_str(region)
  *             parts = re.split( "[:-]", region )
  *             reference = parts[0]             # <<<<<<<<<<<<<<
  *             if len(parts) >= 2: rstart = int(parts[1]) - 1
  *             if len(parts) >= 3: rend = int(parts[2])
  */
-    __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_parts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_parts, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __Pyx_DECREF(__pyx_v_reference);
     __pyx_v_reference = __pyx_t_9;
     __pyx_t_9 = 0;
 
-    /* "pysam/csamtools.pyx":853
+    /* "pysam/csamtools.pyx":979
  *             parts = re.split( "[:-]", region )
  *             reference = parts[0]
  *             if len(parts) >= 2: rstart = int(parts[1]) - 1             # <<<<<<<<<<<<<<
  *             if len(parts) >= 3: rend = int(parts[2])
  * 
  */
-    __pyx_t_12 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_2 = (__pyx_t_12 >= 2);
     if (__pyx_t_2) {
-      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_parts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_parts, 1, sizeof(long), PyInt_FromLong); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
-      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_9);
       __Pyx_GIVEREF(__pyx_t_9);
       __pyx_t_9 = 0;
-      __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
       __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-      __pyx_t_1 = PyNumber_Subtract(__pyx_t_9, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyNumber_Subtract(__pyx_t_9, __pyx_int_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-      __pyx_t_6 = __Pyx_PyInt_AsLongLong(__pyx_t_1); if (unlikely((__pyx_t_6 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyInt_AsLongLong(__pyx_t_1); if (unlikely((__pyx_t_6 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 979; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __pyx_v_rstart = __pyx_t_6;
       goto __pyx_L26;
     }
     __pyx_L26:;
 
-    /* "pysam/csamtools.pyx":854
+    /* "pysam/csamtools.pyx":980
  *             reference = parts[0]
  *             if len(parts) >= 2: rstart = int(parts[1]) - 1
  *             if len(parts) >= 3: rend = int(parts[2])             # <<<<<<<<<<<<<<
  * 
  *         if not reference: return 0, 0, 0, 0
  */
-    __pyx_t_12 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = PyObject_Length(__pyx_v_parts); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_2 = (__pyx_t_12 >= 3);
     if (__pyx_t_2) {
-      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_parts, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_parts, 2, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
       PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_1);
       __Pyx_GIVEREF(__pyx_t_1);
       __pyx_t_1 = 0;
-      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
-      __pyx_t_6 = __Pyx_PyInt_AsLongLong(__pyx_t_1); if (unlikely((__pyx_t_6 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyInt_AsLongLong(__pyx_t_1); if (unlikely((__pyx_t_6 == (PY_LONG_LONG)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 980; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __pyx_v_rend = __pyx_t_6;
       goto __pyx_L27;
@@ -9476,47 +10840,47 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
   }
   __pyx_L25:;
 
-  /* "pysam/csamtools.pyx":856
+  /* "pysam/csamtools.pyx":982
  *             if len(parts) >= 3: rend = int(parts[2])
  * 
  *         if not reference: return 0, 0, 0, 0             # <<<<<<<<<<<<<<
  * 
  *         rtid = self.gettid( reference )
  */
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_reference); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_reference); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_t_13 = (!__pyx_t_2);
   if (__pyx_t_13) {
     __Pyx_XDECREF(__pyx_r);
-    __Pyx_INCREF(((PyObject *)__pyx_k_tuple_44));
-    __pyx_r = ((PyObject *)__pyx_k_tuple_44);
+    __Pyx_INCREF(((PyObject *)__pyx_k_tuple_52));
+    __pyx_r = ((PyObject *)__pyx_k_tuple_52);
     goto __pyx_L0;
     goto __pyx_L28;
   }
   __pyx_L28:;
 
-  /* "pysam/csamtools.pyx":858
+  /* "pysam/csamtools.pyx":984
  *         if not reference: return 0, 0, 0, 0
  * 
  *         rtid = self.gettid( reference )             # <<<<<<<<<<<<<<
  *         if rtid < 0: raise ValueError( "invalid reference `%s`" % reference )
  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__gettid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
   __Pyx_INCREF(__pyx_v_reference);
   PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_reference);
   __Pyx_GIVEREF(__pyx_v_reference);
-  __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
-  __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_8); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = __Pyx_PyInt_AsInt(__pyx_t_8); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
   __pyx_v_rtid = __pyx_t_7;
 
-  /* "pysam/csamtools.pyx":859
+  /* "pysam/csamtools.pyx":985
  * 
  *         rtid = self.gettid( reference )
  *         if rtid < 0: raise ValueError( "invalid reference `%s`" % reference )             # <<<<<<<<<<<<<<
@@ -9525,24 +10889,24 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
  */
   __pyx_t_13 = (__pyx_v_rtid < 0);
   if (__pyx_t_13) {
-    __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_45), __pyx_v_reference); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_53), __pyx_v_reference); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_8));
-    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_8));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
     __pyx_t_8 = 0;
-    __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
     __Pyx_Raise(__pyx_t_8, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L29;
   }
   __pyx_L29:;
 
-  /* "pysam/csamtools.pyx":860
+  /* "pysam/csamtools.pyx":986
  *         rtid = self.gettid( reference )
  *         if rtid < 0: raise ValueError( "invalid reference `%s`" % reference )
  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )             # <<<<<<<<<<<<<<
@@ -9551,11 +10915,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
  */
   __pyx_t_13 = (__pyx_v_rstart > __pyx_v_rend);
   if (__pyx_t_13) {
-    __pyx_t_8 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
-    __pyx_t_9 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
-    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_8);
     __Pyx_GIVEREF(__pyx_t_8);
@@ -9563,25 +10927,25 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
     __Pyx_GIVEREF(__pyx_t_9);
     __pyx_t_8 = 0;
     __pyx_t_9 = 0;
-    __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_46), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_54), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_9));
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_9));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
     __pyx_t_9 = 0;
-    __pyx_t_9 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
     __Pyx_Raise(__pyx_t_9, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 986; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L30;
   }
   __pyx_L30:;
 
-  /* "pysam/csamtools.pyx":861
+  /* "pysam/csamtools.pyx":987
  *         if rtid < 0: raise ValueError( "invalid reference `%s`" % reference )
  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )
  *         if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )             # <<<<<<<<<<<<<<
@@ -9594,27 +10958,27 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
   }
   __pyx_t_2 = (!__pyx_t_13);
   if (__pyx_t_2) {
-    __pyx_t_9 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
-    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_17), __pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_1));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 861; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L31;
   }
   __pyx_L31:;
 
-  /* "pysam/csamtools.pyx":862
+  /* "pysam/csamtools.pyx":988
  *         if rstart > rend: raise ValueError( 'invalid coordinates: start (%i) > end (%i)' % (rstart, rend) )
  *         if not 0 <= rstart < max_pos: raise ValueError( 'start out of range (%i)' % rstart )
  *         if not 0 <= rend <= max_pos: raise ValueError( 'end out of range (%i)' % rend )             # <<<<<<<<<<<<<<
@@ -9627,27 +10991,27 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
   }
   __pyx_t_13 = (!__pyx_t_2);
   if (__pyx_t_13) {
-    __pyx_t_1 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), __pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_18), __pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_9));
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_t_9));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
     __pyx_t_9 = 0;
-    __pyx_t_9 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
     __Pyx_Raise(__pyx_t_9, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 862; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L32;
   }
   __pyx_L32:;
 
-  /* "pysam/csamtools.pyx":864
+  /* "pysam/csamtools.pyx":990
  *         if not 0 <= rend <= max_pos: raise ValueError( 'end out of range (%i)' % rend )
  * 
  *         return 1, rtid, rstart, rend             # <<<<<<<<<<<<<<
@@ -9655,13 +11019,13 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_12_parseRegion(struct __pyx
  *     def reset( self ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_9 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
-  __pyx_t_1 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyLong_FromLongLong(__pyx_v_rstart); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_8 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyLong_FromLongLong(__pyx_v_rend); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
-  __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyTuple_New(4); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_10);
   __Pyx_INCREF(__pyx_int_1);
   PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_int_1);
@@ -9711,7 +11075,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_15reset(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":866
+/* "pysam/csamtools.pyx":992
  *         return 1, rtid, rstart, rend
  * 
  *     def reset( self ):             # <<<<<<<<<<<<<<
@@ -9730,9 +11094,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_14reset(struct __pyx_obj_5p
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("reset", 0);
-  __Pyx_TraceCall("reset", __pyx_f[0], 866);
+  __Pyx_TraceCall("reset", __pyx_f[0], 992);
 
-  /* "pysam/csamtools.pyx":868
+  /* "pysam/csamtools.pyx":994
  *     def reset( self ):
  *         '''reset file position to beginning of read section.'''
  *         return self.seek( self.start_offset, 0 )             # <<<<<<<<<<<<<<
@@ -9740,11 +11104,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_14reset(struct __pyx_obj_5p
  *     def seek( self, uint64_t offset, int where = 0):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__seek); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__seek); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(__pyx_v_self->start_offset); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(__pyx_v_self->start_offset); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
@@ -9752,7 +11116,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_14reset(struct __pyx_obj_5p
   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_int_0);
   __Pyx_GIVEREF(__pyx_int_0);
   __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 868; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
@@ -9808,7 +11172,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_17seek(PyObject *__pyx_v_se
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "seek") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "seek") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -9818,16 +11182,16 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_17seek(PyObject *__pyx_v_se
         default: goto __pyx_L5_argtuple_error;
       }
     }
-    __pyx_v_offset = __Pyx_PyInt_from_py_uint64_t(values[0]); if (unlikely((__pyx_v_offset == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_offset = __Pyx_PyInt_from_py_uint64_t(values[0]); if (unlikely((__pyx_v_offset == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     if (values[1]) {
-      __pyx_v_where = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_where == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_where = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_where == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
       __pyx_v_where = ((int)0);
     }
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("seek", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 870; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("seek", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 996; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.Samfile.seek", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -9838,7 +11202,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_17seek(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":870
+/* "pysam/csamtools.pyx":996
  *         return self.seek( self.start_offset, 0 )
  * 
  *     def seek( self, uint64_t offset, int where = 0):             # <<<<<<<<<<<<<<
@@ -9858,42 +11222,42 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_16seek(struct __pyx_obj_5py
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("seek", 0);
-  __Pyx_TraceCall("seek", __pyx_f[0], 870);
+  __Pyx_TraceCall("seek", __pyx_f[0], 996);
 
-  /* "pysam/csamtools.pyx":875
+  /* "pysam/csamtools.pyx":1001
  *         '''
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 875; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":876
+    /* "pysam/csamtools.pyx":1002
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_47), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_55), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":877
+  /* "pysam/csamtools.pyx":1003
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:             # <<<<<<<<<<<<<<
@@ -9903,23 +11267,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_16seek(struct __pyx_obj_5py
   __pyx_t_4 = (!__pyx_v_self->isbam);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":878
+    /* "pysam/csamtools.pyx":1004
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")             # <<<<<<<<<<<<<<
  *         if self.isstream:
  *             raise OSError("seek no available in streams")
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_49), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_57), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L4;
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":879
+  /* "pysam/csamtools.pyx":1005
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")
  *         if self.isstream:             # <<<<<<<<<<<<<<
@@ -9928,23 +11292,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_16seek(struct __pyx_obj_5py
  */
   if (__pyx_v_self->isstream) {
 
-    /* "pysam/csamtools.pyx":880
+    /* "pysam/csamtools.pyx":1006
  *             raise NotImplementedError("seek only available in bam files")
  *         if self.isstream:
  *             raise OSError("seek no available in streams")             # <<<<<<<<<<<<<<
  * 
  *         return bam_seek( self.samfile.x.bam, offset, where )
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_k_tuple_51), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_OSError, ((PyObject *)__pyx_k_tuple_59), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "pysam/csamtools.pyx":882
+  /* "pysam/csamtools.pyx":1008
  *             raise OSError("seek no available in streams")
  * 
  *         return bam_seek( self.samfile.x.bam, offset, where )             # <<<<<<<<<<<<<<
@@ -9952,7 +11316,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_16seek(struct __pyx_obj_5py
  *     def tell( self ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(bam_seek(__pyx_v_self->samfile->x.bam, __pyx_v_offset, __pyx_v_where)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(bam_seek(__pyx_v_self->samfile->x.bam, __pyx_v_offset, __pyx_v_where)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1008; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -9984,7 +11348,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_19tell(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":884
+/* "pysam/csamtools.pyx":1010
  *         return bam_seek( self.samfile.x.bam, offset, where )
  * 
  *     def tell( self ):             # <<<<<<<<<<<<<<
@@ -10004,42 +11368,42 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_18tell(struct __pyx_obj_5py
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("tell", 0);
-  __Pyx_TraceCall("tell", __pyx_f[0], 884);
+  __Pyx_TraceCall("tell", __pyx_f[0], 1010);
 
-  /* "pysam/csamtools.pyx":888
+  /* "pysam/csamtools.pyx":1014
  *         return current file position
  *         '''
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 888; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1014; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":889
+    /* "pysam/csamtools.pyx":1015
  *         '''
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_52), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_60), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":890
+  /* "pysam/csamtools.pyx":1016
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:             # <<<<<<<<<<<<<<
@@ -10049,23 +11413,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_18tell(struct __pyx_obj_5py
   __pyx_t_4 = (!__pyx_v_self->isbam);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":891
+    /* "pysam/csamtools.pyx":1017
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")             # <<<<<<<<<<<<<<
  * 
  *         return bam_tell( self.samfile.x.bam )
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_53), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_61), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L4;
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":893
+  /* "pysam/csamtools.pyx":1019
  *             raise NotImplementedError("seek only available in bam files")
  * 
  *         return bam_tell( self.samfile.x.bam )             # <<<<<<<<<<<<<<
@@ -10073,7 +11437,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_18tell(struct __pyx_obj_5py
  *     def fetch( self,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(bam_tell(__pyx_v_self->samfile->x.bam)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 893; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int64_t(bam_tell(__pyx_v_self->samfile->x.bam)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -10110,7 +11474,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_21fetch(PyObject *__pyx_v_s
     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,&__pyx_n_s__callback,&__pyx_n_s__until_eof,0};
     PyObject* values[6] = {0,0,0,0,0,0};
 
-    /* "pysam/csamtools.pyx":896
+    /* "pysam/csamtools.pyx":1022
  * 
  *     def fetch( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -10119,7 +11483,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_21fetch(PyObject *__pyx_v_s
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":897
+    /* "pysam/csamtools.pyx":1023
  *     def fetch( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -10128,7 +11492,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_21fetch(PyObject *__pyx_v_s
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":898
+    /* "pysam/csamtools.pyx":1024
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -10137,7 +11501,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_21fetch(PyObject *__pyx_v_s
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":899
+    /* "pysam/csamtools.pyx":1025
  *                start = None,
  *                end = None,
  *                region = None,             # <<<<<<<<<<<<<<
@@ -10146,7 +11510,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_21fetch(PyObject *__pyx_v_s
  */
     values[3] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":900
+    /* "pysam/csamtools.pyx":1026
  *                end = None,
  *                region = None,
  *                callback = None,             # <<<<<<<<<<<<<<
@@ -10154,7 +11518,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_21fetch(PyObject *__pyx_v_s
  *         '''
  */
     values[4] = ((PyObject *)Py_None);
-    values[5] = __pyx_k_54;
+    values[5] = __pyx_k_62;
     if (unlikely(__pyx_kwds)) {
       Py_ssize_t kw_args;
       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
@@ -10202,7 +11566,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_21fetch(PyObject *__pyx_v_s
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "fetch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -10225,7 +11589,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_21fetch(PyObject *__pyx_v_s
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("fetch", 0, 0, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 895; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("fetch", 0, 0, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1021; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.Samfile.fetch", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -10236,7 +11600,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_21fetch(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":895
+/* "pysam/csamtools.pyx":1021
  *         return bam_tell( self.samfile.x.bam )
  * 
  *     def fetch( self,             # <<<<<<<<<<<<<<
@@ -10272,51 +11636,51 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("fetch", 0);
-  __Pyx_TraceCall("fetch", __pyx_f[0], 895);
+  __Pyx_TraceCall("fetch", __pyx_f[0], 1021);
 
-  /* "pysam/csamtools.pyx":925
+  /* "pysam/csamtools.pyx":1051
  *         cdef int rtid, rstart, rend, has_coord
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":926
+    /* "pysam/csamtools.pyx":1052
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_55), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_63), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":928
+  /* "pysam/csamtools.pyx":1054
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
  * 
  *         if self.isstream: reopen = False
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(__pyx_v_reference);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_reference);
@@ -10330,7 +11694,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
   __Pyx_INCREF(__pyx_v_region);
   PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_region);
   __Pyx_GIVEREF(__pyx_v_region);
-  __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
@@ -10344,7 +11708,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
     if (unlikely(size != 4)) {
       if (size > 4) __Pyx_RaiseTooManyValuesError(4);
       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #if CYTHON_COMPILING_IN_CPYTHON
     if (likely(PyTuple_CheckExact(sequence))) {
@@ -10366,7 +11730,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
     Py_ssize_t i;
     PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_6,&__pyx_t_7};
     for (i=0; i < 4; i++) {
-      PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(item);
       *(temps[i]) = item;
     }
@@ -10376,7 +11740,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
   {
     Py_ssize_t index = -1;
     PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_6,&__pyx_t_7};
-    __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
@@ -10385,7 +11749,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
       __Pyx_GOTREF(item);
       *(temps[index]) = item;
     }
-    if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_9 = NULL;
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     goto __pyx_L5_unpacking_done;
@@ -10393,23 +11757,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __pyx_t_9 = NULL;
     if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_L5_unpacking_done:;
   }
-  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-  __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
   __pyx_v_has_coord = __pyx_t_10;
   __pyx_v_rtid = __pyx_t_11;
   __pyx_v_rstart = __pyx_t_12;
   __pyx_v_rend = __pyx_t_13;
 
-  /* "pysam/csamtools.pyx":930
+  /* "pysam/csamtools.pyx":1056
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  * 
  *         if self.isstream: reopen = False             # <<<<<<<<<<<<<<
@@ -10422,7 +11786,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":931
+    /* "pysam/csamtools.pyx":1057
  * 
  *         if self.isstream: reopen = False
  *         else: reopen = True             # <<<<<<<<<<<<<<
@@ -10433,7 +11797,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
   }
   __pyx_L6:;
 
-  /* "pysam/csamtools.pyx":933
+  /* "pysam/csamtools.pyx":1059
  *         else: reopen = True
  * 
  *         if self.isbam:             # <<<<<<<<<<<<<<
@@ -10442,22 +11806,22 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
  */
   if (__pyx_v_self->isbam) {
 
-    /* "pysam/csamtools.pyx":934
+    /* "pysam/csamtools.pyx":1060
  * 
  *         if self.isbam:
  *             if not until_eof and not self._hasIndex() and not self.isremote:             # <<<<<<<<<<<<<<
  *                 raise ValueError( "fetch called on bamfile without index" )
  * 
  */
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_3 = (!__pyx_t_4);
     if (__pyx_t_3) {
-      __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 934; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __pyx_t_14 = (!__pyx_t_4);
       if (__pyx_t_14) {
@@ -10472,33 +11836,33 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
     }
     if (__pyx_t_14) {
 
-      /* "pysam/csamtools.pyx":935
+      /* "pysam/csamtools.pyx":1061
  *         if self.isbam:
  *             if not until_eof and not self._hasIndex() and not self.isremote:
  *                 raise ValueError( "fetch called on bamfile without index" )             # <<<<<<<<<<<<<<
  * 
  *             if callback:
  */
-      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_57), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_65), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_Raise(__pyx_t_7, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "pysam/csamtools.pyx":937
+    /* "pysam/csamtools.pyx":1063
  *                 raise ValueError( "fetch called on bamfile without index" )
  * 
  *             if callback:             # <<<<<<<<<<<<<<
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
  *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )
  */
-    __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 937; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1063; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_14) {
 
-      /* "pysam/csamtools.pyx":938
+      /* "pysam/csamtools.pyx":1064
  * 
  *             if callback:
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )             # <<<<<<<<<<<<<<
@@ -10507,41 +11871,41 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
  */
       __pyx_t_14 = (!__pyx_v_has_coord);
       if (__pyx_t_14) {
-        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_59), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_67), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_Raise(__pyx_t_7, 0, 0, 0);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L10;
       }
       __pyx_L10:;
 
-      /* "pysam/csamtools.pyx":939
+      /* "pysam/csamtools.pyx":1065
  *             if callback:
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
  *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )             # <<<<<<<<<<<<<<
  *                 return bam_fetch(self.samfile.x.bam,
  *                                  self.index,
  */
-      __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_14 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_14 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __pyx_t_3 = (!__pyx_t_14);
       if (__pyx_t_3) {
-        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_61), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_69), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
         __Pyx_Raise(__pyx_t_5, 0, 0, 0);
         __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L11;
       }
       __pyx_L11:;
 
-      /* "pysam/csamtools.pyx":940
+      /* "pysam/csamtools.pyx":1066
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
  *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )
  *                 return bam_fetch(self.samfile.x.bam,             # <<<<<<<<<<<<<<
@@ -10550,14 +11914,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
  */
       __Pyx_XDECREF(__pyx_r);
 
-      /* "pysam/csamtools.pyx":946
+      /* "pysam/csamtools.pyx":1072
  *                                  rend,
  *                                  <void*>callback,
  *                                  fetch_callback )             # <<<<<<<<<<<<<<
  *             else:
  *                 if has_coord:
  */
-      __pyx_t_5 = PyInt_FromLong(bam_fetch(__pyx_v_self->samfile->x.bam, __pyx_v_self->index, __pyx_v_rtid, __pyx_v_rstart, __pyx_v_rend, ((void *)__pyx_v_callback), __pyx_f_5pysam_9csamtools_fetch_callback)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 940; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyInt_FromLong(bam_fetch(__pyx_v_self->samfile->x.bam, __pyx_v_self->index, __pyx_v_rtid, __pyx_v_rstart, __pyx_v_rend, ((void *)__pyx_v_callback), __pyx_f_5pysam_9csamtools_fetch_callback)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1066; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __pyx_r = __pyx_t_5;
       __pyx_t_5 = 0;
@@ -10566,7 +11930,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
     }
     /*else*/ {
 
-      /* "pysam/csamtools.pyx":948
+      /* "pysam/csamtools.pyx":1074
  *                                  fetch_callback )
  *             else:
  *                 if has_coord:             # <<<<<<<<<<<<<<
@@ -10575,7 +11939,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
  */
       if (__pyx_v_has_coord) {
 
-        /* "pysam/csamtools.pyx":949
+        /* "pysam/csamtools.pyx":1075
  *             else:
  *                 if has_coord:
  *                     return IteratorRowRegion( self, rtid, rstart, rend,             # <<<<<<<<<<<<<<
@@ -10583,13 +11947,13 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
  *                 else:
  */
         __Pyx_XDECREF(__pyx_r);
-        __pyx_t_5 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_5);
-        __pyx_t_7 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_6 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
         __Pyx_INCREF(((PyObject *)__pyx_v_self));
         PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
@@ -10603,21 +11967,21 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
         __pyx_t_5 = 0;
         __pyx_t_7 = 0;
         __pyx_t_6 = 0;
-        __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_6));
 
-        /* "pysam/csamtools.pyx":950
+        /* "pysam/csamtools.pyx":1076
  *                 if has_coord:
  *                     return IteratorRowRegion( self, rtid, rstart, rend,
  *                                               reopen=reopen )             # <<<<<<<<<<<<<<
  *                 else:
  *                     if until_eof:
  */
-        __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__reopen), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__reopen), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowRegion)), ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 949; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowRegion)), ((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1075; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
@@ -10628,17 +11992,17 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
       }
       /*else*/ {
 
-        /* "pysam/csamtools.pyx":952
+        /* "pysam/csamtools.pyx":1078
  *                                               reopen=reopen )
  *                 else:
  *                     if until_eof:             # <<<<<<<<<<<<<<
  *                         return IteratorRowAll( self, reopen=reopen )
  *                     else:
  */
-        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         if (__pyx_t_3) {
 
-          /* "pysam/csamtools.pyx":953
+          /* "pysam/csamtools.pyx":1079
  *                 else:
  *                     if until_eof:
  *                         return IteratorRowAll( self, reopen=reopen )             # <<<<<<<<<<<<<<
@@ -10646,18 +12010,18 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
  *                         # AH: check - reason why no reopen for AllRefs?
  */
           __Pyx_XDECREF(__pyx_r);
-          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
           __Pyx_INCREF(((PyObject *)__pyx_v_self));
           PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_self));
           __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
-          __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyDict_New(); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_6));
-          __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = __Pyx_PyBool_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_2);
-          if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__reopen), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (PyDict_SetItem(__pyx_t_6, ((PyObject *)__pyx_n_s__reopen), __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-          __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowAll)), ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowAll)), ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1079; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_2);
           __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
           __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
@@ -10668,7 +12032,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
         }
         /*else*/ {
 
-          /* "pysam/csamtools.pyx":956
+          /* "pysam/csamtools.pyx":1082
  *                     else:
  *                         # AH: check - reason why no reopen for AllRefs?
  *                         return IteratorRowAllRefs(self ) # , reopen=reopen )             # <<<<<<<<<<<<<<
@@ -10676,12 +12040,12 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
  *             if has_coord:
  */
           __Pyx_XDECREF(__pyx_r);
-          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_2);
           __Pyx_INCREF(((PyObject *)__pyx_v_self));
           PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self));
           __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
-          __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowAllRefs)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowAllRefs)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1082; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_6);
           __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
           __pyx_r = __pyx_t_6;
@@ -10697,7 +12061,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":958
+    /* "pysam/csamtools.pyx":1084
  *                         return IteratorRowAllRefs(self ) # , reopen=reopen )
  *         else:
  *             if has_coord:             # <<<<<<<<<<<<<<
@@ -10706,49 +12070,49 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
  */
     if (__pyx_v_has_coord) {
 
-      /* "pysam/csamtools.pyx":959
+      /* "pysam/csamtools.pyx":1085
  *         else:
  *             if has_coord:
  *                 raise ValueError ("fetching by region is not available for sam files" )             # <<<<<<<<<<<<<<
  * 
  *             if callback:
  */
-      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_63), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_71), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L14;
     }
     __pyx_L14:;
 
-    /* "pysam/csamtools.pyx":961
+    /* "pysam/csamtools.pyx":1087
  *                 raise ValueError ("fetching by region is not available for sam files" )
  * 
  *             if callback:             # <<<<<<<<<<<<<<
  *                 raise NotImplementedError( "callback not implemented yet" )
  * 
  */
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1087; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_3) {
 
-      /* "pysam/csamtools.pyx":962
+      /* "pysam/csamtools.pyx":1088
  * 
  *             if callback:
  *                 raise NotImplementedError( "callback not implemented yet" )             # <<<<<<<<<<<<<<
  * 
  *             if self.samfile.header == NULL:
  */
-      __pyx_t_6 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_65), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_73), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L15;
     }
     __pyx_L15:;
 
-    /* "pysam/csamtools.pyx":964
+    /* "pysam/csamtools.pyx":1090
  *                 raise NotImplementedError( "callback not implemented yet" )
  * 
  *             if self.samfile.header == NULL:             # <<<<<<<<<<<<<<
@@ -10758,23 +12122,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
     __pyx_t_3 = (__pyx_v_self->samfile->header == NULL);
     if (__pyx_t_3) {
 
-      /* "pysam/csamtools.pyx":965
+      /* "pysam/csamtools.pyx":1091
  * 
  *             if self.samfile.header == NULL:
  *                 raise ValueError( "fetch called for samfile without header")             # <<<<<<<<<<<<<<
  * 
  *             # check if targets are defined
  */
-      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_67), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_75), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L16;
     }
     __pyx_L16:;
 
-    /* "pysam/csamtools.pyx":969
+    /* "pysam/csamtools.pyx":1095
  *             # check if targets are defined
  *             # give warning, sam_read1 segfaults
  *             if self.samfile.header.n_targets == 0:             # <<<<<<<<<<<<<<
@@ -10784,19 +12148,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
     __pyx_t_3 = (__pyx_v_self->samfile->header->n_targets == 0);
     if (__pyx_t_3) {
 
-      /* "pysam/csamtools.pyx":970
+      /* "pysam/csamtools.pyx":1096
  *             # give warning, sam_read1 segfaults
  *             if self.samfile.header.n_targets == 0:
  *                 warnings.warn( "fetch called for samfile without header")             # <<<<<<<<<<<<<<
  * 
  *             return IteratorRowAll( self, reopen=reopen )
  */
-      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__warnings); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__warnings); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_2 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__warn); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_GetAttr(__pyx_t_6, __pyx_n_s__warn); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_68), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_76), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
@@ -10804,7 +12168,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
     }
     __pyx_L17:;
 
-    /* "pysam/csamtools.pyx":972
+    /* "pysam/csamtools.pyx":1098
  *                 warnings.warn( "fetch called for samfile without header")
  * 
  *             return IteratorRowAll( self, reopen=reopen )             # <<<<<<<<<<<<<<
@@ -10812,18 +12176,18 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_20fetch(struct __pyx_obj_5p
  *     def mate( self,
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __Pyx_INCREF(((PyObject *)__pyx_v_self));
     PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_self));
     __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
-    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_PyBool_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__reopen), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__reopen), __pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowAll)), ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowAll)), ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
@@ -10858,7 +12222,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_23mate(PyObject *__pyx_v_se
   PyObject *__pyx_r = 0;
   __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("mate (wrapper)", 0);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_read), __pyx_ptype_5pysam_9csamtools_AlignedRead, 1, "read", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_read), __pyx_ptype_5pysam_9csamtools_AlignedRead, 1, "read", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1101; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_7Samfile_22mate(((struct __pyx_obj_5pysam_9csamtools_Samfile *)__pyx_v_self), ((struct __pyx_obj_5pysam_9csamtools_AlignedRead *)__pyx_v_read));
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -10868,7 +12232,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_23mate(PyObject *__pyx_v_se
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":974
+/* "pysam/csamtools.pyx":1100
  *             return IteratorRowAll( self, reopen=reopen )
  * 
  *     def mate( self,             # <<<<<<<<<<<<<<
@@ -10893,9 +12257,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_22mate(struct __pyx_obj_5py
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("mate", 0);
-  __Pyx_TraceCall("mate", __pyx_f[0], 974);
+  __Pyx_TraceCall("mate", __pyx_f[0], 1100);
 
-  /* "pysam/csamtools.pyx":987
+  /* "pysam/csamtools.pyx":1113
  * 
  *         '''
  *         cdef uint32_t flag = read._delegate.core.flag             # <<<<<<<<<<<<<<
@@ -10905,7 +12269,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_22mate(struct __pyx_obj_5py
   __pyx_t_1 = __pyx_v_read->_delegate->core.flag;
   __pyx_v_flag = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":989
+  /* "pysam/csamtools.pyx":1115
  *         cdef uint32_t flag = read._delegate.core.flag
  * 
  *         if flag & BAM_FPAIRED == 0:             # <<<<<<<<<<<<<<
@@ -10915,34 +12279,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_22mate(struct __pyx_obj_5py
   __pyx_t_2 = ((__pyx_v_flag & 1) == 0);
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":990
+    /* "pysam/csamtools.pyx":1116
  * 
  *         if flag & BAM_FPAIRED == 0:
  *             raise ValueError( "read %s: is unpaired" % (read.qname))             # <<<<<<<<<<<<<<
  *         if flag & BAM_FMUNMAP != 0:
  *             raise ValueError( "mate %s: is unmapped" % (read.qname))
  */
-    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_read), __pyx_n_s__qname); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_read), __pyx_n_s__qname); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_69), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_77), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
     __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
     __Pyx_Raise(__pyx_t_4, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 990; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":991
+  /* "pysam/csamtools.pyx":1117
  *         if flag & BAM_FPAIRED == 0:
  *             raise ValueError( "read %s: is unpaired" % (read.qname))
  *         if flag & BAM_FMUNMAP != 0:             # <<<<<<<<<<<<<<
@@ -10952,34 +12316,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_22mate(struct __pyx_obj_5py
   __pyx_t_2 = ((__pyx_v_flag & 8) != 0);
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":992
+    /* "pysam/csamtools.pyx":1118
  *             raise ValueError( "read %s: is unpaired" % (read.qname))
  *         if flag & BAM_FMUNMAP != 0:
  *             raise ValueError( "mate %s: is unmapped" % (read.qname))             # <<<<<<<<<<<<<<
  * 
  *         cdef MateData mate_data
  */
-    __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_read), __pyx_n_s__qname); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_read), __pyx_n_s__qname); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_70), __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_78), __pyx_t_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_3));
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
     __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 992; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L4;
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":996
+  /* "pysam/csamtools.pyx":1122
  *         cdef MateData mate_data
  * 
  *         mate_data.name = <char *>bam1_qname(read._delegate)             # <<<<<<<<<<<<<<
@@ -10988,7 +12352,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_22mate(struct __pyx_obj_5py
  */
   __pyx_v_mate_data.name = ((char *)bam1_qname(__pyx_v_read->_delegate));
 
-  /* "pysam/csamtools.pyx":997
+  /* "pysam/csamtools.pyx":1123
  * 
  *         mate_data.name = <char *>bam1_qname(read._delegate)
  *         mate_data.mate = NULL             # <<<<<<<<<<<<<<
@@ -10997,7 +12361,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_22mate(struct __pyx_obj_5py
  */
   __pyx_v_mate_data.mate = NULL;
 
-  /* "pysam/csamtools.pyx":999
+  /* "pysam/csamtools.pyx":1125
  *         mate_data.mate = NULL
  *         # xor flags to get the other mate
  *         cdef int x = BAM_FREAD1 + BAM_FREAD2             # <<<<<<<<<<<<<<
@@ -11006,7 +12370,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_22mate(struct __pyx_obj_5py
  */
   __pyx_v_x = 192;
 
-  /* "pysam/csamtools.pyx":1000
+  /* "pysam/csamtools.pyx":1126
  *         # xor flags to get the other mate
  *         cdef int x = BAM_FREAD1 + BAM_FREAD2
  *         mate_data.flag = ( flag ^ x) & x             # <<<<<<<<<<<<<<
@@ -11015,7 +12379,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_22mate(struct __pyx_obj_5py
  */
   __pyx_v_mate_data.flag = ((__pyx_v_flag ^ __pyx_v_x) & __pyx_v_x);
 
-  /* "pysam/csamtools.pyx":1008
+  /* "pysam/csamtools.pyx":1134
  *                   read._delegate.core.mpos + 1,
  *                   <void*>&mate_data,
  *                   mate_callback )             # <<<<<<<<<<<<<<
@@ -11024,7 +12388,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_22mate(struct __pyx_obj_5py
  */
   bam_fetch(__pyx_v_self->samfile->x.bam, __pyx_v_self->index, __pyx_v_read->_delegate->core.mtid, __pyx_v_read->_delegate->core.mpos, (__pyx_v_read->_delegate->core.mpos + 1), ((void *)(&__pyx_v_mate_data)), __pyx_f_5pysam_9csamtools_mate_callback);
 
-  /* "pysam/csamtools.pyx":1010
+  /* "pysam/csamtools.pyx":1136
  *                   mate_callback )
  * 
  *         if mate_data.mate == NULL:             # <<<<<<<<<<<<<<
@@ -11034,36 +12398,36 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_22mate(struct __pyx_obj_5py
   __pyx_t_2 = (__pyx_v_mate_data.mate == NULL);
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":1011
+    /* "pysam/csamtools.pyx":1137
  * 
  *         if mate_data.mate == NULL:
  *             raise ValueError( "mate not found" )             # <<<<<<<<<<<<<<
  * 
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  */
-    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_72), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_80), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_Raise(__pyx_t_3, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "pysam/csamtools.pyx":1013
+  /* "pysam/csamtools.pyx":1139
  *             raise ValueError( "mate not found" )
  * 
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)             # <<<<<<<<<<<<<<
  *         dest._delegate = mate_data.mate
  *         return dest
  */
-  __pyx_t_3 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5pysam_9csamtools_AlignedRead)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_tp_new(((PyObject*)__pyx_ptype_5pysam_9csamtools_AlignedRead)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5pysam_9csamtools_AlignedRead)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(__Pyx_TypeTest(__pyx_t_3, __pyx_ptype_5pysam_9csamtools_AlignedRead)))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_dest = ((struct __pyx_obj_5pysam_9csamtools_AlignedRead *)__pyx_t_3);
   __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":1014
+  /* "pysam/csamtools.pyx":1140
  * 
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  *         dest._delegate = mate_data.mate             # <<<<<<<<<<<<<<
@@ -11073,7 +12437,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_22mate(struct __pyx_obj_5py
   __pyx_t_5 = __pyx_v_mate_data.mate;
   __pyx_v_dest->_delegate = __pyx_t_5;
 
-  /* "pysam/csamtools.pyx":1015
+  /* "pysam/csamtools.pyx":1141
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  *         dest._delegate = mate_data.mate
  *         return dest             # <<<<<<<<<<<<<<
@@ -11116,7 +12480,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_25count(PyObject *__pyx_v_s
     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,&__pyx_n_s__until_eof,0};
     PyObject* values[5] = {0,0,0,0,0};
 
-    /* "pysam/csamtools.pyx":1018
+    /* "pysam/csamtools.pyx":1144
  * 
  *     def count( self,
  *                reference = None,             # <<<<<<<<<<<<<<
@@ -11125,7 +12489,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_25count(PyObject *__pyx_v_s
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":1019
+    /* "pysam/csamtools.pyx":1145
  *     def count( self,
  *                reference = None,
  *                start = None,             # <<<<<<<<<<<<<<
@@ -11134,7 +12498,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_25count(PyObject *__pyx_v_s
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":1020
+    /* "pysam/csamtools.pyx":1146
  *                reference = None,
  *                start = None,
  *                end = None,             # <<<<<<<<<<<<<<
@@ -11143,7 +12507,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_25count(PyObject *__pyx_v_s
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":1021
+    /* "pysam/csamtools.pyx":1147
  *                start = None,
  *                end = None,
  *                region = None,             # <<<<<<<<<<<<<<
@@ -11151,7 +12515,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_25count(PyObject *__pyx_v_s
  *         '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*
  */
     values[3] = ((PyObject *)Py_None);
-    values[4] = __pyx_k_73;
+    values[4] = __pyx_k_81;
     if (unlikely(__pyx_kwds)) {
       Py_ssize_t kw_args;
       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
@@ -11193,7 +12557,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_25count(PyObject *__pyx_v_s
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "count") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -11214,7 +12578,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_25count(PyObject *__pyx_v_s
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("count", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("count", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1143; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.Samfile.count", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -11225,7 +12589,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_25count(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1017
+/* "pysam/csamtools.pyx":1143
  *         return dest
  * 
  *     def count( self,             # <<<<<<<<<<<<<<
@@ -11259,52 +12623,52 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("count", 0);
-  __Pyx_TraceCall("count", __pyx_f[0], 1017);
+  __Pyx_TraceCall("count", __pyx_f[0], 1143);
   __Pyx_INCREF(__pyx_v_region);
 
-  /* "pysam/csamtools.pyx":1035
+  /* "pysam/csamtools.pyx":1161
  *         cdef int rend
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":1036
+    /* "pysam/csamtools.pyx":1162
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_74), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_82), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1038
+  /* "pysam/csamtools.pyx":1164
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
  * 
  *         cdef int counter
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(__pyx_v_reference);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_reference);
@@ -11318,7 +12682,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
   __Pyx_INCREF(__pyx_v_region);
   PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_region);
   __Pyx_GIVEREF(__pyx_v_region);
-  __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
@@ -11332,7 +12696,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
     if (unlikely(size != 4)) {
       if (size > 4) __Pyx_RaiseTooManyValuesError(4);
       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #if CYTHON_COMPILING_IN_CPYTHON
     if (likely(PyTuple_CheckExact(sequence))) {
@@ -11354,7 +12718,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
     Py_ssize_t i;
     PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_6,&__pyx_t_7};
     for (i=0; i < 4; i++) {
-      PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(item);
       *(temps[i]) = item;
     }
@@ -11364,7 +12728,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
   {
     Py_ssize_t index = -1;
     PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_6,&__pyx_t_7};
-    __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
@@ -11373,7 +12737,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
       __Pyx_GOTREF(item);
       *(temps[index]) = item;
     }
-    if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_9 = NULL;
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     goto __pyx_L5_unpacking_done;
@@ -11381,14 +12745,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __pyx_t_9 = NULL;
     if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_L5_unpacking_done:;
   }
-  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-  __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1038; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
   __Pyx_DECREF(__pyx_v_region);
   __pyx_v_region = __pyx_t_1;
@@ -11397,7 +12761,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
   __pyx_v_rstart = __pyx_t_11;
   __pyx_v_rend = __pyx_t_12;
 
-  /* "pysam/csamtools.pyx":1041
+  /* "pysam/csamtools.pyx":1167
  * 
  *         cdef int counter
  *         counter = 0;             # <<<<<<<<<<<<<<
@@ -11406,7 +12770,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
  */
   __pyx_v_counter = 0;
 
-  /* "pysam/csamtools.pyx":1043
+  /* "pysam/csamtools.pyx":1169
  *         counter = 0;
  * 
  *         if self.isbam:             # <<<<<<<<<<<<<<
@@ -11415,22 +12779,22 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
  */
   if (__pyx_v_self->isbam) {
 
-    /* "pysam/csamtools.pyx":1044
+    /* "pysam/csamtools.pyx":1170
  * 
  *         if self.isbam:
  *             if not until_eof and not self._hasIndex() and not self.isremote:             # <<<<<<<<<<<<<<
  *                 raise ValueError( "fetch called on bamfile without index" )
  * 
  */
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_until_eof); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_3 = (!__pyx_t_4);
     if (__pyx_t_3) {
-      __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1044; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __pyx_t_13 = (!__pyx_t_4);
       if (__pyx_t_13) {
@@ -11445,75 +12809,75 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
     }
     if (__pyx_t_13) {
 
-      /* "pysam/csamtools.pyx":1045
+      /* "pysam/csamtools.pyx":1171
  *         if self.isbam:
  *             if not until_eof and not self._hasIndex() and not self.isremote:
  *                 raise ValueError( "fetch called on bamfile without index" )             # <<<<<<<<<<<<<<
  * 
  *             if not region:
  */
-      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_75), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_83), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_Raise(__pyx_t_7, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L7;
     }
     __pyx_L7:;
 
-    /* "pysam/csamtools.pyx":1047
+    /* "pysam/csamtools.pyx":1173
  *                 raise ValueError( "fetch called on bamfile without index" )
  * 
  *             if not region:             # <<<<<<<<<<<<<<
  *                 raise ValueError( "counting functionality requires a region/reference" )
  *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )
  */
-    __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_13 = __Pyx_PyObject_IsTrue(__pyx_v_region); if (unlikely(__pyx_t_13 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_3 = (!__pyx_t_13);
     if (__pyx_t_3) {
 
-      /* "pysam/csamtools.pyx":1048
+      /* "pysam/csamtools.pyx":1174
  * 
  *             if not region:
  *                 raise ValueError( "counting functionality requires a region/reference" )             # <<<<<<<<<<<<<<
  *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )
  *             bam_fetch(self.samfile.x.bam,
  */
-      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_77), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_85), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_Raise(__pyx_t_7, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L8;
     }
     __pyx_L8:;
 
-    /* "pysam/csamtools.pyx":1049
+    /* "pysam/csamtools.pyx":1175
  *             if not region:
  *                 raise ValueError( "counting functionality requires a region/reference" )
  *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )             # <<<<<<<<<<<<<<
  *             bam_fetch(self.samfile.x.bam,
  *                              self.index,
  */
-    __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __pyx_t_13 = (!__pyx_t_3);
     if (__pyx_t_13) {
-      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_78), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_86), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
       __Pyx_Raise(__pyx_t_5, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L9;
     }
     __pyx_L9:;
 
-    /* "pysam/csamtools.pyx":1056
+    /* "pysam/csamtools.pyx":1182
  *                              rend,
  *                              <void*>&counter,
  *                              count_callback )             # <<<<<<<<<<<<<<
@@ -11522,7 +12886,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
  */
     bam_fetch(__pyx_v_self->samfile->x.bam, __pyx_v_self->index, __pyx_v_rtid, __pyx_v_rstart, __pyx_v_rend, ((void *)(&__pyx_v_counter)), __pyx_f_5pysam_9csamtools_count_callback);
 
-    /* "pysam/csamtools.pyx":1057
+    /* "pysam/csamtools.pyx":1183
  *                              <void*>&counter,
  *                              count_callback )
  *             return counter             # <<<<<<<<<<<<<<
@@ -11530,7 +12894,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
  *             raise ValueError ("count for a region is not available for sam files" )
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_5 = PyInt_FromLong(__pyx_v_counter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1057; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyInt_FromLong(__pyx_v_counter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __pyx_r = __pyx_t_5;
     __pyx_t_5 = 0;
@@ -11539,18 +12903,18 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_24count(struct __pyx_obj_5p
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1059
+    /* "pysam/csamtools.pyx":1185
  *             return counter
  *         else:
  *             raise ValueError ("count for a region is not available for sam files" )             # <<<<<<<<<<<<<<
  * 
  *     def pileup( self,
  */
-    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_80), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_88), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_Raise(__pyx_t_5, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L6:;
 
@@ -11592,7 +12956,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_27pileup(PyObject *__pyx_v_
     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__reference,&__pyx_n_s__start,&__pyx_n_s__end,&__pyx_n_s__region,&__pyx_n_s__callback,0};
     PyObject* values[5] = {0,0,0,0,0};
 
-    /* "pysam/csamtools.pyx":1062
+    /* "pysam/csamtools.pyx":1188
  * 
  *     def pileup( self,
  *                 reference = None,             # <<<<<<<<<<<<<<
@@ -11601,7 +12965,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_27pileup(PyObject *__pyx_v_
  */
     values[0] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":1063
+    /* "pysam/csamtools.pyx":1189
  *     def pileup( self,
  *                 reference = None,
  *                 start = None,             # <<<<<<<<<<<<<<
@@ -11610,7 +12974,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_27pileup(PyObject *__pyx_v_
  */
     values[1] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":1064
+    /* "pysam/csamtools.pyx":1190
  *                 reference = None,
  *                 start = None,
  *                 end = None,             # <<<<<<<<<<<<<<
@@ -11619,7 +12983,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_27pileup(PyObject *__pyx_v_
  */
     values[2] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":1065
+    /* "pysam/csamtools.pyx":1191
  *                 start = None,
  *                 end = None,
  *                 region = None,             # <<<<<<<<<<<<<<
@@ -11628,7 +12992,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_27pileup(PyObject *__pyx_v_
  */
     values[3] = ((PyObject *)Py_None);
 
-    /* "pysam/csamtools.pyx":1066
+    /* "pysam/csamtools.pyx":1192
  *                 end = None,
  *                 region = None,
  *                 callback = None,             # <<<<<<<<<<<<<<
@@ -11677,7 +13041,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_27pileup(PyObject *__pyx_v_
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "pileup") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "pileup") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -11698,7 +13062,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_27pileup(PyObject *__pyx_v_
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("pileup", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("pileup", 0, 0, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1187; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
   __Pyx_AddTraceback("pysam.csamtools.Samfile.pileup", __pyx_clineno, __pyx_lineno, __pyx_filename);
@@ -11711,7 +13075,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_27pileup(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1061
+/* "pysam/csamtools.pyx":1187
  *             raise ValueError ("count for a region is not available for sam files" )
  * 
  *     def pileup( self,             # <<<<<<<<<<<<<<
@@ -11745,51 +13109,51 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("pileup", 0);
-  __Pyx_TraceCall("pileup", __pyx_f[0], 1061);
+  __Pyx_TraceCall("pileup", __pyx_f[0], 1187);
 
-  /* "pysam/csamtools.pyx":1117
+  /* "pysam/csamtools.pyx":1243
  *         cdef bam_plbuf_t *buf
  * 
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":1118
+    /* "pysam/csamtools.pyx":1244
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_81), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_89), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1120
+  /* "pysam/csamtools.pyx":1246
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )             # <<<<<<<<<<<<<<
  * 
  *         if self.isbam:
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___parseRegion); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(__pyx_v_reference);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_reference);
@@ -11803,7 +13167,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
   __Pyx_INCREF(__pyx_v_region);
   PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_region);
   __Pyx_GIVEREF(__pyx_v_region);
-  __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
@@ -11817,7 +13181,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
     if (unlikely(size != 4)) {
       if (size > 4) __Pyx_RaiseTooManyValuesError(4);
       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #if CYTHON_COMPILING_IN_CPYTHON
     if (likely(PyTuple_CheckExact(sequence))) {
@@ -11839,7 +13203,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
     Py_ssize_t i;
     PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_6,&__pyx_t_7};
     for (i=0; i < 4; i++) {
-      PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      PyObject* item = PySequence_ITEM(sequence, i); if (unlikely(!item)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(item);
       *(temps[i]) = item;
     }
@@ -11849,7 +13213,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
   {
     Py_ssize_t index = -1;
     PyObject** temps[4] = {&__pyx_t_1,&__pyx_t_2,&__pyx_t_6,&__pyx_t_7};
-    __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
@@ -11858,7 +13222,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
       __Pyx_GOTREF(item);
       *(temps[index]) = item;
     }
-    if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_9 = NULL;
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     goto __pyx_L5_unpacking_done;
@@ -11866,23 +13230,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     __pyx_t_9 = NULL;
     if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_L5_unpacking_done:;
   }
-  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = __Pyx_PyInt_AsInt(__pyx_t_1); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_11 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_6); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-  __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_t_7); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
   __pyx_v_has_coord = __pyx_t_10;
   __pyx_v_rtid = __pyx_t_11;
   __pyx_v_rstart = __pyx_t_12;
   __pyx_v_rend = __pyx_t_13;
 
-  /* "pysam/csamtools.pyx":1122
+  /* "pysam/csamtools.pyx":1248
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  * 
  *         if self.isbam:             # <<<<<<<<<<<<<<
@@ -11891,42 +13255,42 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
  */
   if (__pyx_v_self->isbam) {
 
-    /* "pysam/csamtools.pyx":1123
+    /* "pysam/csamtools.pyx":1249
  * 
  *         if self.isbam:
  *             if not self._hasIndex(): raise ValueError( "no index available for pileup" )             # <<<<<<<<<<<<<<
  * 
  *             if callback:
  */
-    __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
-    __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
     __pyx_t_3 = (!__pyx_t_4);
     if (__pyx_t_3) {
-      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_83), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_91), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_Raise(__pyx_t_7, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L7;
     }
     __pyx_L7:;
 
-    /* "pysam/csamtools.pyx":1125
+    /* "pysam/csamtools.pyx":1251
  *             if not self._hasIndex(): raise ValueError( "no index available for pileup" )
  * 
  *             if callback:             # <<<<<<<<<<<<<<
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
  * 
  */
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_v_callback); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1251; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_3) {
 
-      /* "pysam/csamtools.pyx":1126
+      /* "pysam/csamtools.pyx":1252
  * 
  *             if callback:
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )             # <<<<<<<<<<<<<<
@@ -11935,16 +13299,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
  */
       __pyx_t_3 = (!__pyx_v_has_coord);
       if (__pyx_t_3) {
-        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_84), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_92), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_Raise(__pyx_t_7, 0, 0, 0);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L9;
       }
       __pyx_L9:;
 
-      /* "pysam/csamtools.pyx":1128
+      /* "pysam/csamtools.pyx":1254
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
  * 
  *                 buf = bam_plbuf_init( <bam_pileup_f>pileup_callback, <void*>callback )             # <<<<<<<<<<<<<<
@@ -11953,7 +13317,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
  */
       __pyx_v_buf = bam_plbuf_init(((bam_pileup_f)__pyx_f_5pysam_9csamtools_pileup_callback), ((void *)__pyx_v_callback));
 
-      /* "pysam/csamtools.pyx":1131
+      /* "pysam/csamtools.pyx":1257
  *                 bam_fetch(self.samfile.x.bam,
  *                           self.index, rtid, rstart, rend,
  *                           buf, pileup_fetch_callback )             # <<<<<<<<<<<<<<
@@ -11962,7 +13326,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
  */
       bam_fetch(__pyx_v_self->samfile->x.bam, __pyx_v_self->index, __pyx_v_rtid, __pyx_v_rstart, __pyx_v_rend, __pyx_v_buf, __pyx_f_5pysam_9csamtools_pileup_fetch_callback);
 
-      /* "pysam/csamtools.pyx":1134
+      /* "pysam/csamtools.pyx":1260
  * 
  *                 # finalize pileup
  *                 bam_plbuf_push( NULL, buf)             # <<<<<<<<<<<<<<
@@ -11971,7 +13335,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
  */
       bam_plbuf_push(NULL, __pyx_v_buf);
 
-      /* "pysam/csamtools.pyx":1135
+      /* "pysam/csamtools.pyx":1261
  *                 # finalize pileup
  *                 bam_plbuf_push( NULL, buf)
  *                 bam_plbuf_destroy(buf)             # <<<<<<<<<<<<<<
@@ -11983,7 +13347,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
     }
     /*else*/ {
 
-      /* "pysam/csamtools.pyx":1137
+      /* "pysam/csamtools.pyx":1263
  *                 bam_plbuf_destroy(buf)
  *             else:
  *                 if has_coord:             # <<<<<<<<<<<<<<
@@ -11992,7 +13356,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
  */
       if (__pyx_v_has_coord) {
 
-        /* "pysam/csamtools.pyx":1138
+        /* "pysam/csamtools.pyx":1264
  *             else:
  *                 if has_coord:
  *                     return IteratorColumnRegion( self,             # <<<<<<<<<<<<<<
@@ -12000,67 +13364,67 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
  *                                                  start = rstart,
  */
         __Pyx_XDECREF(__pyx_r);
-        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_INCREF(((PyObject *)__pyx_v_self));
         PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_self));
         __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
 
-        /* "pysam/csamtools.pyx":1142
+        /* "pysam/csamtools.pyx":1268
  *                                                  start = rstart,
  *                                                  end = rend,
  *                                                  **kwargs )             # <<<<<<<<<<<<<<
  *                 else:
  *                     return IteratorColumnAllRefs(self, **kwargs )
  */
-        __pyx_t_5 = PyDict_Copy(((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = PyDict_Copy(((PyObject *)__pyx_v_kwargs)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_5));
 
-        /* "pysam/csamtools.pyx":1139
+        /* "pysam/csamtools.pyx":1265
  *                 if has_coord:
  *                     return IteratorColumnRegion( self,
  *                                                  tid = rtid,             # <<<<<<<<<<<<<<
  *                                                  start = rstart,
  *                                                  end = rend,
  */
-        __pyx_t_6 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyInt_FromLong(__pyx_v_rtid); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1265; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         if (unlikely(PyDict_GetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__tid)))) {
-          __Pyx_RaiseDoubleKeywordsError("function", ((PyObject *)__pyx_n_s__tid)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_RaiseDoubleKeywordsError("function", ((PyObject *)__pyx_n_s__tid)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
-        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__tid), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__tid), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-        /* "pysam/csamtools.pyx":1140
+        /* "pysam/csamtools.pyx":1266
  *                     return IteratorColumnRegion( self,
  *                                                  tid = rtid,
  *                                                  start = rstart,             # <<<<<<<<<<<<<<
  *                                                  end = rend,
  *                                                  **kwargs )
  */
-        __pyx_t_6 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyInt_FromLong(__pyx_v_rstart); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         if (unlikely(PyDict_GetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__start)))) {
-          __Pyx_RaiseDoubleKeywordsError("function", ((PyObject *)__pyx_n_s__start)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_RaiseDoubleKeywordsError("function", ((PyObject *)__pyx_n_s__start)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
-        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__start), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__start), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-        /* "pysam/csamtools.pyx":1141
+        /* "pysam/csamtools.pyx":1267
  *                                                  tid = rtid,
  *                                                  start = rstart,
  *                                                  end = rend,             # <<<<<<<<<<<<<<
  *                                                  **kwargs )
  *                 else:
  */
-        __pyx_t_6 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyInt_FromLong(__pyx_v_rend); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         if (unlikely(PyDict_GetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__end)))) {
-          __Pyx_RaiseDoubleKeywordsError("function", ((PyObject *)__pyx_n_s__end)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_RaiseDoubleKeywordsError("function", ((PyObject *)__pyx_n_s__end)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
-        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__end), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_SetItem(__pyx_t_5, ((PyObject *)__pyx_n_s__end), __pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-        __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorColumnRegion)), ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorColumnRegion)), ((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
@@ -12071,7 +13435,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
       }
       /*else*/ {
 
-        /* "pysam/csamtools.pyx":1144
+        /* "pysam/csamtools.pyx":1270
  *                                                  **kwargs )
  *                 else:
  *                     return IteratorColumnAllRefs(self, **kwargs )             # <<<<<<<<<<<<<<
@@ -12079,14 +13443,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
  *         else:
  */
         __Pyx_XDECREF(__pyx_r);
-        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_INCREF(((PyObject *)__pyx_v_self));
         PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_v_self));
         __Pyx_GIVEREF(((PyObject *)__pyx_v_self));
         __pyx_t_5 = ((PyObject *)__pyx_v_kwargs);
         __Pyx_INCREF(__pyx_t_5);
-        __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorColumnAllRefs)), ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorColumnAllRefs)), ((PyObject *)__pyx_t_6), ((PyObject *)__pyx_t_5)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
@@ -12101,18 +13465,18 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_26pileup(struct __pyx_obj_5
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1147
+    /* "pysam/csamtools.pyx":1273
  * 
  *         else:
  *             raise NotImplementedError( "pileup of samfiles not implemented yet" )             # <<<<<<<<<<<<<<
  * 
  *     def close( self ):
  */
-    __pyx_t_7 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_86), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_94), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_Raise(__pyx_t_7, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L6:;
 
@@ -12146,7 +13510,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_29close(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1149
+/* "pysam/csamtools.pyx":1275
  *             raise NotImplementedError( "pileup of samfiles not implemented yet" )
  * 
  *     def close( self ):             # <<<<<<<<<<<<<<
@@ -12160,9 +13524,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_28close(struct __pyx_obj_5p
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("close", 0);
-  __Pyx_TraceCall("close", __pyx_f[0], 1149);
+  __Pyx_TraceCall("close", __pyx_f[0], 1275);
 
-  /* "pysam/csamtools.pyx":1152
+  /* "pysam/csamtools.pyx":1278
  *         '''
  *         closes the :class:`pysam.Samfile`.'''
  *         if self.samfile != NULL:             # <<<<<<<<<<<<<<
@@ -12172,7 +13536,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_28close(struct __pyx_obj_5p
   __pyx_t_1 = (__pyx_v_self->samfile != NULL);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":1153
+    /* "pysam/csamtools.pyx":1279
  *         closes the :class:`pysam.Samfile`.'''
  *         if self.samfile != NULL:
  *             samclose( self.samfile )             # <<<<<<<<<<<<<<
@@ -12181,7 +13545,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_28close(struct __pyx_obj_5p
  */
     samclose(__pyx_v_self->samfile);
 
-    /* "pysam/csamtools.pyx":1154
+    /* "pysam/csamtools.pyx":1280
  *         if self.samfile != NULL:
  *             samclose( self.samfile )
  *             bam_index_destroy(self.index);             # <<<<<<<<<<<<<<
@@ -12190,7 +13554,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_28close(struct __pyx_obj_5p
  */
     bam_index_destroy(__pyx_v_self->index);
 
-    /* "pysam/csamtools.pyx":1155
+    /* "pysam/csamtools.pyx":1281
  *             samclose( self.samfile )
  *             bam_index_destroy(self.index);
  *             self.samfile = NULL             # <<<<<<<<<<<<<<
@@ -12218,7 +13582,7 @@ static void __pyx_pw_5pysam_9csamtools_7Samfile_31__dealloc__(PyObject *__pyx_v_
   __Pyx_RefNannyFinishContext();
 }
 
-/* "pysam/csamtools.pyx":1157
+/* "pysam/csamtools.pyx":1283
  *             self.samfile = NULL
  * 
  *     def __dealloc__( self ):             # <<<<<<<<<<<<<<
@@ -12236,23 +13600,23 @@ static void __pyx_pf_5pysam_9csamtools_7Samfile_30__dealloc__(struct __pyx_obj_5
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__", 0);
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1157);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1283);
 
-  /* "pysam/csamtools.pyx":1161
+  /* "pysam/csamtools.pyx":1287
  *         # note: no doc string
  *         # note: __del__ is not called.
  *         self.close()             # <<<<<<<<<<<<<<
  *         bam_destroy1(self.b)
  *         if self._filename != NULL: free( self._filename )
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":1162
+  /* "pysam/csamtools.pyx":1288
  *         # note: __del__ is not called.
  *         self.close()
  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
@@ -12261,7 +13625,7 @@ static void __pyx_pf_5pysam_9csamtools_7Samfile_30__dealloc__(struct __pyx_obj_5
  */
   bam_destroy1(__pyx_v_self->b);
 
-  /* "pysam/csamtools.pyx":1163
+  /* "pysam/csamtools.pyx":1289
  *         self.close()
  *         bam_destroy1(self.b)
  *         if self._filename != NULL: free( self._filename )             # <<<<<<<<<<<<<<
@@ -12285,7 +13649,7 @@ static void __pyx_pf_5pysam_9csamtools_7Samfile_30__dealloc__(struct __pyx_obj_5
   __Pyx_RefNannyFinishContext();
 }
 
-/* "pysam/csamtools.pyx":1165
+/* "pysam/csamtools.pyx":1291
  *         if self._filename != NULL: free( self._filename )
  * 
  *     cpdef int write( self, AlignedRead read ) except -1:             # <<<<<<<<<<<<<<
@@ -12308,23 +13672,23 @@ static int __pyx_f_5pysam_9csamtools_7Samfile_write(struct __pyx_obj_5pysam_9csa
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("write", 0);
-  __Pyx_TraceCall("write", __pyx_f[0], 1165);
+  __Pyx_TraceCall("write", __pyx_f[0], 1291);
   /* Check if called by wrapper */
   if (unlikely(__pyx_skip_dispatch)) ;
   /* Check if overridden in Python */
   else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) {
-    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__write); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5pysam_9csamtools_7Samfile_33write)) {
-      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_INCREF(((PyObject *)__pyx_v_read));
       PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_read));
       __Pyx_GIVEREF(((PyObject *)__pyx_v_read));
-      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyInt_AsInt(__pyx_t_3); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __pyx_r = __pyx_t_4;
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -12333,24 +13697,24 @@ static int __pyx_f_5pysam_9csamtools_7Samfile_write(struct __pyx_obj_5pysam_9csa
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
 
-  /* "pysam/csamtools.pyx":1171
+  /* "pysam/csamtools.pyx":1297
  *         returns the number of bytes written.
  *         '''
  *         if not self._isOpen():             # <<<<<<<<<<<<<<
  *             return 0
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __pyx_t_6 = (!__pyx_t_5);
   if (__pyx_t_6) {
 
-    /* "pysam/csamtools.pyx":1172
+    /* "pysam/csamtools.pyx":1298
  *         '''
  *         if not self._isOpen():
  *             return 0             # <<<<<<<<<<<<<<
@@ -12363,7 +13727,7 @@ static int __pyx_f_5pysam_9csamtools_7Samfile_write(struct __pyx_obj_5pysam_9csa
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1174
+  /* "pysam/csamtools.pyx":1300
  *             return 0
  * 
  *         return samwrite( self.samfile, read._delegate )             # <<<<<<<<<<<<<<
@@ -12394,7 +13758,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_33write(PyObject *__pyx_v_s
   PyObject *__pyx_r = 0;
   __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("write (wrapper)", 0);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_read), __pyx_ptype_5pysam_9csamtools_AlignedRead, 1, "read", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_read), __pyx_ptype_5pysam_9csamtools_AlignedRead, 1, "read", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_7Samfile_32write(((struct __pyx_obj_5pysam_9csamtools_Samfile *)__pyx_v_self), ((struct __pyx_obj_5pysam_9csamtools_AlignedRead *)__pyx_v_read));
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -12404,7 +13768,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_33write(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1165
+/* "pysam/csamtools.pyx":1291
  *         if self._filename != NULL: free( self._filename )
  * 
  *     cpdef int write( self, AlignedRead read ) except -1:             # <<<<<<<<<<<<<<
@@ -12421,9 +13785,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_32write(struct __pyx_obj_5p
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("write", 0);
-  __Pyx_TraceCall("write", __pyx_f[0], 1165);
+  __Pyx_TraceCall("write", __pyx_f[0], 1291);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(((struct __pyx_vtabstruct_5pysam_9csamtools_Samfile *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, __pyx_v_read, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(((struct __pyx_vtabstruct_5pysam_9csamtools_Samfile *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, __pyx_v_read, 1)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1291; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -12454,7 +13818,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_35__enter__(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1176
+/* "pysam/csamtools.pyx":1302
  *         return samwrite( self.samfile, read._delegate )
  * 
  *     def __enter__(self):             # <<<<<<<<<<<<<<
@@ -12467,9 +13831,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_34__enter__(struct __pyx_ob
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__enter__", 0);
-  __Pyx_TraceCall("__enter__", __pyx_f[0], 1176);
+  __Pyx_TraceCall("__enter__", __pyx_f[0], 1302);
 
-  /* "pysam/csamtools.pyx":1177
+  /* "pysam/csamtools.pyx":1303
  * 
  *     def __enter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -12520,16 +13884,16 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_37__exit__(PyObject *__pyx_
         case  1:
         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__exc_value)) != 0)) kw_args--;
         else {
-          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
         }
         case  2:
         if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__traceback)) != 0)) kw_args--;
         else {
-          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+          __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__exit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else if (PyTuple_GET_SIZE(__pyx_args) != 3) {
       goto __pyx_L5_argtuple_error;
@@ -12544,7 +13908,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_37__exit__(PyObject *__pyx_
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1179; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__exit__", 1, 3, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1305; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.Samfile.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -12555,7 +13919,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_37__exit__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1179
+/* "pysam/csamtools.pyx":1305
  *         return self
  * 
  *     def __exit__(self, exc_type, exc_value, traceback):             # <<<<<<<<<<<<<<
@@ -12573,23 +13937,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_36__exit__(struct __pyx_obj
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__exit__", 0);
-  __Pyx_TraceCall("__exit__", __pyx_f[0], 1179);
+  __Pyx_TraceCall("__exit__", __pyx_f[0], 1305);
 
-  /* "pysam/csamtools.pyx":1180
+  /* "pysam/csamtools.pyx":1306
  * 
  *     def __exit__(self, exc_type, exc_value, traceback):
  *         self.close()             # <<<<<<<<<<<<<<
  *         return False
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__close); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":1181
+  /* "pysam/csamtools.pyx":1307
  *     def __exit__(self, exc_type, exc_value, traceback):
  *         self.close()
  *         return False             # <<<<<<<<<<<<<<
@@ -12597,7 +13961,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_36__exit__(struct __pyx_obj
  *     ###############################################################
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1181; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -12628,7 +13992,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_8filename_1__get__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1190
+/* "pysam/csamtools.pyx":1316
  *     property filename:
  *         '''number of :term:`filename` associated with this object.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -12648,34 +14012,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_8filename___get__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1190);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1316);
 
-  /* "pysam/csamtools.pyx":1191
+  /* "pysam/csamtools.pyx":1317
  *         '''number of :term:`filename` associated with this object.'''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             return self._filename
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_87), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_95), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1192
+  /* "pysam/csamtools.pyx":1318
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             return self._filename             # <<<<<<<<<<<<<<
@@ -12683,7 +14047,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_8filename___get__(struct __
  *     property nreferences:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyBytes_FromString(__pyx_v_self->_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyBytes_FromString(__pyx_v_self->_filename); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __pyx_r = ((PyObject *)__pyx_t_2);
   __pyx_t_2 = 0;
@@ -12714,7 +14078,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_11nreferences_1__get__(PyOb
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1196
+/* "pysam/csamtools.pyx":1322
  *     property nreferences:
  *         '''number of :term:`reference` sequences in the file.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -12734,34 +14098,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_11nreferences___get__(struc
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1196);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1322);
 
-  /* "pysam/csamtools.pyx":1197
+  /* "pysam/csamtools.pyx":1323
  *         '''number of :term:`reference` sequences in the file.'''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             return self.samfile.header.n_targets
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_88), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_96), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1198
+  /* "pysam/csamtools.pyx":1324
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             return self.samfile.header.n_targets             # <<<<<<<<<<<<<<
@@ -12769,7 +14133,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_11nreferences___get__(struc
  *     property references:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->samfile->header->n_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->samfile->header->n_targets); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1324; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -12800,7 +14164,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_10references_1__get__(PyObj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1202
+/* "pysam/csamtools.pyx":1328
  *     property references:
  *         """tuple with the names of :term:`reference` sequences."""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -12824,46 +14188,46 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_10references___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1202);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1328);
 
-  /* "pysam/csamtools.pyx":1203
+  /* "pysam/csamtools.pyx":1329
  *         """tuple with the names of :term:`reference` sequences."""
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_89), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_97), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1204
+  /* "pysam/csamtools.pyx":1330
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             t = []             # <<<<<<<<<<<<<<
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( _charptr_to_str(self.samfile.header.target_name[x]) )
  */
-  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_v_t = ((PyObject*)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":1205
+  /* "pysam/csamtools.pyx":1331
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
@@ -12873,20 +14237,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_10references___get__(struct
   __pyx_t_5 = __pyx_v_self->samfile->header->n_targets;
   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_5; __pyx_v_x++) {
 
-    /* "pysam/csamtools.pyx":1206
+    /* "pysam/csamtools.pyx":1332
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( _charptr_to_str(self.samfile.header.target_name[x]) )             # <<<<<<<<<<<<<<
  *             return tuple(t)
  * 
  */
-    __pyx_t_2 = __pyx_f_5pysam_9csamtools__charptr_to_str((__pyx_v_self->samfile->header->target_name[__pyx_v_x])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __pyx_f_5pysam_9csamtools__charptr_to_str((__pyx_v_self->samfile->header->target_name[__pyx_v_x])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_6 = PyList_Append(__pyx_v_t, __pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyList_Append(__pyx_v_t, __pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   }
 
-  /* "pysam/csamtools.pyx":1207
+  /* "pysam/csamtools.pyx":1333
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( _charptr_to_str(self.samfile.header.target_name[x]) )
  *             return tuple(t)             # <<<<<<<<<<<<<<
@@ -12894,7 +14258,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_10references___get__(struct
  *     property lengths:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = ((PyObject *)PyList_AsTuple(__pyx_v_t)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = ((PyObject *)PyList_AsTuple(__pyx_v_t)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __pyx_r = ((PyObject *)__pyx_t_2);
   __pyx_t_2 = 0;
@@ -12926,7 +14290,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_7lengths_1__get__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1213
+/* "pysam/csamtools.pyx":1339
  *         :attr:`pysam.Samfile.references`
  *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -12950,46 +14314,46 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_7lengths___get__(struct __p
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1213);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1339);
 
-  /* "pysam/csamtools.pyx":1214
+  /* "pysam/csamtools.pyx":1340
  *         """
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_90), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_98), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1215
+  /* "pysam/csamtools.pyx":1341
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             t = []             # <<<<<<<<<<<<<<
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_len[x] )
  */
-  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_v_t = ((PyObject*)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":1216
+  /* "pysam/csamtools.pyx":1342
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
@@ -12999,20 +14363,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_7lengths___get__(struct __p
   __pyx_t_5 = __pyx_v_self->samfile->header->n_targets;
   for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_5; __pyx_v_x++) {
 
-    /* "pysam/csamtools.pyx":1217
+    /* "pysam/csamtools.pyx":1343
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_len[x] )             # <<<<<<<<<<<<<<
  *             return tuple(t)
  * 
  */
-    __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t((__pyx_v_self->samfile->header->target_len[__pyx_v_x])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t((__pyx_v_self->samfile->header->target_len[__pyx_v_x])); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_6 = PyList_Append(__pyx_v_t, __pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyList_Append(__pyx_v_t, __pyx_t_2); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   }
 
-  /* "pysam/csamtools.pyx":1218
+  /* "pysam/csamtools.pyx":1344
  *             for x from 0 <= x < self.samfile.header.n_targets:
  *                 t.append( self.samfile.header.target_len[x] )
  *             return tuple(t)             # <<<<<<<<<<<<<<
@@ -13020,7 +14384,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_7lengths___get__(struct __p
  *     property mapped:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = ((PyObject *)PyList_AsTuple(__pyx_v_t)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1218; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = ((PyObject *)PyList_AsTuple(__pyx_v_t)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __pyx_r = ((PyObject *)__pyx_t_2);
   __pyx_t_2 = 0;
@@ -13052,7 +14416,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_6mapped_1__get__(PyObject *
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1223
+/* "pysam/csamtools.pyx":1349
  *         """total number of mapped reads in file.
  *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -13075,34 +14439,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6mapped___get__(struct __py
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1223);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1349);
 
-  /* "pysam/csamtools.pyx":1224
+  /* "pysam/csamtools.pyx":1350
  *         """
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             if not self.isbam: raise AttributeError( "Samfile.mapped only available in bam files" )
  *             if self.index == NULL:
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_91), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_99), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1225
+  /* "pysam/csamtools.pyx":1351
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             if not self.isbam: raise AttributeError( "Samfile.mapped only available in bam files" )             # <<<<<<<<<<<<<<
@@ -13111,16 +14475,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6mapped___get__(struct __py
  */
   __pyx_t_4 = (!__pyx_v_self->isbam);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_AttributeError, ((PyObject *)__pyx_k_tuple_93), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_AttributeError, ((PyObject *)__pyx_k_tuple_101), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L4;
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":1226
+  /* "pysam/csamtools.pyx":1352
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             if not self.isbam: raise AttributeError( "Samfile.mapped only available in bam files" )
  *             if self.index == NULL:             # <<<<<<<<<<<<<<
@@ -13130,23 +14494,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6mapped___get__(struct __py
   __pyx_t_4 = (__pyx_v_self->index == NULL);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":1227
+    /* "pysam/csamtools.pyx":1353
  *             if not self.isbam: raise AttributeError( "Samfile.mapped only available in bam files" )
  *             if self.index == NULL:
  *                 raise ValueError( "mapping information not recorded in index or index not available")             # <<<<<<<<<<<<<<
  * 
  *             cdef int tid
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_95), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_103), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "pysam/csamtools.pyx":1230
+  /* "pysam/csamtools.pyx":1356
  * 
  *             cdef int tid
  *             cdef uint32_t total = 0             # <<<<<<<<<<<<<<
@@ -13155,7 +14519,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6mapped___get__(struct __py
  */
   __pyx_v_total = 0;
 
-  /* "pysam/csamtools.pyx":1231
+  /* "pysam/csamtools.pyx":1357
  *             cdef int tid
  *             cdef uint32_t total = 0
  *             for tid from 0 <= tid < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
@@ -13165,7 +14529,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6mapped___get__(struct __py
   __pyx_t_5 = __pyx_v_self->samfile->header->n_targets;
   for (__pyx_v_tid = 0; __pyx_v_tid < __pyx_t_5; __pyx_v_tid++) {
 
-    /* "pysam/csamtools.pyx":1232
+    /* "pysam/csamtools.pyx":1358
  *             cdef uint32_t total = 0
  *             for tid from 0 <= tid < self.samfile.header.n_targets:
  *                 total += pysam_get_mapped( self.index, tid )             # <<<<<<<<<<<<<<
@@ -13175,7 +14539,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6mapped___get__(struct __py
     __pyx_v_total = (__pyx_v_total + pysam_get_mapped(__pyx_v_self->index, __pyx_v_tid));
   }
 
-  /* "pysam/csamtools.pyx":1233
+  /* "pysam/csamtools.pyx":1359
  *             for tid from 0 <= tid < self.samfile.header.n_targets:
  *                 total += pysam_get_mapped( self.index, tid )
  *             return total             # <<<<<<<<<<<<<<
@@ -13183,7 +14547,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6mapped___get__(struct __py
  *     property unmapped:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_total); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1233; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_total); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -13214,7 +14578,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_8unmapped_1__get__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1238
+/* "pysam/csamtools.pyx":1364
  *         """total number of unmapped reads in file.
  *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -13237,34 +14601,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_8unmapped___get__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1238);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1364);
 
-  /* "pysam/csamtools.pyx":1239
+  /* "pysam/csamtools.pyx":1365
  *         """
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             if not self.isbam: raise AttributeError( "Samfile.unmapped only available in bam files" )
  *             cdef int tid
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_96), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_104), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1240
+  /* "pysam/csamtools.pyx":1366
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             if not self.isbam: raise AttributeError( "Samfile.unmapped only available in bam files" )             # <<<<<<<<<<<<<<
@@ -13273,16 +14637,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_8unmapped___get__(struct __
  */
   __pyx_t_4 = (!__pyx_v_self->isbam);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_AttributeError, ((PyObject *)__pyx_k_tuple_98), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_AttributeError, ((PyObject *)__pyx_k_tuple_106), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L4;
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":1242
+  /* "pysam/csamtools.pyx":1368
  *             if not self.isbam: raise AttributeError( "Samfile.unmapped only available in bam files" )
  *             cdef int tid
  *             cdef uint32_t total = 0             # <<<<<<<<<<<<<<
@@ -13291,7 +14655,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_8unmapped___get__(struct __
  */
   __pyx_v_total = 0;
 
-  /* "pysam/csamtools.pyx":1243
+  /* "pysam/csamtools.pyx":1369
  *             cdef int tid
  *             cdef uint32_t total = 0
  *             for tid from 0 <= tid < self.samfile.header.n_targets:             # <<<<<<<<<<<<<<
@@ -13301,7 +14665,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_8unmapped___get__(struct __
   __pyx_t_5 = __pyx_v_self->samfile->header->n_targets;
   for (__pyx_v_tid = 0; __pyx_v_tid < __pyx_t_5; __pyx_v_tid++) {
 
-    /* "pysam/csamtools.pyx":1244
+    /* "pysam/csamtools.pyx":1370
  *             cdef uint32_t total = 0
  *             for tid from 0 <= tid < self.samfile.header.n_targets:
  *                 total += pysam_get_unmapped( self.index, tid )             # <<<<<<<<<<<<<<
@@ -13311,7 +14675,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_8unmapped___get__(struct __
     __pyx_v_total = (__pyx_v_total + pysam_get_unmapped(__pyx_v_self->index, __pyx_v_tid));
   }
 
-  /* "pysam/csamtools.pyx":1246
+  /* "pysam/csamtools.pyx":1372
  *                 total += pysam_get_unmapped( self.index, tid )
  *             # get unmapped reads without coordinates
  *             total += pysam_get_unmapped( self.index, -1 )             # <<<<<<<<<<<<<<
@@ -13320,7 +14684,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_8unmapped___get__(struct __
  */
   __pyx_v_total = (__pyx_v_total + pysam_get_unmapped(__pyx_v_self->index, -1));
 
-  /* "pysam/csamtools.pyx":1247
+  /* "pysam/csamtools.pyx":1373
  *             # get unmapped reads without coordinates
  *             total += pysam_get_unmapped( self.index, -1 )
  *             return total             # <<<<<<<<<<<<<<
@@ -13328,7 +14692,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_8unmapped___get__(struct __
  *     property text:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_total); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_total); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -13359,7 +14723,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_4text_1__get__(PyObject *__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1251
+/* "pysam/csamtools.pyx":1377
  *     property text:
  *         '''full contents of the :term:`sam file` header as a string.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -13379,34 +14743,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_4text___get__(struct __pyx_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1251);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1377);
 
-  /* "pysam/csamtools.pyx":1252
+  /* "pysam/csamtools.pyx":1378
  *         '''full contents of the :term:`sam file` header as a string.'''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             return from_string_and_size(self.samfile.header.text, self.samfile.header.l_text)
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_99), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_107), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1253
+  /* "pysam/csamtools.pyx":1379
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             return from_string_and_size(self.samfile.header.text, self.samfile.header.l_text)             # <<<<<<<<<<<<<<
@@ -13414,7 +14778,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_4text___get__(struct __pyx_
  *     property header:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __pyx_f_5pysam_9csamtools_from_string_and_size(__pyx_v_self->samfile->header->text, __pyx_v_self->samfile->header->l_text); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1253; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_5pysam_9csamtools_from_string_and_size(__pyx_v_self->samfile->header->text, __pyx_v_self->samfile->header->l_text); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1379; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -13445,7 +14809,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_6header_1__get__(PyObject *
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1259
+/* "pysam/csamtools.pyx":1385
  *         a two-level dictionary.
  *         '''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -13487,46 +14851,46 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1259);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1385);
 
-  /* "pysam/csamtools.pyx":1260
+  /* "pysam/csamtools.pyx":1386
  *         '''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *             result = {}
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_100), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_108), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1262
+  /* "pysam/csamtools.pyx":1388
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  * 
  *             result = {}             # <<<<<<<<<<<<<<
  * 
  *             if self.samfile.header.text != NULL:
  */
-  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1262; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
   __pyx_v_result = ((PyObject*)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":1264
+  /* "pysam/csamtools.pyx":1390
  *             result = {}
  * 
  *             if self.samfile.header.text != NULL:             # <<<<<<<<<<<<<<
@@ -13536,35 +14900,35 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
   __pyx_t_4 = (__pyx_v_self->samfile->header->text != NULL);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":1266
+    /* "pysam/csamtools.pyx":1392
  *             if self.samfile.header.text != NULL:
  *                 # convert to python string (note: call self.text to create 0-terminated string)
  *                 t = self.text             # <<<<<<<<<<<<<<
  *                 for line in t.split("\n"):
  *                     if not line.strip(): continue
  */
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__text); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1266; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__text); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_v_t = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "pysam/csamtools.pyx":1267
+    /* "pysam/csamtools.pyx":1393
  *                 # convert to python string (note: call self.text to create 0-terminated string)
  *                 t = self.text
  *                 for line in t.split("\n"):             # <<<<<<<<<<<<<<
  *                     if not line.strip(): continue
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_t, __pyx_n_s__split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_t, __pyx_n_s__split); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_101), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_109), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
       __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_5 = 0;
       __pyx_t_6 = NULL;
     } else {
-      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __pyx_t_6 = Py_TYPE(__pyx_t_2)->tp_iternext;
     }
@@ -13573,23 +14937,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
       if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_2)) {
         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_2)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_2)) {
         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else {
         __pyx_t_1 = __pyx_t_6(__pyx_t_2);
         if (unlikely(!__pyx_t_1)) {
           if (PyErr_Occurred()) {
             if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           }
           break;
         }
@@ -13599,19 +14963,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
       __pyx_v_line = __pyx_t_1;
       __pyx_t_1 = 0;
 
-      /* "pysam/csamtools.pyx":1268
+      /* "pysam/csamtools.pyx":1394
  *                 t = self.text
  *                 for line in t.split("\n"):
  *                     if not line.strip(): continue             # <<<<<<<<<<<<<<
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
  *                     fields = line[1:].split("\t")
  */
-      __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1394; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __pyx_t_3 = (!__pyx_t_4);
       if (__pyx_t_3) {
@@ -13620,7 +14984,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
       }
       __pyx_L7:;
 
-      /* "pysam/csamtools.pyx":1269
+      /* "pysam/csamtools.pyx":1395
  *                 for line in t.split("\n"):
  *                     if not line.strip(): continue
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line             # <<<<<<<<<<<<<<
@@ -13628,55 +14992,55 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
  *                     record = fields[0]
  */
       #ifndef CYTHON_WITHOUT_ASSERTIONS
-      __pyx_t_7 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__startswith); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_line, __pyx_n_s__startswith); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_103), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_111), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       if (unlikely(!__pyx_t_3)) {
-        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_104), __pyx_v_line); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_112), __pyx_v_line); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_1));
         PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_1));
         __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #endif
 
-      /* "pysam/csamtools.pyx":1270
+      /* "pysam/csamtools.pyx":1396
  *                     if not line.strip(): continue
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
  *                     fields = line[1:].split("\t")             # <<<<<<<<<<<<<<
  *                     record = fields[0]
  *                     assert record in VALID_HEADER_TYPES, "header line with invalid type '%s': '%s'" % (record, line)
  */
-      __pyx_t_1 = __Pyx_PySequence_GetSlice(__pyx_v_line, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PySequence_GetSlice(__pyx_v_line, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_7 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__split); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__split); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_105), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_113), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __Pyx_XDECREF(__pyx_v_fields);
       __pyx_v_fields = __pyx_t_1;
       __pyx_t_1 = 0;
 
-      /* "pysam/csamtools.pyx":1271
+      /* "pysam/csamtools.pyx":1397
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
  *                     fields = line[1:].split("\t")
  *                     record = fields[0]             # <<<<<<<<<<<<<<
  *                     assert record in VALID_HEADER_TYPES, "header line with invalid type '%s': '%s'" % (record, line)
  * 
  */
-      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_fields, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1271; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_fields, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_XDECREF(__pyx_v_record);
       __pyx_v_record = __pyx_t_1;
       __pyx_t_1 = 0;
 
-      /* "pysam/csamtools.pyx":1272
+      /* "pysam/csamtools.pyx":1398
  *                     fields = line[1:].split("\t")
  *                     record = fields[0]
  *                     assert record in VALID_HEADER_TYPES, "header line with invalid type '%s': '%s'" % (record, line)             # <<<<<<<<<<<<<<
@@ -13684,12 +15048,12 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
  *                     # treat comments
  */
       #ifndef CYTHON_WITHOUT_ASSERTIONS
-      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_3 = (__Pyx_PySequence_Contains(__pyx_v_record, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = (__Pyx_PySequence_Contains(__pyx_v_record, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       if (unlikely(!__pyx_t_3)) {
-        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_INCREF(__pyx_v_record);
         PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_record);
@@ -13697,73 +15061,73 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
         __Pyx_INCREF(__pyx_v_line);
         PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_line);
         __Pyx_GIVEREF(__pyx_v_line);
-        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_106), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_114), ((PyObject *)__pyx_t_1)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
         __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
         PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_t_7));
         __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #endif
 
-      /* "pysam/csamtools.pyx":1275
+      /* "pysam/csamtools.pyx":1401
  * 
  *                     # treat comments
  *                     if record == "CO":             # <<<<<<<<<<<<<<
  *                         if record not in result: result[record] = []
  *                         result[record].append( "\t".join( fields[1:] ) )
  */
-      __pyx_t_7 = PyObject_RichCompare(__pyx_v_record, ((PyObject *)__pyx_n_s__CO), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1275; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_RichCompare(__pyx_v_record, ((PyObject *)__pyx_n_s__CO), Py_EQ); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       if (__pyx_t_3) {
 
-        /* "pysam/csamtools.pyx":1276
+        /* "pysam/csamtools.pyx":1402
  *                     # treat comments
  *                     if record == "CO":
  *                         if record not in result: result[record] = []             # <<<<<<<<<<<<<<
  *                         result[record].append( "\t".join( fields[1:] ) )
  *                         continue
  */
-        __pyx_t_3 = (__Pyx_PyDict_Contains(__pyx_v_record, ((PyObject *)__pyx_v_result), Py_NE)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = (__Pyx_PyDict_Contains(__pyx_v_record, ((PyObject *)__pyx_v_result), Py_NE)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         if (__pyx_t_3) {
-          __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
-          if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_t_7)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_t_7)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
           goto __pyx_L9;
         }
         __pyx_L9:;
 
-        /* "pysam/csamtools.pyx":1277
+        /* "pysam/csamtools.pyx":1403
  *                     if record == "CO":
  *                         if record not in result: result[record] = []
  *                         result[record].append( "\t".join( fields[1:] ) )             # <<<<<<<<<<<<<<
  *                         continue
  *                     # the following is clumsy as generators do not work?
  */
-        __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_v_fields, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_v_fields, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
-        __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_9);
         PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8);
         __Pyx_GIVEREF(__pyx_t_8);
         __pyx_t_8 = 0;
-        __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
-        __pyx_t_9 = __Pyx_PyObject_Append(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = __Pyx_PyObject_Append(__pyx_t_7, __pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_9);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 
-        /* "pysam/csamtools.pyx":1278
+        /* "pysam/csamtools.pyx":1404
  *                         if record not in result: result[record] = []
  *                         result[record].append( "\t".join( fields[1:] ) )
  *                         continue             # <<<<<<<<<<<<<<
@@ -13775,33 +15139,33 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
       }
       __pyx_L8:;
 
-      /* "pysam/csamtools.pyx":1280
+      /* "pysam/csamtools.pyx":1406
  *                         continue
  *                     # the following is clumsy as generators do not work?
  *                     x = {}             # <<<<<<<<<<<<<<
  *                     for field in fields[1:]:
  *                         if ":" not in field:
  */
-      __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_9));
       __Pyx_XDECREF(((PyObject *)__pyx_v_x));
       __pyx_v_x = ((PyObject*)__pyx_t_9);
       __pyx_t_9 = 0;
 
-      /* "pysam/csamtools.pyx":1281
+      /* "pysam/csamtools.pyx":1407
  *                     # the following is clumsy as generators do not work?
  *                     x = {}
  *                     for field in fields[1:]:             # <<<<<<<<<<<<<<
  *                         if ":" not in field:
  *                             raise ValueError("malformatted header: no ':' in field" )
  */
-      __pyx_t_9 = __Pyx_PySequence_GetSlice(__pyx_v_fields, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = __Pyx_PySequence_GetSlice(__pyx_v_fields, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
       if (PyList_CheckExact(__pyx_t_9) || PyTuple_CheckExact(__pyx_t_9)) {
         __pyx_t_8 = __pyx_t_9; __Pyx_INCREF(__pyx_t_8); __pyx_t_10 = 0;
         __pyx_t_11 = NULL;
       } else {
-        __pyx_t_10 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_10 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __pyx_t_11 = Py_TYPE(__pyx_t_8)->tp_iternext;
       }
@@ -13810,23 +15174,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
         if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_8)) {
           if (__pyx_t_10 >= PyList_GET_SIZE(__pyx_t_8)) break;
           #if CYTHON_COMPILING_IN_CPYTHON
-          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_9); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_9); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #else
-          __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #endif
         } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_8)) {
           if (__pyx_t_10 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
           #if CYTHON_COMPILING_IN_CPYTHON
-          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_9); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_10); __Pyx_INCREF(__pyx_t_9); __pyx_t_10++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #else
-          __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_10); __pyx_t_10++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #endif
         } else {
           __pyx_t_9 = __pyx_t_11(__pyx_t_8);
           if (unlikely(!__pyx_t_9)) {
             if (PyErr_Occurred()) {
               if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             }
             break;
           }
@@ -13836,42 +15200,42 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
         __pyx_v_field = __pyx_t_9;
         __pyx_t_9 = 0;
 
-        /* "pysam/csamtools.pyx":1282
+        /* "pysam/csamtools.pyx":1408
  *                     x = {}
  *                     for field in fields[1:]:
  *                         if ":" not in field:             # <<<<<<<<<<<<<<
  *                             raise ValueError("malformatted header: no ':' in field" )
  *                         key, value = field.split(":",1)
  */
-        __pyx_t_3 = (__Pyx_PySequence_Contains(((PyObject *)__pyx_kp_s_107), __pyx_v_field, Py_NE)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1282; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = (__Pyx_PySequence_Contains(((PyObject *)__pyx_kp_s_115), __pyx_v_field, Py_NE)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1408; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         if (__pyx_t_3) {
 
-          /* "pysam/csamtools.pyx":1283
+          /* "pysam/csamtools.pyx":1409
  *                     for field in fields[1:]:
  *                         if ":" not in field:
  *                             raise ValueError("malformatted header: no ':' in field" )             # <<<<<<<<<<<<<<
  *                         key, value = field.split(":",1)
  *                         # uppercase keys must be valid
  */
-          __pyx_t_9 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_109), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_117), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_9);
           __Pyx_Raise(__pyx_t_9, 0, 0, 0);
           __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           goto __pyx_L12;
         }
         __pyx_L12:;
 
-        /* "pysam/csamtools.pyx":1284
+        /* "pysam/csamtools.pyx":1410
  *                         if ":" not in field:
  *                             raise ValueError("malformatted header: no ':' in field" )
  *                         key, value = field.split(":",1)             # <<<<<<<<<<<<<<
  *                         # uppercase keys must be valid
  *                         # lowercase are permitted for user fields
  */
-        __pyx_t_9 = PyObject_GetAttr(__pyx_v_field, __pyx_n_s__split); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyObject_GetAttr(__pyx_v_field, __pyx_n_s__split); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_9);
-        __pyx_t_7 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_k_tuple_110), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_k_tuple_118), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
         if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
@@ -13884,7 +15248,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
           if (unlikely(size != 2)) {
             if (size > 2) __Pyx_RaiseTooManyValuesError(2);
             else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           }
           #if CYTHON_COMPILING_IN_CPYTHON
           if (likely(PyTuple_CheckExact(sequence))) {
@@ -13897,16 +15261,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
           __Pyx_INCREF(__pyx_t_9);
           __Pyx_INCREF(__pyx_t_1);
           #else
-          __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_9);
-          __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_1);
           #endif
           __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
         } else
         {
           Py_ssize_t index = -1;
-          __pyx_t_12 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_12 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_12);
           __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
           __pyx_t_13 = Py_TYPE(__pyx_t_12)->tp_iternext;
@@ -13914,7 +15278,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
           __Pyx_GOTREF(__pyx_t_9);
           index = 1; __pyx_t_1 = __pyx_t_13(__pyx_t_12); if (unlikely(!__pyx_t_1)) goto __pyx_L13_unpacking_failed;
           __Pyx_GOTREF(__pyx_t_1);
-          if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_12), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __pyx_t_13 = NULL;
           __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
           goto __pyx_L14_unpacking_done;
@@ -13922,7 +15286,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
           __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
           __pyx_t_13 = NULL;
           if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __pyx_L14_unpacking_done:;
         }
         __Pyx_XDECREF(__pyx_v_key);
@@ -13932,88 +15296,88 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
         __pyx_v_value = __pyx_t_1;
         __pyx_t_1 = 0;
 
-        /* "pysam/csamtools.pyx":1287
+        /* "pysam/csamtools.pyx":1413
  *                         # uppercase keys must be valid
  *                         # lowercase are permitted for user fields
  *                         if key in VALID_HEADER_FIELDS[record]:             # <<<<<<<<<<<<<<
  *                             x[key] = VALID_HEADER_FIELDS[record][key](value)
  *                         elif not key.isupper():
  */
-        __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_1 = PyObject_GetItem(__pyx_t_7, __pyx_v_record); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_GetItem(__pyx_t_7, __pyx_v_record); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-        __pyx_t_3 = (__Pyx_PySequence_Contains(__pyx_v_key, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = (__Pyx_PySequence_Contains(__pyx_v_key, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1413; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         if (__pyx_t_3) {
 
-          /* "pysam/csamtools.pyx":1288
+          /* "pysam/csamtools.pyx":1414
  *                         # lowercase are permitted for user fields
  *                         if key in VALID_HEADER_FIELDS[record]:
  *                             x[key] = VALID_HEADER_FIELDS[record][key](value)             # <<<<<<<<<<<<<<
  *                         elif not key.isupper():
  *                             x[key] = value
  */
-          __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_1);
-          __pyx_t_7 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-          __pyx_t_1 = PyObject_GetItem(__pyx_t_7, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_1 = PyObject_GetItem(__pyx_t_7, __pyx_v_key); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_1);
           __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
           __Pyx_INCREF(__pyx_v_value);
           PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_value);
           __Pyx_GIVEREF(__pyx_v_value);
-          __pyx_t_9 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_9);
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
           __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-          if (PyDict_SetItem(((PyObject *)__pyx_v_x), __pyx_v_key, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (PyDict_SetItem(((PyObject *)__pyx_v_x), __pyx_v_key, __pyx_t_9) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1414; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
           goto __pyx_L15;
         }
 
-        /* "pysam/csamtools.pyx":1289
+        /* "pysam/csamtools.pyx":1415
  *                         if key in VALID_HEADER_FIELDS[record]:
  *                             x[key] = VALID_HEADER_FIELDS[record][key](value)
  *                         elif not key.isupper():             # <<<<<<<<<<<<<<
  *                             x[key] = value
  *                         else:
  */
-        __pyx_t_9 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__isupper); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__isupper); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_9);
-        __pyx_t_7 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_Call(__pyx_t_9, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1289; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
         __pyx_t_4 = (!__pyx_t_3);
         if (__pyx_t_4) {
 
-          /* "pysam/csamtools.pyx":1290
+          /* "pysam/csamtools.pyx":1416
  *                             x[key] = VALID_HEADER_FIELDS[record][key](value)
  *                         elif not key.isupper():
  *                             x[key] = value             # <<<<<<<<<<<<<<
  *                         else:
  *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )
  */
-          if (PyDict_SetItem(((PyObject *)__pyx_v_x), __pyx_v_key, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (PyDict_SetItem(((PyObject *)__pyx_v_x), __pyx_v_key, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           goto __pyx_L15;
         }
         /*else*/ {
 
-          /* "pysam/csamtools.pyx":1292
+          /* "pysam/csamtools.pyx":1418
  *                             x[key] = value
  *                         else:
  *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )             # <<<<<<<<<<<<<<
  * 
  *                     if VALID_HEADER_TYPES[record] == dict:
  */
-          __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
           __Pyx_INCREF(__pyx_v_key);
           PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_key);
@@ -14021,133 +15385,133 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
           __Pyx_INCREF(__pyx_v_record);
           PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_v_record);
           __Pyx_GIVEREF(__pyx_v_record);
-          __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_111), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_119), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_9));
           __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
           PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_9));
           __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
           __pyx_t_9 = 0;
-          __pyx_t_9 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_9);
           __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
           __Pyx_Raise(__pyx_t_9, 0, 0, 0);
           __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1418; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         __pyx_L15:;
       }
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
-      /* "pysam/csamtools.pyx":1294
+      /* "pysam/csamtools.pyx":1420
  *                             raise ValueError( "unknown field code '%s' in record '%s'" % (key, record) )
  * 
  *                     if VALID_HEADER_TYPES[record] == dict:             # <<<<<<<<<<<<<<
  *                         if record in result:
  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )
  */
-      __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
-      __pyx_t_9 = PyObject_GetItem(__pyx_t_8, __pyx_v_record); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PyObject_GetItem(__pyx_t_8, __pyx_v_record); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-      __pyx_t_8 = PyObject_RichCompare(__pyx_t_9, ((PyObject *)((PyObject*)(&PyDict_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyObject_RichCompare(__pyx_t_9, ((PyObject *)((PyObject*)(&PyDict_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1294; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1420; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
       if (__pyx_t_4) {
 
-        /* "pysam/csamtools.pyx":1295
+        /* "pysam/csamtools.pyx":1421
  * 
  *                     if VALID_HEADER_TYPES[record] == dict:
  *                         if record in result:             # <<<<<<<<<<<<<<
  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )
  *                         result[record] = x
  */
-        __pyx_t_4 = (__Pyx_PyDict_Contains(__pyx_v_record, ((PyObject *)__pyx_v_result), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_4 = (__Pyx_PyDict_Contains(__pyx_v_record, ((PyObject *)__pyx_v_result), Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         if (__pyx_t_4) {
 
-          /* "pysam/csamtools.pyx":1296
+          /* "pysam/csamtools.pyx":1422
  *                     if VALID_HEADER_TYPES[record] == dict:
  *                         if record in result:
  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )             # <<<<<<<<<<<<<<
  *                         result[record] = x
  *                     elif VALID_HEADER_TYPES[record] == list:
  */
-          __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_112), __pyx_v_record); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_120), __pyx_v_record); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_8));
-          __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_9);
           PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_8));
           __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
           __pyx_t_8 = 0;
-          __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_8);
           __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
           __Pyx_Raise(__pyx_t_8, 0, 0, 0);
           __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           goto __pyx_L17;
         }
         __pyx_L17:;
 
-        /* "pysam/csamtools.pyx":1297
+        /* "pysam/csamtools.pyx":1423
  *                         if record in result:
  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )
  *                         result[record] = x             # <<<<<<<<<<<<<<
  *                     elif VALID_HEADER_TYPES[record] == list:
  *                         if record not in result: result[record] = []
  */
-        if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_v_x)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_v_x)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L16;
       }
 
-      /* "pysam/csamtools.pyx":1298
+      /* "pysam/csamtools.pyx":1424
  *                             raise ValueError( "multiple '%s' lines are not permitted" % record )
  *                         result[record] = x
  *                     elif VALID_HEADER_TYPES[record] == list:             # <<<<<<<<<<<<<<
  *                         if record not in result: result[record] = []
  *                         result[record].append( x )
  */
-      __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
-      __pyx_t_9 = PyObject_GetItem(__pyx_t_8, __pyx_v_record); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PyObject_GetItem(__pyx_t_8, __pyx_v_record); if (!__pyx_t_9) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-      __pyx_t_8 = PyObject_RichCompare(__pyx_t_9, ((PyObject *)((PyObject*)(&PyList_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyObject_RichCompare(__pyx_t_9, ((PyObject *)((PyObject*)(&PyList_Type))), Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
       if (__pyx_t_4) {
 
-        /* "pysam/csamtools.pyx":1299
+        /* "pysam/csamtools.pyx":1425
  *                         result[record] = x
  *                     elif VALID_HEADER_TYPES[record] == list:
  *                         if record not in result: result[record] = []             # <<<<<<<<<<<<<<
  *                         result[record].append( x )
  * 
  */
-        __pyx_t_4 = (__Pyx_PyDict_Contains(__pyx_v_record, ((PyObject *)__pyx_v_result), Py_NE)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_4 = (__Pyx_PyDict_Contains(__pyx_v_record, ((PyObject *)__pyx_v_result), Py_NE)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         if (__pyx_t_4) {
-          __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyList_New(0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_8);
-          if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_t_8)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (PyDict_SetItem(((PyObject *)__pyx_v_result), __pyx_v_record, ((PyObject *)__pyx_t_8)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
           goto __pyx_L18;
         }
         __pyx_L18:;
 
-        /* "pysam/csamtools.pyx":1300
+        /* "pysam/csamtools.pyx":1426
  *                     elif VALID_HEADER_TYPES[record] == list:
  *                         if record not in result: result[record] = []
  *                         result[record].append( x )             # <<<<<<<<<<<<<<
  * 
  *                 # if there are no SQ lines in the header, add the reference names
  */
-        __pyx_t_8 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_v_record); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_result), __pyx_v_record); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
-        __pyx_t_9 = __Pyx_PyObject_Append(__pyx_t_8, ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = __Pyx_PyObject_Append(__pyx_t_8, ((PyObject *)__pyx_v_x)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1426; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_9);
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
@@ -14158,40 +15522,40 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
     }
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-    /* "pysam/csamtools.pyx":1308
+    /* "pysam/csamtools.pyx":1434
  *                 # SQ lines, the SQ information is not part of the textual header and thus
  *                 # are missing from the output. See issue 84.
  *                 if "SQ" not in result:             # <<<<<<<<<<<<<<
  *                     sq = []
  *                     for ref, length in zip( self.references, self.lengths ):
  */
-    __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_v_result), Py_NE)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = (__Pyx_PyDict_Contains(((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_v_result), Py_NE)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_4) {
 
-      /* "pysam/csamtools.pyx":1309
+      /* "pysam/csamtools.pyx":1435
  *                 # are missing from the output. See issue 84.
  *                 if "SQ" not in result:
  *                     sq = []             # <<<<<<<<<<<<<<
  *                     for ref, length in zip( self.references, self.lengths ):
  *                         sq.append( {'LN': length, 'SN': ref } )
  */
-      __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __pyx_v_sq = ((PyObject*)__pyx_t_2);
       __pyx_t_2 = 0;
 
-      /* "pysam/csamtools.pyx":1310
+      /* "pysam/csamtools.pyx":1436
  *                 if "SQ" not in result:
  *                     sq = []
  *                     for ref, length in zip( self.references, self.lengths ):             # <<<<<<<<<<<<<<
  *                         sq.append( {'LN': length, 'SN': ref } )
  *                     result["SQ"] = sq
  */
-      __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__references); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__references); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_9 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__lengths); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__lengths); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
-      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_2);
       __Pyx_GIVEREF(__pyx_t_2);
@@ -14199,14 +15563,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
       __Pyx_GIVEREF(__pyx_t_9);
       __pyx_t_2 = 0;
       __pyx_t_9 = 0;
-      __pyx_t_9 = PyObject_Call(__pyx_builtin_zip, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PyObject_Call(__pyx_builtin_zip, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
       __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
       if (PyList_CheckExact(__pyx_t_9) || PyTuple_CheckExact(__pyx_t_9)) {
         __pyx_t_8 = __pyx_t_9; __Pyx_INCREF(__pyx_t_8); __pyx_t_5 = 0;
         __pyx_t_6 = NULL;
       } else {
-        __pyx_t_5 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_5 = -1; __pyx_t_8 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __pyx_t_6 = Py_TYPE(__pyx_t_8)->tp_iternext;
       }
@@ -14215,23 +15579,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
         if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_8)) {
           if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_8)) break;
           #if CYTHON_COMPILING_IN_CPYTHON
-          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PyList_GET_ITEM(__pyx_t_8, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #else
-          __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #endif
         } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_8)) {
           if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_8)) break;
           #if CYTHON_COMPILING_IN_CPYTHON
-          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PyTuple_GET_ITEM(__pyx_t_8, __pyx_t_5); __Pyx_INCREF(__pyx_t_9); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #else
-          __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PySequence_ITEM(__pyx_t_8, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #endif
         } else {
           __pyx_t_9 = __pyx_t_6(__pyx_t_8);
           if (unlikely(!__pyx_t_9)) {
             if (PyErr_Occurred()) {
               if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             }
             break;
           }
@@ -14247,7 +15611,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
           if (unlikely(size != 2)) {
             if (size > 2) __Pyx_RaiseTooManyValuesError(2);
             else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           }
           #if CYTHON_COMPILING_IN_CPYTHON
           if (likely(PyTuple_CheckExact(sequence))) {
@@ -14260,16 +15624,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
           __Pyx_INCREF(__pyx_t_2);
           __Pyx_INCREF(__pyx_t_7);
           #else
-          __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_2);
-          __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
           #endif
           __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
         } else
         {
           Py_ssize_t index = -1;
-          __pyx_t_1 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_1 = PyObject_GetIter(__pyx_t_9); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_1);
           __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
           __pyx_t_13 = Py_TYPE(__pyx_t_1)->tp_iternext;
@@ -14277,7 +15641,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
           __Pyx_GOTREF(__pyx_t_2);
           index = 1; __pyx_t_7 = __pyx_t_13(__pyx_t_1); if (unlikely(!__pyx_t_7)) goto __pyx_L22_unpacking_failed;
           __Pyx_GOTREF(__pyx_t_7);
-          if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_1), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          if (__Pyx_IternextUnpackEndCheck(__pyx_t_13(__pyx_t_1), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __pyx_t_13 = NULL;
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
           goto __pyx_L23_unpacking_done;
@@ -14285,7 +15649,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
           __pyx_t_13 = NULL;
           if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __pyx_L23_unpacking_done:;
         }
         __Pyx_XDECREF(__pyx_v_ref);
@@ -14295,30 +15659,30 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
         __pyx_v_length = __pyx_t_7;
         __pyx_t_7 = 0;
 
-        /* "pysam/csamtools.pyx":1311
+        /* "pysam/csamtools.pyx":1437
  *                     sq = []
  *                     for ref, length in zip( self.references, self.lengths ):
  *                         sq.append( {'LN': length, 'SN': ref } )             # <<<<<<<<<<<<<<
  *                     result["SQ"] = sq
  * 
  */
-        __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyDict_New(); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_9));
-        if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__LN), __pyx_v_length) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__SN), __pyx_v_ref) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_14 = PyList_Append(__pyx_v_sq, ((PyObject *)__pyx_t_9)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__LN), __pyx_v_length) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (PyDict_SetItem(__pyx_t_9, ((PyObject *)__pyx_n_s__SN), __pyx_v_ref) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_14 = PyList_Append(__pyx_v_sq, ((PyObject *)__pyx_t_9)); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
       }
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
-      /* "pysam/csamtools.pyx":1312
+      /* "pysam/csamtools.pyx":1438
  *                     for ref, length in zip( self.references, self.lengths ):
  *                         sq.append( {'LN': length, 'SN': ref } )
  *                     result["SQ"] = sq             # <<<<<<<<<<<<<<
  * 
  *             return result
  */
-      if (PyDict_SetItem(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_v_sq)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (PyDict_SetItem(((PyObject *)__pyx_v_result), ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_v_sq)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L19;
     }
     __pyx_L19:;
@@ -14326,7 +15690,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_6header___get__(struct __py
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":1314
+  /* "pysam/csamtools.pyx":1440
  *                     result["SQ"] = sq
  * 
  *             return result             # <<<<<<<<<<<<<<
@@ -14397,11 +15761,11 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_39_buildLine(PyObject *__py
         case  1:
         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__record)) != 0)) kw_args--;
         else {
-          __Pyx_RaiseArgtupleInvalid("_buildLine", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+          __Pyx_RaiseArgtupleInvalid("_buildLine", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_buildLine") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_buildLine") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
       goto __pyx_L5_argtuple_error;
@@ -14414,7 +15778,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_39_buildLine(PyObject *__py
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("_buildLine", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1316; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("_buildLine", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1442; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.Samfile._buildLine", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -14425,7 +15789,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_39_buildLine(PyObject *__py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1316
+/* "pysam/csamtools.pyx":1442
  *             return result
  * 
  *     def _buildLine( self, fields, record ):             # <<<<<<<<<<<<<<
@@ -14451,18 +15815,18 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_buildLine", 0);
-  __Pyx_TraceCall("_buildLine", __pyx_f[0], 1316);
+  __Pyx_TraceCall("_buildLine", __pyx_f[0], 1442);
 
-  /* "pysam/csamtools.pyx":1320
+  /* "pysam/csamtools.pyx":1446
  * 
  *         # TODO: add checking for field and sort order
  *         line = ["@%s" % record ]             # <<<<<<<<<<<<<<
  *         # comment
  *         if record == "CO":
  */
-  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_113), __pyx_v_record); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_121), __pyx_v_record); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_1));
   __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
@@ -14470,65 +15834,65 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
   __pyx_v_line = ((PyObject*)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":1322
+  /* "pysam/csamtools.pyx":1448
  *         line = ["@%s" % record ]
  *         # comment
  *         if record == "CO":             # <<<<<<<<<<<<<<
  *             line.append( fields )
  *         # user tags
  */
-  __pyx_t_2 = PyObject_RichCompare(__pyx_v_record, ((PyObject *)__pyx_n_s__CO), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1322; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_v_record, ((PyObject *)__pyx_n_s__CO), Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1448; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_3) {
 
-    /* "pysam/csamtools.pyx":1323
+    /* "pysam/csamtools.pyx":1449
  *         # comment
  *         if record == "CO":
  *             line.append( fields )             # <<<<<<<<<<<<<<
  *         # user tags
  *         elif record.islower():
  */
-    __pyx_t_4 = PyList_Append(__pyx_v_line, __pyx_v_fields); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyList_Append(__pyx_v_line, __pyx_v_fields); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
 
-  /* "pysam/csamtools.pyx":1325
+  /* "pysam/csamtools.pyx":1451
  *             line.append( fields )
  *         # user tags
  *         elif record.islower():             # <<<<<<<<<<<<<<
  *             for key in sorted(fields):
  *                 line.append( "%s:%s" % (key, str(fields[key])))
  */
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_record, __pyx_n_s__islower); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_record, __pyx_n_s__islower); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1325; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1451; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_3) {
 
-    /* "pysam/csamtools.pyx":1326
+    /* "pysam/csamtools.pyx":1452
  *         # user tags
  *         elif record.islower():
  *             for key in sorted(fields):             # <<<<<<<<<<<<<<
  *                 line.append( "%s:%s" % (key, str(fields[key])))
  *         # defined tags
  */
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_INCREF(__pyx_v_fields);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_fields);
     __Pyx_GIVEREF(__pyx_v_fields);
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
     if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
       __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
       __pyx_t_6 = NULL;
     } else {
-      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext;
     }
@@ -14537,23 +15901,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
       if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_1)) {
         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_1)) {
         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else {
         __pyx_t_2 = __pyx_t_6(__pyx_t_1);
         if (unlikely(!__pyx_t_2)) {
           if (PyErr_Occurred()) {
             if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           }
           break;
         }
@@ -14563,24 +15927,24 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
       __pyx_v_key = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "pysam/csamtools.pyx":1327
+      /* "pysam/csamtools.pyx":1453
  *         elif record.islower():
  *             for key in sorted(fields):
  *                 line.append( "%s:%s" % (key, str(fields[key])))             # <<<<<<<<<<<<<<
  *         # defined tags
  *         else:
  */
-      __pyx_t_2 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
       __Pyx_GIVEREF(__pyx_t_2);
       __pyx_t_2 = 0;
-      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_INCREF(__pyx_v_key);
       PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_key);
@@ -14588,10 +15952,10 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
       PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
       __Pyx_GIVEREF(__pyx_t_2);
       __pyx_t_2 = 0;
-      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_114), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_122), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_2));
       __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-      __pyx_t_4 = PyList_Append(__pyx_v_line, ((PyObject *)__pyx_t_2)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1327; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyList_Append(__pyx_v_line, ((PyObject *)__pyx_t_2)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1453; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
     }
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -14599,23 +15963,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1331
+    /* "pysam/csamtools.pyx":1457
  *         else:
  *             # write fields of the specification
  *             for key in VALID_HEADER_ORDER[record]:             # <<<<<<<<<<<<<<
  *                 if key in fields:
  *                     line.append( "%s:%s" % (key, str(fields[key])))
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_ORDER); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_ORDER); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     if (PyList_CheckExact(__pyx_t_2) || PyTuple_CheckExact(__pyx_t_2)) {
       __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
       __pyx_t_6 = NULL;
     } else {
-      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext;
     }
@@ -14624,23 +15988,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
       if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_1)) {
         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_1)) {
         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else {
         __pyx_t_2 = __pyx_t_6(__pyx_t_1);
         if (unlikely(!__pyx_t_2)) {
           if (PyErr_Occurred()) {
             if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1331; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           }
           break;
         }
@@ -14650,34 +16014,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
       __pyx_v_key = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "pysam/csamtools.pyx":1332
+      /* "pysam/csamtools.pyx":1458
  *             # write fields of the specification
  *             for key in VALID_HEADER_ORDER[record]:
  *                 if key in fields:             # <<<<<<<<<<<<<<
  *                     line.append( "%s:%s" % (key, str(fields[key])))
  *             # write user fields
  */
-      __pyx_t_3 = (__Pyx_PySequence_Contains(__pyx_v_key, __pyx_v_fields, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = (__Pyx_PySequence_Contains(__pyx_v_key, __pyx_v_fields, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1458; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       if (__pyx_t_3) {
 
-        /* "pysam/csamtools.pyx":1333
+        /* "pysam/csamtools.pyx":1459
  *             for key in VALID_HEADER_ORDER[record]:
  *                 if key in fields:
  *                     line.append( "%s:%s" % (key, str(fields[key])))             # <<<<<<<<<<<<<<
  *             # write user fields
  *             for key in fields:
  */
-        __pyx_t_2 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
-        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_2);
         __Pyx_GIVEREF(__pyx_t_2);
         __pyx_t_2 = 0;
-        __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
         __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-        __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_INCREF(__pyx_v_key);
         PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_key);
@@ -14685,10 +16049,10 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
         PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_2);
         __Pyx_GIVEREF(__pyx_t_2);
         __pyx_t_2 = 0;
-        __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_114), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_122), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_2));
         __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-        __pyx_t_4 = PyList_Append(__pyx_v_line, ((PyObject *)__pyx_t_2)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1333; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_4 = PyList_Append(__pyx_v_line, ((PyObject *)__pyx_t_2)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1459; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
         goto __pyx_L8;
       }
@@ -14696,7 +16060,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
     }
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":1335
+    /* "pysam/csamtools.pyx":1461
  *                     line.append( "%s:%s" % (key, str(fields[key])))
  *             # write user fields
  *             for key in fields:             # <<<<<<<<<<<<<<
@@ -14707,7 +16071,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
       __pyx_t_1 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_1); __pyx_t_5 = 0;
       __pyx_t_6 = NULL;
     } else {
-      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __pyx_t_6 = Py_TYPE(__pyx_t_1)->tp_iternext;
     }
@@ -14715,23 +16079,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
       if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_1)) {
         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_1)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_1)) {
         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else {
         __pyx_t_2 = __pyx_t_6(__pyx_t_1);
         if (unlikely(!__pyx_t_2)) {
           if (PyErr_Occurred()) {
             if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           }
           break;
         }
@@ -14741,41 +16105,41 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
       __pyx_v_key = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "pysam/csamtools.pyx":1336
+      /* "pysam/csamtools.pyx":1462
  *             # write user fields
  *             for key in fields:
  *                 if not key.isupper():             # <<<<<<<<<<<<<<
  *                     line.append( "%s:%s" % (key, str(fields[key])))
  * 
  */
-      __pyx_t_2 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__isupper); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_GetAttr(__pyx_v_key, __pyx_n_s__isupper); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
-      __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __pyx_t_8 = (!__pyx_t_3);
       if (__pyx_t_8) {
 
-        /* "pysam/csamtools.pyx":1337
+        /* "pysam/csamtools.pyx":1463
  *             for key in fields:
  *                 if not key.isupper():
  *                     line.append( "%s:%s" % (key, str(fields[key])))             # <<<<<<<<<<<<<<
  * 
  *         return "\t".join( line )
  */
-        __pyx_t_7 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_GetItem(__pyx_v_fields, __pyx_v_key); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
         PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7);
         __Pyx_GIVEREF(__pyx_t_7);
         __pyx_t_7 = 0;
-        __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
         __Pyx_INCREF(__pyx_v_key);
         PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_key);
@@ -14783,10 +16147,10 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
         PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_7);
         __Pyx_GIVEREF(__pyx_t_7);
         __pyx_t_7 = 0;
-        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_114), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_122), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
         __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-        __pyx_t_4 = PyList_Append(__pyx_v_line, ((PyObject *)__pyx_t_7)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_4 = PyList_Append(__pyx_v_line, ((PyObject *)__pyx_t_7)); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
         goto __pyx_L11;
       }
@@ -14796,7 +16160,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1339
+  /* "pysam/csamtools.pyx":1465
  *                     line.append( "%s:%s" % (key, str(fields[key])))
  * 
  *         return "\t".join( line )             # <<<<<<<<<<<<<<
@@ -14804,14 +16168,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
  *     cdef bam_header_t * _buildHeader( self, new_header ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
   __Pyx_INCREF(((PyObject *)__pyx_v_line));
   PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_line));
   __Pyx_GIVEREF(((PyObject *)__pyx_v_line));
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
@@ -14836,7 +16200,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_38_buildLine(CYTHON_UNUSED
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1341
+/* "pysam/csamtools.pyx":1467
  *         return "\t".join( line )
  * 
  *     cdef bam_header_t * _buildHeader( self, new_header ):             # <<<<<<<<<<<<<<
@@ -14885,21 +16249,21 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_buildHeader", 0);
-  __Pyx_TraceCall("_buildHeader", __pyx_f[0], 1341);
+  __Pyx_TraceCall("_buildHeader", __pyx_f[0], 1467);
 
-  /* "pysam/csamtools.pyx":1347
+  /* "pysam/csamtools.pyx":1473
  *         '''
  * 
  *         lines = []             # <<<<<<<<<<<<<<
  * 
  *         # check if hash exists
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1473; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_v_lines = ((PyObject*)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":1354
+  /* "pysam/csamtools.pyx":1480
  *         cdef bam_header_t * dest
  * 
  *         dest = bam_header_init()             # <<<<<<<<<<<<<<
@@ -14908,20 +16272,20 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
  */
   __pyx_v_dest = bam_header_init();
 
-  /* "pysam/csamtools.pyx":1357
+  /* "pysam/csamtools.pyx":1483
  * 
  *         # first: defined tags
  *         for record in VALID_HEADERS:             # <<<<<<<<<<<<<<
  *             if record in new_header:
  *                 ttype = VALID_HEADER_TYPES[record]
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADERS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADERS); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
     __pyx_t_2 = __pyx_t_1; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
     __pyx_t_4 = NULL;
   } else {
-    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
   }
@@ -14930,23 +16294,23 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
     if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
       if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
       if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_1); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else {
       __pyx_t_1 = __pyx_t_4(__pyx_t_2);
       if (unlikely(!__pyx_t_1)) {
         if (PyErr_Occurred()) {
           if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1483; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         break;
       }
@@ -14956,70 +16320,70 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
     __pyx_v_record = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":1358
+    /* "pysam/csamtools.pyx":1484
  *         # first: defined tags
  *         for record in VALID_HEADERS:
  *             if record in new_header:             # <<<<<<<<<<<<<<
  *                 ttype = VALID_HEADER_TYPES[record]
  *                 data = new_header[record]
  */
-    __pyx_t_5 = (__Pyx_PySequence_Contains(__pyx_v_record, __pyx_v_new_header, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = (__Pyx_PySequence_Contains(__pyx_v_record, __pyx_v_new_header, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (__pyx_t_5) {
 
-      /* "pysam/csamtools.pyx":1359
+      /* "pysam/csamtools.pyx":1485
  *         for record in VALID_HEADERS:
  *             if record in new_header:
  *                 ttype = VALID_HEADER_TYPES[record]             # <<<<<<<<<<<<<<
  *                 data = new_header[record]
  *                 if type( data ) != type( ttype() ):
  */
-      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetItem(__pyx_t_1, __pyx_v_record); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __Pyx_XDECREF(__pyx_v_ttype);
       __pyx_v_ttype = __pyx_t_6;
       __pyx_t_6 = 0;
 
-      /* "pysam/csamtools.pyx":1360
+      /* "pysam/csamtools.pyx":1486
  *             if record in new_header:
  *                 ttype = VALID_HEADER_TYPES[record]
  *                 data = new_header[record]             # <<<<<<<<<<<<<<
  *                 if type( data ) != type( ttype() ):
  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
  */
-      __pyx_t_6 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_6) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_XDECREF(__pyx_v_data);
       __pyx_v_data = __pyx_t_6;
       __pyx_t_6 = 0;
 
-      /* "pysam/csamtools.pyx":1361
+      /* "pysam/csamtools.pyx":1487
  *                 ttype = VALID_HEADER_TYPES[record]
  *                 data = new_header[record]
  *                 if type( data ) != type( ttype() ):             # <<<<<<<<<<<<<<
  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
  *                 if type( data ) is dict:
  */
-      __pyx_t_6 = PyObject_Call(__pyx_v_ttype, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_Call(__pyx_v_ttype, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_data)), ((PyObject *)Py_TYPE(__pyx_t_6)), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_RichCompare(((PyObject *)Py_TYPE(__pyx_v_data)), ((PyObject *)Py_TYPE(__pyx_t_6)), Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1487; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       if (__pyx_t_5) {
 
-        /* "pysam/csamtools.pyx":1362
+        /* "pysam/csamtools.pyx":1488
  *                 data = new_header[record]
  *                 if type( data ) != type( ttype() ):
  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )             # <<<<<<<<<<<<<<
  *                 if type( data ) is dict:
  *                     lines.append( self._buildLine( data, record ) )
  */
-        __pyx_t_1 = PyObject_Call(__pyx_v_ttype, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_Call(__pyx_v_ttype, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_INCREF(__pyx_v_record);
         PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_record);
@@ -15031,25 +16395,25 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
         PyTuple_SET_ITEM(__pyx_t_6, 2, ((PyObject *)Py_TYPE(__pyx_t_1)));
         __Pyx_GIVEREF(((PyObject *)Py_TYPE(__pyx_t_1)));
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_115), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_123), ((PyObject *)__pyx_t_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_1));
         __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         PyTuple_SET_ITEM(__pyx_t_6, 0, ((PyObject *)__pyx_t_1));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
         __pyx_t_1 = 0;
-        __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
         __Pyx_Raise(__pyx_t_1, 0, 0, 0);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1362; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L6;
       }
       __pyx_L6:;
 
-      /* "pysam/csamtools.pyx":1363
+      /* "pysam/csamtools.pyx":1489
  *                 if type( data ) != type( ttype() ):
  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
  *                 if type( data ) is dict:             # <<<<<<<<<<<<<<
@@ -15059,16 +16423,16 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
       __pyx_t_5 = (((PyObject *)Py_TYPE(__pyx_v_data)) == ((PyObject *)((PyObject*)(&PyDict_Type))));
       if (__pyx_t_5) {
 
-        /* "pysam/csamtools.pyx":1364
+        /* "pysam/csamtools.pyx":1490
  *                     raise ValueError( "invalid type for record %s: %s, expected %s" % (record, type(data), type(ttype()) ) )
  *                 if type( data ) is dict:
  *                     lines.append( self._buildLine( data, record ) )             # <<<<<<<<<<<<<<
  *                 else:
  *                     for fields in new_header[record]:
  */
-        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLine); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_INCREF(__pyx_v_data);
         PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_data);
@@ -15076,30 +16440,30 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
         __Pyx_INCREF(__pyx_v_record);
         PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_record);
         __Pyx_GIVEREF(__pyx_v_record);
-        __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-        __pyx_t_8 = PyList_Append(__pyx_v_lines, __pyx_t_7); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyList_Append(__pyx_v_lines, __pyx_t_7); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
         goto __pyx_L7;
       }
       /*else*/ {
 
-        /* "pysam/csamtools.pyx":1366
+        /* "pysam/csamtools.pyx":1492
  *                     lines.append( self._buildLine( data, record ) )
  *                 else:
  *                     for fields in new_header[record]:             # <<<<<<<<<<<<<<
  *                         lines.append( self._buildLine( fields, record ) )
  * 
  */
-        __pyx_t_7 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         if (PyList_CheckExact(__pyx_t_7) || PyTuple_CheckExact(__pyx_t_7)) {
           __pyx_t_6 = __pyx_t_7; __Pyx_INCREF(__pyx_t_6); __pyx_t_9 = 0;
           __pyx_t_10 = NULL;
         } else {
-          __pyx_t_9 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = -1; __pyx_t_6 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_6);
           __pyx_t_10 = Py_TYPE(__pyx_t_6)->tp_iternext;
         }
@@ -15108,23 +16472,23 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
           if (!__pyx_t_10 && PyList_CheckExact(__pyx_t_6)) {
             if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_6)) break;
             #if CYTHON_COMPILING_IN_CPYTHON
-            __pyx_t_7 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_7); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_7 = PyList_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_7); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             #else
-            __pyx_t_7 = PySequence_ITEM(__pyx_t_6, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_7 = PySequence_ITEM(__pyx_t_6, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             #endif
           } else if (!__pyx_t_10 && PyTuple_CheckExact(__pyx_t_6)) {
             if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_6)) break;
             #if CYTHON_COMPILING_IN_CPYTHON
-            __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_7); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_6, __pyx_t_9); __Pyx_INCREF(__pyx_t_7); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             #else
-            __pyx_t_7 = PySequence_ITEM(__pyx_t_6, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_7 = PySequence_ITEM(__pyx_t_6, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             #endif
           } else {
             __pyx_t_7 = __pyx_t_10(__pyx_t_6);
             if (unlikely(!__pyx_t_7)) {
               if (PyErr_Occurred()) {
                 if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-                else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+                else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
               }
               break;
             }
@@ -15134,16 +16498,16 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
           __pyx_v_fields = __pyx_t_7;
           __pyx_t_7 = 0;
 
-          /* "pysam/csamtools.pyx":1367
+          /* "pysam/csamtools.pyx":1493
  *                 else:
  *                     for fields in new_header[record]:
  *                         lines.append( self._buildLine( fields, record ) )             # <<<<<<<<<<<<<<
  * 
  *         # then: user tags (lower case), sorted alphabetically
  */
-          __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLine); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLine); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
-          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_1);
           __Pyx_INCREF(__pyx_v_fields);
           PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_fields);
@@ -15151,11 +16515,11 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
           __Pyx_INCREF(__pyx_v_record);
           PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_record);
           __Pyx_GIVEREF(__pyx_v_record);
-          __pyx_t_11 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_11 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_11);
           __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
           __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-          __pyx_t_8 = PyList_Append(__pyx_v_lines, __pyx_t_11); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyList_Append(__pyx_v_lines, __pyx_t_11); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
         }
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
@@ -15167,31 +16531,31 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
   }
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":1370
+  /* "pysam/csamtools.pyx":1496
  * 
  *         # then: user tags (lower case), sorted alphabetically
  *         for record, data in sorted(new_header.items()):             # <<<<<<<<<<<<<<
  *             if record in VALID_HEADERS: continue
  *             if type( data ) is dict:
  */
-  __pyx_t_2 = PyObject_GetAttr(__pyx_v_new_header, __pyx_n_s__items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_v_new_header, __pyx_n_s__items); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
   __Pyx_GIVEREF(__pyx_t_6);
   __pyx_t_6 = 0;
-  __pyx_t_6 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_Call(__pyx_builtin_sorted, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
   if (PyList_CheckExact(__pyx_t_6) || PyTuple_CheckExact(__pyx_t_6)) {
     __pyx_t_2 = __pyx_t_6; __Pyx_INCREF(__pyx_t_2); __pyx_t_3 = 0;
     __pyx_t_4 = NULL;
   } else {
-    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_t_4 = Py_TYPE(__pyx_t_2)->tp_iternext;
   }
@@ -15200,23 +16564,23 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
     if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_2)) {
       if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_2)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_2)) {
       if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PySequence_ITEM(__pyx_t_2, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else {
       __pyx_t_6 = __pyx_t_4(__pyx_t_2);
       if (unlikely(!__pyx_t_6)) {
         if (PyErr_Occurred()) {
           if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         break;
       }
@@ -15232,7 +16596,7 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
       if (unlikely(size != 2)) {
         if (size > 2) __Pyx_RaiseTooManyValuesError(2);
         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #if CYTHON_COMPILING_IN_CPYTHON
       if (likely(PyTuple_CheckExact(sequence))) {
@@ -15245,16 +16609,16 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
       __Pyx_INCREF(__pyx_t_11);
       __Pyx_INCREF(__pyx_t_1);
       #else
-      __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_11);
-      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       #endif
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     } else
     {
       Py_ssize_t index = -1;
-      __pyx_t_7 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __pyx_t_12 = Py_TYPE(__pyx_t_7)->tp_iternext;
@@ -15262,7 +16626,7 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
       __Pyx_GOTREF(__pyx_t_11);
       index = 1; __pyx_t_1 = __pyx_t_12(__pyx_t_7); if (unlikely(!__pyx_t_1)) goto __pyx_L12_unpacking_failed;
       __Pyx_GOTREF(__pyx_t_1);
-      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_t_12 = NULL;
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       goto __pyx_L13_unpacking_done;
@@ -15270,7 +16634,7 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __pyx_t_12 = NULL;
       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1370; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_L13_unpacking_done:;
     }
     __Pyx_XDECREF(__pyx_v_record);
@@ -15280,16 +16644,16 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
     __pyx_v_data = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":1371
+    /* "pysam/csamtools.pyx":1497
  *         # then: user tags (lower case), sorted alphabetically
  *         for record, data in sorted(new_header.items()):
  *             if record in VALID_HEADERS: continue             # <<<<<<<<<<<<<<
  *             if type( data ) is dict:
  *                 lines.append( self._buildLine( data, record ) )
  */
-    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADERS); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__VALID_HEADERS); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_5 = (__Pyx_PySequence_Contains(__pyx_v_record, __pyx_t_6, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = (__Pyx_PySequence_Contains(__pyx_v_record, __pyx_t_6, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     if (__pyx_t_5) {
       goto __pyx_L10_continue;
@@ -15297,7 +16661,7 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
     }
     __pyx_L14:;
 
-    /* "pysam/csamtools.pyx":1372
+    /* "pysam/csamtools.pyx":1498
  *         for record, data in sorted(new_header.items()):
  *             if record in VALID_HEADERS: continue
  *             if type( data ) is dict:             # <<<<<<<<<<<<<<
@@ -15307,16 +16671,16 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
     __pyx_t_5 = (((PyObject *)Py_TYPE(__pyx_v_data)) == ((PyObject *)((PyObject*)(&PyDict_Type))));
     if (__pyx_t_5) {
 
-      /* "pysam/csamtools.pyx":1373
+      /* "pysam/csamtools.pyx":1499
  *             if record in VALID_HEADERS: continue
  *             if type( data ) is dict:
  *                 lines.append( self._buildLine( data, record ) )             # <<<<<<<<<<<<<<
  *             else:
  *                 for fields in new_header[record]:
  */
-      __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLine); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __Pyx_INCREF(__pyx_v_data);
       PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_data);
@@ -15324,30 +16688,30 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
       __Pyx_INCREF(__pyx_v_record);
       PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_record);
       __Pyx_GIVEREF(__pyx_v_record);
-      __pyx_t_11 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_11);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-      __pyx_t_8 = PyList_Append(__pyx_v_lines, __pyx_t_11); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1373; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyList_Append(__pyx_v_lines, __pyx_t_11); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
       goto __pyx_L15;
     }
     /*else*/ {
 
-      /* "pysam/csamtools.pyx":1375
+      /* "pysam/csamtools.pyx":1501
  *                 lines.append( self._buildLine( data, record ) )
  *             else:
  *                 for fields in new_header[record]:             # <<<<<<<<<<<<<<
  *                     lines.append( self._buildLine( fields, record ) )
  * 
  */
-      __pyx_t_11 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = PyObject_GetItem(__pyx_v_new_header, __pyx_v_record); if (!__pyx_t_11) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_11);
       if (PyList_CheckExact(__pyx_t_11) || PyTuple_CheckExact(__pyx_t_11)) {
         __pyx_t_1 = __pyx_t_11; __Pyx_INCREF(__pyx_t_1); __pyx_t_9 = 0;
         __pyx_t_10 = NULL;
       } else {
-        __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_11); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __pyx_t_10 = Py_TYPE(__pyx_t_1)->tp_iternext;
       }
@@ -15356,23 +16720,23 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
         if (!__pyx_t_10 && PyList_CheckExact(__pyx_t_1)) {
           if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_1)) break;
           #if CYTHON_COMPILING_IN_CPYTHON
-          __pyx_t_11 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_11 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #else
-          __pyx_t_11 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_11 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #endif
         } else if (!__pyx_t_10 && PyTuple_CheckExact(__pyx_t_1)) {
           if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
           #if CYTHON_COMPILING_IN_CPYTHON
-          __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_11 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_11); __pyx_t_9++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #else
-          __pyx_t_11 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_11 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           #endif
         } else {
           __pyx_t_11 = __pyx_t_10(__pyx_t_1);
           if (unlikely(!__pyx_t_11)) {
             if (PyErr_Occurred()) {
               if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             }
             break;
           }
@@ -15382,16 +16746,16 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
         __pyx_v_fields = __pyx_t_11;
         __pyx_t_11 = 0;
 
-        /* "pysam/csamtools.pyx":1376
+        /* "pysam/csamtools.pyx":1502
  *             else:
  *                 for fields in new_header[record]:
  *                     lines.append( self._buildLine( fields, record ) )             # <<<<<<<<<<<<<<
  * 
  *         text = "\n".join(lines) + "\n"
  */
-        __pyx_t_11 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLine); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_11 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___buildLine); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_11);
-        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_INCREF(__pyx_v_fields);
         PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_fields);
@@ -15399,11 +16763,11 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
         __Pyx_INCREF(__pyx_v_record);
         PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_record);
         __Pyx_GIVEREF(__pyx_v_record);
-        __pyx_t_7 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_Call(__pyx_t_11, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-        __pyx_t_8 = PyList_Append(__pyx_v_lines, __pyx_t_7); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyList_Append(__pyx_v_lines, __pyx_t_7); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1502; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       }
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -15413,31 +16777,31 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
   }
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":1378
+  /* "pysam/csamtools.pyx":1504
  *                     lines.append( self._buildLine( fields, record ) )
  * 
  *         text = "\n".join(lines) + "\n"             # <<<<<<<<<<<<<<
  *         if dest.text != NULL: free( dest.text )
  *         dest.text = <char*>calloc( len(text), sizeof(char))
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_6), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_6), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(((PyObject *)__pyx_v_lines));
   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_lines));
   __Pyx_GIVEREF(((PyObject *)__pyx_v_lines));
-  __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-  __pyx_t_1 = PyNumber_Add(__pyx_t_7, ((PyObject *)__pyx_kp_s_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyNumber_Add(__pyx_t_7, ((PyObject *)__pyx_kp_s_6)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
   __pyx_v_text = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":1379
+  /* "pysam/csamtools.pyx":1505
  * 
  *         text = "\n".join(lines) + "\n"
  *         if dest.text != NULL: free( dest.text )             # <<<<<<<<<<<<<<
@@ -15451,88 +16815,88 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
   }
   __pyx_L18:;
 
-  /* "pysam/csamtools.pyx":1380
+  /* "pysam/csamtools.pyx":1506
  *         text = "\n".join(lines) + "\n"
  *         if dest.text != NULL: free( dest.text )
  *         dest.text = <char*>calloc( len(text), sizeof(char))             # <<<<<<<<<<<<<<
  *         dest.l_text = len(text)
  *         cdef bytes btext = text.encode('ascii')
  */
-  __pyx_t_3 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1380; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_dest->text = ((char *)calloc(__pyx_t_3, (sizeof(char))));
 
-  /* "pysam/csamtools.pyx":1381
+  /* "pysam/csamtools.pyx":1507
  *         if dest.text != NULL: free( dest.text )
  *         dest.text = <char*>calloc( len(text), sizeof(char))
  *         dest.l_text = len(text)             # <<<<<<<<<<<<<<
  *         cdef bytes btext = text.encode('ascii')
  *         strncpy( dest.text, btext, dest.l_text )
  */
-  __pyx_t_3 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1381; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Length(__pyx_v_text); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_dest->l_text = __pyx_t_3;
 
-  /* "pysam/csamtools.pyx":1382
+  /* "pysam/csamtools.pyx":1508
  *         dest.text = <char*>calloc( len(text), sizeof(char))
  *         dest.l_text = len(text)
  *         cdef bytes btext = text.encode('ascii')             # <<<<<<<<<<<<<<
  *         strncpy( dest.text, btext, dest.l_text )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_text, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_text, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_116), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_124), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (!(likely(PyBytes_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_7)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(PyBytes_CheckExact(__pyx_t_7))||((__pyx_t_7) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_7)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_btext = ((PyObject*)__pyx_t_7);
   __pyx_t_7 = 0;
 
-  /* "pysam/csamtools.pyx":1383
+  /* "pysam/csamtools.pyx":1509
  *         dest.l_text = len(text)
  *         cdef bytes btext = text.encode('ascii')
  *         strncpy( dest.text, btext, dest.l_text )             # <<<<<<<<<<<<<<
  * 
  *         cdef bytes bseqname
  */
-  __pyx_t_13 = PyBytes_AsString(((PyObject *)__pyx_v_btext)); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1383; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_13 = PyBytes_AsString(((PyObject *)__pyx_v_btext)); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   strncpy(__pyx_v_dest->text, __pyx_t_13, __pyx_v_dest->l_text);
 
-  /* "pysam/csamtools.pyx":1387
+  /* "pysam/csamtools.pyx":1513
  *         cdef bytes bseqname
  *         # collect targets
  *         if "SQ" in new_header:             # <<<<<<<<<<<<<<
  *             seqs = []
  *             for fields in new_header["SQ"]:
  */
-  __pyx_t_5 = (__Pyx_PySequence_Contains(((PyObject *)__pyx_n_s__SQ), __pyx_v_new_header, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1387; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = (__Pyx_PySequence_Contains(((PyObject *)__pyx_n_s__SQ), __pyx_v_new_header, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_5) {
 
-    /* "pysam/csamtools.pyx":1388
+    /* "pysam/csamtools.pyx":1514
  *         # collect targets
  *         if "SQ" in new_header:
  *             seqs = []             # <<<<<<<<<<<<<<
  *             for fields in new_header["SQ"]:
  *                 try:
  */
-    __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __pyx_v_seqs = ((PyObject*)__pyx_t_7);
     __pyx_t_7 = 0;
 
-    /* "pysam/csamtools.pyx":1389
+    /* "pysam/csamtools.pyx":1515
  *         if "SQ" in new_header:
  *             seqs = []
  *             for fields in new_header["SQ"]:             # <<<<<<<<<<<<<<
  *                 try:
  *                     seqs.append( (fields["SN"], fields["LN"] ) )
  */
-    __pyx_t_7 = PyObject_GetItem(__pyx_v_new_header, ((PyObject *)__pyx_n_s__SQ)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_GetItem(__pyx_v_new_header, ((PyObject *)__pyx_n_s__SQ)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     if (PyList_CheckExact(__pyx_t_7) || PyTuple_CheckExact(__pyx_t_7)) {
       __pyx_t_1 = __pyx_t_7; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
       __pyx_t_4 = NULL;
     } else {
-      __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext;
     }
@@ -15541,23 +16905,23 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
       if (!__pyx_t_4 && PyList_CheckExact(__pyx_t_1)) {
         if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_7); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_7); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else if (!__pyx_t_4 && PyTuple_CheckExact(__pyx_t_1)) {
         if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_7); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_7); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else {
         __pyx_t_7 = __pyx_t_4(__pyx_t_1);
         if (unlikely(!__pyx_t_7)) {
           if (PyErr_Occurred()) {
             if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1389; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           }
           break;
         }
@@ -15567,7 +16931,7 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
       __pyx_v_fields = __pyx_t_7;
       __pyx_t_7 = 0;
 
-      /* "pysam/csamtools.pyx":1390
+      /* "pysam/csamtools.pyx":1516
  *             seqs = []
  *             for fields in new_header["SQ"]:
  *                 try:             # <<<<<<<<<<<<<<
@@ -15581,18 +16945,18 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
         __Pyx_XGOTREF(__pyx_t_16);
         /*try:*/ {
 
-          /* "pysam/csamtools.pyx":1391
+          /* "pysam/csamtools.pyx":1517
  *             for fields in new_header["SQ"]:
  *                 try:
  *                     seqs.append( (fields["SN"], fields["LN"] ) )             # <<<<<<<<<<<<<<
  *                 except KeyError:
  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))
  */
-          __pyx_t_7 = PyObject_GetItem(__pyx_v_fields, ((PyObject *)__pyx_n_s__SN)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
+          __pyx_t_7 = PyObject_GetItem(__pyx_v_fields, ((PyObject *)__pyx_n_s__SN)); if (!__pyx_t_7) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
           __Pyx_GOTREF(__pyx_t_7);
-          __pyx_t_2 = PyObject_GetItem(__pyx_v_fields, ((PyObject *)__pyx_n_s__LN)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
+          __pyx_t_2 = PyObject_GetItem(__pyx_v_fields, ((PyObject *)__pyx_n_s__LN)); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
           __Pyx_GOTREF(__pyx_t_2);
-          __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
+          __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
           __Pyx_GOTREF(__pyx_t_6);
           PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_7);
           __Pyx_GIVEREF(__pyx_t_7);
@@ -15600,7 +16964,7 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
           __Pyx_GIVEREF(__pyx_t_2);
           __pyx_t_7 = 0;
           __pyx_t_2 = 0;
-          __pyx_t_8 = PyList_Append(__pyx_v_seqs, ((PyObject *)__pyx_t_6)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1391; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
+          __pyx_t_8 = PyList_Append(__pyx_v_seqs, ((PyObject *)__pyx_t_6)); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1517; __pyx_clineno = __LINE__; goto __pyx_L22_error;}
           __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
         }
         __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
@@ -15613,7 +16977,7 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
         __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
         __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
 
-        /* "pysam/csamtools.pyx":1392
+        /* "pysam/csamtools.pyx":1518
  *                 try:
  *                     seqs.append( (fields["SN"], fields["LN"] ) )
  *                 except KeyError:             # <<<<<<<<<<<<<<
@@ -15623,40 +16987,40 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
         __pyx_t_17 = PyErr_ExceptionMatches(__pyx_builtin_KeyError);
         if (__pyx_t_17) {
           __Pyx_AddTraceback("pysam.csamtools.Samfile._buildHeader", __pyx_clineno, __pyx_lineno, __pyx_filename);
-          if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_2, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1392; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
+          if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_2, &__pyx_t_7) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
           __Pyx_GOTREF(__pyx_t_6);
           __Pyx_GOTREF(__pyx_t_2);
           __Pyx_GOTREF(__pyx_t_7);
 
-          /* "pysam/csamtools.pyx":1393
+          /* "pysam/csamtools.pyx":1519
  *                     seqs.append( (fields["SN"], fields["LN"] ) )
  *                 except KeyError:
  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))             # <<<<<<<<<<<<<<
  * 
  *             dest.n_targets = len(seqs)
  */
-          __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
+          __pyx_t_11 = PyTuple_New(1); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
           __Pyx_GOTREF(__pyx_t_11);
           __Pyx_INCREF(__pyx_v_fields);
           PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_v_fields);
           __Pyx_GIVEREF(__pyx_v_fields);
-          __pyx_t_18 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
+          __pyx_t_18 = PyObject_Call(((PyObject *)((PyObject*)(&PyString_Type))), ((PyObject *)__pyx_t_11), NULL); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
           __Pyx_GOTREF(__pyx_t_18);
           __Pyx_DECREF(((PyObject *)__pyx_t_11)); __pyx_t_11 = 0;
-          __pyx_t_11 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_117), __pyx_t_18); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
+          __pyx_t_11 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_125), __pyx_t_18); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_11));
           __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
-          __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
+          __pyx_t_18 = PyTuple_New(1); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
           __Pyx_GOTREF(__pyx_t_18);
           PyTuple_SET_ITEM(__pyx_t_18, 0, ((PyObject *)__pyx_t_11));
           __Pyx_GIVEREF(((PyObject *)__pyx_t_11));
           __pyx_t_11 = 0;
-          __pyx_t_11 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_18), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
+          __pyx_t_11 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_18), NULL); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
           __Pyx_GOTREF(__pyx_t_11);
           __Pyx_DECREF(((PyObject *)__pyx_t_18)); __pyx_t_18 = 0;
           __Pyx_Raise(__pyx_t_11, 0, 0, 0);
           __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1519; __pyx_clineno = __LINE__; goto __pyx_L24_except_error;}
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
           __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
@@ -15678,17 +17042,17 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
     }
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":1395
+    /* "pysam/csamtools.pyx":1521
  *                     raise KeyError( "incomplete sequence information in '%s'" % str(fields))
  * 
  *             dest.n_targets = len(seqs)             # <<<<<<<<<<<<<<
  *             dest.target_name = <char**>calloc( dest.n_targets, sizeof(char*) )
  *             dest.target_len = <uint32_t*>calloc( dest.n_targets, sizeof(uint32_t) )
  */
-    __pyx_t_3 = PyList_GET_SIZE(((PyObject *)__pyx_v_seqs)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyList_GET_SIZE(((PyObject *)__pyx_v_seqs)); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_v_dest->n_targets = __pyx_t_3;
 
-    /* "pysam/csamtools.pyx":1396
+    /* "pysam/csamtools.pyx":1522
  * 
  *             dest.n_targets = len(seqs)
  *             dest.target_name = <char**>calloc( dest.n_targets, sizeof(char*) )             # <<<<<<<<<<<<<<
@@ -15697,7 +17061,7 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
  */
     __pyx_v_dest->target_name = ((char **)calloc(__pyx_v_dest->n_targets, (sizeof(char *))));
 
-    /* "pysam/csamtools.pyx":1397
+    /* "pysam/csamtools.pyx":1523
  *             dest.n_targets = len(seqs)
  *             dest.target_name = <char**>calloc( dest.n_targets, sizeof(char*) )
  *             dest.target_len = <uint32_t*>calloc( dest.n_targets, sizeof(uint32_t) )             # <<<<<<<<<<<<<<
@@ -15706,7 +17070,7 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
  */
     __pyx_v_dest->target_len = ((uint32_t *)calloc(__pyx_v_dest->n_targets, (sizeof(uint32_t))));
 
-    /* "pysam/csamtools.pyx":1399
+    /* "pysam/csamtools.pyx":1525
  *             dest.target_len = <uint32_t*>calloc( dest.n_targets, sizeof(uint32_t) )
  * 
  *             for x from 0 <= x < dest.n_targets:             # <<<<<<<<<<<<<<
@@ -15716,14 +17080,14 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
     __pyx_t_19 = __pyx_v_dest->n_targets;
     for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_19; __pyx_v_x++) {
 
-      /* "pysam/csamtools.pyx":1400
+      /* "pysam/csamtools.pyx":1526
  * 
  *             for x from 0 <= x < dest.n_targets:
  *                 seqname, seqlen = seqs[x]             # <<<<<<<<<<<<<<
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
  *                 bseqname = seqname.encode('ascii')
  */
-      __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_seqs), __pyx_v_x, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_GetItemInt_List(((PyObject *)__pyx_v_seqs), __pyx_v_x, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
       if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
         PyObject* sequence = __pyx_t_1;
@@ -15735,7 +17099,7 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
         if (unlikely(size != 2)) {
           if (size > 2) __Pyx_RaiseTooManyValuesError(2);
           else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         #if CYTHON_COMPILING_IN_CPYTHON
         if (likely(PyTuple_CheckExact(sequence))) {
@@ -15748,16 +17112,16 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
         __Pyx_INCREF(__pyx_t_7);
         __Pyx_INCREF(__pyx_t_2);
         #else
-        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
         #endif
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       } else
       {
         Py_ssize_t index = -1;
-        __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __pyx_t_12 = Py_TYPE(__pyx_t_6)->tp_iternext;
@@ -15765,7 +17129,7 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
         __Pyx_GOTREF(__pyx_t_7);
         index = 1; __pyx_t_2 = __pyx_t_12(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L34_unpacking_failed;
         __Pyx_GOTREF(__pyx_t_2);
-        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_t_12 = NULL;
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         goto __pyx_L35_unpacking_done;
@@ -15773,7 +17137,7 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
         __pyx_t_12 = NULL;
         if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1526; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_L35_unpacking_done:;
       }
       __Pyx_XDECREF(__pyx_v_seqname);
@@ -15783,59 +17147,59 @@ static bam_header_t *__pyx_f_5pysam_9csamtools_7Samfile__buildHeader(struct __py
       __pyx_v_seqlen = __pyx_t_2;
       __pyx_t_2 = 0;
 
-      /* "pysam/csamtools.pyx":1401
+      /* "pysam/csamtools.pyx":1527
  *             for x from 0 <= x < dest.n_targets:
  *                 seqname, seqlen = seqs[x]
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )             # <<<<<<<<<<<<<<
  *                 bseqname = seqname.encode('ascii')
  *                 strncpy( dest.target_name[x], bseqname, len(seqname) + 1 )
  */
-      __pyx_t_3 = PyObject_Length(__pyx_v_seqname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_Length(__pyx_v_seqname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1527; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       (__pyx_v_dest->target_name[__pyx_v_x]) = ((char *)calloc((__pyx_t_3 + 1), (sizeof(char))));
 
-      /* "pysam/csamtools.pyx":1402
+      /* "pysam/csamtools.pyx":1528
  *                 seqname, seqlen = seqs[x]
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
  *                 bseqname = seqname.encode('ascii')             # <<<<<<<<<<<<<<
  *                 strncpy( dest.target_name[x], bseqname, len(seqname) + 1 )
  *                 dest.target_len[x] = seqlen
  */
-      __pyx_t_1 = PyObject_GetAttr(__pyx_v_seqname, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_GetAttr(__pyx_v_seqname, __pyx_n_s__encode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_118), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_126), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-      if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected bytes, got %.200s", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_XDECREF(((PyObject *)__pyx_v_bseqname));
       __pyx_v_bseqname = ((PyObject*)__pyx_t_2);
       __pyx_t_2 = 0;
 
-      /* "pysam/csamtools.pyx":1403
+      /* "pysam/csamtools.pyx":1529
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
  *                 bseqname = seqname.encode('ascii')
  *                 strncpy( dest.target_name[x], bseqname, len(seqname) + 1 )             # <<<<<<<<<<<<<<
  *                 dest.target_len[x] = seqlen
  * 
  */
-      __pyx_t_13 = PyBytes_AsString(((PyObject *)__pyx_v_bseqname)); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_t_3 = PyObject_Length(__pyx_v_seqname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_13 = PyBytes_AsString(((PyObject *)__pyx_v_bseqname)); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_Length(__pyx_v_seqname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1529; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       strncpy((__pyx_v_dest->target_name[__pyx_v_x]), __pyx_t_13, (__pyx_t_3 + 1));
 
-      /* "pysam/csamtools.pyx":1404
+      /* "pysam/csamtools.pyx":1530
  *                 bseqname = seqname.encode('ascii')
  *                 strncpy( dest.target_name[x], bseqname, len(seqname) + 1 )
  *                 dest.target_len[x] = seqlen             # <<<<<<<<<<<<<<
  * 
  *         return dest
  */
-      __pyx_t_20 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_seqlen); if (unlikely((__pyx_t_20 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_20 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_seqlen); if (unlikely((__pyx_t_20 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       (__pyx_v_dest->target_len[__pyx_v_x]) = __pyx_t_20;
     }
     goto __pyx_L19;
   }
   __pyx_L19:;
 
-  /* "pysam/csamtools.pyx":1406
+  /* "pysam/csamtools.pyx":1532
  *                 dest.target_len[x] = seqlen
  * 
  *         return dest             # <<<<<<<<<<<<<<
@@ -15884,7 +17248,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_41__iter__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1416
+/* "pysam/csamtools.pyx":1542
  *     ## Possible solutions: deprecate or open new file handle
  *     ###############################################################
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -15905,34 +17269,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_40__iter__(struct __pyx_obj
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__", 0);
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1416);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1542);
 
-  /* "pysam/csamtools.pyx":1417
+  /* "pysam/csamtools.pyx":1543
  *     ###############################################################
  *     def __iter__(self):
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not self.isbam and self.samfile.header.n_targets == 0:
  *                 raise NotImplementedError( "can not iterate over samfile without header")
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_119), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_127), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1418
+  /* "pysam/csamtools.pyx":1544
  *     def __iter__(self):
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam and self.samfile.header.n_targets == 0:             # <<<<<<<<<<<<<<
@@ -15948,23 +17312,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_40__iter__(struct __pyx_obj
   }
   if (__pyx_t_5) {
 
-    /* "pysam/csamtools.pyx":1419
+    /* "pysam/csamtools.pyx":1545
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam and self.samfile.header.n_targets == 0:
  *                 raise NotImplementedError( "can not iterate over samfile without header")             # <<<<<<<<<<<<<<
  *         return self
  * 
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_121), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_NotImplementedError, ((PyObject *)__pyx_k_tuple_129), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L4;
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":1420
+  /* "pysam/csamtools.pyx":1546
  *         if not self.isbam and self.samfile.header.n_targets == 0:
  *                 raise NotImplementedError( "can not iterate over samfile without header")
  *         return self             # <<<<<<<<<<<<<<
@@ -15990,7 +17354,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_40__iter__(struct __pyx_obj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1422
+/* "pysam/csamtools.pyx":1548
  *         return self
  * 
  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
@@ -16003,9 +17367,9 @@ static bam1_t *__pyx_f_5pysam_9csamtools_7Samfile_getCurrent(struct __pyx_obj_5p
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getCurrent", 0);
-  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1422);
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1548);
 
-  /* "pysam/csamtools.pyx":1423
+  /* "pysam/csamtools.pyx":1549
  * 
  *     cdef bam1_t * getCurrent( self ):
  *         return self.b             # <<<<<<<<<<<<<<
@@ -16022,7 +17386,7 @@ static bam1_t *__pyx_f_5pysam_9csamtools_7Samfile_getCurrent(struct __pyx_obj_5p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1425
+/* "pysam/csamtools.pyx":1551
  *         return self.b
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
@@ -16035,9 +17399,9 @@ static int __pyx_f_5pysam_9csamtools_7Samfile_cnext(struct __pyx_obj_5pysam_9csa
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext", 0);
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1425);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1551);
 
-  /* "pysam/csamtools.pyx":1430
+  /* "pysam/csamtools.pyx":1556
  *         '''
  *         cdef int ret
  *         return samread(self.samfile, self.b)             # <<<<<<<<<<<<<<
@@ -16069,7 +17433,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7Samfile_43__next__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1432
+/* "pysam/csamtools.pyx":1558
  *         return samread(self.samfile, self.b)
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -16088,9 +17452,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_42__next__(struct __pyx_obj
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__", 0);
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1432);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1558);
 
-  /* "pysam/csamtools.pyx":1437
+  /* "pysam/csamtools.pyx":1563
  *         """
  *         cdef int ret
  *         ret = samread(self.samfile, self.b)             # <<<<<<<<<<<<<<
@@ -16099,7 +17463,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_42__next__(struct __pyx_obj
  */
   __pyx_v_ret = samread(__pyx_v_self->samfile, __pyx_v_self->b);
 
-  /* "pysam/csamtools.pyx":1438
+  /* "pysam/csamtools.pyx":1564
  *         cdef int ret
  *         ret = samread(self.samfile, self.b)
  *         if (ret > 0):             # <<<<<<<<<<<<<<
@@ -16109,7 +17473,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_42__next__(struct __pyx_obj
   __pyx_t_1 = (__pyx_v_ret > 0);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":1439
+    /* "pysam/csamtools.pyx":1565
  *         ret = samread(self.samfile, self.b)
  *         if (ret > 0):
  *             return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
@@ -16117,7 +17481,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_42__next__(struct __pyx_obj
  *             raise StopIteration
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = __pyx_f_5pysam_9csamtools_makeAlignedRead(__pyx_v_self->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __pyx_f_5pysam_9csamtools_makeAlignedRead(__pyx_v_self->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_r = __pyx_t_2;
     __pyx_t_2 = 0;
@@ -16126,7 +17490,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_42__next__(struct __pyx_obj
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1441
+    /* "pysam/csamtools.pyx":1567
  *             return makeAlignedRead( self.b )
  *         else:
  *             raise StopIteration             # <<<<<<<<<<<<<<
@@ -16134,7 +17498,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7Samfile_42__next__(struct __pyx_obj
  * ##-------------------------------------------------------------------
  */
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L3:;
 
@@ -16185,17 +17549,17 @@ static int __pyx_pw_5pysam_9csamtools_17IteratorRowRegion_1__cinit__(PyObject *_
         case  1:
         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__tid)) != 0)) kw_args--;
         else {
-          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
         }
         case  2:
         if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__beg)) != 0)) kw_args--;
         else {
-          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
         }
         case  3:
         if (likely((values[3] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end)) != 0)) kw_args--;
         else {
-          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, 3); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
         }
         case  4:
         if (kw_args > 0) {
@@ -16204,7 +17568,7 @@ static int __pyx_pw_5pysam_9csamtools_17IteratorRowRegion_1__cinit__(PyObject *_
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -16218,14 +17582,14 @@ static int __pyx_pw_5pysam_9csamtools_17IteratorRowRegion_1__cinit__(PyObject *_
       }
     }
     __pyx_v_samfile = ((struct __pyx_obj_5pysam_9csamtools_Samfile *)values[0]);
-    __pyx_v_tid = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_beg = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_beg == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_tid = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_beg = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_beg == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     if (values[4]) {
-      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
 
-      /* "pysam/csamtools.pyx":1486
+      /* "pysam/csamtools.pyx":1622
  *     """
  * 
  *     def __cinit__(self, Samfile samfile, int tid, int beg, int end, int reopen = True ):             # <<<<<<<<<<<<<<
@@ -16237,13 +17601,13 @@ static int __pyx_pw_5pysam_9csamtools_17IteratorRowRegion_1__cinit__(PyObject *_
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 4, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.IteratorRowRegion.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1486; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1622; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_17IteratorRowRegion___cinit__(((struct __pyx_obj_5pysam_9csamtools_IteratorRowRegion *)__pyx_v_self), __pyx_v_samfile, __pyx_v_tid, __pyx_v_beg, __pyx_v_end, __pyx_v_reopen);
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -16269,75 +17633,75 @@ static int __pyx_pf_5pysam_9csamtools_17IteratorRowRegion___cinit__(struct __pyx
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__", 0);
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1486);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1622);
 
-  /* "pysam/csamtools.pyx":1488
+  /* "pysam/csamtools.pyx":1624
  *     def __cinit__(self, Samfile samfile, int tid, int beg, int end, int reopen = True ):
  * 
  *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1624; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":1489
+    /* "pysam/csamtools.pyx":1625
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         if not samfile._hasIndex():
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_122), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_130), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1491
+  /* "pysam/csamtools.pyx":1627
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         if not samfile._hasIndex():             # <<<<<<<<<<<<<<
  *             raise ValueError( "no index available for iteration" )
  * 
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_t_3 = (!__pyx_t_4);
   if (__pyx_t_3) {
 
-    /* "pysam/csamtools.pyx":1492
+    /* "pysam/csamtools.pyx":1628
  * 
  *         if not samfile._hasIndex():
  *             raise ValueError( "no index available for iteration" )             # <<<<<<<<<<<<<<
  * 
  *         # makes sure that samfile stays alive as long as the
  */
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_124), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_132), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L4;
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":1496
+  /* "pysam/csamtools.pyx":1632
  *         # makes sure that samfile stays alive as long as the
  *         # iterator is alive
  *         self.samfile = samfile             # <<<<<<<<<<<<<<
@@ -16350,7 +17714,7 @@ static int __pyx_pf_5pysam_9csamtools_17IteratorRowRegion___cinit__(struct __pyx
   __Pyx_DECREF(((PyObject *)__pyx_v_self->samfile));
   __pyx_v_self->samfile = __pyx_v_samfile;
 
-  /* "pysam/csamtools.pyx":1498
+  /* "pysam/csamtools.pyx":1634
  *         self.samfile = samfile
  * 
  *         if samfile.isbam: mode = b"rb"             # <<<<<<<<<<<<<<
@@ -16364,7 +17728,7 @@ static int __pyx_pf_5pysam_9csamtools_17IteratorRowRegion___cinit__(struct __pyx
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1499
+    /* "pysam/csamtools.pyx":1635
  * 
  *         if samfile.isbam: mode = b"rb"
  *         else: mode = b"r"             # <<<<<<<<<<<<<<
@@ -16376,7 +17740,7 @@ static int __pyx_pf_5pysam_9csamtools_17IteratorRowRegion___cinit__(struct __pyx
   }
   __pyx_L5:;
 
-  /* "pysam/csamtools.pyx":1503
+  /* "pysam/csamtools.pyx":1639
  *         # reopen the file - note that this makes the iterator
  *         # slow and causes pileup to slow down significantly.
  *         if reopen:             # <<<<<<<<<<<<<<
@@ -16385,46 +17749,46 @@ static int __pyx_pf_5pysam_9csamtools_17IteratorRowRegion___cinit__(struct __pyx
  */
   if (__pyx_v_reopen) {
 
-    /* "pysam/csamtools.pyx":1504
+    /* "pysam/csamtools.pyx":1640
  *         # slow and causes pileup to slow down significantly.
  *         if reopen:
  *             store = StderrStore()             # <<<<<<<<<<<<<<
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1504; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_v_store = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "pysam/csamtools.pyx":1505
+    /* "pysam/csamtools.pyx":1641
  *         if reopen:
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
  *             store.release()
  *             assert self.fp != NULL
  */
-    __pyx_t_5 = PyBytes_AsString(((PyObject *)__pyx_v_mode)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyBytes_AsString(((PyObject *)__pyx_v_mode)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_v_self->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_5, NULL);
 
-    /* "pysam/csamtools.pyx":1506
+    /* "pysam/csamtools.pyx":1642
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()             # <<<<<<<<<<<<<<
  *             assert self.fp != NULL
  *             self.owns_samfile = True
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1506; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":1507
+    /* "pysam/csamtools.pyx":1643
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
@@ -16434,11 +17798,11 @@ static int __pyx_pf_5pysam_9csamtools_17IteratorRowRegion___cinit__(struct __pyx
     #ifndef CYTHON_WITHOUT_ASSERTIONS
     if (unlikely(!(__pyx_v_self->fp != NULL))) {
       PyErr_SetNone(PyExc_AssertionError);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1507; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #endif
 
-    /* "pysam/csamtools.pyx":1508
+    /* "pysam/csamtools.pyx":1644
  *             store.release()
  *             assert self.fp != NULL
  *             self.owns_samfile = True             # <<<<<<<<<<<<<<
@@ -16450,7 +17814,7 @@ static int __pyx_pf_5pysam_9csamtools_17IteratorRowRegion___cinit__(struct __pyx
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1510
+    /* "pysam/csamtools.pyx":1646
  *             self.owns_samfile = True
  *         else:
  *             self.fp = self.samfile.samfile             # <<<<<<<<<<<<<<
@@ -16460,7 +17824,7 @@ static int __pyx_pf_5pysam_9csamtools_17IteratorRowRegion___cinit__(struct __pyx
     __pyx_t_6 = __pyx_v_self->samfile->samfile;
     __pyx_v_self->fp = __pyx_t_6;
 
-    /* "pysam/csamtools.pyx":1511
+    /* "pysam/csamtools.pyx":1647
  *         else:
  *             self.fp = self.samfile.samfile
  *             self.owns_samfile = False             # <<<<<<<<<<<<<<
@@ -16471,7 +17835,7 @@ static int __pyx_pf_5pysam_9csamtools_17IteratorRowRegion___cinit__(struct __pyx
   }
   __pyx_L6:;
 
-  /* "pysam/csamtools.pyx":1513
+  /* "pysam/csamtools.pyx":1649
  *             self.owns_samfile = False
  * 
  *         self.retval = 0             # <<<<<<<<<<<<<<
@@ -16480,7 +17844,7 @@ static int __pyx_pf_5pysam_9csamtools_17IteratorRowRegion___cinit__(struct __pyx
  */
   __pyx_v_self->retval = 0;
 
-  /* "pysam/csamtools.pyx":1515
+  /* "pysam/csamtools.pyx":1651
  *         self.retval = 0
  * 
  *         self.iter = bam_iter_query(self.samfile.index,             # <<<<<<<<<<<<<<
@@ -16489,7 +17853,7 @@ static int __pyx_pf_5pysam_9csamtools_17IteratorRowRegion___cinit__(struct __pyx
  */
   __pyx_v_self->iter = bam_iter_query(__pyx_v_self->samfile->index, __pyx_v_tid, __pyx_v_beg, __pyx_v_end);
 
-  /* "pysam/csamtools.pyx":1519
+  /* "pysam/csamtools.pyx":1655
  *                                    beg,
  *                                    end)
  *         self.b = bam_init1()             # <<<<<<<<<<<<<<
@@ -16524,7 +17888,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_17IteratorRowRegion_3__iter__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1521
+/* "pysam/csamtools.pyx":1657
  *         self.b = bam_init1()
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -16537,9 +17901,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_17IteratorRowRegion_2__iter__(struct
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__", 0);
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1521);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1657);
 
-  /* "pysam/csamtools.pyx":1522
+  /* "pysam/csamtools.pyx":1658
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -16559,7 +17923,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_17IteratorRowRegion_2__iter__(struct
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1524
+/* "pysam/csamtools.pyx":1660
  *         return self
  * 
  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
@@ -16572,9 +17936,9 @@ static bam1_t *__pyx_f_5pysam_9csamtools_17IteratorRowRegion_getCurrent(struct _
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getCurrent", 0);
-  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1524);
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1660);
 
-  /* "pysam/csamtools.pyx":1525
+  /* "pysam/csamtools.pyx":1661
  * 
  *     cdef bam1_t * getCurrent( self ):
  *         return self.b             # <<<<<<<<<<<<<<
@@ -16591,7 +17955,7 @@ static bam1_t *__pyx_f_5pysam_9csamtools_17IteratorRowRegion_getCurrent(struct _
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1527
+/* "pysam/csamtools.pyx":1663
  *         return self.b
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
@@ -16604,9 +17968,9 @@ static int __pyx_f_5pysam_9csamtools_17IteratorRowRegion_cnext(struct __pyx_obj_
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext", 0);
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1527);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1663);
 
-  /* "pysam/csamtools.pyx":1529
+  /* "pysam/csamtools.pyx":1665
  *     cdef int cnext(self):
  *         '''cversion of iterator. Used by IteratorColumn'''
  *         self.retval = bam_iter_read( self.fp.x.bam,             # <<<<<<<<<<<<<<
@@ -16636,7 +18000,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_17IteratorRowRegion_5__next__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1533
+/* "pysam/csamtools.pyx":1669
  *                                      self.b)
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -16654,9 +18018,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_17IteratorRowRegion_4__next__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__", 0);
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1533);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1669);
 
-  /* "pysam/csamtools.pyx":1536
+  /* "pysam/csamtools.pyx":1672
  *         """python version of next().
  *         """
  *         self.cnext()             # <<<<<<<<<<<<<<
@@ -16665,7 +18029,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_17IteratorRowRegion_4__next__(struct
  */
   ((struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowRegion *)__pyx_v_self->__pyx_vtab)->cnext(__pyx_v_self);
 
-  /* "pysam/csamtools.pyx":1537
+  /* "pysam/csamtools.pyx":1673
  *         """
  *         self.cnext()
  *         if self.retval < 0: raise StopIteration             # <<<<<<<<<<<<<<
@@ -16675,12 +18039,12 @@ static PyObject *__pyx_pf_5pysam_9csamtools_17IteratorRowRegion_4__next__(struct
   __pyx_t_1 = (__pyx_v_self->retval < 0);
   if (__pyx_t_1) {
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1537; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1538
+  /* "pysam/csamtools.pyx":1674
  *         self.cnext()
  *         if self.retval < 0: raise StopIteration
  *         return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
@@ -16688,7 +18052,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_17IteratorRowRegion_4__next__(struct
  *     def __dealloc__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __pyx_f_5pysam_9csamtools_makeAlignedRead(__pyx_v_self->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_5pysam_9csamtools_makeAlignedRead(__pyx_v_self->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1674; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -16716,7 +18080,7 @@ static void __pyx_pw_5pysam_9csamtools_17IteratorRowRegion_7__dealloc__(PyObject
   __Pyx_RefNannyFinishContext();
 }
 
-/* "pysam/csamtools.pyx":1540
+/* "pysam/csamtools.pyx":1676
  *         return makeAlignedRead( self.b )
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -16728,9 +18092,9 @@ static void __pyx_pf_5pysam_9csamtools_17IteratorRowRegion_6__dealloc__(struct _
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__", 0);
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1540);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1676);
 
-  /* "pysam/csamtools.pyx":1541
+  /* "pysam/csamtools.pyx":1677
  * 
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
@@ -16739,7 +18103,7 @@ static void __pyx_pf_5pysam_9csamtools_17IteratorRowRegion_6__dealloc__(struct _
  */
   bam_destroy1(__pyx_v_self->b);
 
-  /* "pysam/csamtools.pyx":1542
+  /* "pysam/csamtools.pyx":1678
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)
  *         bam_iter_destroy( self.iter )             # <<<<<<<<<<<<<<
@@ -16748,7 +18112,7 @@ static void __pyx_pf_5pysam_9csamtools_17IteratorRowRegion_6__dealloc__(struct _
  */
   bam_iter_destroy(__pyx_v_self->iter);
 
-  /* "pysam/csamtools.pyx":1543
+  /* "pysam/csamtools.pyx":1679
  *         bam_destroy1(self.b)
  *         bam_iter_destroy( self.iter )
  *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
@@ -16797,7 +18161,7 @@ static int __pyx_pw_5pysam_9csamtools_14IteratorRowAll_1__cinit__(PyObject *__py
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1555; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -16809,10 +18173,10 @@ static int __pyx_pw_5pysam_9csamtools_14IteratorRowAll_1__cinit__(PyObject *__py
     }
     __pyx_v_samfile = ((struct __pyx_obj_5pysam_9csamtools_Samfile *)values[0]);
     if (values[1]) {
-      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1555; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
 
-      /* "pysam/csamtools.pyx":1555
+      /* "pysam/csamtools.pyx":1697
  *     """
  * 
  *     def __cinit__(self, Samfile samfile, int reopen = True ):             # <<<<<<<<<<<<<<
@@ -16824,13 +18188,13 @@ static int __pyx_pw_5pysam_9csamtools_14IteratorRowAll_1__cinit__(PyObject *__py
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1555; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.IteratorRowAll.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1555; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1697; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_14IteratorRowAll___cinit__(((struct __pyx_obj_5pysam_9csamtools_IteratorRowAll *)__pyx_v_self), __pyx_v_samfile, __pyx_v_reopen);
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -16856,42 +18220,42 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorRowAll___cinit__(struct __pyx_ob
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__", 0);
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1555);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1697);
 
-  /* "pysam/csamtools.pyx":1557
+  /* "pysam/csamtools.pyx":1699
  *     def __cinit__(self, Samfile samfile, int reopen = True ):
  * 
  *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1699; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":1558
+    /* "pysam/csamtools.pyx":1700
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         if samfile.isbam: mode = b"rb"
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_125), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_133), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1560
+  /* "pysam/csamtools.pyx":1702
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         if samfile.isbam: mode = b"rb"             # <<<<<<<<<<<<<<
@@ -16905,7 +18269,7 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorRowAll___cinit__(struct __pyx_ob
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1561
+    /* "pysam/csamtools.pyx":1703
  * 
  *         if samfile.isbam: mode = b"rb"
  *         else: mode = b"r"             # <<<<<<<<<<<<<<
@@ -16917,7 +18281,7 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorRowAll___cinit__(struct __pyx_ob
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":1564
+  /* "pysam/csamtools.pyx":1706
  * 
  *         # reopen the file to avoid iterator conflict
  *         if reopen:             # <<<<<<<<<<<<<<
@@ -16926,46 +18290,46 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorRowAll___cinit__(struct __pyx_ob
  */
   if (__pyx_v_reopen) {
 
-    /* "pysam/csamtools.pyx":1565
+    /* "pysam/csamtools.pyx":1707
  *         # reopen the file to avoid iterator conflict
  *         if reopen:
  *             store = StderrStore()             # <<<<<<<<<<<<<<
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  */
-    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1565; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __pyx_v_store = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":1566
+    /* "pysam/csamtools.pyx":1708
  *         if reopen:
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
  *             store.release()
  *             assert self.fp != NULL
  */
-    __pyx_t_5 = PyBytes_AsString(((PyObject *)__pyx_v_mode)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1566; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyBytes_AsString(((PyObject *)__pyx_v_mode)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1708; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_v_self->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_5, NULL);
 
-    /* "pysam/csamtools.pyx":1567
+    /* "pysam/csamtools.pyx":1709
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()             # <<<<<<<<<<<<<<
  *             assert self.fp != NULL
  *             self.owns_samfile = True
  */
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1567; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-    /* "pysam/csamtools.pyx":1568
+    /* "pysam/csamtools.pyx":1710
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
@@ -16975,11 +18339,11 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorRowAll___cinit__(struct __pyx_ob
     #ifndef CYTHON_WITHOUT_ASSERTIONS
     if (unlikely(!(__pyx_v_self->fp != NULL))) {
       PyErr_SetNone(PyExc_AssertionError);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1710; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #endif
 
-    /* "pysam/csamtools.pyx":1569
+    /* "pysam/csamtools.pyx":1711
  *             store.release()
  *             assert self.fp != NULL
  *             self.owns_samfile = True             # <<<<<<<<<<<<<<
@@ -16991,7 +18355,7 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorRowAll___cinit__(struct __pyx_ob
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1571
+    /* "pysam/csamtools.pyx":1713
  *             self.owns_samfile = True
  *         else:
  *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
@@ -17001,7 +18365,7 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorRowAll___cinit__(struct __pyx_ob
     __pyx_t_6 = __pyx_v_samfile->samfile;
     __pyx_v_self->fp = __pyx_t_6;
 
-    /* "pysam/csamtools.pyx":1572
+    /* "pysam/csamtools.pyx":1714
  *         else:
  *             self.fp = samfile.samfile
  *             self.owns_samfile = False             # <<<<<<<<<<<<<<
@@ -17012,7 +18376,7 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorRowAll___cinit__(struct __pyx_ob
   }
   __pyx_L5:;
 
-  /* "pysam/csamtools.pyx":1575
+  /* "pysam/csamtools.pyx":1717
  * 
  *         # allocate memory for alignment
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))             # <<<<<<<<<<<<<<
@@ -17047,7 +18411,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_14IteratorRowAll_3__iter__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1577
+/* "pysam/csamtools.pyx":1719
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -17060,9 +18424,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorRowAll_2__iter__(struct __
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__", 0);
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1577);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1719);
 
-  /* "pysam/csamtools.pyx":1578
+  /* "pysam/csamtools.pyx":1720
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -17082,7 +18446,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorRowAll_2__iter__(struct __
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1580
+/* "pysam/csamtools.pyx":1722
  *         return self
  * 
  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
@@ -17095,9 +18459,9 @@ static bam1_t *__pyx_f_5pysam_9csamtools_14IteratorRowAll_getCurrent(struct __py
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getCurrent", 0);
-  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1580);
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1722);
 
-  /* "pysam/csamtools.pyx":1581
+  /* "pysam/csamtools.pyx":1723
  * 
  *     cdef bam1_t * getCurrent( self ):
  *         return self.b             # <<<<<<<<<<<<<<
@@ -17114,7 +18478,7 @@ static bam1_t *__pyx_f_5pysam_9csamtools_14IteratorRowAll_getCurrent(struct __py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1583
+/* "pysam/csamtools.pyx":1725
  *         return self.b
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
@@ -17127,9 +18491,9 @@ static int __pyx_f_5pysam_9csamtools_14IteratorRowAll_cnext(struct __pyx_obj_5py
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext", 0);
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1583);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1725);
 
-  /* "pysam/csamtools.pyx":1585
+  /* "pysam/csamtools.pyx":1727
  *     cdef int cnext(self):
  *         '''cversion of iterator. Used by IteratorColumn'''
  *         return samread(self.fp, self.b)             # <<<<<<<<<<<<<<
@@ -17161,7 +18525,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_14IteratorRowAll_5__next__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1587
+/* "pysam/csamtools.pyx":1729
  *         return samread(self.fp, self.b)
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -17180,9 +18544,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorRowAll_4__next__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__", 0);
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1587);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1729);
 
-  /* "pysam/csamtools.pyx":1593
+  /* "pysam/csamtools.pyx":1735
  *         """
  *         cdef int ret
  *         ret = samread(self.fp, self.b)             # <<<<<<<<<<<<<<
@@ -17191,7 +18555,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorRowAll_4__next__(struct __
  */
   __pyx_v_ret = samread(__pyx_v_self->fp, __pyx_v_self->b);
 
-  /* "pysam/csamtools.pyx":1594
+  /* "pysam/csamtools.pyx":1736
  *         cdef int ret
  *         ret = samread(self.fp, self.b)
  *         if (ret > 0):             # <<<<<<<<<<<<<<
@@ -17201,7 +18565,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorRowAll_4__next__(struct __
   __pyx_t_1 = (__pyx_v_ret > 0);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":1595
+    /* "pysam/csamtools.pyx":1737
  *         ret = samread(self.fp, self.b)
  *         if (ret > 0):
  *             return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
@@ -17209,7 +18573,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorRowAll_4__next__(struct __
  *             raise StopIteration
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = __pyx_f_5pysam_9csamtools_makeAlignedRead(__pyx_v_self->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1595; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __pyx_f_5pysam_9csamtools_makeAlignedRead(__pyx_v_self->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1737; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_r = __pyx_t_2;
     __pyx_t_2 = 0;
@@ -17218,7 +18582,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorRowAll_4__next__(struct __
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1597
+    /* "pysam/csamtools.pyx":1739
  *             return makeAlignedRead( self.b )
  *         else:
  *             raise StopIteration             # <<<<<<<<<<<<<<
@@ -17226,7 +18590,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorRowAll_4__next__(struct __
  *     def __dealloc__(self):
  */
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1739; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L3:;
 
@@ -17252,7 +18616,7 @@ static void __pyx_pw_5pysam_9csamtools_14IteratorRowAll_7__dealloc__(PyObject *_
   __Pyx_RefNannyFinishContext();
 }
 
-/* "pysam/csamtools.pyx":1599
+/* "pysam/csamtools.pyx":1741
  *             raise StopIteration
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -17264,9 +18628,9 @@ static void __pyx_pf_5pysam_9csamtools_14IteratorRowAll_6__dealloc__(struct __py
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__", 0);
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1599);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1741);
 
-  /* "pysam/csamtools.pyx":1600
+  /* "pysam/csamtools.pyx":1742
  * 
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
@@ -17275,7 +18639,7 @@ static void __pyx_pf_5pysam_9csamtools_14IteratorRowAll_6__dealloc__(struct __py
  */
   bam_destroy1(__pyx_v_self->b);
 
-  /* "pysam/csamtools.pyx":1601
+  /* "pysam/csamtools.pyx":1743
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)
  *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
@@ -17317,7 +18681,7 @@ static int __pyx_pw_5pysam_9csamtools_18IteratorRowAllRefs_1__cinit__(PyObject *
         else goto __pyx_L5_argtuple_error;
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
       goto __pyx_L5_argtuple_error;
@@ -17328,13 +18692,13 @@ static int __pyx_pw_5pysam_9csamtools_18IteratorRowAllRefs_1__cinit__(PyObject *
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.IteratorRowAllRefs.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1753; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs___cinit__(((struct __pyx_obj_5pysam_9csamtools_IteratorRowAllRefs *)__pyx_v_self), __pyx_v_samfile);
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -17344,7 +18708,7 @@ static int __pyx_pw_5pysam_9csamtools_18IteratorRowAllRefs_1__cinit__(PyObject *
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1607
+/* "pysam/csamtools.pyx":1753
  *     """
  * 
  *     def __cinit__(self, Samfile samfile):             # <<<<<<<<<<<<<<
@@ -17364,9 +18728,9 @@ static int __pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs___cinit__(struct __py
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__", 0);
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1607);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1753);
 
-  /* "pysam/csamtools.pyx":1608
+  /* "pysam/csamtools.pyx":1754
  * 
  *     def __cinit__(self, Samfile samfile):
  *         assert samfile._isOpen()             # <<<<<<<<<<<<<<
@@ -17374,45 +18738,45 @@ static int __pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs___cinit__(struct __py
  *         self.samfile = samfile
  */
   #ifndef CYTHON_WITHOUT_ASSERTIONS
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (unlikely(!__pyx_t_3)) {
     PyErr_SetNone(PyExc_AssertionError);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1754; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "pysam/csamtools.pyx":1609
+  /* "pysam/csamtools.pyx":1755
  *     def __cinit__(self, Samfile samfile):
  *         assert samfile._isOpen()
  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")             # <<<<<<<<<<<<<<
  *         self.samfile = samfile
  *         self.tid = -1
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___hasIndex); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_126), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_134), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1610
+  /* "pysam/csamtools.pyx":1756
  *         assert samfile._isOpen()
  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")
  *         self.samfile = samfile             # <<<<<<<<<<<<<<
@@ -17425,7 +18789,7 @@ static int __pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs___cinit__(struct __py
   __Pyx_DECREF(((PyObject *)__pyx_v_self->samfile));
   __pyx_v_self->samfile = __pyx_v_samfile;
 
-  /* "pysam/csamtools.pyx":1611
+  /* "pysam/csamtools.pyx":1757
  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")
  *         self.samfile = samfile
  *         self.tid = -1             # <<<<<<<<<<<<<<
@@ -17459,7 +18823,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_18IteratorRowAllRefs_3nextiter(PyObj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1613
+/* "pysam/csamtools.pyx":1759
  *         self.tid = -1
  * 
  *     def nextiter(self):             # <<<<<<<<<<<<<<
@@ -17477,18 +18841,18 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_2nextiter(struc
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("nextiter", 0);
-  __Pyx_TraceCall("nextiter", __pyx_f[0], 1613);
+  __Pyx_TraceCall("nextiter", __pyx_f[0], 1759);
 
-  /* "pysam/csamtools.pyx":1614
+  /* "pysam/csamtools.pyx":1760
  * 
  *     def nextiter(self):
  *         self.rowiter = IteratorRowRegion(self.samfile, self.tid, 0, 1<<29)             # <<<<<<<<<<<<<<
  * 
  *     def __iter__(self):
  */
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_INCREF(((PyObject *)__pyx_v_self->samfile));
   PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_v_self->samfile));
@@ -17502,7 +18866,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_2nextiter(struc
   PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_int_536870912);
   __Pyx_GIVEREF(__pyx_int_536870912);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowRegion)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowRegion)), ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
   __Pyx_GIVEREF(__pyx_t_1);
@@ -17536,7 +18900,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_18IteratorRowAllRefs_5__iter__(PyObj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1616
+/* "pysam/csamtools.pyx":1762
  *         self.rowiter = IteratorRowRegion(self.samfile, self.tid, 0, 1<<29)
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -17549,9 +18913,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_4__iter__(struc
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__", 0);
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1616);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1762);
 
-  /* "pysam/csamtools.pyx":1617
+  /* "pysam/csamtools.pyx":1763
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -17586,7 +18950,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_18IteratorRowAllRefs_7__next__(PyObj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1619
+/* "pysam/csamtools.pyx":1765
  *         return self
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -17607,9 +18971,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__", 0);
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1619);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1765);
 
-  /* "pysam/csamtools.pyx":1625
+  /* "pysam/csamtools.pyx":1771
  *         """
  *         # Create an initial iterator
  *         if self.tid==-1:             # <<<<<<<<<<<<<<
@@ -17619,21 +18983,21 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
   __pyx_t_1 = (__pyx_v_self->tid == -1);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":1626
+    /* "pysam/csamtools.pyx":1772
  *         # Create an initial iterator
  *         if self.tid==-1:
  *             if not self.samfile.nreferences:             # <<<<<<<<<<<<<<
  *                 raise StopIteration
  *             self.tid = 0
  */
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self->samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self->samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __pyx_t_3 = (!__pyx_t_1);
     if (__pyx_t_3) {
 
-      /* "pysam/csamtools.pyx":1627
+      /* "pysam/csamtools.pyx":1773
  *         if self.tid==-1:
  *             if not self.samfile.nreferences:
  *                 raise StopIteration             # <<<<<<<<<<<<<<
@@ -17641,12 +19005,12 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
  *             self.nextiter()
  */
       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L4;
     }
     __pyx_L4:;
 
-    /* "pysam/csamtools.pyx":1628
+    /* "pysam/csamtools.pyx":1774
  *             if not self.samfile.nreferences:
  *                 raise StopIteration
  *             self.tid = 0             # <<<<<<<<<<<<<<
@@ -17655,16 +19019,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
  */
     __pyx_v_self->tid = 0;
 
-    /* "pysam/csamtools.pyx":1629
+    /* "pysam/csamtools.pyx":1775
  *                 raise StopIteration
  *             self.tid = 0
  *             self.nextiter()             # <<<<<<<<<<<<<<
  * 
  *         while 1:
  */
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__nextiter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__nextiter); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1629; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1775; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
@@ -17672,7 +19036,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1631
+  /* "pysam/csamtools.pyx":1777
  *             self.nextiter()
  * 
  *         while 1:             # <<<<<<<<<<<<<<
@@ -17682,7 +19046,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
   while (1) {
     if (!1) break;
 
-    /* "pysam/csamtools.pyx":1632
+    /* "pysam/csamtools.pyx":1778
  * 
  *         while 1:
  *             self.rowiter.cnext()             # <<<<<<<<<<<<<<
@@ -17691,7 +19055,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
  */
     ((struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowRegion *)__pyx_v_self->rowiter->__pyx_vtab)->cnext(__pyx_v_self->rowiter);
 
-    /* "pysam/csamtools.pyx":1635
+    /* "pysam/csamtools.pyx":1781
  * 
  *             # If current iterator is not exhausted, return aligned read
  *             if self.rowiter.retval>0:             # <<<<<<<<<<<<<<
@@ -17701,7 +19065,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
     __pyx_t_3 = (__pyx_v_self->rowiter->retval > 0);
     if (__pyx_t_3) {
 
-      /* "pysam/csamtools.pyx":1636
+      /* "pysam/csamtools.pyx":1782
  *             # If current iterator is not exhausted, return aligned read
  *             if self.rowiter.retval>0:
  *                 return makeAlignedRead(self.rowiter.b)             # <<<<<<<<<<<<<<
@@ -17709,7 +19073,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
  *             self.tid += 1
  */
       __Pyx_XDECREF(__pyx_r);
-      __pyx_t_4 = __pyx_f_5pysam_9csamtools_makeAlignedRead(__pyx_v_self->rowiter->b); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1636; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = __pyx_f_5pysam_9csamtools_makeAlignedRead(__pyx_v_self->rowiter->b); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __pyx_r = __pyx_t_4;
       __pyx_t_4 = 0;
@@ -17718,7 +19082,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
     }
     __pyx_L7:;
 
-    /* "pysam/csamtools.pyx":1638
+    /* "pysam/csamtools.pyx":1784
  *                 return makeAlignedRead(self.rowiter.b)
  * 
  *             self.tid += 1             # <<<<<<<<<<<<<<
@@ -17727,34 +19091,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
  */
     __pyx_v_self->tid = (__pyx_v_self->tid + 1);
 
-    /* "pysam/csamtools.pyx":1641
+    /* "pysam/csamtools.pyx":1787
  * 
  *             # Otherwise, proceed to next reference or stop
  *             if self.tid<self.samfile.nreferences:             # <<<<<<<<<<<<<<
  *                 self.nextiter()
  *             else:
  */
-    __pyx_t_4 = PyInt_FromLong(__pyx_v_self->tid); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyInt_FromLong(__pyx_v_self->tid); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self->samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self->samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_t_2, Py_LT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1641; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     if (__pyx_t_3) {
 
-      /* "pysam/csamtools.pyx":1642
+      /* "pysam/csamtools.pyx":1788
  *             # Otherwise, proceed to next reference or stop
  *             if self.tid<self.samfile.nreferences:
  *                 self.nextiter()             # <<<<<<<<<<<<<<
  *             else:
  *                 raise StopIteration
  */
-      __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__nextiter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__nextiter); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1642; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
@@ -17762,7 +19126,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
     }
     /*else*/ {
 
-      /* "pysam/csamtools.pyx":1644
+      /* "pysam/csamtools.pyx":1790
  *                 self.nextiter()
  *             else:
  *                 raise StopIteration             # <<<<<<<<<<<<<<
@@ -17770,7 +19134,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_18IteratorRowAllRefs_6__next__(struc
  * cdef class IteratorRowSelection(IteratorRow):
  */
       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     __pyx_L8:;
   }
@@ -17820,7 +19184,7 @@ static int __pyx_pw_5pysam_9csamtools_20IteratorRowSelection_1__cinit__(PyObject
         case  1:
         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__positions)) != 0)) kw_args--;
         else {
-          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1802; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
         }
         case  2:
         if (kw_args > 0) {
@@ -17829,7 +19193,7 @@ static int __pyx_pw_5pysam_9csamtools_20IteratorRowSelection_1__cinit__(PyObject
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1802; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -17843,10 +19207,10 @@ static int __pyx_pw_5pysam_9csamtools_20IteratorRowSelection_1__cinit__(PyObject
     __pyx_v_samfile = ((struct __pyx_obj_5pysam_9csamtools_Samfile *)values[0]);
     __pyx_v_positions = values[1];
     if (values[2]) {
-      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1802; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
 
-      /* "pysam/csamtools.pyx":1652
+      /* "pysam/csamtools.pyx":1802
  *     """
  * 
  *     def __cinit__(self, Samfile samfile, positions, int reopen = True ):             # <<<<<<<<<<<<<<
@@ -17858,13 +19222,13 @@ static int __pyx_pw_5pysam_9csamtools_20IteratorRowSelection_1__cinit__(PyObject
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1802; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.IteratorRowSelection.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1802; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_20IteratorRowSelection___cinit__(((struct __pyx_obj_5pysam_9csamtools_IteratorRowSelection *)__pyx_v_self), __pyx_v_samfile, __pyx_v_positions, __pyx_v_reopen);
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -17890,75 +19254,75 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorRowSelection___cinit__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__", 0);
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1652);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1802);
 
-  /* "pysam/csamtools.pyx":1654
+  /* "pysam/csamtools.pyx":1804
  *     def __cinit__(self, Samfile samfile, positions, int reopen = True ):
  * 
  *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_t_4 = (!__pyx_t_3);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":1655
+    /* "pysam/csamtools.pyx":1805
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         if not samfile._isOpen():
  */
-    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_127), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_135), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_Raise(__pyx_t_2, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1657
+  /* "pysam/csamtools.pyx":1807
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         if not samfile._isOpen():             # <<<<<<<<<<<<<<
  *             raise ValueError( "I/O operation on closed file" )
  * 
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s___isOpen); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1657; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_t_3 = (!__pyx_t_4);
   if (__pyx_t_3) {
 
-    /* "pysam/csamtools.pyx":1658
+    /* "pysam/csamtools.pyx":1808
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         assert samfile.isbam, "can only use this iterator on bam files"
  */
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_128), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_136), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L4;
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":1660
+  /* "pysam/csamtools.pyx":1810
  *             raise ValueError( "I/O operation on closed file" )
  * 
  *         assert samfile.isbam, "can only use this iterator on bam files"             # <<<<<<<<<<<<<<
@@ -17967,12 +19331,12 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorRowSelection___cinit__(struct __
  */
   #ifndef CYTHON_WITHOUT_ASSERTIONS
   if (unlikely(!__pyx_v_samfile->isbam)) {
-    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_129));
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_137));
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "pysam/csamtools.pyx":1661
+  /* "pysam/csamtools.pyx":1811
  * 
  *         assert samfile.isbam, "can only use this iterator on bam files"
  *         mode = b"rb"             # <<<<<<<<<<<<<<
@@ -17982,7 +19346,7 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorRowSelection___cinit__(struct __
   __Pyx_INCREF(((PyObject *)__pyx_n_b__rb));
   __pyx_v_mode = __pyx_n_b__rb;
 
-  /* "pysam/csamtools.pyx":1664
+  /* "pysam/csamtools.pyx":1814
  * 
  *         # reopen the file to avoid iterator conflict
  *         if reopen:             # <<<<<<<<<<<<<<
@@ -17991,46 +19355,46 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorRowSelection___cinit__(struct __
  */
   if (__pyx_v_reopen) {
 
-    /* "pysam/csamtools.pyx":1665
+    /* "pysam/csamtools.pyx":1815
  *         # reopen the file to avoid iterator conflict
  *         if reopen:
  *             store = StderrStore()             # <<<<<<<<<<<<<<
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1665; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1815; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_v_store = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "pysam/csamtools.pyx":1666
+    /* "pysam/csamtools.pyx":1816
  *         if reopen:
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
  *             store.release()
  *             assert self.fp != NULL
  */
-    __pyx_t_5 = PyBytes_AsString(((PyObject *)__pyx_v_mode)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1666; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyBytes_AsString(((PyObject *)__pyx_v_mode)); if (unlikely((!__pyx_t_5) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_v_self->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_5, NULL);
 
-    /* "pysam/csamtools.pyx":1667
+    /* "pysam/csamtools.pyx":1817
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()             # <<<<<<<<<<<<<<
  *             assert self.fp != NULL
  *             self.owns_samfile = True
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1817; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":1668
+    /* "pysam/csamtools.pyx":1818
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
@@ -18040,11 +19404,11 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorRowSelection___cinit__(struct __
     #ifndef CYTHON_WITHOUT_ASSERTIONS
     if (unlikely(!(__pyx_v_self->fp != NULL))) {
       PyErr_SetNone(PyExc_AssertionError);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #endif
 
-    /* "pysam/csamtools.pyx":1669
+    /* "pysam/csamtools.pyx":1819
  *             store.release()
  *             assert self.fp != NULL
  *             self.owns_samfile = True             # <<<<<<<<<<<<<<
@@ -18056,7 +19420,7 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorRowSelection___cinit__(struct __
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1671
+    /* "pysam/csamtools.pyx":1821
  *             self.owns_samfile = True
  *         else:
  *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
@@ -18066,7 +19430,7 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorRowSelection___cinit__(struct __
     __pyx_t_6 = __pyx_v_samfile->samfile;
     __pyx_v_self->fp = __pyx_t_6;
 
-    /* "pysam/csamtools.pyx":1672
+    /* "pysam/csamtools.pyx":1822
  *         else:
  *             self.fp = samfile.samfile
  *             self.owns_samfile = False             # <<<<<<<<<<<<<<
@@ -18077,7 +19441,7 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorRowSelection___cinit__(struct __
   }
   __pyx_L5:;
 
-  /* "pysam/csamtools.pyx":1675
+  /* "pysam/csamtools.pyx":1825
  * 
  *         # allocate memory for alignment
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))             # <<<<<<<<<<<<<<
@@ -18086,7 +19450,7 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorRowSelection___cinit__(struct __
  */
   __pyx_v_self->b = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
 
-  /* "pysam/csamtools.pyx":1677
+  /* "pysam/csamtools.pyx":1827
  *         self.b = <bam1_t*>calloc(1, sizeof(bam1_t))
  * 
  *         self.positions = positions             # <<<<<<<<<<<<<<
@@ -18099,7 +19463,7 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorRowSelection___cinit__(struct __
   __Pyx_DECREF(__pyx_v_self->positions);
   __pyx_v_self->positions = __pyx_v_positions;
 
-  /* "pysam/csamtools.pyx":1678
+  /* "pysam/csamtools.pyx":1828
  * 
  *         self.positions = positions
  *         self.current_pos = 0             # <<<<<<<<<<<<<<
@@ -18134,7 +19498,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_20IteratorRowSelection_3__iter__(PyO
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1680
+/* "pysam/csamtools.pyx":1830
  *         self.current_pos = 0
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
@@ -18147,9 +19511,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorRowSelection_2__iter__(str
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__", 0);
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1680);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1830);
 
-  /* "pysam/csamtools.pyx":1681
+  /* "pysam/csamtools.pyx":1831
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -18169,7 +19533,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorRowSelection_2__iter__(str
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1683
+/* "pysam/csamtools.pyx":1833
  *         return self
  * 
  *     cdef bam1_t * getCurrent( self ):             # <<<<<<<<<<<<<<
@@ -18182,9 +19546,9 @@ static bam1_t *__pyx_f_5pysam_9csamtools_20IteratorRowSelection_getCurrent(struc
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getCurrent", 0);
-  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1683);
+  __Pyx_TraceCall("getCurrent", __pyx_f[0], 1833);
 
-  /* "pysam/csamtools.pyx":1684
+  /* "pysam/csamtools.pyx":1834
  * 
  *     cdef bam1_t * getCurrent( self ):
  *         return self.b             # <<<<<<<<<<<<<<
@@ -18201,7 +19565,7 @@ static bam1_t *__pyx_f_5pysam_9csamtools_20IteratorRowSelection_getCurrent(struc
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1686
+/* "pysam/csamtools.pyx":1836
  *         return self.b
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
@@ -18221,9 +19585,9 @@ static int __pyx_f_5pysam_9csamtools_20IteratorRowSelection_cnext(struct __pyx_o
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext", 0);
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1686);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1836);
 
-  /* "pysam/csamtools.pyx":1690
+  /* "pysam/csamtools.pyx":1840
  * 
  *         # end iteration if out of positions
  *         if self.current_pos >= len(self.positions): return -1             # <<<<<<<<<<<<<<
@@ -18232,7 +19596,7 @@ static int __pyx_f_5pysam_9csamtools_20IteratorRowSelection_cnext(struct __pyx_o
  */
   __pyx_t_1 = __pyx_v_self->positions;
   __Pyx_INCREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1690; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_t_3 = (__pyx_v_self->current_pos >= __pyx_t_2);
   if (__pyx_t_3) {
@@ -18242,20 +19606,20 @@ static int __pyx_f_5pysam_9csamtools_20IteratorRowSelection_cnext(struct __pyx_o
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1692
+  /* "pysam/csamtools.pyx":1842
  *         if self.current_pos >= len(self.positions): return -1
  * 
  *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )             # <<<<<<<<<<<<<<
  *         self.current_pos += 1
  *         return samread(self.fp, self.b)
  */
-  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->positions, __pyx_v_self->current_pos, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_self->positions, __pyx_v_self->current_pos, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = __Pyx_PyInt_from_py_uint64_t(__pyx_t_1); if (unlikely((__pyx_t_4 == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1692; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyInt_from_py_uint64_t(__pyx_t_1); if (unlikely((__pyx_t_4 == (uint64_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   bam_seek(__pyx_v_self->fp->x.bam, __pyx_t_4, 0);
 
-  /* "pysam/csamtools.pyx":1693
+  /* "pysam/csamtools.pyx":1843
  * 
  *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )
  *         self.current_pos += 1             # <<<<<<<<<<<<<<
@@ -18264,7 +19628,7 @@ static int __pyx_f_5pysam_9csamtools_20IteratorRowSelection_cnext(struct __pyx_o
  */
   __pyx_v_self->current_pos = (__pyx_v_self->current_pos + 1);
 
-  /* "pysam/csamtools.pyx":1694
+  /* "pysam/csamtools.pyx":1844
  *         bam_seek( self.fp.x.bam, self.positions[self.current_pos], 0 )
  *         self.current_pos += 1
  *         return samread(self.fp, self.b)             # <<<<<<<<<<<<<<
@@ -18301,7 +19665,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_20IteratorRowSelection_5__next__(PyO
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1696
+/* "pysam/csamtools.pyx":1846
  *         return samread(self.fp, self.b)
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -18320,9 +19684,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorRowSelection_4__next__(str
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__", 0);
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1696);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 1846);
 
-  /* "pysam/csamtools.pyx":1702
+  /* "pysam/csamtools.pyx":1852
  *         """
  * 
  *         cdef int ret = self.cnext()             # <<<<<<<<<<<<<<
@@ -18331,7 +19695,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorRowSelection_4__next__(str
  */
   __pyx_v_ret = ((struct __pyx_vtabstruct_5pysam_9csamtools_IteratorRowSelection *)__pyx_v_self->__pyx_vtab)->cnext(__pyx_v_self);
 
-  /* "pysam/csamtools.pyx":1703
+  /* "pysam/csamtools.pyx":1853
  * 
  *         cdef int ret = self.cnext()
  *         if (ret > 0):             # <<<<<<<<<<<<<<
@@ -18341,7 +19705,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorRowSelection_4__next__(str
   __pyx_t_1 = (__pyx_v_ret > 0);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":1704
+    /* "pysam/csamtools.pyx":1854
  *         cdef int ret = self.cnext()
  *         if (ret > 0):
  *             return makeAlignedRead( self.b )             # <<<<<<<<<<<<<<
@@ -18349,7 +19713,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorRowSelection_4__next__(str
  *             raise StopIteration
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = __pyx_f_5pysam_9csamtools_makeAlignedRead(__pyx_v_self->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __pyx_f_5pysam_9csamtools_makeAlignedRead(__pyx_v_self->b); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_r = __pyx_t_2;
     __pyx_t_2 = 0;
@@ -18358,7 +19722,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorRowSelection_4__next__(str
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1706
+    /* "pysam/csamtools.pyx":1856
  *             return makeAlignedRead( self.b )
  *         else:
  *             raise StopIteration             # <<<<<<<<<<<<<<
@@ -18366,7 +19730,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorRowSelection_4__next__(str
  *     def __dealloc__(self):
  */
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1706; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L3:;
 
@@ -18392,7 +19756,7 @@ static void __pyx_pw_5pysam_9csamtools_20IteratorRowSelection_7__dealloc__(PyObj
   __Pyx_RefNannyFinishContext();
 }
 
-/* "pysam/csamtools.pyx":1708
+/* "pysam/csamtools.pyx":1858
  *             raise StopIteration
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -18404,9 +19768,9 @@ static void __pyx_pf_5pysam_9csamtools_20IteratorRowSelection_6__dealloc__(struc
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__", 0);
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1708);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1858);
 
-  /* "pysam/csamtools.pyx":1709
+  /* "pysam/csamtools.pyx":1859
  * 
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)             # <<<<<<<<<<<<<<
@@ -18415,7 +19779,7 @@ static void __pyx_pf_5pysam_9csamtools_20IteratorRowSelection_6__dealloc__(struc
  */
   bam_destroy1(__pyx_v_self->b);
 
-  /* "pysam/csamtools.pyx":1710
+  /* "pysam/csamtools.pyx":1860
  *     def __dealloc__(self):
  *         bam_destroy1(self.b)
  *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
@@ -18432,7 +19796,7 @@ static void __pyx_pf_5pysam_9csamtools_20IteratorRowSelection_6__dealloc__(struc
   __Pyx_RefNannyFinishContext();
 }
 
-/* "pysam/csamtools.pyx":1715
+/* "pysam/csamtools.pyx":1865
  * ##-------------------------------------------------------------------
  * ##-------------------------------------------------------------------
  * cdef int __advance_all( void * data, bam1_t * b ):             # <<<<<<<<<<<<<<
@@ -18446,9 +19810,9 @@ static int __pyx_f_5pysam_9csamtools___advance_all(void *__pyx_v_data, bam1_t *_
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__advance_all", 0);
-  __Pyx_TraceCall("__advance_all", __pyx_f[0], 1715);
+  __Pyx_TraceCall("__advance_all", __pyx_f[0], 1865);
 
-  /* "pysam/csamtools.pyx":1719
+  /* "pysam/csamtools.pyx":1869
  *     '''
  *     cdef __iterdata * d
  *     d = <__iterdata*>data             # <<<<<<<<<<<<<<
@@ -18457,7 +19821,7 @@ static int __pyx_f_5pysam_9csamtools___advance_all(void *__pyx_v_data, bam1_t *_
  */
   __pyx_v_d = ((__pyx_t_5pysam_9csamtools___iterdata *)__pyx_v_data);
 
-  /* "pysam/csamtools.pyx":1720
+  /* "pysam/csamtools.pyx":1870
  *     cdef __iterdata * d
  *     d = <__iterdata*>data
  *     return bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
@@ -18474,7 +19838,7 @@ static int __pyx_f_5pysam_9csamtools___advance_all(void *__pyx_v_data, bam1_t *_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1722
+/* "pysam/csamtools.pyx":1872
  *     return bam_iter_read( d.samfile.x.bam, d.iter, b )
  * 
  * cdef int __advance_snpcalls( void * data, bam1_t * b ):             # <<<<<<<<<<<<<<
@@ -18505,9 +19869,9 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__advance_snpcalls", 0);
-  __Pyx_TraceCall("__advance_snpcalls", __pyx_f[0], 1722);
+  __Pyx_TraceCall("__advance_snpcalls", __pyx_f[0], 1872);
 
-  /* "pysam/csamtools.pyx":1727
+  /* "pysam/csamtools.pyx":1877
  *     '''
  *     cdef __iterdata * d
  *     d = <__iterdata*>data             # <<<<<<<<<<<<<<
@@ -18516,7 +19880,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
  */
   __pyx_v_d = ((__pyx_t_5pysam_9csamtools___iterdata *)__pyx_v_data);
 
-  /* "pysam/csamtools.pyx":1729
+  /* "pysam/csamtools.pyx":1879
  *     d = <__iterdata*>data
  * 
  *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
@@ -18525,7 +19889,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
  */
   __pyx_v_ret = bam_iter_read(__pyx_v_d->samfile->x.bam, __pyx_v_d->iter, __pyx_v_b);
 
-  /* "pysam/csamtools.pyx":1730
+  /* "pysam/csamtools.pyx":1880
  * 
  *     cdef int ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
  *     cdef int skip = 0             # <<<<<<<<<<<<<<
@@ -18534,7 +19898,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
  */
   __pyx_v_skip = 0;
 
-  /* "pysam/csamtools.pyx":1732
+  /* "pysam/csamtools.pyx":1882
  *     cdef int skip = 0
  *     cdef int q
  *     cdef int is_cns = 1             # <<<<<<<<<<<<<<
@@ -18543,7 +19907,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
  */
   __pyx_v_is_cns = 1;
 
-  /* "pysam/csamtools.pyx":1733
+  /* "pysam/csamtools.pyx":1883
  *     cdef int q
  *     cdef int is_cns = 1
  *     cdef int is_nobaq = 0             # <<<<<<<<<<<<<<
@@ -18552,7 +19916,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
  */
   __pyx_v_is_nobaq = 0;
 
-  /* "pysam/csamtools.pyx":1734
+  /* "pysam/csamtools.pyx":1884
  *     cdef int is_cns = 1
  *     cdef int is_nobaq = 0
  *     cdef int capQ_thres = 0             # <<<<<<<<<<<<<<
@@ -18561,7 +19925,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
  */
   __pyx_v_capQ_thres = 0;
 
-  /* "pysam/csamtools.pyx":1737
+  /* "pysam/csamtools.pyx":1887
  * 
  *     # reload sequence
  *     if d.fastafile != NULL and b.core.tid != d.tid:             # <<<<<<<<<<<<<<
@@ -18577,7 +19941,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
   }
   if (__pyx_t_3) {
 
-    /* "pysam/csamtools.pyx":1738
+    /* "pysam/csamtools.pyx":1888
  *     # reload sequence
  *     if d.fastafile != NULL and b.core.tid != d.tid:
  *         if d.seq != NULL: free(d.seq)             # <<<<<<<<<<<<<<
@@ -18591,7 +19955,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
     }
     __pyx_L4:;
 
-    /* "pysam/csamtools.pyx":1739
+    /* "pysam/csamtools.pyx":1889
  *     if d.fastafile != NULL and b.core.tid != d.tid:
  *         if d.seq != NULL: free(d.seq)
  *         d.tid = b.core.tid             # <<<<<<<<<<<<<<
@@ -18601,7 +19965,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
     __pyx_t_4 = __pyx_v_b->core.tid;
     __pyx_v_d->tid = __pyx_t_4;
 
-    /* "pysam/csamtools.pyx":1740
+    /* "pysam/csamtools.pyx":1890
  *         if d.seq != NULL: free(d.seq)
  *         d.tid = b.core.tid
  *         d.seq = faidx_fetch_seq(d.fastafile,             # <<<<<<<<<<<<<<
@@ -18610,7 +19974,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
  */
     __pyx_v_d->seq = faidx_fetch_seq(__pyx_v_d->fastafile, (__pyx_v_d->samfile->header->target_name[__pyx_v_d->tid]), 0, __pyx_v_5pysam_9csamtools_max_pos, (&__pyx_v_d->seq_len));
 
-    /* "pysam/csamtools.pyx":1744
+    /* "pysam/csamtools.pyx":1894
  *                                 0, max_pos,
  *                                 &d.seq_len)
  *         if d.seq == NULL:             # <<<<<<<<<<<<<<
@@ -18620,26 +19984,26 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
     __pyx_t_3 = (__pyx_v_d->seq == NULL);
     if (__pyx_t_3) {
 
-      /* "pysam/csamtools.pyx":1746
+      /* "pysam/csamtools.pyx":1896
  *         if d.seq == NULL:
  *             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
  *                                   (d.samfile.header.target_name[d.tid],             # <<<<<<<<<<<<<<
  *                                    d.tid))
  * 
  */
-      __pyx_t_5 = PyBytes_FromString((__pyx_v_d->samfile->header->target_name[__pyx_v_d->tid])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = PyBytes_FromString((__pyx_v_d->samfile->header->target_name[__pyx_v_d->tid])); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_5));
 
-      /* "pysam/csamtools.pyx":1747
+      /* "pysam/csamtools.pyx":1897
  *             raise ValueError( "reference sequence for '%s' (tid=%i) not found" % \
  *                                   (d.samfile.header.target_name[d.tid],
  *                                    d.tid))             # <<<<<<<<<<<<<<
  * 
  * 
  */
-      __pyx_t_6 = PyInt_FromLong(__pyx_v_d->tid); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyInt_FromLong(__pyx_v_d->tid); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_5));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
@@ -18647,20 +20011,20 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
       __Pyx_GIVEREF(__pyx_t_6);
       __pyx_t_5 = 0;
       __pyx_t_6 = 0;
-      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_130), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_138), ((PyObject *)__pyx_t_7)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_6));
       __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_6));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_6));
       __pyx_t_6 = 0;
-      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
       __Pyx_Raise(__pyx_t_6, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1895; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L5;
     }
     __pyx_L5:;
@@ -18668,7 +20032,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1750
+  /* "pysam/csamtools.pyx":1900
  * 
  * 
  *     while ret >= 0:             # <<<<<<<<<<<<<<
@@ -18679,7 +20043,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
     __pyx_t_3 = (__pyx_v_ret >= 0);
     if (!__pyx_t_3) break;
 
-    /* "pysam/csamtools.pyx":1752
+    /* "pysam/csamtools.pyx":1902
  *     while ret >= 0:
  * 
  *         skip = 0             # <<<<<<<<<<<<<<
@@ -18688,7 +20052,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
  */
     __pyx_v_skip = 0;
 
-    /* "pysam/csamtools.pyx":1755
+    /* "pysam/csamtools.pyx":1905
  * 
  *         # realign read - changes base qualities
  *         if d.seq != NULL and is_cns and not is_nobaq: bam_prob_realn( b, d.seq )             # <<<<<<<<<<<<<<
@@ -18713,7 +20077,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
     }
     __pyx_L8:;
 
-    /* "pysam/csamtools.pyx":1757
+    /* "pysam/csamtools.pyx":1907
  *         if d.seq != NULL and is_cns and not is_nobaq: bam_prob_realn( b, d.seq )
  * 
  *         if d.seq != NULL and capQ_thres > 10:             # <<<<<<<<<<<<<<
@@ -18729,7 +20093,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
     }
     if (__pyx_t_2) {
 
-      /* "pysam/csamtools.pyx":1758
+      /* "pysam/csamtools.pyx":1908
  * 
  *         if d.seq != NULL and capQ_thres > 10:
  *             q = bam_cap_mapQ(b, d.seq, capQ_thres)             # <<<<<<<<<<<<<<
@@ -18738,7 +20102,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
  */
       __pyx_v_q = bam_cap_mapQ(__pyx_v_b, __pyx_v_d->seq, __pyx_v_capQ_thres);
 
-      /* "pysam/csamtools.pyx":1759
+      /* "pysam/csamtools.pyx":1909
  *         if d.seq != NULL and capQ_thres > 10:
  *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
  *             if q < 0: skip = 1             # <<<<<<<<<<<<<<
@@ -18751,7 +20115,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
         goto __pyx_L10;
       }
 
-      /* "pysam/csamtools.pyx":1760
+      /* "pysam/csamtools.pyx":1910
  *             q = bam_cap_mapQ(b, d.seq, capQ_thres)
  *             if q < 0: skip = 1
  *             elif b.core.qual > q: b.core.qual = q             # <<<<<<<<<<<<<<
@@ -18768,7 +20132,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
     }
     __pyx_L9:;
 
-    /* "pysam/csamtools.pyx":1761
+    /* "pysam/csamtools.pyx":1911
  *             if q < 0: skip = 1
  *             elif b.core.qual > q: b.core.qual = q
  *         if b.core.flag & BAM_FUNMAP: skip = 1             # <<<<<<<<<<<<<<
@@ -18781,7 +20145,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
       goto __pyx_L11;
     }
 
-    /* "pysam/csamtools.pyx":1762
+    /* "pysam/csamtools.pyx":1912
  *             elif b.core.qual > q: b.core.qual = q
  *         if b.core.flag & BAM_FUNMAP: skip = 1
  *         elif b.core.flag & 1 and not b.core.flag & 2: skip = 1             # <<<<<<<<<<<<<<
@@ -18800,7 +20164,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
     }
     __pyx_L11:;
 
-    /* "pysam/csamtools.pyx":1764
+    /* "pysam/csamtools.pyx":1914
  *         elif b.core.flag & 1 and not b.core.flag & 2: skip = 1
  * 
  *         if not skip: break             # <<<<<<<<<<<<<<
@@ -18814,7 +20178,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
     }
     __pyx_L12:;
 
-    /* "pysam/csamtools.pyx":1767
+    /* "pysam/csamtools.pyx":1917
  *         # additional filters
  * 
  *         ret = bam_iter_read( d.samfile.x.bam, d.iter, b )             # <<<<<<<<<<<<<<
@@ -18825,7 +20189,7 @@ static int __pyx_f_5pysam_9csamtools___advance_snpcalls(void *__pyx_v_data, bam1
   }
   __pyx_L7_break:;
 
-  /* "pysam/csamtools.pyx":1769
+  /* "pysam/csamtools.pyx":1919
  *         ret = bam_iter_read( d.samfile.x.bam, d.iter, b )
  * 
  *     return ret             # <<<<<<<<<<<<<<
@@ -18877,7 +20241,7 @@ static int __pyx_pw_5pysam_9csamtools_14IteratorColumn_1__cinit__(PyObject *__py
         else goto __pyx_L5_argtuple_error;
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1818; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1968; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
       goto __pyx_L5_argtuple_error;
@@ -18888,14 +20252,14 @@ static int __pyx_pw_5pysam_9csamtools_14IteratorColumn_1__cinit__(PyObject *__py
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1818; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1968; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
   __Pyx_AddTraceback("pysam.csamtools.IteratorColumn.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_14IteratorColumn___cinit__(((struct __pyx_obj_5pysam_9csamtools_IteratorColumn *)__pyx_v_self), __pyx_v_samfile, __pyx_v_kwargs);
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -18906,7 +20270,7 @@ static int __pyx_pw_5pysam_9csamtools_14IteratorColumn_1__cinit__(PyObject *__py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1818
+/* "pysam/csamtools.pyx":1968
  *     '''
  * 
  *     def __cinit__( self, Samfile samfile, **kwargs ):             # <<<<<<<<<<<<<<
@@ -18925,9 +20289,9 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorColumn___cinit__(struct __pyx_ob
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__", 0);
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1818);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1968);
 
-  /* "pysam/csamtools.pyx":1819
+  /* "pysam/csamtools.pyx":1969
  * 
  *     def __cinit__( self, Samfile samfile, **kwargs ):
  *         self.samfile = samfile             # <<<<<<<<<<<<<<
@@ -18940,46 +20304,46 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorColumn___cinit__(struct __pyx_ob
   __Pyx_DECREF(((PyObject *)__pyx_v_self->samfile));
   __pyx_v_self->samfile = __pyx_v_samfile;
 
-  /* "pysam/csamtools.pyx":1820
+  /* "pysam/csamtools.pyx":1970
  *     def __cinit__( self, Samfile samfile, **kwargs ):
  *         self.samfile = samfile
  *         self.mask = kwargs.get("mask", BAM_DEF_MASK )             # <<<<<<<<<<<<<<
  *         self.fastafile = kwargs.get( "fastafile", None )
  *         self.stepper = kwargs.get( "stepper", None )
  */
-  __pyx_t_1 = PyInt_FromLong(BAM_DEF_MASK); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(BAM_DEF_MASK); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__mask), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__mask), __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1820; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_v_self->mask = __pyx_t_3;
 
-  /* "pysam/csamtools.pyx":1821
+  /* "pysam/csamtools.pyx":1971
  *         self.samfile = samfile
  *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
  *         self.fastafile = kwargs.get( "fastafile", None )             # <<<<<<<<<<<<<<
  *         self.stepper = kwargs.get( "stepper", None )
  *         self.max_depth = kwargs.get( "max_depth", 8000 )
  */
-  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__fastafile), Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__fastafile), Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5pysam_9csamtools_Fastafile))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1821; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_5pysam_9csamtools_Fastafile))))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GIVEREF(__pyx_t_2);
   __Pyx_GOTREF(__pyx_v_self->fastafile);
   __Pyx_DECREF(((PyObject *)__pyx_v_self->fastafile));
   __pyx_v_self->fastafile = ((struct __pyx_obj_5pysam_9csamtools_Fastafile *)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":1822
+  /* "pysam/csamtools.pyx":1972
  *         self.mask = kwargs.get("mask", BAM_DEF_MASK )
  *         self.fastafile = kwargs.get( "fastafile", None )
  *         self.stepper = kwargs.get( "stepper", None )             # <<<<<<<<<<<<<<
  *         self.max_depth = kwargs.get( "max_depth", 8000 )
  *         self.iterdata.seq = NULL
  */
-  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__stepper), Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__stepper), Py_None); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
   __Pyx_GOTREF(__pyx_v_self->stepper);
@@ -18987,20 +20351,20 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorColumn___cinit__(struct __pyx_ob
   __pyx_v_self->stepper = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":1823
+  /* "pysam/csamtools.pyx":1973
  *         self.fastafile = kwargs.get( "fastafile", None )
  *         self.stepper = kwargs.get( "stepper", None )
  *         self.max_depth = kwargs.get( "max_depth", 8000 )             # <<<<<<<<<<<<<<
  *         self.iterdata.seq = NULL
  *         self.tid = 0
  */
-  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__max_depth), __pyx_int_8000); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyDict_GetItemDefault(((PyObject *)__pyx_v_kwargs), ((PyObject *)__pyx_n_s__max_depth), __pyx_int_8000); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyInt_AsInt(__pyx_t_2); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_v_self->max_depth = __pyx_t_3;
 
-  /* "pysam/csamtools.pyx":1824
+  /* "pysam/csamtools.pyx":1974
  *         self.stepper = kwargs.get( "stepper", None )
  *         self.max_depth = kwargs.get( "max_depth", 8000 )
  *         self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
@@ -19009,7 +20373,7 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorColumn___cinit__(struct __pyx_ob
  */
   __pyx_v_self->iterdata.seq = NULL;
 
-  /* "pysam/csamtools.pyx":1825
+  /* "pysam/csamtools.pyx":1975
  *         self.max_depth = kwargs.get( "max_depth", 8000 )
  *         self.iterdata.seq = NULL
  *         self.tid = 0             # <<<<<<<<<<<<<<
@@ -19018,7 +20382,7 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorColumn___cinit__(struct __pyx_ob
  */
   __pyx_v_self->tid = 0;
 
-  /* "pysam/csamtools.pyx":1826
+  /* "pysam/csamtools.pyx":1976
  *         self.iterdata.seq = NULL
  *         self.tid = 0
  *         self.pos = 0             # <<<<<<<<<<<<<<
@@ -19027,7 +20391,7 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorColumn___cinit__(struct __pyx_ob
  */
   __pyx_v_self->pos = 0;
 
-  /* "pysam/csamtools.pyx":1827
+  /* "pysam/csamtools.pyx":1977
  *         self.tid = 0
  *         self.pos = 0
  *         self.n_plp = 0             # <<<<<<<<<<<<<<
@@ -19036,7 +20400,7 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorColumn___cinit__(struct __pyx_ob
  */
   __pyx_v_self->n_plp = 0;
 
-  /* "pysam/csamtools.pyx":1828
+  /* "pysam/csamtools.pyx":1978
  *         self.pos = 0
  *         self.n_plp = 0
  *         self.plp = NULL             # <<<<<<<<<<<<<<
@@ -19045,12 +20409,12 @@ static int __pyx_pf_5pysam_9csamtools_14IteratorColumn___cinit__(struct __pyx_ob
  */
   __pyx_v_self->plp = NULL;
 
-  /* "pysam/csamtools.pyx":1829
+  /* "pysam/csamtools.pyx":1979
  *         self.n_plp = 0
  *         self.plp = NULL
  *         self.pileup_iter = <bam_plp_t>NULL             # <<<<<<<<<<<<<<
  * 
- * 
+ *     def __iter__(self):
  */
   __pyx_v_self->pileup_iter = NULL;
 
@@ -19078,8 +20442,8 @@ static PyObject *__pyx_pw_5pysam_9csamtools_14IteratorColumn_3__iter__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1832
- * 
+/* "pysam/csamtools.pyx":1981
+ *         self.pileup_iter = <bam_plp_t>NULL
  * 
  *     def __iter__(self):             # <<<<<<<<<<<<<<
  *         return self
@@ -19091,9 +20455,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorColumn_2__iter__(struct __
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__iter__", 0);
-  __Pyx_TraceCall("__iter__", __pyx_f[0], 1832);
+  __Pyx_TraceCall("__iter__", __pyx_f[0], 1981);
 
-  /* "pysam/csamtools.pyx":1833
+  /* "pysam/csamtools.pyx":1982
  * 
  *     def __iter__(self):
  *         return self             # <<<<<<<<<<<<<<
@@ -19113,12 +20477,12 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorColumn_2__iter__(struct __
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1835
+/* "pysam/csamtools.pyx":1984
  *         return self
  * 
  *     cdef int cnext(self):             # <<<<<<<<<<<<<<
  *         '''perform next iteration.
- * 
+ *         '''
  */
 
 static int __pyx_f_5pysam_9csamtools_14IteratorColumn_cnext(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *__pyx_v_self) {
@@ -19126,10 +20490,10 @@ static int __pyx_f_5pysam_9csamtools_14IteratorColumn_cnext(struct __pyx_obj_5py
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("cnext", 0);
-  __Pyx_TraceCall("cnext", __pyx_f[0], 1835);
+  __Pyx_TraceCall("cnext", __pyx_f[0], 1984);
 
-  /* "pysam/csamtools.pyx":1841
- *         It has been re-implemented to permit for filtering.
+  /* "pysam/csamtools.pyx":1987
+ *         '''perform next iteration.
  *         '''
  *         self.plp = bam_plp_auto( self.pileup_iter,             # <<<<<<<<<<<<<<
  *                                  &self.tid,
@@ -19143,7 +20507,7 @@ static int __pyx_f_5pysam_9csamtools_14IteratorColumn_cnext(struct __pyx_obj_5py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1846
+/* "pysam/csamtools.pyx":1992
  *                                  &self.n_plp )
  * 
  *     cdef char * getSequence( self ):             # <<<<<<<<<<<<<<
@@ -19156,9 +20520,9 @@ static char *__pyx_f_5pysam_9csamtools_14IteratorColumn_getSequence(struct __pyx
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("getSequence", 0);
-  __Pyx_TraceCall("getSequence", __pyx_f[0], 1846);
+  __Pyx_TraceCall("getSequence", __pyx_f[0], 1992);
 
-  /* "pysam/csamtools.pyx":1849
+  /* "pysam/csamtools.pyx":1995
  *         '''return current reference sequence underlying the iterator.
  *         '''
  *         return self.iterdata.seq             # <<<<<<<<<<<<<<
@@ -19186,7 +20550,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_14IteratorColumn_7seq_len_1__get__(P
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1853
+/* "pysam/csamtools.pyx":1999
  *     property seq_len:
  *         '''current sequence length.'''
  *         def __get__(self): return self.iterdata.seq_len             # <<<<<<<<<<<<<<
@@ -19203,9 +20567,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorColumn_7seq_len___get__(st
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 1853);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 1999);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->iterdata.seq_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1853; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->iterdata.seq_len); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -19231,7 +20595,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_14IteratorColumn_5addReference(PyObj
   PyObject *__pyx_r = 0;
   __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("addReference (wrapper)", 0);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fastafile), __pyx_ptype_5pysam_9csamtools_Fastafile, 1, "fastafile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_fastafile), __pyx_ptype_5pysam_9csamtools_Fastafile, 1, "fastafile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_14IteratorColumn_4addReference(((struct __pyx_obj_5pysam_9csamtools_IteratorColumn *)__pyx_v_self), ((struct __pyx_obj_5pysam_9csamtools_Fastafile *)__pyx_v_fastafile));
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -19241,7 +20605,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_14IteratorColumn_5addReference(PyObj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1855
+/* "pysam/csamtools.pyx":2001
  *         def __get__(self): return self.iterdata.seq_len
  * 
  *     def addReference( self, Fastafile fastafile ):             # <<<<<<<<<<<<<<
@@ -19256,9 +20620,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorColumn_4addReference(struc
   faidx_t *__pyx_t_2;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("addReference", 0);
-  __Pyx_TraceCall("addReference", __pyx_f[0], 1855);
+  __Pyx_TraceCall("addReference", __pyx_f[0], 2001);
 
-  /* "pysam/csamtools.pyx":1858
+  /* "pysam/csamtools.pyx":2004
  *        '''
  *        add reference sequences in *fastafile* to iterator.'''
  *        self.fastafile = fastafile             # <<<<<<<<<<<<<<
@@ -19271,7 +20635,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorColumn_4addReference(struc
   __Pyx_DECREF(((PyObject *)__pyx_v_self->fastafile));
   __pyx_v_self->fastafile = __pyx_v_fastafile;
 
-  /* "pysam/csamtools.pyx":1859
+  /* "pysam/csamtools.pyx":2005
  *        add reference sequences in *fastafile* to iterator.'''
  *        self.fastafile = fastafile
  *        if self.iterdata.seq != NULL: free(self.iterdata.seq)             # <<<<<<<<<<<<<<
@@ -19285,7 +20649,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorColumn_4addReference(struc
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1860
+  /* "pysam/csamtools.pyx":2006
  *        self.fastafile = fastafile
  *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
  *        self.iterdata.tid = -1             # <<<<<<<<<<<<<<
@@ -19294,7 +20658,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorColumn_4addReference(struc
  */
   __pyx_v_self->iterdata.tid = -1;
 
-  /* "pysam/csamtools.pyx":1861
+  /* "pysam/csamtools.pyx":2007
  *        if self.iterdata.seq != NULL: free(self.iterdata.seq)
  *        self.iterdata.tid = -1
  *        self.iterdata.fastafile = self.fastafile.fastafile             # <<<<<<<<<<<<<<
@@ -19323,7 +20687,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_14IteratorColumn_7hasReference(PyObj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1863
+/* "pysam/csamtools.pyx":2009
  *        self.iterdata.fastafile = self.fastafile.fastafile
  * 
  *     def hasReference( self ):             # <<<<<<<<<<<<<<
@@ -19336,9 +20700,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorColumn_6hasReference(struc
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("hasReference", 0);
-  __Pyx_TraceCall("hasReference", __pyx_f[0], 1863);
+  __Pyx_TraceCall("hasReference", __pyx_f[0], 2009);
 
-  /* "pysam/csamtools.pyx":1866
+  /* "pysam/csamtools.pyx":2012
  *         '''
  *         return true if iterator is associated with a reference'''
  *         return self.fastafile             # <<<<<<<<<<<<<<
@@ -19358,7 +20722,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_14IteratorColumn_6hasReference(struc
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1868
+/* "pysam/csamtools.pyx":2014
  *         return self.fastafile
  * 
  *     cdef setMask( self, mask ):             # <<<<<<<<<<<<<<
@@ -19375,19 +20739,19 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setMask(struct __pyx
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setMask", 0);
-  __Pyx_TraceCall("setMask", __pyx_f[0], 1868);
+  __Pyx_TraceCall("setMask", __pyx_f[0], 2014);
 
-  /* "pysam/csamtools.pyx":1873
+  /* "pysam/csamtools.pyx":2019
  *         reads with bits set in *mask* will be skipped.
  *         '''
  *         self.mask = mask             # <<<<<<<<<<<<<<
  *         bam_plp_set_mask( self.pileup_iter, self.mask )
  * 
  */
-  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_mask); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_mask); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->mask = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":1874
+  /* "pysam/csamtools.pyx":2020
  *         '''
  *         self.mask = mask
  *         bam_plp_set_mask( self.pileup_iter, self.mask )             # <<<<<<<<<<<<<<
@@ -19408,7 +20772,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setMask(struct __pyx
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1876
+/* "pysam/csamtools.pyx":2022
  *         bam_plp_set_mask( self.pileup_iter, self.mask )
  * 
  *     cdef setupIteratorData( self,             # <<<<<<<<<<<<<<
@@ -19436,29 +20800,29 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setupIteratorData", 0);
-  __Pyx_TraceCall("setupIteratorData", __pyx_f[0], 1876);
+  __Pyx_TraceCall("setupIteratorData", __pyx_f[0], 2022);
   if (__pyx_optional_args) {
     if (__pyx_optional_args->__pyx_n > 0) {
       __pyx_v_reopen = __pyx_optional_args->reopen;
     }
   }
 
-  /* "pysam/csamtools.pyx":1883
+  /* "pysam/csamtools.pyx":2029
  *         '''setup the iterator structure'''
  * 
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen )             # <<<<<<<<<<<<<<
  *         self.iterdata.samfile = self.samfile.samfile
  *         self.iterdata.iter = self.iter.iter
  */
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_start); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_end); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyInt_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyInt_FromLong(__pyx_v_reopen); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_INCREF(((PyObject *)__pyx_v_self->samfile));
   PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_v_self->samfile));
@@ -19475,7 +20839,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
   __pyx_t_2 = 0;
   __pyx_t_3 = 0;
   __pyx_t_4 = 0;
-  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowRegion)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowRegion)), ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
   __Pyx_GIVEREF(__pyx_t_4);
@@ -19484,7 +20848,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
   __pyx_v_self->iter = ((struct __pyx_obj_5pysam_9csamtools_IteratorRowRegion *)__pyx_t_4);
   __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":1884
+  /* "pysam/csamtools.pyx":2030
  * 
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen )
  *         self.iterdata.samfile = self.samfile.samfile             # <<<<<<<<<<<<<<
@@ -19494,7 +20858,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
   __pyx_t_6 = __pyx_v_self->samfile->samfile;
   __pyx_v_self->iterdata.samfile = __pyx_t_6;
 
-  /* "pysam/csamtools.pyx":1885
+  /* "pysam/csamtools.pyx":2031
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen )
  *         self.iterdata.samfile = self.samfile.samfile
  *         self.iterdata.iter = self.iter.iter             # <<<<<<<<<<<<<<
@@ -19504,7 +20868,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
   __pyx_t_7 = __pyx_v_self->iter->iter;
   __pyx_v_self->iterdata.iter = __pyx_t_7;
 
-  /* "pysam/csamtools.pyx":1886
+  /* "pysam/csamtools.pyx":2032
  *         self.iterdata.samfile = self.samfile.samfile
  *         self.iterdata.iter = self.iter.iter
  *         self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
@@ -19513,7 +20877,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
  */
   __pyx_v_self->iterdata.seq = NULL;
 
-  /* "pysam/csamtools.pyx":1887
+  /* "pysam/csamtools.pyx":2033
  *         self.iterdata.iter = self.iter.iter
  *         self.iterdata.seq = NULL
  *         self.iterdata.tid = -1             # <<<<<<<<<<<<<<
@@ -19522,19 +20886,19 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
  */
   __pyx_v_self->iterdata.tid = -1;
 
-  /* "pysam/csamtools.pyx":1889
+  /* "pysam/csamtools.pyx":2035
  *         self.iterdata.tid = -1
  * 
  *         if self.fastafile != None:             # <<<<<<<<<<<<<<
  *             self.iterdata.fastafile = self.fastafile.fastafile
  *         else:
  */
-  __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_self->fastafile), Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(((PyObject *)__pyx_v_self->fastafile), Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (__pyx_t_8) {
 
-    /* "pysam/csamtools.pyx":1890
+    /* "pysam/csamtools.pyx":2036
  * 
  *         if self.fastafile != None:
  *             self.iterdata.fastafile = self.fastafile.fastafile             # <<<<<<<<<<<<<<
@@ -19547,7 +20911,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1892
+    /* "pysam/csamtools.pyx":2038
  *             self.iterdata.fastafile = self.fastafile.fastafile
  *         else:
  *             self.iterdata.fastafile = NULL             # <<<<<<<<<<<<<<
@@ -19558,19 +20922,19 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1894
+  /* "pysam/csamtools.pyx":2040
  *             self.iterdata.fastafile = NULL
  * 
  *         if self.stepper == None or self.stepper == "all":             # <<<<<<<<<<<<<<
  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )
  *         elif self.stepper == "samtools":
  */
-  __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_8 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (!__pyx_t_8) {
-    __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, ((PyObject *)__pyx_n_s__all), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1894; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, ((PyObject *)__pyx_n_s__all), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_10 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __pyx_t_11 = __pyx_t_10;
   } else {
@@ -19578,7 +20942,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
   }
   if (__pyx_t_11) {
 
-    /* "pysam/csamtools.pyx":1895
+    /* "pysam/csamtools.pyx":2041
  * 
  *         if self.stepper == None or self.stepper == "all":
  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )             # <<<<<<<<<<<<<<
@@ -19589,19 +20953,19 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
     goto __pyx_L4;
   }
 
-  /* "pysam/csamtools.pyx":1896
+  /* "pysam/csamtools.pyx":2042
  *         if self.stepper == None or self.stepper == "all":
  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )
  *         elif self.stepper == "samtools":             # <<<<<<<<<<<<<<
  *             self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata )
  *         else:
  */
-  __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, ((PyObject *)__pyx_n_s__samtools), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(__pyx_v_self->stepper, ((PyObject *)__pyx_n_s__samtools), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_11 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_11 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (__pyx_t_11) {
 
-    /* "pysam/csamtools.pyx":1897
+    /* "pysam/csamtools.pyx":2043
  *             self.pileup_iter = bam_plp_init( &__advance_all, &self.iterdata )
  *         elif self.stepper == "samtools":
  *             self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata )             # <<<<<<<<<<<<<<
@@ -19613,30 +20977,30 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":1899
+    /* "pysam/csamtools.pyx":2045
  *             self.pileup_iter = bam_plp_init( &__advance_snpcalls, &self.iterdata )
  *         else:
  *             raise ValueError( "unknown stepper option `%s` in IteratorColumn" % self.stepper)             # <<<<<<<<<<<<<<
  * 
  *         if self.max_depth:
  */
-    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_131), __pyx_v_self->stepper); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_139), __pyx_v_self->stepper); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyTuple_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     PyTuple_SET_ITEM(__pyx_t_5, 0, ((PyObject *)__pyx_t_4));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
     __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
     __Pyx_Raise(__pyx_t_4, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1899; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":1901
+  /* "pysam/csamtools.pyx":2047
  *             raise ValueError( "unknown stepper option `%s` in IteratorColumn" % self.stepper)
  * 
  *         if self.max_depth:             # <<<<<<<<<<<<<<
@@ -19645,7 +21009,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
  */
   if (__pyx_v_self->max_depth) {
 
-    /* "pysam/csamtools.pyx":1902
+    /* "pysam/csamtools.pyx":2048
  * 
  *         if self.max_depth:
  *             bam_plp_set_maxcnt( self.pileup_iter, self.max_depth )             # <<<<<<<<<<<<<<
@@ -19657,7 +21021,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
   }
   __pyx_L5:;
 
-  /* "pysam/csamtools.pyx":1904
+  /* "pysam/csamtools.pyx":2050
  *             bam_plp_set_maxcnt( self.pileup_iter, self.max_depth )
  * 
  *         bam_plp_set_mask( self.pileup_iter, self.mask )             # <<<<<<<<<<<<<<
@@ -19683,7 +21047,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData(st
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1906
+/* "pysam/csamtools.pyx":2052
  *         bam_plp_set_mask( self.pileup_iter, self.mask )
  * 
  *     cdef reset( self, tid, start, end ):             # <<<<<<<<<<<<<<
@@ -19704,16 +21068,16 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_reset(struct __pyx_o
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("reset", 0);
-  __Pyx_TraceCall("reset", __pyx_f[0], 1906);
+  __Pyx_TraceCall("reset", __pyx_f[0], 2052);
 
-  /* "pysam/csamtools.pyx":1912
+  /* "pysam/csamtools.pyx":2058
  *         having to incur the full set-up costs.
  *         '''
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen = 0 )             # <<<<<<<<<<<<<<
  *         self.iterdata.iter = self.iter.iter
  * 
  */
-  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyTuple_New(4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(((PyObject *)__pyx_v_self->samfile));
   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_v_self->samfile));
@@ -19727,10 +21091,10 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_reset(struct __pyx_o
   __Pyx_INCREF(__pyx_v_end);
   PyTuple_SET_ITEM(__pyx_t_1, 3, __pyx_v_end);
   __Pyx_GIVEREF(__pyx_v_end);
-  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__reopen), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowRegion)), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1912; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__reopen), __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowRegion)), ((PyObject *)__pyx_t_1), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2058; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
@@ -19740,7 +21104,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_reset(struct __pyx_o
   __pyx_v_self->iter = ((struct __pyx_obj_5pysam_9csamtools_IteratorRowRegion *)__pyx_t_3);
   __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":1913
+  /* "pysam/csamtools.pyx":2059
  *         '''
  *         self.iter = IteratorRowRegion( self.samfile, tid, start, end, reopen = 0 )
  *         self.iterdata.iter = self.iter.iter             # <<<<<<<<<<<<<<
@@ -19750,22 +21114,22 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_reset(struct __pyx_o
   __pyx_t_4 = __pyx_v_self->iter->iter;
   __pyx_v_self->iterdata.iter = __pyx_t_4;
 
-  /* "pysam/csamtools.pyx":1916
+  /* "pysam/csamtools.pyx":2062
  * 
  *         # invalidate sequence if different tid
  *         if self.tid != tid:             # <<<<<<<<<<<<<<
  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )
  *             self.iterdata.seq = NULL
  */
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->tid); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_v_tid, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_v_tid, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2062; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_5) {
 
-    /* "pysam/csamtools.pyx":1917
+    /* "pysam/csamtools.pyx":2063
  *         # invalidate sequence if different tid
  *         if self.tid != tid:
  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )             # <<<<<<<<<<<<<<
@@ -19779,7 +21143,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_reset(struct __pyx_o
     }
     __pyx_L4:;
 
-    /* "pysam/csamtools.pyx":1918
+    /* "pysam/csamtools.pyx":2064
  *         if self.tid != tid:
  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )
  *             self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
@@ -19788,7 +21152,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_reset(struct __pyx_o
  */
     __pyx_v_self->iterdata.seq = NULL;
 
-    /* "pysam/csamtools.pyx":1919
+    /* "pysam/csamtools.pyx":2065
  *             if self.iterdata.seq != NULL: free( self.iterdata.seq )
  *             self.iterdata.seq = NULL
  *             self.iterdata.tid = -1             # <<<<<<<<<<<<<<
@@ -19800,7 +21164,7 @@ static PyObject *__pyx_f_5pysam_9csamtools_14IteratorColumn_reset(struct __pyx_o
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1922
+  /* "pysam/csamtools.pyx":2068
  * 
  *         # self.pileup_iter = bam_plp_init( &__advancepileup, &self.iterdata )
  *         bam_plp_reset(self.pileup_iter)             # <<<<<<<<<<<<<<
@@ -19833,12 +21197,12 @@ static void __pyx_pw_5pysam_9csamtools_14IteratorColumn_9__dealloc__(PyObject *_
   __Pyx_RefNannyFinishContext();
 }
 
-/* "pysam/csamtools.pyx":1924
+/* "pysam/csamtools.pyx":2070
  *         bam_plp_reset(self.pileup_iter)
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
- *         # reset in order to avoid memory leak messages for iterators that have
- *         # not been fully consumed
+ *         # reset in order to avoid memory leak messages for iterators
+ *         # that have not been fully consumed
  */
 
 static void __pyx_pf_5pysam_9csamtools_14IteratorColumn_8__dealloc__(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *__pyx_v_self) {
@@ -19846,11 +21210,11 @@ static void __pyx_pf_5pysam_9csamtools_14IteratorColumn_8__dealloc__(struct __py
   int __pyx_t_1;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__", 0);
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 1924);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 2070);
 
-  /* "pysam/csamtools.pyx":1927
- *         # reset in order to avoid memory leak messages for iterators that have
- *         # not been fully consumed
+  /* "pysam/csamtools.pyx":2073
+ *         # reset in order to avoid memory leak messages for iterators
+ *         # that have not been fully consumed
  *         if self.pileup_iter != <bam_plp_t>NULL:             # <<<<<<<<<<<<<<
  *             bam_plp_reset(self.pileup_iter)
  *             bam_plp_destroy(self.pileup_iter)
@@ -19858,8 +21222,8 @@ static void __pyx_pf_5pysam_9csamtools_14IteratorColumn_8__dealloc__(struct __py
   __pyx_t_1 = (__pyx_v_self->pileup_iter != NULL);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":1928
- *         # not been fully consumed
+    /* "pysam/csamtools.pyx":2074
+ *         # that have not been fully consumed
  *         if self.pileup_iter != <bam_plp_t>NULL:
  *             bam_plp_reset(self.pileup_iter)             # <<<<<<<<<<<<<<
  *             bam_plp_destroy(self.pileup_iter)
@@ -19867,29 +21231,38 @@ static void __pyx_pf_5pysam_9csamtools_14IteratorColumn_8__dealloc__(struct __py
  */
     bam_plp_reset(__pyx_v_self->pileup_iter);
 
-    /* "pysam/csamtools.pyx":1929
+    /* "pysam/csamtools.pyx":2075
  *         if self.pileup_iter != <bam_plp_t>NULL:
  *             bam_plp_reset(self.pileup_iter)
  *             bam_plp_destroy(self.pileup_iter)             # <<<<<<<<<<<<<<
  *             self.pileup_iter = <bam_plp_t>NULL
- * 
+ *             self.plp = <const_bam_pileup1_t_ptr>NULL
  */
     bam_plp_destroy(__pyx_v_self->pileup_iter);
 
-    /* "pysam/csamtools.pyx":1930
+    /* "pysam/csamtools.pyx":2076
  *             bam_plp_reset(self.pileup_iter)
  *             bam_plp_destroy(self.pileup_iter)
  *             self.pileup_iter = <bam_plp_t>NULL             # <<<<<<<<<<<<<<
+ *             self.plp = <const_bam_pileup1_t_ptr>NULL
  * 
- *         if self.iterdata.seq != NULL:
  */
     __pyx_v_self->pileup_iter = NULL;
+
+    /* "pysam/csamtools.pyx":2077
+ *             bam_plp_destroy(self.pileup_iter)
+ *             self.pileup_iter = <bam_plp_t>NULL
+ *             self.plp = <const_bam_pileup1_t_ptr>NULL             # <<<<<<<<<<<<<<
+ * 
+ *         if self.iterdata.seq != NULL:
+ */
+    __pyx_v_self->plp = ((const bam_pileup1_t *)NULL);
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1932
- *             self.pileup_iter = <bam_plp_t>NULL
+  /* "pysam/csamtools.pyx":2079
+ *             self.plp = <const_bam_pileup1_t_ptr>NULL
  * 
  *         if self.iterdata.seq != NULL:             # <<<<<<<<<<<<<<
  *             free(self.iterdata.seq)
@@ -19898,7 +21271,7 @@ static void __pyx_pf_5pysam_9csamtools_14IteratorColumn_8__dealloc__(struct __py
   __pyx_t_1 = (__pyx_v_self->iterdata.seq != NULL);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":1933
+    /* "pysam/csamtools.pyx":2080
  * 
  *         if self.iterdata.seq != NULL:
  *             free(self.iterdata.seq)             # <<<<<<<<<<<<<<
@@ -19907,7 +21280,7 @@ static void __pyx_pf_5pysam_9csamtools_14IteratorColumn_8__dealloc__(struct __py
  */
     free(__pyx_v_self->iterdata.seq);
 
-    /* "pysam/csamtools.pyx":1934
+    /* "pysam/csamtools.pyx":2081
  *         if self.iterdata.seq != NULL:
  *             free(self.iterdata.seq)
  *             self.iterdata.seq = NULL             # <<<<<<<<<<<<<<
@@ -19979,7 +21352,7 @@ static int __pyx_pw_5pysam_9csamtools_20IteratorColumnRegion_1__cinit__(PyObject
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1939; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -19994,25 +21367,25 @@ static int __pyx_pw_5pysam_9csamtools_20IteratorColumnRegion_1__cinit__(PyObject
     }
     __pyx_v_samfile = ((struct __pyx_obj_5pysam_9csamtools_Samfile *)values[0]);
     if (values[1]) {
-      __pyx_v_tid = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1940; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_tid = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_tid == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2087; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
       __pyx_v_tid = ((int)0);
     }
     if (values[2]) {
-      __pyx_v_start = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1941; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_start = __Pyx_PyInt_AsInt(values[2]); if (unlikely((__pyx_v_start == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2088; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
       __pyx_v_start = ((int)0);
     }
     if (values[3]) {
-      __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1942; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_end = __Pyx_PyInt_AsInt(values[3]); if (unlikely((__pyx_v_end == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2089; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
-      __pyx_v_end = __pyx_k_132;
+      __pyx_v_end = __pyx_k_140;
     }
     if (values[4]) {
-      __pyx_v_truncate = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_truncate == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1943; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_truncate = __Pyx_PyInt_AsInt(values[4]); if (unlikely((__pyx_v_truncate == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2090; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
 
-      /* "pysam/csamtools.pyx":1943
+      /* "pysam/csamtools.pyx":2090
  *                   int start = 0,
  *                   int end = max_pos,
  *                   int truncate = False,             # <<<<<<<<<<<<<<
@@ -20024,14 +21397,14 @@ static int __pyx_pw_5pysam_9csamtools_20IteratorColumnRegion_1__cinit__(PyObject
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1939; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 1, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
   __Pyx_AddTraceback("pysam.csamtools.IteratorColumnRegion.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_20IteratorColumnRegion___cinit__(((struct __pyx_obj_5pysam_9csamtools_IteratorColumnRegion *)__pyx_v_self), __pyx_v_samfile, __pyx_v_tid, __pyx_v_start, __pyx_v_end, __pyx_v_truncate, __pyx_v_kwargs);
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -20042,7 +21415,7 @@ static int __pyx_pw_5pysam_9csamtools_20IteratorColumnRegion_1__cinit__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1939
+/* "pysam/csamtools.pyx":2086
  *     '''iterates over a region only.
  *     '''
  *     def __cinit__(self, Samfile samfile,             # <<<<<<<<<<<<<<
@@ -20060,9 +21433,9 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorColumnRegion___cinit__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__", 0);
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1939);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 2086);
 
-  /* "pysam/csamtools.pyx":1947
+  /* "pysam/csamtools.pyx":2094
  * 
  *         # initialize iterator
  *         self.setupIteratorData( tid, start, end, 1 )             # <<<<<<<<<<<<<<
@@ -20071,11 +21444,11 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorColumnRegion___cinit__(struct __
  */
   __pyx_t_2.__pyx_n = 1;
   __pyx_t_2.reopen = 1;
-  __pyx_t_1 = ((struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnRegion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_5pysam_9csamtools_IteratorColumn *)__pyx_v_self), __pyx_v_tid, __pyx_v_start, __pyx_v_end, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1947; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnRegion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_5pysam_9csamtools_IteratorColumn *)__pyx_v_self), __pyx_v_tid, __pyx_v_start, __pyx_v_end, &__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2094; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":1948
+  /* "pysam/csamtools.pyx":2095
  *         # initialize iterator
  *         self.setupIteratorData( tid, start, end, 1 )
  *         self.start = start             # <<<<<<<<<<<<<<
@@ -20084,7 +21457,7 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorColumnRegion___cinit__(struct __
  */
   __pyx_v_self->start = __pyx_v_start;
 
-  /* "pysam/csamtools.pyx":1949
+  /* "pysam/csamtools.pyx":2096
  *         self.setupIteratorData( tid, start, end, 1 )
  *         self.start = start
  *         self.end = end             # <<<<<<<<<<<<<<
@@ -20093,7 +21466,7 @@ static int __pyx_pf_5pysam_9csamtools_20IteratorColumnRegion___cinit__(struct __
  */
   __pyx_v_self->end = __pyx_v_end;
 
-  /* "pysam/csamtools.pyx":1950
+  /* "pysam/csamtools.pyx":2097
  *         self.start = start
  *         self.end = end
  *         self.truncate = truncate             # <<<<<<<<<<<<<<
@@ -20129,7 +21502,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_20IteratorColumnRegion_3__next__(PyO
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1952
+/* "pysam/csamtools.pyx":2099
  *         self.truncate = truncate
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -20147,9 +21520,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorColumnRegion_2__next__(str
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__", 0);
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1952);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 2099);
 
-  /* "pysam/csamtools.pyx":1956
+  /* "pysam/csamtools.pyx":2103
  *         """
  * 
  *         while 1:             # <<<<<<<<<<<<<<
@@ -20159,7 +21532,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorColumnRegion_2__next__(str
   while (1) {
     if (!1) break;
 
-    /* "pysam/csamtools.pyx":1957
+    /* "pysam/csamtools.pyx":2104
  * 
  *         while 1:
  *             self.cnext()             # <<<<<<<<<<<<<<
@@ -20168,7 +21541,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorColumnRegion_2__next__(str
  */
     ((struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnRegion *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.cnext(((struct __pyx_obj_5pysam_9csamtools_IteratorColumn *)__pyx_v_self));
 
-    /* "pysam/csamtools.pyx":1958
+    /* "pysam/csamtools.pyx":2105
  *         while 1:
  *             self.cnext()
  *             if self.n_plp < 0:             # <<<<<<<<<<<<<<
@@ -20178,23 +21551,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorColumnRegion_2__next__(str
     __pyx_t_1 = (__pyx_v_self->__pyx_base.n_plp < 0);
     if (__pyx_t_1) {
 
-      /* "pysam/csamtools.pyx":1959
+      /* "pysam/csamtools.pyx":2106
  *             self.cnext()
  *             if self.n_plp < 0:
  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
  * 
  *             if self.plp == NULL:
  */
-      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_134), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_142), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_Raise(__pyx_t_2, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L5;
     }
     __pyx_L5:;
 
-    /* "pysam/csamtools.pyx":1961
+    /* "pysam/csamtools.pyx":2108
  *                 raise ValueError("error during iteration" )
  * 
  *             if self.plp == NULL:             # <<<<<<<<<<<<<<
@@ -20204,7 +21577,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorColumnRegion_2__next__(str
     __pyx_t_1 = (__pyx_v_self->__pyx_base.plp == NULL);
     if (__pyx_t_1) {
 
-      /* "pysam/csamtools.pyx":1962
+      /* "pysam/csamtools.pyx":2109
  * 
  *             if self.plp == NULL:
  *                 raise StopIteration             # <<<<<<<<<<<<<<
@@ -20212,12 +21585,12 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorColumnRegion_2__next__(str
  *             if self.truncate:
  */
       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L6;
     }
     __pyx_L6:;
 
-    /* "pysam/csamtools.pyx":1964
+    /* "pysam/csamtools.pyx":2111
  *                 raise StopIteration
  * 
  *             if self.truncate:             # <<<<<<<<<<<<<<
@@ -20226,7 +21599,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorColumnRegion_2__next__(str
  */
     if (__pyx_v_self->truncate) {
 
-      /* "pysam/csamtools.pyx":1965
+      /* "pysam/csamtools.pyx":2112
  * 
  *             if self.truncate:
  *                 if self.start > self.pos: continue             # <<<<<<<<<<<<<<
@@ -20240,7 +21613,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorColumnRegion_2__next__(str
       }
       __pyx_L8:;
 
-      /* "pysam/csamtools.pyx":1966
+      /* "pysam/csamtools.pyx":2113
  *             if self.truncate:
  *                 if self.start > self.pos: continue
  *                 if self.pos >= self.end: raise StopIteration             # <<<<<<<<<<<<<<
@@ -20250,7 +21623,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorColumnRegion_2__next__(str
       __pyx_t_1 = (__pyx_v_self->__pyx_base.pos >= __pyx_v_self->end);
       if (__pyx_t_1) {
         __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2113; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L9;
       }
       __pyx_L9:;
@@ -20258,7 +21631,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorColumnRegion_2__next__(str
     }
     __pyx_L7:;
 
-    /* "pysam/csamtools.pyx":1968
+    /* "pysam/csamtools.pyx":2115
  *                 if self.pos >= self.end: raise StopIteration
  * 
  *             return makePileupProxy( &self.plp,             # <<<<<<<<<<<<<<
@@ -20267,14 +21640,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_20IteratorColumnRegion_2__next__(str
  */
     __Pyx_XDECREF(__pyx_r);
 
-    /* "pysam/csamtools.pyx":1971
+    /* "pysam/csamtools.pyx":2118
  *                                      self.tid,
  *                                      self.pos,
  *                                      self.n_plp )             # <<<<<<<<<<<<<<
  * 
  * cdef class IteratorColumnAllRefs(IteratorColumn):
  */
-    __pyx_t_2 = __pyx_f_5pysam_9csamtools_makePileupProxy((&__pyx_v_self->__pyx_base.plp), __pyx_v_self->__pyx_base.tid, __pyx_v_self->__pyx_base.pos, __pyx_v_self->__pyx_base.n_plp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __pyx_f_5pysam_9csamtools_makePileupProxy((&__pyx_v_self->__pyx_base.plp), __pyx_v_self->__pyx_base.tid, __pyx_v_self->__pyx_base.pos, __pyx_v_self->__pyx_base.n_plp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_r = __pyx_t_2;
     __pyx_t_2 = 0;
@@ -20323,7 +21696,7 @@ static int __pyx_pw_5pysam_9csamtools_21IteratorColumnAllRefs_1__cinit__(PyObjec
         else goto __pyx_L5_argtuple_error;
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, __pyx_v_kwargs, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else if (PyTuple_GET_SIZE(__pyx_args) != 1) {
       goto __pyx_L5_argtuple_error;
@@ -20334,14 +21707,14 @@ static int __pyx_pw_5pysam_9csamtools_21IteratorColumnAllRefs_1__cinit__(PyObjec
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1977; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2124; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_DECREF(__pyx_v_kwargs); __pyx_v_kwargs = 0;
   __Pyx_AddTraceback("pysam.csamtools.IteratorColumnAllRefs.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs___cinit__(((struct __pyx_obj_5pysam_9csamtools_IteratorColumnAllRefs *)__pyx_v_self), __pyx_v_samfile, __pyx_v_kwargs);
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -20352,7 +21725,7 @@ static int __pyx_pw_5pysam_9csamtools_21IteratorColumnAllRefs_1__cinit__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1977
+/* "pysam/csamtools.pyx":2124
  *     """
  * 
  *     def __cinit__(self,             # <<<<<<<<<<<<<<
@@ -20372,28 +21745,28 @@ static int __pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs___cinit__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__cinit__", 0);
-  __Pyx_TraceCall("__cinit__", __pyx_f[0], 1977);
+  __Pyx_TraceCall("__cinit__", __pyx_f[0], 2124);
 
-  /* "pysam/csamtools.pyx":1982
+  /* "pysam/csamtools.pyx":2129
  * 
  *         # no iteration over empty files
  *         if not samfile.nreferences: raise StopIteration             # <<<<<<<<<<<<<<
  * 
  *         # initialize iterator
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_t_3 = (!__pyx_t_2);
   if (__pyx_t_3) {
     __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2129; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":1985
+  /* "pysam/csamtools.pyx":2132
  * 
  *         # initialize iterator
  *         self.setupIteratorData( self.tid, 0, max_pos, 1 )             # <<<<<<<<<<<<<<
@@ -20402,7 +21775,7 @@ static int __pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs___cinit__(struct _
  */
   __pyx_t_4.__pyx_n = 1;
   __pyx_t_4.reopen = 1;
-  __pyx_t_1 = ((struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnAllRefs *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_5pysam_9csamtools_IteratorColumn *)__pyx_v_self), __pyx_v_self->__pyx_base.tid, 0, __pyx_v_5pysam_9csamtools_max_pos, &__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnAllRefs *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_5pysam_9csamtools_IteratorColumn *)__pyx_v_self), __pyx_v_self->__pyx_base.tid, 0, __pyx_v_5pysam_9csamtools_max_pos, &__pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
@@ -20433,7 +21806,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_21IteratorColumnAllRefs_3__next__(Py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":1987
+/* "pysam/csamtools.pyx":2134
  *         self.setupIteratorData( self.tid, 0, max_pos, 1 )
  * 
  *     def __next__(self):             # <<<<<<<<<<<<<<
@@ -20454,9 +21827,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__(st
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__next__", 0);
-  __Pyx_TraceCall("__next__", __pyx_f[0], 1987);
+  __Pyx_TraceCall("__next__", __pyx_f[0], 2134);
 
-  /* "pysam/csamtools.pyx":1991
+  /* "pysam/csamtools.pyx":2138
  *         """
  * 
  *         while 1:             # <<<<<<<<<<<<<<
@@ -20466,7 +21839,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__(st
   while (1) {
     if (!1) break;
 
-    /* "pysam/csamtools.pyx":1992
+    /* "pysam/csamtools.pyx":2139
  * 
  *         while 1:
  *             self.cnext()             # <<<<<<<<<<<<<<
@@ -20475,7 +21848,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__(st
  */
     ((struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnAllRefs *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.cnext(((struct __pyx_obj_5pysam_9csamtools_IteratorColumn *)__pyx_v_self));
 
-    /* "pysam/csamtools.pyx":1994
+    /* "pysam/csamtools.pyx":2141
  *             self.cnext()
  * 
  *             if self.n_plp < 0:             # <<<<<<<<<<<<<<
@@ -20485,23 +21858,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__(st
     __pyx_t_1 = (__pyx_v_self->__pyx_base.n_plp < 0);
     if (__pyx_t_1) {
 
-      /* "pysam/csamtools.pyx":1995
+      /* "pysam/csamtools.pyx":2142
  * 
  *             if self.n_plp < 0:
  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
  * 
  *             # return result, if within same reference
  */
-      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_135), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_143), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_Raise(__pyx_t_2, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L5;
     }
     __pyx_L5:;
 
-    /* "pysam/csamtools.pyx":1998
+    /* "pysam/csamtools.pyx":2145
  * 
  *             # return result, if within same reference
  *             if self.plp != NULL:             # <<<<<<<<<<<<<<
@@ -20511,7 +21884,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__(st
     __pyx_t_1 = (__pyx_v_self->__pyx_base.plp != NULL);
     if (__pyx_t_1) {
 
-      /* "pysam/csamtools.pyx":1999
+      /* "pysam/csamtools.pyx":2146
  *             # return result, if within same reference
  *             if self.plp != NULL:
  *                 return makePileupProxy( &self.plp,             # <<<<<<<<<<<<<<
@@ -20520,14 +21893,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__(st
  */
       __Pyx_XDECREF(__pyx_r);
 
-      /* "pysam/csamtools.pyx":2002
+      /* "pysam/csamtools.pyx":2149
  *                                          self.tid,
  *                                          self.pos,
  *                                          self.n_plp )             # <<<<<<<<<<<<<<
  * 
  *             # otherwise, proceed to next reference or stop
  */
-      __pyx_t_2 = __pyx_f_5pysam_9csamtools_makePileupProxy((&__pyx_v_self->__pyx_base.plp), __pyx_v_self->__pyx_base.tid, __pyx_v_self->__pyx_base.pos, __pyx_v_self->__pyx_base.n_plp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = __pyx_f_5pysam_9csamtools_makePileupProxy((&__pyx_v_self->__pyx_base.plp), __pyx_v_self->__pyx_base.tid, __pyx_v_self->__pyx_base.pos, __pyx_v_self->__pyx_base.n_plp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __pyx_r = __pyx_t_2;
       __pyx_t_2 = 0;
@@ -20536,7 +21909,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__(st
     }
     __pyx_L6:;
 
-    /* "pysam/csamtools.pyx":2005
+    /* "pysam/csamtools.pyx":2152
  * 
  *             # otherwise, proceed to next reference or stop
  *             self.tid += 1             # <<<<<<<<<<<<<<
@@ -20545,25 +21918,25 @@ static PyObject *__pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__(st
  */
     __pyx_v_self->__pyx_base.tid = (__pyx_v_self->__pyx_base.tid + 1);
 
-    /* "pysam/csamtools.pyx":2006
+    /* "pysam/csamtools.pyx":2153
  *             # otherwise, proceed to next reference or stop
  *             self.tid += 1
  *             if self.tid < self.samfile.nreferences:             # <<<<<<<<<<<<<<
  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )
  *             else:
  */
-    __pyx_t_2 = PyInt_FromLong(__pyx_v_self->__pyx_base.tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyInt_FromLong(__pyx_v_self->__pyx_base.tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self->__pyx_base.samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self->__pyx_base.samfile), __pyx_n_s__nreferences); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_LT); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2153; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     if (__pyx_t_1) {
 
-      /* "pysam/csamtools.pyx":2007
+      /* "pysam/csamtools.pyx":2154
  *             self.tid += 1
  *             if self.tid < self.samfile.nreferences:
  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )             # <<<<<<<<<<<<<<
@@ -20572,14 +21945,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__(st
  */
       __pyx_t_5.__pyx_n = 1;
       __pyx_t_5.reopen = 0;
-      __pyx_t_4 = ((struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnAllRefs *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_5pysam_9csamtools_IteratorColumn *)__pyx_v_self), __pyx_v_self->__pyx_base.tid, 0, __pyx_v_5pysam_9csamtools_max_pos, &__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = ((struct __pyx_vtabstruct_5pysam_9csamtools_IteratorColumnAllRefs *)__pyx_v_self->__pyx_base.__pyx_vtab)->__pyx_base.setupIteratorData(((struct __pyx_obj_5pysam_9csamtools_IteratorColumn *)__pyx_v_self), __pyx_v_self->__pyx_base.tid, 0, __pyx_v_5pysam_9csamtools_max_pos, &__pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
       goto __pyx_L7;
     }
     /*else*/ {
 
-      /* "pysam/csamtools.pyx":2009
+      /* "pysam/csamtools.pyx":2156
  *                 self.setupIteratorData( self.tid, 0, max_pos, 0 )
  *             else:
  *                 raise StopIteration             # <<<<<<<<<<<<<<
@@ -20587,7 +21960,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__(st
  * ##-------------------------------------------------------------------
  */
       __Pyx_Raise(__pyx_builtin_StopIteration, 0, 0, 0);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2009; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     __pyx_L7:;
   }
@@ -20607,7 +21980,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__(st
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2014
+/* "pysam/csamtools.pyx":2161
  * ##-------------------------------------------------------------------
  * ##-------------------------------------------------------------------
  * cdef inline int32_t query_start(bam1_t *src) except -1:             # <<<<<<<<<<<<<<
@@ -20628,9 +22001,9 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("query_start", 0);
-  __Pyx_TraceCall("query_start", __pyx_f[0], 2014);
+  __Pyx_TraceCall("query_start", __pyx_f[0], 2161);
 
-  /* "pysam/csamtools.pyx":2017
+  /* "pysam/csamtools.pyx":2164
  *     cdef uint32_t * cigar_p, op
  *     cdef uint32_t k
  *     cdef uint32_t start_offset = 0             # <<<<<<<<<<<<<<
@@ -20639,7 +22012,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
  */
   __pyx_v_start_offset = 0;
 
-  /* "pysam/csamtools.pyx":2019
+  /* "pysam/csamtools.pyx":2166
  *     cdef uint32_t start_offset = 0
  * 
  *     if src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -20648,7 +22021,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
  */
   if (__pyx_v_src->core.n_cigar) {
 
-    /* "pysam/csamtools.pyx":2020
+    /* "pysam/csamtools.pyx":2167
  * 
  *     if src.core.n_cigar:
  *         cigar_p = bam1_cigar(src);             # <<<<<<<<<<<<<<
@@ -20657,7 +22030,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
  */
     __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-    /* "pysam/csamtools.pyx":2021
+    /* "pysam/csamtools.pyx":2168
  *     if src.core.n_cigar:
  *         cigar_p = bam1_cigar(src);
  *         for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -20667,7 +22040,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
     __pyx_t_1 = __pyx_v_src->core.n_cigar;
     for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_1; __pyx_v_k++) {
 
-      /* "pysam/csamtools.pyx":2022
+      /* "pysam/csamtools.pyx":2169
  *         cigar_p = bam1_cigar(src);
  *         for k from 0 <= k < src.core.n_cigar:
  *             op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
@@ -20676,7 +22049,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
  */
       __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
 
-      /* "pysam/csamtools.pyx":2027
+      /* "pysam/csamtools.pyx":2174
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
@@ -20685,7 +22058,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
  */
       switch (__pyx_v_op) {
 
-        /* "pysam/csamtools.pyx":2023
+        /* "pysam/csamtools.pyx":2170
  *         for k from 0 <= k < src.core.n_cigar:
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             if op==BAM_CHARD_CLIP:             # <<<<<<<<<<<<<<
@@ -20694,7 +22067,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
  */
         case 5:
 
-        /* "pysam/csamtools.pyx":2024
+        /* "pysam/csamtools.pyx":2171
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             if op==BAM_CHARD_CLIP:
  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:             # <<<<<<<<<<<<<<
@@ -20710,16 +22083,16 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
         }
         if (__pyx_t_4) {
 
-          /* "pysam/csamtools.pyx":2025
+          /* "pysam/csamtools.pyx":2172
  *             if op==BAM_CHARD_CLIP:
  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')             # <<<<<<<<<<<<<<
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:
  */
-          PyErr_SetString(__pyx_builtin_ValueError, __pyx_k_136);
+          PyErr_SetString(__pyx_builtin_ValueError, __pyx_k_144);
 
-          /* "pysam/csamtools.pyx":2026
+          /* "pysam/csamtools.pyx":2173
  *                 if start_offset!=0 and start_offset!=src.core.l_qseq:
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1             # <<<<<<<<<<<<<<
@@ -20733,7 +22106,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
         __pyx_L6:;
         break;
 
-        /* "pysam/csamtools.pyx":2027
+        /* "pysam/csamtools.pyx":2174
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
@@ -20742,7 +22115,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
  */
         case 4:
 
-        /* "pysam/csamtools.pyx":2028
+        /* "pysam/csamtools.pyx":2175
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:
  *                 start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
@@ -20753,7 +22126,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
         break;
         default:
 
-        /* "pysam/csamtools.pyx":2030
+        /* "pysam/csamtools.pyx":2177
  *                 start_offset += cigar_p[k] >> BAM_CIGAR_SHIFT
  *             else:
  *                 break             # <<<<<<<<<<<<<<
@@ -20769,7 +22142,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2032
+  /* "pysam/csamtools.pyx":2179
  *                 break
  * 
  *     return start_offset             # <<<<<<<<<<<<<<
@@ -20786,7 +22159,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_start(bam1_t *__pyx
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2037
+/* "pysam/csamtools.pyx":2184
  * ##-------------------------------------------------------------------
  * ##-------------------------------------------------------------------
  * cdef inline int32_t query_end(bam1_t *src) except -1:             # <<<<<<<<<<<<<<
@@ -20807,9 +22180,9 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
   int __pyx_t_4;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("query_end", 0);
-  __Pyx_TraceCall("query_end", __pyx_f[0], 2037);
+  __Pyx_TraceCall("query_end", __pyx_f[0], 2184);
 
-  /* "pysam/csamtools.pyx":2040
+  /* "pysam/csamtools.pyx":2187
  *     cdef uint32_t * cigar_p, op
  *     cdef uint32_t k
  *     cdef uint32_t end_offset = src.core.l_qseq             # <<<<<<<<<<<<<<
@@ -20819,7 +22192,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
   __pyx_t_1 = __pyx_v_src->core.l_qseq;
   __pyx_v_end_offset = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2042
+  /* "pysam/csamtools.pyx":2189
  *     cdef uint32_t end_offset = src.core.l_qseq
  * 
  *     if src.core.n_cigar>1:             # <<<<<<<<<<<<<<
@@ -20829,7 +22202,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
   __pyx_t_2 = (__pyx_v_src->core.n_cigar > 1);
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":2043
+    /* "pysam/csamtools.pyx":2190
  * 
  *     if src.core.n_cigar>1:
  *         cigar_p = bam1_cigar(src);             # <<<<<<<<<<<<<<
@@ -20838,7 +22211,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
  */
     __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-    /* "pysam/csamtools.pyx":2044
+    /* "pysam/csamtools.pyx":2191
  *     if src.core.n_cigar>1:
  *         cigar_p = bam1_cigar(src);
  *         for k from src.core.n_cigar > k >= 1:             # <<<<<<<<<<<<<<
@@ -20847,7 +22220,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
  */
     for (__pyx_v_k = __pyx_v_src->core.n_cigar-1; __pyx_v_k >= 1; __pyx_v_k--) {
 
-      /* "pysam/csamtools.pyx":2045
+      /* "pysam/csamtools.pyx":2192
  *         cigar_p = bam1_cigar(src);
  *         for k from src.core.n_cigar > k >= 1:
  *             op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
@@ -20856,7 +22229,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
  */
       __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
 
-      /* "pysam/csamtools.pyx":2050
+      /* "pysam/csamtools.pyx":2197
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
@@ -20865,7 +22238,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
  */
       switch (__pyx_v_op) {
 
-        /* "pysam/csamtools.pyx":2046
+        /* "pysam/csamtools.pyx":2193
  *         for k from src.core.n_cigar > k >= 1:
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             if op==BAM_CHARD_CLIP:             # <<<<<<<<<<<<<<
@@ -20874,7 +22247,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
  */
         case 5:
 
-        /* "pysam/csamtools.pyx":2047
+        /* "pysam/csamtools.pyx":2194
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             if op==BAM_CHARD_CLIP:
  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:             # <<<<<<<<<<<<<<
@@ -20890,16 +22263,16 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
         }
         if (__pyx_t_4) {
 
-          /* "pysam/csamtools.pyx":2048
+          /* "pysam/csamtools.pyx":2195
  *             if op==BAM_CHARD_CLIP:
  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')             # <<<<<<<<<<<<<<
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:
  */
-          PyErr_SetString(__pyx_builtin_ValueError, __pyx_k_136);
+          PyErr_SetString(__pyx_builtin_ValueError, __pyx_k_144);
 
-          /* "pysam/csamtools.pyx":2049
+          /* "pysam/csamtools.pyx":2196
  *                 if end_offset!=0 and end_offset!=src.core.l_qseq:
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1             # <<<<<<<<<<<<<<
@@ -20913,7 +22286,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
         __pyx_L6:;
         break;
 
-        /* "pysam/csamtools.pyx":2050
+        /* "pysam/csamtools.pyx":2197
  *                     PyErr_SetString(ValueError, 'Invalid clipping in CIGAR string')
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
@@ -20922,7 +22295,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
  */
         case 4:
 
-        /* "pysam/csamtools.pyx":2051
+        /* "pysam/csamtools.pyx":2198
  *                     return -1
  *             elif op==BAM_CSOFT_CLIP:
  *                 end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
@@ -20933,7 +22306,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
         break;
         default:
 
-        /* "pysam/csamtools.pyx":2053
+        /* "pysam/csamtools.pyx":2200
  *                 end_offset -= cigar_p[k] >> BAM_CIGAR_SHIFT
  *             else:
  *                 break             # <<<<<<<<<<<<<<
@@ -20949,7 +22322,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2055
+  /* "pysam/csamtools.pyx":2202
  *                 break
  * 
  *     if end_offset==0:             # <<<<<<<<<<<<<<
@@ -20959,7 +22332,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
   __pyx_t_4 = (__pyx_v_end_offset == 0);
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":2056
+    /* "pysam/csamtools.pyx":2203
  * 
  *     if end_offset==0:
  *         end_offset = src.core.l_qseq             # <<<<<<<<<<<<<<
@@ -20972,7 +22345,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
   }
   __pyx_L7:;
 
-  /* "pysam/csamtools.pyx":2058
+  /* "pysam/csamtools.pyx":2205
  *         end_offset = src.core.l_qseq
  * 
  *     return end_offset             # <<<<<<<<<<<<<<
@@ -20989,7 +22362,7 @@ static CYTHON_INLINE int32_t __pyx_f_5pysam_9csamtools_query_end(bam1_t *__pyx_v
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2061
+/* "pysam/csamtools.pyx":2208
  * 
  * 
  * cdef inline object get_seq_range(bam1_t *src, uint32_t start, uint32_t end):             # <<<<<<<<<<<<<<
@@ -21013,9 +22386,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_seq_range(bam1_t *_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("get_seq_range", 0);
-  __Pyx_TraceCall("get_seq_range", __pyx_f[0], 2061);
+  __Pyx_TraceCall("get_seq_range", __pyx_f[0], 2208);
 
-  /* "pysam/csamtools.pyx":2066
+  /* "pysam/csamtools.pyx":2213
  *     cdef char * s
  * 
  *     if not src.core.l_qseq:             # <<<<<<<<<<<<<<
@@ -21025,7 +22398,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_seq_range(bam1_t *_
   __pyx_t_1 = (!__pyx_v_src->core.l_qseq);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":2067
+    /* "pysam/csamtools.pyx":2214
  * 
  *     if not src.core.l_qseq:
  *         return None             # <<<<<<<<<<<<<<
@@ -21040,29 +22413,29 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_seq_range(bam1_t *_
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2069
+  /* "pysam/csamtools.pyx":2216
  *         return None
  * 
  *     seq = PyBytes_FromStringAndSize(NULL, end - start)             # <<<<<<<<<<<<<<
  *     s   = <char*>seq
  *     p   = bam1_seq(src)
  */
-  __pyx_t_2 = ((PyObject *)PyBytes_FromStringAndSize(NULL, (__pyx_v_end - __pyx_v_start))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = ((PyObject *)PyBytes_FromStringAndSize(NULL, (__pyx_v_end - __pyx_v_start))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_v_seq = ((PyObject*)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":2070
+  /* "pysam/csamtools.pyx":2217
  * 
  *     seq = PyBytes_FromStringAndSize(NULL, end - start)
  *     s   = <char*>seq             # <<<<<<<<<<<<<<
  *     p   = bam1_seq(src)
  * 
  */
-  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_seq)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_seq)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_s = ((char *)__pyx_t_3);
 
-  /* "pysam/csamtools.pyx":2071
+  /* "pysam/csamtools.pyx":2218
  *     seq = PyBytes_FromStringAndSize(NULL, end - start)
  *     s   = <char*>seq
  *     p   = bam1_seq(src)             # <<<<<<<<<<<<<<
@@ -21071,7 +22444,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_seq_range(bam1_t *_
  */
   __pyx_v_p = bam1_seq(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2073
+  /* "pysam/csamtools.pyx":2220
  *     p   = bam1_seq(src)
  * 
  *     for k from start <= k < end:             # <<<<<<<<<<<<<<
@@ -21081,7 +22454,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_seq_range(bam1_t *_
   __pyx_t_4 = __pyx_v_end;
   for (__pyx_v_k = __pyx_v_start; __pyx_v_k < __pyx_t_4; __pyx_v_k++) {
 
-    /* "pysam/csamtools.pyx":2076
+    /* "pysam/csamtools.pyx":2223
  *         # equivalent to bam_nt16_rev_table[bam1_seqi(s, i)] (see bam.c)
  *         # note: do not use string literal as it will be a python string
  *         s[k-start] = bam_nt16_rev_table[p[k/2] >> 4 * (1 - k%2) & 0xf]             # <<<<<<<<<<<<<<
@@ -21091,7 +22464,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_seq_range(bam1_t *_
     (__pyx_v_s[(__pyx_v_k - __pyx_v_start)]) = (__pyx_v_5pysam_9csamtools_bam_nt16_rev_table[(((__pyx_v_p[__Pyx_div_long(__pyx_v_k, 2)]) >> (4 * (1 - __Pyx_mod_long(__pyx_v_k, 2)))) & 0xf)]);
   }
 
-  /* "pysam/csamtools.pyx":2078
+  /* "pysam/csamtools.pyx":2225
  *         s[k-start] = bam_nt16_rev_table[p[k/2] >> 4 * (1 - k%2) & 0xf]
  * 
  *     return seq             # <<<<<<<<<<<<<<
@@ -21117,7 +22490,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_seq_range(bam1_t *_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2081
+/* "pysam/csamtools.pyx":2228
  * 
  * 
  * cdef inline object get_qual_range(bam1_t *src, uint32_t start, uint32_t end):             # <<<<<<<<<<<<<<
@@ -21141,9 +22514,9 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_qual_range(bam1_t *
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("get_qual_range", 0);
-  __Pyx_TraceCall("get_qual_range", __pyx_f[0], 2081);
+  __Pyx_TraceCall("get_qual_range", __pyx_f[0], 2228);
 
-  /* "pysam/csamtools.pyx":2086
+  /* "pysam/csamtools.pyx":2233
  *     cdef char * q
  * 
  *     p = bam1_qual(src)             # <<<<<<<<<<<<<<
@@ -21152,7 +22525,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_qual_range(bam1_t *
  */
   __pyx_v_p = bam1_qual(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2087
+  /* "pysam/csamtools.pyx":2234
  * 
  *     p = bam1_qual(src)
  *     if p[0] == 0xff:             # <<<<<<<<<<<<<<
@@ -21162,7 +22535,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_qual_range(bam1_t *
   __pyx_t_1 = ((__pyx_v_p[0]) == 0xff);
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":2088
+    /* "pysam/csamtools.pyx":2235
  *     p = bam1_qual(src)
  *     if p[0] == 0xff:
  *         return None             # <<<<<<<<<<<<<<
@@ -21177,29 +22550,29 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_qual_range(bam1_t *
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2090
+  /* "pysam/csamtools.pyx":2237
  *         return None
  * 
  *     qual = PyBytes_FromStringAndSize(NULL, end - start)             # <<<<<<<<<<<<<<
  *     q    = <char*>qual
  * 
  */
-  __pyx_t_2 = ((PyObject *)PyBytes_FromStringAndSize(NULL, (__pyx_v_end - __pyx_v_start))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2090; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = ((PyObject *)PyBytes_FromStringAndSize(NULL, (__pyx_v_end - __pyx_v_start))); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_v_qual = ((PyObject*)__pyx_t_2);
   __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":2091
+  /* "pysam/csamtools.pyx":2238
  * 
  *     qual = PyBytes_FromStringAndSize(NULL, end - start)
  *     q    = <char*>qual             # <<<<<<<<<<<<<<
  * 
  *     for k from start <= k < end:
  */
-  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_qual)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_qual)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2238; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_q = ((char *)__pyx_t_3);
 
-  /* "pysam/csamtools.pyx":2093
+  /* "pysam/csamtools.pyx":2240
  *     q    = <char*>qual
  * 
  *     for k from start <= k < end:             # <<<<<<<<<<<<<<
@@ -21209,7 +22582,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_qual_range(bam1_t *
   __pyx_t_4 = __pyx_v_end;
   for (__pyx_v_k = __pyx_v_start; __pyx_v_k < __pyx_t_4; __pyx_v_k++) {
 
-    /* "pysam/csamtools.pyx":2095
+    /* "pysam/csamtools.pyx":2242
  *     for k from start <= k < end:
  *         ## equivalent to t[i] + 33 (see bam.c)
  *         q[k-start] = p[k] + 33             # <<<<<<<<<<<<<<
@@ -21219,7 +22592,7 @@ static CYTHON_INLINE PyObject *__pyx_f_5pysam_9csamtools_get_qual_range(bam1_t *
     (__pyx_v_q[(__pyx_v_k - __pyx_v_start)]) = ((__pyx_v_p[__pyx_v_k]) + 33);
   }
 
-  /* "pysam/csamtools.pyx":2097
+  /* "pysam/csamtools.pyx":2244
  *         q[k-start] = p[k] + 33
  * 
  *     return qual             # <<<<<<<<<<<<<<
@@ -21259,7 +22632,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_1__init__(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2129
+/* "pysam/csamtools.pyx":2276
  * 
  *     # Now only called when instances are created from Python
  *     def __init__(self):             # <<<<<<<<<<<<<<
@@ -21272,9 +22645,9 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead___init__(struct __pyx_obj_5p
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__", 0);
-  __Pyx_TraceCall("__init__", __pyx_f[0], 2129);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 2276);
 
-  /* "pysam/csamtools.pyx":2131
+  /* "pysam/csamtools.pyx":2278
  *     def __init__(self):
  *         # see bam_init1
  *         self._delegate = <bam1_t*>calloc( 1, sizeof( bam1_t) )             # <<<<<<<<<<<<<<
@@ -21283,7 +22656,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead___init__(struct __pyx_obj_5p
  */
   __pyx_v_self->_delegate = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
 
-  /* "pysam/csamtools.pyx":2135
+  /* "pysam/csamtools.pyx":2282
  *         # If size is 0, calloc does not return a pointer that can be passed to free()
  *         # so allocate 40 bytes for a new read
  *         self._delegate.m_data = 40             # <<<<<<<<<<<<<<
@@ -21292,7 +22665,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead___init__(struct __pyx_obj_5p
  */
   __pyx_v_self->_delegate->m_data = 40;
 
-  /* "pysam/csamtools.pyx":2136
+  /* "pysam/csamtools.pyx":2283
  *         # so allocate 40 bytes for a new read
  *         self._delegate.m_data = 40
  *         self._delegate.data = <uint8_t *>calloc( self._delegate.m_data, 1 )             # <<<<<<<<<<<<<<
@@ -21301,7 +22674,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead___init__(struct __pyx_obj_5p
  */
   __pyx_v_self->_delegate->data = ((uint8_t *)calloc(__pyx_v_self->_delegate->m_data, 1));
 
-  /* "pysam/csamtools.pyx":2137
+  /* "pysam/csamtools.pyx":2284
  *         self._delegate.m_data = 40
  *         self._delegate.data = <uint8_t *>calloc( self._delegate.m_data, 1 )
  *         self._delegate.data_len = 0             # <<<<<<<<<<<<<<
@@ -21325,7 +22698,7 @@ static void __pyx_pw_5pysam_9csamtools_11AlignedRead_3__dealloc__(PyObject *__py
   __Pyx_RefNannyFinishContext();
 }
 
-/* "pysam/csamtools.pyx":2139
+/* "pysam/csamtools.pyx":2286
  *         self._delegate.data_len = 0
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -21337,9 +22710,9 @@ static void __pyx_pf_5pysam_9csamtools_11AlignedRead_2__dealloc__(struct __pyx_o
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__", 0);
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 2139);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 2286);
 
-  /* "pysam/csamtools.pyx":2140
+  /* "pysam/csamtools.pyx":2287
  * 
  *     def __dealloc__(self):
  *         bam_destroy1(self._delegate)             # <<<<<<<<<<<<<<
@@ -21367,7 +22740,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_5__str__(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2142
+/* "pysam/csamtools.pyx":2289
  *         bam_destroy1(self._delegate)
  * 
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -21398,49 +22771,49 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4__str__(struct __pyx_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__", 0);
-  __Pyx_TraceCall("__str__", __pyx_f[0], 2142);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 2289);
 
-  /* "pysam/csamtools.pyx":2154
+  /* "pysam/csamtools.pyx":2301
  *         # sam-parsing is done in sam.c/bam_format1_core which
  *         # requires a valid header.
  *         if sys.version_info[0] < 3:             # <<<<<<<<<<<<<<
  *             seq = self.seq
  *             qual = self.qual
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__version_info); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__version_info); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_3, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_3, Py_LT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (__pyx_t_3) {
 
-    /* "pysam/csamtools.pyx":2155
+    /* "pysam/csamtools.pyx":2302
  *         # requires a valid header.
  *         if sys.version_info[0] < 3:
  *             seq = self.seq             # <<<<<<<<<<<<<<
  *             qual = self.qual
  *         else:
  */
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__seq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__seq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_v_seq = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "pysam/csamtools.pyx":2156
+    /* "pysam/csamtools.pyx":2303
  *         if sys.version_info[0] < 3:
  *             seq = self.seq
  *             qual = self.qual             # <<<<<<<<<<<<<<
  *         else:
  *             seq = self.seq.decode('ascii')
  */
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__qual); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2156; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__qual); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __pyx_v_qual = __pyx_t_2;
     __pyx_t_2 = 0;
@@ -21448,37 +22821,37 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4__str__(struct __pyx_
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2158
+    /* "pysam/csamtools.pyx":2305
  *             qual = self.qual
  *         else:
  *             seq = self.seq.decode('ascii')             # <<<<<<<<<<<<<<
  *             qual = self.qual.decode('ascii')
  *         return "\t".join(map(str, (self.qname,
  */
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__seq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__seq); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__decode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__decode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_137), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_145), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_v_seq = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "pysam/csamtools.pyx":2159
+    /* "pysam/csamtools.pyx":2306
  *         else:
  *             seq = self.seq.decode('ascii')
  *             qual = self.qual.decode('ascii')             # <<<<<<<<<<<<<<
  *         return "\t".join(map(str, (self.qname,
  *                                    self.flag,
  */
-    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__qual); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__qual); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__decode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_2, __pyx_n_s__decode); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_138), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_k_tuple_146), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_v_qual = __pyx_t_2;
@@ -21486,7 +22859,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4__str__(struct __pyx_
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2160
+  /* "pysam/csamtools.pyx":2307
  *             seq = self.seq.decode('ascii')
  *             qual = self.qual.decode('ascii')
  *         return "\t".join(map(str, (self.qname,             # <<<<<<<<<<<<<<
@@ -21494,101 +22867,101 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4__str__(struct __pyx_
  *                                    self.rname,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__qname); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__qname); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
 
-  /* "pysam/csamtools.pyx":2161
+  /* "pysam/csamtools.pyx":2308
  *             qual = self.qual.decode('ascii')
  *         return "\t".join(map(str, (self.qname,
  *                                    self.flag,             # <<<<<<<<<<<<<<
  *                                    self.rname,
  *                                    self.pos,
  */
-  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2161; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
 
-  /* "pysam/csamtools.pyx":2162
+  /* "pysam/csamtools.pyx":2309
  *         return "\t".join(map(str, (self.qname,
  *                                    self.flag,
  *                                    self.rname,             # <<<<<<<<<<<<<<
  *                                    self.pos,
  *                                    self.mapq,
  */
-  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__rname); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__rname); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2309; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
 
-  /* "pysam/csamtools.pyx":2163
+  /* "pysam/csamtools.pyx":2310
  *                                    self.flag,
  *                                    self.rname,
  *                                    self.pos,             # <<<<<<<<<<<<<<
  *                                    self.mapq,
  *                                    self.cigar,
  */
-  __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__pos); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__pos); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
 
-  /* "pysam/csamtools.pyx":2164
+  /* "pysam/csamtools.pyx":2311
  *                                    self.rname,
  *                                    self.pos,
  *                                    self.mapq,             # <<<<<<<<<<<<<<
  *                                    self.cigar,
  *                                    self.mrnm,
  */
-  __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__mapq); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__mapq); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
 
-  /* "pysam/csamtools.pyx":2165
+  /* "pysam/csamtools.pyx":2312
  *                                    self.pos,
  *                                    self.mapq,
  *                                    self.cigar,             # <<<<<<<<<<<<<<
  *                                    self.mrnm,
  *                                    self.mpos,
  */
-  __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__cigar); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__cigar); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2312; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
 
-  /* "pysam/csamtools.pyx":2166
+  /* "pysam/csamtools.pyx":2313
  *                                    self.mapq,
  *                                    self.cigar,
  *                                    self.mrnm,             # <<<<<<<<<<<<<<
  *                                    self.mpos,
  *                                    self.rlen,
  */
-  __pyx_t_9 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__mrnm); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2166; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__mrnm); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2313; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
 
-  /* "pysam/csamtools.pyx":2167
+  /* "pysam/csamtools.pyx":2314
  *                                    self.cigar,
  *                                    self.mrnm,
  *                                    self.mpos,             # <<<<<<<<<<<<<<
  *                                    self.rlen,
  *                                    seq,
  */
-  __pyx_t_10 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__mpos); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__mpos); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_10);
 
-  /* "pysam/csamtools.pyx":2168
+  /* "pysam/csamtools.pyx":2315
  *                                    self.mrnm,
  *                                    self.mpos,
  *                                    self.rlen,             # <<<<<<<<<<<<<<
  *                                    seq,
  *                                    qual,
  */
-  __pyx_t_11 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__rlen); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_11 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__rlen); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_11);
 
-  /* "pysam/csamtools.pyx":2171
+  /* "pysam/csamtools.pyx":2318
  *                                    seq,
  *                                    qual,
  *                                    self.tags )))             # <<<<<<<<<<<<<<
  * 
  *     def compare(self, AlignedRead other):
  */
-  __pyx_t_12 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__tags); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__tags); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_12);
-  __pyx_t_13 = PyTuple_New(12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_13 = PyTuple_New(12); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_13);
   PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
@@ -21626,7 +22999,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4__str__(struct __pyx_
   __pyx_t_10 = 0;
   __pyx_t_11 = 0;
   __pyx_t_12 = 0;
-  __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = PyTuple_New(2); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_12);
   __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
   PyTuple_SET_ITEM(__pyx_t_12, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
@@ -21634,15 +23007,15 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4__str__(struct __pyx_
   PyTuple_SET_ITEM(__pyx_t_12, 1, ((PyObject *)__pyx_t_13));
   __Pyx_GIVEREF(((PyObject *)__pyx_t_13));
   __pyx_t_13 = 0;
-  __pyx_t_13 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_13 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_13);
   __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
-  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = PyTuple_New(1); if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_12);
   PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_13);
   __Pyx_GIVEREF(__pyx_t_13);
   __pyx_t_13 = 0;
-  __pyx_t_13 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_13 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_12), NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2307; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_13);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_12)); __pyx_t_12 = 0;
@@ -21683,7 +23056,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_7compare(PyObject *__p
   PyObject *__pyx_r = 0;
   __Pyx_RefNannyDeclarations
   __Pyx_RefNannySetupContext("compare (wrapper)", 0);
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5pysam_9csamtools_AlignedRead, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_other), __pyx_ptype_5pysam_9csamtools_AlignedRead, 1, "other", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2320; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(((struct __pyx_obj_5pysam_9csamtools_AlignedRead *)__pyx_v_self), ((struct __pyx_obj_5pysam_9csamtools_AlignedRead *)__pyx_v_other));
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -21693,7 +23066,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_7compare(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2173
+/* "pysam/csamtools.pyx":2320
  *                                    self.tags )))
  * 
  *     def compare(self, AlignedRead other):             # <<<<<<<<<<<<<<
@@ -21715,9 +23088,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(struct __pyx_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("compare", 0);
-  __Pyx_TraceCall("compare", __pyx_f[0], 2173);
+  __Pyx_TraceCall("compare", __pyx_f[0], 2320);
 
-  /* "pysam/csamtools.pyx":2179
+  /* "pysam/csamtools.pyx":2326
  *         cdef bam1_t *t, *o
  * 
  *         t = self._delegate             # <<<<<<<<<<<<<<
@@ -21727,7 +23100,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(struct __pyx_
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_t = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2180
+  /* "pysam/csamtools.pyx":2327
  * 
  *         t = self._delegate
  *         o = other._delegate             # <<<<<<<<<<<<<<
@@ -21737,7 +23110,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(struct __pyx_
   __pyx_t_1 = __pyx_v_other->_delegate;
   __pyx_v_o = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2192
+  /* "pysam/csamtools.pyx":2339
  * 
  *         # Fast-path test for object identity
  *         if t==o:             # <<<<<<<<<<<<<<
@@ -21747,7 +23120,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(struct __pyx_
   __pyx_t_2 = (__pyx_v_t == __pyx_v_o);
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":2193
+    /* "pysam/csamtools.pyx":2340
  *         # Fast-path test for object identity
  *         if t==o:
  *             return 0             # <<<<<<<<<<<<<<
@@ -21762,7 +23135,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(struct __pyx_
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2195
+  /* "pysam/csamtools.pyx":2342
  *             return 0
  * 
  *         retval = memcmp(&t.core, &o.core, sizeof(bam1_core_t))             # <<<<<<<<<<<<<<
@@ -21771,7 +23144,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(struct __pyx_
  */
   __pyx_v_retval = memcmp((&__pyx_v_t->core), (&__pyx_v_o->core), (sizeof(bam1_core_t)));
 
-  /* "pysam/csamtools.pyx":2197
+  /* "pysam/csamtools.pyx":2344
  *         retval = memcmp(&t.core, &o.core, sizeof(bam1_core_t))
  * 
  *         if retval: return retval             # <<<<<<<<<<<<<<
@@ -21780,7 +23153,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(struct __pyx_
  */
   if (__pyx_v_retval) {
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2344; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -21789,7 +23162,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(struct __pyx_
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":2198
+  /* "pysam/csamtools.pyx":2345
  * 
  *         if retval: return retval
  *         retval = (t.data_len > o.data_len) - (t.data_len < o.data_len) # cmp(t.data_len, o.data_len)             # <<<<<<<<<<<<<<
@@ -21798,7 +23171,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(struct __pyx_
  */
   __pyx_v_retval = ((__pyx_v_t->data_len > __pyx_v_o->data_len) - (__pyx_v_t->data_len < __pyx_v_o->data_len));
 
-  /* "pysam/csamtools.pyx":2199
+  /* "pysam/csamtools.pyx":2346
  *         if retval: return retval
  *         retval = (t.data_len > o.data_len) - (t.data_len < o.data_len) # cmp(t.data_len, o.data_len)
  *         if retval: return retval             # <<<<<<<<<<<<<<
@@ -21807,7 +23180,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(struct __pyx_
  */
   if (__pyx_v_retval) {
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = __pyx_t_3;
     __pyx_t_3 = 0;
@@ -21816,7 +23189,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(struct __pyx_
   }
   __pyx_L5:;
 
-  /* "pysam/csamtools.pyx":2200
+  /* "pysam/csamtools.pyx":2347
  *         retval = (t.data_len > o.data_len) - (t.data_len < o.data_len) # cmp(t.data_len, o.data_len)
  *         if retval: return retval
  *         return memcmp(t.data, o.data, t.data_len)             # <<<<<<<<<<<<<<
@@ -21824,7 +23197,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6compare(struct __pyx_
  *     # Disabled so long as __cmp__ is a special method
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_3 = PyInt_FromLong(memcmp(__pyx_v_t->data, __pyx_v_o->data, __pyx_v_t->data_len)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(memcmp(__pyx_v_t->data, __pyx_v_o->data, __pyx_v_t->data_len)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -21854,7 +23227,7 @@ static Py_hash_t __pyx_pw_5pysam_9csamtools_11AlignedRead_9__hash__(PyObject *__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2203
+/* "pysam/csamtools.pyx":2350
  * 
  *     # Disabled so long as __cmp__ is a special method
  *     def __hash__(self):             # <<<<<<<<<<<<<<
@@ -21867,14 +23240,14 @@ static Py_hash_t __pyx_pf_5pysam_9csamtools_11AlignedRead_8__hash__(struct __pyx
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__hash__", 0);
-  __Pyx_TraceCall("__hash__", __pyx_f[0], 2203);
+  __Pyx_TraceCall("__hash__", __pyx_f[0], 2350);
 
-  /* "pysam/csamtools.pyx":2204
+  /* "pysam/csamtools.pyx":2351
  *     # Disabled so long as __cmp__ is a special method
  *     def __hash__(self):
  *         return _Py_HashPointer(<void *>self)             # <<<<<<<<<<<<<<
  * 
- *     property qname:
+ *     #######################################################################
  */
   __pyx_r = _Py_HashPointer(((void *)__pyx_v_self));
   goto __pyx_L0;
@@ -21898,7 +23271,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_5qname_1__get__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2208
+/* "pysam/csamtools.pyx":2359
  *     property qname:
  *         """the query name (None if not present)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -21918,9 +23291,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5qname___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2208);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2359);
 
-  /* "pysam/csamtools.pyx":2210
+  /* "pysam/csamtools.pyx":2361
  *         def __get__(self):
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -21930,7 +23303,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5qname___get__(struct
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2211
+  /* "pysam/csamtools.pyx":2362
  *             cdef bam1_t * src
  *             src = self._delegate
  *             if src.core.l_qname == 0: return None             # <<<<<<<<<<<<<<
@@ -21947,7 +23320,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5qname___get__(struct
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2212
+  /* "pysam/csamtools.pyx":2363
  *             src = self._delegate
  *             if src.core.l_qname == 0: return None
  *             return _charptr_to_str(<char *>bam1_qname( src ))             # <<<<<<<<<<<<<<
@@ -21955,7 +23328,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5qname___get__(struct
  *         def __set__(self, qname ):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_3 = __pyx_f_5pysam_9csamtools__charptr_to_str(((char *)bam1_qname(__pyx_v_src))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __pyx_f_5pysam_9csamtools__charptr_to_str(((char *)bam1_qname(__pyx_v_src))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -21985,7 +23358,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_5qname_3__set__(PyObject *__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2214
+/* "pysam/csamtools.pyx":2365
  *             return _charptr_to_str(<char *>bam1_qname( src ))
  * 
  *         def __set__(self, qname ):             # <<<<<<<<<<<<<<
@@ -22011,21 +23384,21 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5qname_2__set__(struct __pyx
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2214);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2365);
   __Pyx_INCREF(__pyx_v_qname);
 
-  /* "pysam/csamtools.pyx":2215
+  /* "pysam/csamtools.pyx":2366
  * 
  *         def __set__(self, qname ):
  *             if qname == None or len(qname) == 0: return             # <<<<<<<<<<<<<<
  *             qname = _force_bytes(qname)
  *             cdef bam1_t * src
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_qname, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_qname, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (!__pyx_t_2) {
-    __pyx_t_3 = PyObject_Length(__pyx_v_qname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2215; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Length(__pyx_v_qname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (__pyx_t_3 == 0);
     __pyx_t_5 = __pyx_t_4;
   } else {
@@ -22038,20 +23411,20 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5qname_2__set__(struct __pyx
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2216
+  /* "pysam/csamtools.pyx":2367
  *         def __set__(self, qname ):
  *             if qname == None or len(qname) == 0: return
  *             qname = _force_bytes(qname)             # <<<<<<<<<<<<<<
  *             cdef bam1_t * src
  *             cdef int l
  */
-  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_qname)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_qname)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_v_qname);
   __pyx_v_qname = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":2221
+  /* "pysam/csamtools.pyx":2372
  *             cdef char * p
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -22061,7 +23434,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5qname_2__set__(struct __pyx
   __pyx_t_6 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_6;
 
-  /* "pysam/csamtools.pyx":2222
+  /* "pysam/csamtools.pyx":2373
  * 
  *             src = self._delegate
  *             p = bam1_qname( src )             # <<<<<<<<<<<<<<
@@ -22070,17 +23443,17 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5qname_2__set__(struct __pyx
  */
   __pyx_v_p = bam1_qname(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2225
+  /* "pysam/csamtools.pyx":2376
  * 
  *             # the qname is \0 terminated
  *             l = len(qname) + 1             # <<<<<<<<<<<<<<
  *             pysam_bam_update( src,
  *                               src.core.l_qname,
  */
-  __pyx_t_3 = PyObject_Length(__pyx_v_qname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Length(__pyx_v_qname); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_l = (__pyx_t_3 + 1);
 
-  /* "pysam/csamtools.pyx":2229
+  /* "pysam/csamtools.pyx":2380
  *                               src.core.l_qname,
  *                               l,
  *                               <uint8_t*>p )             # <<<<<<<<<<<<<<
@@ -22089,7 +23462,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5qname_2__set__(struct __pyx
  */
   pysam_bam_update(__pyx_v_src, __pyx_v_src->core.l_qname, __pyx_v_l, ((uint8_t *)__pyx_v_p));
 
-  /* "pysam/csamtools.pyx":2231
+  /* "pysam/csamtools.pyx":2382
  *                               <uint8_t*>p )
  * 
  *             src.core.l_qname = l             # <<<<<<<<<<<<<<
@@ -22098,7 +23471,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5qname_2__set__(struct __pyx
  */
   __pyx_v_src->core.l_qname = __pyx_v_l;
 
-  /* "pysam/csamtools.pyx":2235
+  /* "pysam/csamtools.pyx":2386
  *             # re-acquire pointer to location in memory
  *             # as it might have moved
  *             p = bam1_qname(src)             # <<<<<<<<<<<<<<
@@ -22107,14 +23480,14 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5qname_2__set__(struct __pyx
  */
   __pyx_v_p = bam1_qname(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2237
+  /* "pysam/csamtools.pyx":2388
  *             p = bam1_qname(src)
  * 
  *             strncpy( p, qname, l )             # <<<<<<<<<<<<<<
  * 
  *     property cigar:
  */
-  __pyx_t_7 = PyBytes_AsString(__pyx_v_qname); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyBytes_AsString(__pyx_v_qname); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2388; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   strncpy(__pyx_v_p, __pyx_t_7, __pyx_v_l);
 
   __pyx_r = 0;
@@ -22141,7 +23514,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_5cigar_1__get__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2272
+/* "pysam/csamtools.pyx":2423
  * 
  *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -22168,9 +23541,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2272);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2423);
 
-  /* "pysam/csamtools.pyx":2278
+  /* "pysam/csamtools.pyx":2429
  *             cdef int k
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -22180,7 +23553,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar___get__(struct
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2279
+  /* "pysam/csamtools.pyx":2430
  * 
  *             src = self._delegate
  *             if src.core.n_cigar == 0: return None             # <<<<<<<<<<<<<<
@@ -22197,19 +23570,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar___get__(struct
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2281
+  /* "pysam/csamtools.pyx":2432
  *             if src.core.n_cigar == 0: return None
  * 
  *             cigar = []             # <<<<<<<<<<<<<<
  *             cigar_p = bam1_cigar(src);
  *             for k from 0 <= k < src.core.n_cigar:
  */
-  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_v_cigar = ((PyObject *)__pyx_t_3);
   __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":2282
+  /* "pysam/csamtools.pyx":2433
  * 
  *             cigar = []
  *             cigar_p = bam1_cigar(src);             # <<<<<<<<<<<<<<
@@ -22218,7 +23591,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar___get__(struct
  */
   __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2283
+  /* "pysam/csamtools.pyx":2434
  *             cigar = []
  *             cigar_p = bam1_cigar(src);
  *             for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -22228,40 +23601,40 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar___get__(struct
   __pyx_t_4 = __pyx_v_src->core.n_cigar;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_4; __pyx_v_k++) {
 
-    /* "pysam/csamtools.pyx":2284
+    /* "pysam/csamtools.pyx":2435
  *             cigar_p = bam1_cigar(src);
  *             for k from 0 <= k < src.core.n_cigar:
  *                 op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
  *                 cigar.append((op, l))
  */
-    __pyx_t_3 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) & 15)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) & 15)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_XDECREF(__pyx_v_op);
     __pyx_v_op = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "pysam/csamtools.pyx":2285
+    /* "pysam/csamtools.pyx":2436
  *             for k from 0 <= k < src.core.n_cigar:
  *                 op = cigar_p[k] & BAM_CIGAR_MASK
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
  *                 cigar.append((op, l))
  *             return cigar
  */
-    __pyx_t_3 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2285; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_XDECREF(__pyx_v_l);
     __pyx_v_l = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "pysam/csamtools.pyx":2286
+    /* "pysam/csamtools.pyx":2437
  *                 op = cigar_p[k] & BAM_CIGAR_MASK
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
  *                 cigar.append((op, l))             # <<<<<<<<<<<<<<
  *             return cigar
  * 
  */
-    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_INCREF(__pyx_v_op);
     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_op);
@@ -22269,13 +23642,13 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar___get__(struct
     __Pyx_INCREF(__pyx_v_l);
     PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_l);
     __Pyx_GIVEREF(__pyx_v_l);
-    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_cigar, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2286; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = __Pyx_PyObject_Append(__pyx_v_cigar, ((PyObject *)__pyx_t_3)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2437; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   }
 
-  /* "pysam/csamtools.pyx":2287
+  /* "pysam/csamtools.pyx":2438
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
  *                 cigar.append((op, l))
  *             return cigar             # <<<<<<<<<<<<<<
@@ -22315,7 +23688,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_5cigar_3__set__(PyObject *__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2289
+/* "pysam/csamtools.pyx":2440
  *             return cigar
  * 
  *         def __set__(self, values ):             # <<<<<<<<<<<<<<
@@ -22349,20 +23722,20 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2289);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2440);
 
-  /* "pysam/csamtools.pyx":2290
+  /* "pysam/csamtools.pyx":2441
  * 
  *         def __set__(self, values ):
  *             if values == None or len(values) == 0: return             # <<<<<<<<<<<<<<
  *             cdef uint32_t * p
  *             cdef bam1_t * src
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_values, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_values, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (!__pyx_t_2) {
-    __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (__pyx_t_3 == 0);
     __pyx_t_5 = __pyx_t_4;
   } else {
@@ -22375,7 +23748,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2296
+  /* "pysam/csamtools.pyx":2447
  *             cdef int k
  * 
  *             k = 0             # <<<<<<<<<<<<<<
@@ -22384,7 +23757,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
  */
   __pyx_v_k = 0;
 
-  /* "pysam/csamtools.pyx":2298
+  /* "pysam/csamtools.pyx":2449
  *             k = 0
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -22394,7 +23767,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
   __pyx_t_6 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_6;
 
-  /* "pysam/csamtools.pyx":2301
+  /* "pysam/csamtools.pyx":2452
  * 
  *             # get location of cigar string
  *             p = bam1_cigar(src)             # <<<<<<<<<<<<<<
@@ -22403,16 +23776,16 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
  */
   __pyx_v_p = bam1_cigar(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2306
+  /* "pysam/csamtools.pyx":2457
  *             pysam_bam_update( src,
  *                               src.core.n_cigar * 4,
  *                               len(values) * 4,             # <<<<<<<<<<<<<<
  *                               <uint8_t*>p )
  * 
  */
-  __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":2307
+  /* "pysam/csamtools.pyx":2458
  *                               src.core.n_cigar * 4,
  *                               len(values) * 4,
  *                               <uint8_t*>p )             # <<<<<<<<<<<<<<
@@ -22421,17 +23794,17 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
  */
   pysam_bam_update(__pyx_v_src, (__pyx_v_src->core.n_cigar * 4), (__pyx_t_3 * 4), ((uint8_t *)__pyx_v_p));
 
-  /* "pysam/csamtools.pyx":2310
+  /* "pysam/csamtools.pyx":2461
  * 
  *             # length is number of cigar operations, not bytes
  *             src.core.n_cigar = len(values)             # <<<<<<<<<<<<<<
  * 
  *             # re-acquire pointer to location in memory
  */
-  __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Length(__pyx_v_values); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2461; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_src->core.n_cigar = __pyx_t_3;
 
-  /* "pysam/csamtools.pyx":2314
+  /* "pysam/csamtools.pyx":2465
  *             # re-acquire pointer to location in memory
  *             # as it might have moved
  *             p = bam1_cigar(src)             # <<<<<<<<<<<<<<
@@ -22440,7 +23813,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
  */
   __pyx_v_p = bam1_cigar(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2317
+  /* "pysam/csamtools.pyx":2468
  * 
  *             # insert cigar operations
  *             for op, l in values:             # <<<<<<<<<<<<<<
@@ -22451,7 +23824,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
     __pyx_t_1 = __pyx_v_values; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
     __pyx_t_7 = NULL;
   } else {
-    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_values); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __pyx_t_7 = Py_TYPE(__pyx_t_1)->tp_iternext;
   }
@@ -22459,23 +23832,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
     if (!__pyx_t_7 && PyList_CheckExact(__pyx_t_1)) {
       if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_8 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else if (!__pyx_t_7 && PyTuple_CheckExact(__pyx_t_1)) {
       if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_8); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else {
       __pyx_t_8 = __pyx_t_7(__pyx_t_1);
       if (unlikely(!__pyx_t_8)) {
         if (PyErr_Occurred()) {
           if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         break;
       }
@@ -22491,7 +23864,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
       if (unlikely(size != 2)) {
         if (size > 2) __Pyx_RaiseTooManyValuesError(2);
         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #if CYTHON_COMPILING_IN_CPYTHON
       if (likely(PyTuple_CheckExact(sequence))) {
@@ -22504,16 +23877,16 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
       __Pyx_INCREF(__pyx_t_9);
       __Pyx_INCREF(__pyx_t_10);
       #else
-      __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
-      __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_10);
       #endif
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
     } else
     {
       Py_ssize_t index = -1;
-      __pyx_t_11 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_11);
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
       __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
@@ -22521,7 +23894,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
       __Pyx_GOTREF(__pyx_t_9);
       index = 1; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L6_unpacking_failed;
       __Pyx_GOTREF(__pyx_t_10);
-      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_t_12 = NULL;
       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
       goto __pyx_L7_unpacking_done;
@@ -22529,7 +23902,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
       __pyx_t_12 = NULL;
       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2468; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_L7_unpacking_done:;
     }
     __Pyx_XDECREF(__pyx_v_op);
@@ -22539,23 +23912,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
     __pyx_v_l = __pyx_t_10;
     __pyx_t_10 = 0;
 
-    /* "pysam/csamtools.pyx":2318
+    /* "pysam/csamtools.pyx":2469
  *             # insert cigar operations
  *             for op, l in values:
  *                 p[k] = l << BAM_CIGAR_SHIFT | op             # <<<<<<<<<<<<<<
  *                 k += 1
  * 
  */
-    __pyx_t_8 = PyNumber_Lshift(__pyx_v_l, __pyx_int_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyNumber_Lshift(__pyx_v_l, __pyx_int_4); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
-    __pyx_t_10 = PyNumber_Or(__pyx_t_8, __pyx_v_op); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = PyNumber_Or(__pyx_t_8, __pyx_v_op); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_10);
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-    __pyx_t_13 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_10); if (unlikely((__pyx_t_13 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2318; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_13 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_10); if (unlikely((__pyx_t_13 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
     (__pyx_v_p[__pyx_v_k]) = __pyx_t_13;
 
-    /* "pysam/csamtools.pyx":2319
+    /* "pysam/csamtools.pyx":2470
  *             for op, l in values:
  *                 p[k] = l << BAM_CIGAR_SHIFT | op
  *                 k += 1             # <<<<<<<<<<<<<<
@@ -22566,7 +23939,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5cigar_2__set__(struct __pyx
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":2322
+  /* "pysam/csamtools.pyx":2473
  * 
  *             ## setting the cigar string also updates the "bin" attribute
  *             src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, p))             # <<<<<<<<<<<<<<
@@ -22604,7 +23977,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_11cigarstring_1__get__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2338
+/* "pysam/csamtools.pyx":2489
  *         Returns the empty string if not present.
  *         '''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -22635,29 +24008,29 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring___get__(
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2338);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2489);
 
-  /* "pysam/csamtools.pyx":2339
+  /* "pysam/csamtools.pyx":2490
  *         '''
  *         def __get__(self):
  *             c = self.cigar             # <<<<<<<<<<<<<<
  *             if c == None: return ""
  *             # reverse order
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__cigar); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__cigar); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2490; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_v_c = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":2340
+  /* "pysam/csamtools.pyx":2491
  *         def __get__(self):
  *             c = self.cigar
  *             if c == None: return ""             # <<<<<<<<<<<<<<
  *             # reverse order
  *             else: return "".join([ "%i%c" % (y,CODE2CIGAR[x]) for x,y in c])
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_c, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_c, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2491; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
     __Pyx_XDECREF(__pyx_r);
@@ -22668,7 +24041,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring___get__(
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2342
+    /* "pysam/csamtools.pyx":2493
  *             if c == None: return ""
  *             # reverse order
  *             else: return "".join([ "%i%c" % (y,CODE2CIGAR[x]) for x,y in c])             # <<<<<<<<<<<<<<
@@ -22676,15 +24049,15 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring___get__(
  *         def __set__(self, cigar):
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_16), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_16), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     if (PyList_CheckExact(__pyx_v_c) || PyTuple_CheckExact(__pyx_v_c)) {
       __pyx_t_4 = __pyx_v_c; __Pyx_INCREF(__pyx_t_4); __pyx_t_5 = 0;
       __pyx_t_6 = NULL;
     } else {
-      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_c); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_c); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext;
     }
@@ -22692,23 +24065,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring___get__(
       if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_4)) {
         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_4)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_4)) {
         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_5); __Pyx_INCREF(__pyx_t_7); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PySequence_ITEM(__pyx_t_4, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else {
         __pyx_t_7 = __pyx_t_6(__pyx_t_4);
         if (unlikely(!__pyx_t_7)) {
           if (PyErr_Occurred()) {
             if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           }
           break;
         }
@@ -22724,7 +24097,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring___get__(
         if (unlikely(size != 2)) {
           if (size > 2) __Pyx_RaiseTooManyValuesError(2);
           else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         #if CYTHON_COMPILING_IN_CPYTHON
         if (likely(PyTuple_CheckExact(sequence))) {
@@ -22737,16 +24110,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring___get__(
         __Pyx_INCREF(__pyx_t_8);
         __Pyx_INCREF(__pyx_t_9);
         #else
-        __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
-        __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_9);
         #endif
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       } else
       {
         Py_ssize_t index = -1;
-        __pyx_t_10 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_10 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_10);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
         __pyx_t_11 = Py_TYPE(__pyx_t_10)->tp_iternext;
@@ -22754,7 +24127,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring___get__(
         __Pyx_GOTREF(__pyx_t_8);
         index = 1; __pyx_t_9 = __pyx_t_11(__pyx_t_10); if (unlikely(!__pyx_t_9)) goto __pyx_L6_unpacking_failed;
         __Pyx_GOTREF(__pyx_t_9);
-        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_10), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_t_11 = NULL;
         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
         goto __pyx_L7_unpacking_done;
@@ -22762,7 +24135,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring___get__(
         __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
         __pyx_t_11 = NULL;
         if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_L7_unpacking_done:;
       }
       __Pyx_XDECREF(__pyx_v_x);
@@ -22771,10 +24144,10 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring___get__(
       __Pyx_XDECREF(__pyx_v_y);
       __pyx_v_y = __pyx_t_9;
       __pyx_t_9 = 0;
-      __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_t_7 = PyInt_FromLong((__pyx_v_5pysam_9csamtools_CODE2CIGAR[__pyx_t_12])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_12 = __Pyx_PyIndex_AsSsize_t(__pyx_v_x); if (unlikely((__pyx_t_12 == (Py_ssize_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyInt_FromLong((__pyx_v_5pysam_9csamtools_CODE2CIGAR[__pyx_t_12])); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
       __Pyx_INCREF(__pyx_v_y);
       PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_y);
@@ -22782,20 +24155,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring___get__(
       PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_7);
       __Pyx_GIVEREF(__pyx_t_7);
       __pyx_t_7 = 0;
-      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_139), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_147), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_7));
       __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
-      if (unlikely(__Pyx_PyList_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (unlikely(__Pyx_PyList_Append(__pyx_t_3, (PyObject*)__pyx_t_7))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
     }
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_INCREF(((PyObject *)__pyx_t_3));
     PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_3));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_3));
     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
@@ -22838,7 +24211,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_11cigarstring_3__set__(PyObj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2344
+/* "pysam/csamtools.pyx":2495
  *             else: return "".join([ "%i%c" % (y,CODE2CIGAR[x]) for x,y in c])
  * 
  *         def __set__(self, cigar):             # <<<<<<<<<<<<<<
@@ -22869,72 +24242,72 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring_2__set__(struc
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2344);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2495);
 
-  /* "pysam/csamtools.pyx":2345
+  /* "pysam/csamtools.pyx":2496
  * 
  *         def __set__(self, cigar):
  *             if cigar == None or len(cigar) == 0: self.cigar = []             # <<<<<<<<<<<<<<
  *             parts = CIGAR_REGEX.findall( cigar )
  *             # reverse order
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_cigar, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_cigar, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (!__pyx_t_2) {
-    __pyx_t_3 = PyObject_Length(__pyx_v_cigar); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Length(__pyx_v_cigar); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (__pyx_t_3 == 0);
     __pyx_t_5 = __pyx_t_4;
   } else {
     __pyx_t_5 = __pyx_t_2;
   }
   if (__pyx_t_5) {
-    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__cigar, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__cigar, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2496; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2346
+  /* "pysam/csamtools.pyx":2497
  *         def __set__(self, cigar):
  *             if cigar == None or len(cigar) == 0: self.cigar = []
  *             parts = CIGAR_REGEX.findall( cigar )             # <<<<<<<<<<<<<<
  *             # reverse order
  *             self.cigar = [ (CIGAR2CODE[ord(y)], int(x)) for x,y in parts ]
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__CIGAR_REGEX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__CIGAR_REGEX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__findall); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__findall); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(__pyx_v_cigar);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_cigar);
   __Pyx_GIVEREF(__pyx_v_cigar);
-  __pyx_t_7 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
   __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
   __pyx_v_parts = __pyx_t_7;
   __pyx_t_7 = 0;
 
-  /* "pysam/csamtools.pyx":2348
+  /* "pysam/csamtools.pyx":2499
  *             parts = CIGAR_REGEX.findall( cigar )
  *             # reverse order
  *             self.cigar = [ (CIGAR2CODE[ord(y)], int(x)) for x,y in parts ]             # <<<<<<<<<<<<<<
  * 
  *     property seq:
  */
-  __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyList_New(0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
   if (PyList_CheckExact(__pyx_v_parts) || PyTuple_CheckExact(__pyx_v_parts)) {
     __pyx_t_1 = __pyx_v_parts; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
     __pyx_t_8 = NULL;
   } else {
-    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_parts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_parts); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __pyx_t_8 = Py_TYPE(__pyx_t_1)->tp_iternext;
   }
@@ -22942,23 +24315,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring_2__set__(struc
     if (!__pyx_t_8 && PyList_CheckExact(__pyx_t_1)) {
       if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else if (!__pyx_t_8 && PyTuple_CheckExact(__pyx_t_1)) {
       if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_6); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else {
       __pyx_t_6 = __pyx_t_8(__pyx_t_1);
       if (unlikely(!__pyx_t_6)) {
         if (PyErr_Occurred()) {
           if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         break;
       }
@@ -22974,7 +24347,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring_2__set__(struc
       if (unlikely(size != 2)) {
         if (size > 2) __Pyx_RaiseTooManyValuesError(2);
         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #if CYTHON_COMPILING_IN_CPYTHON
       if (likely(PyTuple_CheckExact(sequence))) {
@@ -22987,16 +24360,16 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring_2__set__(struc
       __Pyx_INCREF(__pyx_t_9);
       __Pyx_INCREF(__pyx_t_10);
       #else
-      __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
-      __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_10);
       #endif
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     } else
     {
       Py_ssize_t index = -1;
-      __pyx_t_11 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = PyObject_GetIter(__pyx_t_6); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_11);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
@@ -23004,7 +24377,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring_2__set__(struc
       __Pyx_GOTREF(__pyx_t_9);
       index = 1; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L6_unpacking_failed;
       __Pyx_GOTREF(__pyx_t_10);
-      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_t_12 = NULL;
       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
       goto __pyx_L7_unpacking_done;
@@ -23012,7 +24385,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring_2__set__(struc
       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
       __pyx_t_12 = NULL;
       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_L7_unpacking_done:;
     }
     __Pyx_XDECREF(__pyx_v_x);
@@ -23021,29 +24394,29 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring_2__set__(struc
     __Pyx_XDECREF(__pyx_v_y);
     __pyx_v_y = __pyx_t_10;
     __pyx_t_10 = 0;
-    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__CIGAR2CODE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_GetName(__pyx_m, __pyx_n_s__CIGAR2CODE); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_10);
     __Pyx_INCREF(__pyx_v_y);
     PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_v_y);
     __Pyx_GIVEREF(__pyx_v_y);
-    __pyx_t_9 = PyObject_Call(__pyx_builtin_ord, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyObject_Call(__pyx_builtin_ord, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
-    __pyx_t_10 = PyObject_GetItem(__pyx_t_6, __pyx_t_9); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = PyObject_GetItem(__pyx_t_6, __pyx_t_9); if (!__pyx_t_10) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_10);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __Pyx_INCREF(__pyx_v_x);
     PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_v_x);
     __Pyx_GIVEREF(__pyx_v_x);
-    __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_Call(((PyObject *)((PyObject*)(&PyInt_Type))), ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
-    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10);
     __Pyx_GIVEREF(__pyx_t_10);
@@ -23051,14 +24424,14 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_11cigarstring_2__set__(struc
     __Pyx_GIVEREF(__pyx_t_6);
     __pyx_t_10 = 0;
     __pyx_t_6 = 0;
-    if (unlikely(__Pyx_PyList_Append(__pyx_t_7, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(__Pyx_PyList_Append(__pyx_t_7, (PyObject*)__pyx_t_9))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_t_1 = ((PyObject *)__pyx_t_7);
   __Pyx_INCREF(__pyx_t_1);
   __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
-  if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__cigar, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__cigar, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2499; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
   __pyx_r = 0;
@@ -23092,9 +24465,9 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_3seq_1__get__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2354
+/* "pysam/csamtools.pyx":2518
  * 
- *         In Python 3, this property is of type bytes and assigning a unicode string to it consisting of ASCII characters only will work, but is inefficient."""
+ *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
  *             cdef bam1_t * src
  *             cdef char * s
@@ -23112,9 +24485,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_3seq___get__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2354);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2518);
 
-  /* "pysam/csamtools.pyx":2357
+  /* "pysam/csamtools.pyx":2521
  *             cdef bam1_t * src
  *             cdef char * s
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -23124,7 +24497,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_3seq___get__(struct __
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2359
+  /* "pysam/csamtools.pyx":2523
  *             src = self._delegate
  * 
  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
@@ -23141,7 +24514,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_3seq___get__(struct __
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2361
+  /* "pysam/csamtools.pyx":2525
  *             if src.core.l_qseq == 0: return None
  * 
  *             return get_seq_range(src, 0, src.core.l_qseq)             # <<<<<<<<<<<<<<
@@ -23149,7 +24522,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_3seq___get__(struct __
  *         def __set__(self,seq):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_3 = __pyx_f_5pysam_9csamtools_get_seq_range(__pyx_v_src, 0, __pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __pyx_f_5pysam_9csamtools_get_seq_range(__pyx_v_src, 0, __pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2525; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -23179,7 +24552,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_3seq_3__set__(PyObject *__py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2363
+/* "pysam/csamtools.pyx":2527
  *             return get_seq_range(src, 0, src.core.l_qseq)
  * 
  *         def __set__(self,seq):             # <<<<<<<<<<<<<<
@@ -23200,97 +24573,97 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_3seq_2__set__(struct __pyx_o
   PyObject *__pyx_t_1 = NULL;
   int __pyx_t_2;
   Py_ssize_t __pyx_t_3;
-  int __pyx_t_4;
+  bam1_t *__pyx_t_4;
   int __pyx_t_5;
-  bam1_t *__pyx_t_6;
-  int __pyx_t_7;
-  char *__pyx_t_8;
-  long __pyx_t_9;
+  char *__pyx_t_6;
+  long __pyx_t_7;
   int __pyx_lineno = 0;
   const char *__pyx_filename = NULL;
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2363);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2527);
   __Pyx_INCREF(__pyx_v_seq);
 
-  /* "pysam/csamtools.pyx":2367
- *             # if no quality information is present, the first byte says 0xff.
+  /* "pysam/csamtools.pyx":2535
+ *             cdef int l, k, nbytes_new, nbytes_old
  * 
- *             if seq == None or len(seq) == 0: return             # <<<<<<<<<<<<<<
- *             seq = _force_bytes(seq)
- *             cdef bam1_t * src
+ *             if seq == None:             # <<<<<<<<<<<<<<
+ *                 l = 0
+ *             else:
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_seq, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_seq, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2535; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  if (!__pyx_t_2) {
-    __pyx_t_3 = PyObject_Length(__pyx_v_seq); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_4 = (__pyx_t_3 == 0);
-    __pyx_t_5 = __pyx_t_4;
-  } else {
-    __pyx_t_5 = __pyx_t_2;
-  }
-  if (__pyx_t_5) {
-    __pyx_r = 0;
-    goto __pyx_L0;
+  if (__pyx_t_2) {
+
+    /* "pysam/csamtools.pyx":2536
+ * 
+ *             if seq == None:
+ *                 l = 0             # <<<<<<<<<<<<<<
+ *             else:
+ *                 l = len(seq)
+ */
+    __pyx_v_l = 0;
     goto __pyx_L3;
   }
-  __pyx_L3:;
+  /*else*/ {
 
-  /* "pysam/csamtools.pyx":2368
+    /* "pysam/csamtools.pyx":2538
+ *                 l = 0
+ *             else:
+ *                 l = len(seq)             # <<<<<<<<<<<<<<
+ *                 seq = _force_bytes(seq)
  * 
- *             if seq == None or len(seq) == 0: return
- *             seq = _force_bytes(seq)             # <<<<<<<<<<<<<<
- *             cdef bam1_t * src
- *             cdef uint8_t * p
  */
-  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_seq)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_DECREF(__pyx_v_seq);
-  __pyx_v_seq = __pyx_t_1;
-  __pyx_t_1 = 0;
+    __pyx_t_3 = PyObject_Length(__pyx_v_seq); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2538; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_v_l = __pyx_t_3;
 
-  /* "pysam/csamtools.pyx":2374
- *             cdef int l, k, nbytes_new, nbytes_old
- * 
- *             src = self._delegate             # <<<<<<<<<<<<<<
+    /* "pysam/csamtools.pyx":2539
+ *             else:
+ *                 l = len(seq)
+ *                 seq = _force_bytes(seq)             # <<<<<<<<<<<<<<
  * 
- *             l = len(seq)
+ *             src = self._delegate
  */
-  __pyx_t_6 = __pyx_v_self->_delegate;
-  __pyx_v_src = __pyx_t_6;
+    __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_seq)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_DECREF(__pyx_v_seq);
+    __pyx_v_seq = __pyx_t_1;
+    __pyx_t_1 = 0;
+  }
+  __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2376
- *             src = self._delegate
+  /* "pysam/csamtools.pyx":2541
+ *                 seq = _force_bytes(seq)
  * 
- *             l = len(seq)             # <<<<<<<<<<<<<<
+ *             src = self._delegate             # <<<<<<<<<<<<<<
  * 
  *             # as the sequence is stored in half-bytes, the total length (sequence
  */
-  __pyx_t_3 = PyObject_Length(__pyx_v_seq); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2376; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_l = __pyx_t_3;
+  __pyx_t_4 = __pyx_v_self->_delegate;
+  __pyx_v_src = __pyx_t_4;
 
-  /* "pysam/csamtools.pyx":2380
+  /* "pysam/csamtools.pyx":2545
  *             # as the sequence is stored in half-bytes, the total length (sequence
  *             # plus quality scores) is (l+1)/2 + l
  *             nbytes_new = (l+1)/2 + l             # <<<<<<<<<<<<<<
  *             nbytes_old = (src.core.l_qseq+1)/2 + src.core.l_qseq
- *             # acquire pointer to location in memory
+ * 
  */
   __pyx_v_nbytes_new = (__Pyx_div_long((__pyx_v_l + 1), 2) + __pyx_v_l);
 
-  /* "pysam/csamtools.pyx":2381
+  /* "pysam/csamtools.pyx":2546
  *             # plus quality scores) is (l+1)/2 + l
  *             nbytes_new = (l+1)/2 + l
  *             nbytes_old = (src.core.l_qseq+1)/2 + src.core.l_qseq             # <<<<<<<<<<<<<<
+ * 
  *             # acquire pointer to location in memory
- *             p = bam1_seq( src )
  */
   __pyx_v_nbytes_old = (__Pyx_div_long((__pyx_v_src->core.l_qseq + 1), 2) + __pyx_v_src->core.l_qseq);
 
-  /* "pysam/csamtools.pyx":2383
- *             nbytes_old = (src.core.l_qseq+1)/2 + src.core.l_qseq
+  /* "pysam/csamtools.pyx":2549
+ * 
  *             # acquire pointer to location in memory
  *             p = bam1_seq( src )             # <<<<<<<<<<<<<<
  *             src.core.l_qseq = l
@@ -23298,93 +24671,106 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_3seq_2__set__(struct __pyx_o
  */
   __pyx_v_p = bam1_seq(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2384
+  /* "pysam/csamtools.pyx":2550
  *             # acquire pointer to location in memory
  *             p = bam1_seq( src )
  *             src.core.l_qseq = l             # <<<<<<<<<<<<<<
  * 
- *             pysam_bam_update( src,
+ *             # change length of data field
  */
   __pyx_v_src->core.l_qseq = __pyx_v_l;
 
-  /* "pysam/csamtools.pyx":2389
+  /* "pysam/csamtools.pyx":2556
  *                               nbytes_old,
  *                               nbytes_new,
  *                               p)             # <<<<<<<<<<<<<<
- *             # re-acquire pointer to location in memory
- *             # as it might have moved
+ * 
+ *             if l > 0:
  */
   pysam_bam_update(__pyx_v_src, __pyx_v_nbytes_old, __pyx_v_nbytes_new, __pyx_v_p);
 
-  /* "pysam/csamtools.pyx":2392
- *             # re-acquire pointer to location in memory
- *             # as it might have moved
- *             p = bam1_seq( src )             # <<<<<<<<<<<<<<
- *             for k from 0 <= k < nbytes_new: p[k] = 0
- *             # convert to C string
+  /* "pysam/csamtools.pyx":2558
+ *                               p)
+ * 
+ *             if l > 0:             # <<<<<<<<<<<<<<
+ *                 # re-acquire pointer to location in memory
+ *                 # as it might have moved
  */
-  __pyx_v_p = bam1_seq(__pyx_v_src);
+  __pyx_t_2 = (__pyx_v_l > 0);
+  if (__pyx_t_2) {
 
-  /* "pysam/csamtools.pyx":2393
- *             # as it might have moved
- *             p = bam1_seq( src )
- *             for k from 0 <= k < nbytes_new: p[k] = 0             # <<<<<<<<<<<<<<
- *             # convert to C string
- *             s = seq
+    /* "pysam/csamtools.pyx":2561
+ *                 # re-acquire pointer to location in memory
+ *                 # as it might have moved
+ *                 p = bam1_seq( src )             # <<<<<<<<<<<<<<
+ *                 for k from 0 <= k < nbytes_new: p[k] = 0
+ *                 # convert to C string
  */
-  __pyx_t_7 = __pyx_v_nbytes_new;
-  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_7; __pyx_v_k++) {
-    (__pyx_v_p[__pyx_v_k]) = 0;
-  }
+    __pyx_v_p = bam1_seq(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2395
- *             for k from 0 <= k < nbytes_new: p[k] = 0
- *             # convert to C string
- *             s = seq             # <<<<<<<<<<<<<<
- *             for k from 0 <= k < l:
- *                 p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)
+    /* "pysam/csamtools.pyx":2562
+ *                 # as it might have moved
+ *                 p = bam1_seq( src )
+ *                 for k from 0 <= k < nbytes_new: p[k] = 0             # <<<<<<<<<<<<<<
+ *                 # convert to C string
+ *                 s = seq
  */
-  __pyx_t_8 = PyBytes_AsString(__pyx_v_seq); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_v_s = __pyx_t_8;
+    __pyx_t_5 = __pyx_v_nbytes_new;
+    for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_5; __pyx_v_k++) {
+      (__pyx_v_p[__pyx_v_k]) = 0;
+    }
 
-  /* "pysam/csamtools.pyx":2396
- *             # convert to C string
- *             s = seq
- *             for k from 0 <= k < l:             # <<<<<<<<<<<<<<
- *                 p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)
+    /* "pysam/csamtools.pyx":2564
+ *                 for k from 0 <= k < nbytes_new: p[k] = 0
+ *                 # convert to C string
+ *                 s = seq             # <<<<<<<<<<<<<<
+ *                 for k from 0 <= k < l:
+ *                     p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)
+ */
+    __pyx_t_6 = PyBytes_AsString(__pyx_v_seq); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2564; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_v_s = __pyx_t_6;
+
+    /* "pysam/csamtools.pyx":2565
+ *                 # convert to C string
+ *                 s = seq
+ *                 for k from 0 <= k < l:             # <<<<<<<<<<<<<<
+ *                     p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)
  * 
  */
-  __pyx_t_7 = __pyx_v_l;
-  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_7; __pyx_v_k++) {
+    __pyx_t_5 = __pyx_v_l;
+    for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_5; __pyx_v_k++) {
 
-    /* "pysam/csamtools.pyx":2397
- *             s = seq
- *             for k from 0 <= k < l:
- *                 p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)             # <<<<<<<<<<<<<<
+      /* "pysam/csamtools.pyx":2566
+ *                 s = seq
+ *                 for k from 0 <= k < l:
+ *                     p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)             # <<<<<<<<<<<<<<
  * 
- *             # erase qualities
+ *                 # erase qualities
  */
-    __pyx_t_9 = __Pyx_div_long(__pyx_v_k, 2);
-    (__pyx_v_p[__pyx_t_9]) = ((__pyx_v_p[__pyx_t_9]) | (pysam_translate_sequence((__pyx_v_s[__pyx_v_k])) << (4 * (1 - __Pyx_mod_long(__pyx_v_k, 2)))));
-  }
+      __pyx_t_7 = __Pyx_div_long(__pyx_v_k, 2);
+      (__pyx_v_p[__pyx_t_7]) = ((__pyx_v_p[__pyx_t_7]) | (pysam_translate_sequence((__pyx_v_s[__pyx_v_k])) << (4 * (1 - __Pyx_mod_long(__pyx_v_k, 2)))));
+    }
 
-  /* "pysam/csamtools.pyx":2400
+    /* "pysam/csamtools.pyx":2569
  * 
- *             # erase qualities
- *             p = bam1_qual( src )             # <<<<<<<<<<<<<<
- *             p[0] = 0xff
+ *                 # erase qualities
+ *                 p = bam1_qual( src )             # <<<<<<<<<<<<<<
+ *                 p[0] = 0xff
  * 
  */
-  __pyx_v_p = bam1_qual(__pyx_v_src);
+    __pyx_v_p = bam1_qual(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2401
- *             # erase qualities
- *             p = bam1_qual( src )
- *             p[0] = 0xff             # <<<<<<<<<<<<<<
- * 
+    /* "pysam/csamtools.pyx":2570
+ *                 # erase qualities
+ *                 p = bam1_qual( src )
+ *                 p[0] = 0xff             # <<<<<<<<<<<<<<
  * 
+ *     property qual:
  */
-  (__pyx_v_p[0]) = 0xff;
+    (__pyx_v_p[0]) = 0xff;
+    goto __pyx_L4;
+  }
+  __pyx_L4:;
 
   __pyx_r = 0;
   goto __pyx_L0;
@@ -23410,9 +24796,9 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_4qual_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2408
- * 
- *         In Python 3, this property is of type bytes and assigning a unicode string to it consisting of ASCII characters only will work, but is inefficient."""
+/* "pysam/csamtools.pyx":2587
+ *         quality scores and the sequence are not the same.
+ *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
  * 
  *             cdef bam1_t * src
@@ -23430,9 +24816,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4qual___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2408);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2587);
 
-  /* "pysam/csamtools.pyx":2413
+  /* "pysam/csamtools.pyx":2592
  *             cdef char * q
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -23442,7 +24828,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4qual___get__(struct _
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2415
+  /* "pysam/csamtools.pyx":2594
  *             src = self._delegate
  * 
  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
@@ -23459,7 +24845,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4qual___get__(struct _
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2417
+  /* "pysam/csamtools.pyx":2596
  *             if src.core.l_qseq == 0: return None
  * 
  *             return get_qual_range(src, 0, src.core.l_qseq)             # <<<<<<<<<<<<<<
@@ -23467,7 +24853,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4qual___get__(struct _
  *         def __set__(self,qual):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_3 = __pyx_f_5pysam_9csamtools_get_qual_range(__pyx_v_src, 0, __pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __pyx_f_5pysam_9csamtools_get_qual_range(__pyx_v_src, 0, __pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2596; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -23497,7 +24883,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_4qual_3__set__(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2419
+/* "pysam/csamtools.pyx":2598
  *             return get_qual_range(src, 0, src.core.l_qseq)
  * 
  *         def __set__(self,qual):             # <<<<<<<<<<<<<<
@@ -23528,10 +24914,10 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4qual_2__set__(struct __pyx_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2419);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2598);
   __Pyx_INCREF(__pyx_v_qual);
 
-  /* "pysam/csamtools.pyx":2426
+  /* "pysam/csamtools.pyx":2605
  *             cdef int k
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -23541,7 +24927,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4qual_2__set__(struct __pyx_
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2427
+  /* "pysam/csamtools.pyx":2606
  * 
  *             src = self._delegate
  *             p = bam1_qual( src )             # <<<<<<<<<<<<<<
@@ -23550,18 +24936,18 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4qual_2__set__(struct __pyx_
  */
   __pyx_v_p = bam1_qual(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2428
+  /* "pysam/csamtools.pyx":2607
  *             src = self._delegate
  *             p = bam1_qual( src )
  *             if qual == None or len(qual) == 0:             # <<<<<<<<<<<<<<
  *                 # if absent - set to 0xff
  *                 p[0] = 0xff
  */
-  __pyx_t_2 = PyObject_RichCompare(__pyx_v_qual, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_RichCompare(__pyx_v_qual, Py_None, Py_EQ); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (!__pyx_t_3) {
-    __pyx_t_4 = PyObject_Length(__pyx_v_qual); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2428; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Length(__pyx_v_qual); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2607; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_5 = (__pyx_t_4 == 0);
     __pyx_t_6 = __pyx_t_5;
   } else {
@@ -23569,7 +24955,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4qual_2__set__(struct __pyx_
   }
   if (__pyx_t_6) {
 
-    /* "pysam/csamtools.pyx":2430
+    /* "pysam/csamtools.pyx":2609
  *             if qual == None or len(qual) == 0:
  *                 # if absent - set to 0xff
  *                 p[0] = 0xff             # <<<<<<<<<<<<<<
@@ -23578,7 +24964,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4qual_2__set__(struct __pyx_
  */
     (__pyx_v_p[0]) = 0xff;
 
-    /* "pysam/csamtools.pyx":2431
+    /* "pysam/csamtools.pyx":2610
  *                 # if absent - set to 0xff
  *                 p[0] = 0xff
  *                 return             # <<<<<<<<<<<<<<
@@ -23591,40 +24977,40 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4qual_2__set__(struct __pyx_
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2432
+  /* "pysam/csamtools.pyx":2611
  *                 p[0] = 0xff
  *                 return
  *             qual = _force_bytes(qual)             # <<<<<<<<<<<<<<
  *             cdef int l
  *             # convert to C string
  */
-  __pyx_t_2 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_qual)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2432; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_qual)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2611; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_v_qual);
   __pyx_v_qual = __pyx_t_2;
   __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":2435
+  /* "pysam/csamtools.pyx":2614
  *             cdef int l
  *             # convert to C string
  *             q = qual             # <<<<<<<<<<<<<<
  *             l = len(qual)
  *             if src.core.l_qseq != l:
  */
-  __pyx_t_7 = PyBytes_AsString(__pyx_v_qual); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2435; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyBytes_AsString(__pyx_v_qual); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_q = __pyx_t_7;
 
-  /* "pysam/csamtools.pyx":2436
+  /* "pysam/csamtools.pyx":2615
  *             # convert to C string
  *             q = qual
  *             l = len(qual)             # <<<<<<<<<<<<<<
  *             if src.core.l_qseq != l:
  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))
  */
-  __pyx_t_4 = PyObject_Length(__pyx_v_qual); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Length(__pyx_v_qual); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_l = __pyx_t_4;
 
-  /* "pysam/csamtools.pyx":2437
+  /* "pysam/csamtools.pyx":2616
  *             q = qual
  *             l = len(qual)
  *             if src.core.l_qseq != l:             # <<<<<<<<<<<<<<
@@ -23634,18 +25020,18 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4qual_2__set__(struct __pyx_
   __pyx_t_6 = (__pyx_v_src->core.l_qseq != __pyx_v_l);
   if (__pyx_t_6) {
 
-    /* "pysam/csamtools.pyx":2438
+    /* "pysam/csamtools.pyx":2617
  *             l = len(qual)
  *             if src.core.l_qseq != l:
  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))             # <<<<<<<<<<<<<<
  *             assert src.core.l_qseq == l
  *             for k from 0 <= k < l:
  */
-    __pyx_t_2 = PyInt_FromLong(__pyx_v_l); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyInt_FromLong(__pyx_v_l); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_8 = __Pyx_PyInt_to_py_int32_t(__pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = __Pyx_PyInt_to_py_int32_t(__pyx_v_src->core.l_qseq); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
-    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
     __Pyx_GIVEREF(__pyx_t_2);
@@ -23653,25 +25039,25 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4qual_2__set__(struct __pyx_
     __Pyx_GIVEREF(__pyx_t_8);
     __pyx_t_2 = 0;
     __pyx_t_8 = 0;
-    __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_140), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_148), ((PyObject *)__pyx_t_9)); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_8));
     __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
-    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)__pyx_t_8));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
     __pyx_t_8 = 0;
-    __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
     __Pyx_Raise(__pyx_t_8, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L4;
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":2439
+  /* "pysam/csamtools.pyx":2618
  *             if src.core.l_qseq != l:
  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))
  *             assert src.core.l_qseq == l             # <<<<<<<<<<<<<<
@@ -23681,11 +25067,11 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4qual_2__set__(struct __pyx_
   #ifndef CYTHON_WITHOUT_ASSERTIONS
   if (unlikely(!(__pyx_v_src->core.l_qseq == __pyx_v_l))) {
     PyErr_SetNone(PyExc_AssertionError);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
-  /* "pysam/csamtools.pyx":2440
+  /* "pysam/csamtools.pyx":2619
  *                 raise ValueError("quality and sequence mismatch: %i != %i" % (l, src.core.l_qseq))
  *             assert src.core.l_qseq == l
  *             for k from 0 <= k < l:             # <<<<<<<<<<<<<<
@@ -23695,7 +25081,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4qual_2__set__(struct __pyx_
   __pyx_t_10 = __pyx_v_l;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_10; __pyx_v_k++) {
 
-    /* "pysam/csamtools.pyx":2441
+    /* "pysam/csamtools.pyx":2620
  *             assert src.core.l_qseq == l
  *             for k from 0 <= k < l:
  *                 p[k] = <uint8_t>q[k] - 33             # <<<<<<<<<<<<<<
@@ -23731,7 +25117,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_5query_1__get__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2455
+/* "pysam/csamtools.pyx":2634
  *         were not considered for alignment may have been retained."""
  * 
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -23754,9 +25140,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5query___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2455);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2634);
 
-  /* "pysam/csamtools.pyx":2460
+  /* "pysam/csamtools.pyx":2639
  *             cdef char * s
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -23766,7 +25152,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5query___get__(struct
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2462
+  /* "pysam/csamtools.pyx":2641
  *             src = self._delegate
  * 
  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
@@ -23783,27 +25169,27 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5query___get__(struct
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2464
+  /* "pysam/csamtools.pyx":2643
  *             if src.core.l_qseq == 0: return None
  * 
  *             start = query_start(src)             # <<<<<<<<<<<<<<
  *             end   = query_end(src)
  * 
  */
-  __pyx_t_3 = __pyx_f_5pysam_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2464; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __pyx_f_5pysam_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_start = __pyx_t_3;
 
-  /* "pysam/csamtools.pyx":2465
+  /* "pysam/csamtools.pyx":2644
  * 
  *             start = query_start(src)
  *             end   = query_end(src)             # <<<<<<<<<<<<<<
  * 
  *             return get_seq_range(src, start, end)
  */
-  __pyx_t_3 = __pyx_f_5pysam_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __pyx_f_5pysam_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2644; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_end = __pyx_t_3;
 
-  /* "pysam/csamtools.pyx":2467
+  /* "pysam/csamtools.pyx":2646
  *             end   = query_end(src)
  * 
  *             return get_seq_range(src, start, end)             # <<<<<<<<<<<<<<
@@ -23811,7 +25197,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5query___get__(struct
  *     property qqual:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_4 = __pyx_f_5pysam_9csamtools_get_seq_range(__pyx_v_src, __pyx_v_start, __pyx_v_end); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __pyx_f_5pysam_9csamtools_get_seq_range(__pyx_v_src, __pyx_v_start, __pyx_v_end); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __pyx_r = __pyx_t_4;
   __pyx_t_4 = 0;
@@ -23841,7 +25227,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_5qqual_1__get__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2473
+/* "pysam/csamtools.pyx":2652
  * 
  *         In Python 3, this property is of type bytes."""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -23864,9 +25250,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5qqual___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2473);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2652);
 
-  /* "pysam/csamtools.pyx":2477
+  /* "pysam/csamtools.pyx":2656
  *             cdef uint32_t start, end
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -23876,7 +25262,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5qqual___get__(struct
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2479
+  /* "pysam/csamtools.pyx":2658
  *             src = self._delegate
  * 
  *             if src.core.l_qseq == 0: return None             # <<<<<<<<<<<<<<
@@ -23893,27 +25279,27 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5qqual___get__(struct
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2481
+  /* "pysam/csamtools.pyx":2660
  *             if src.core.l_qseq == 0: return None
  * 
  *             start = query_start(src)             # <<<<<<<<<<<<<<
  *             end   = query_end(src)
  * 
  */
-  __pyx_t_3 = __pyx_f_5pysam_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __pyx_f_5pysam_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2660; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_start = __pyx_t_3;
 
-  /* "pysam/csamtools.pyx":2482
+  /* "pysam/csamtools.pyx":2661
  * 
  *             start = query_start(src)
  *             end   = query_end(src)             # <<<<<<<<<<<<<<
  * 
  *             return get_qual_range(src, start, end)
  */
-  __pyx_t_3 = __pyx_f_5pysam_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2482; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __pyx_f_5pysam_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2661; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_end = __pyx_t_3;
 
-  /* "pysam/csamtools.pyx":2484
+  /* "pysam/csamtools.pyx":2663
  *             end   = query_end(src)
  * 
  *             return get_qual_range(src, start, end)             # <<<<<<<<<<<<<<
@@ -23921,7 +25307,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5qqual___get__(struct
  *     property qstart:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_4 = __pyx_f_5pysam_9csamtools_get_qual_range(__pyx_v_src, __pyx_v_start, __pyx_v_end); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2484; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __pyx_f_5pysam_9csamtools_get_qual_range(__pyx_v_src, __pyx_v_start, __pyx_v_end); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __pyx_r = __pyx_t_4;
   __pyx_t_4 = 0;
@@ -23951,7 +25337,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_6qstart_1__get__(PyObj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2488
+/* "pysam/csamtools.pyx":2667
  *     property qstart:
  *         """start index of the aligned query portion of the sequence (0-based, inclusive)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -23969,9 +25355,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6qstart___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2488);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2667);
 
-  /* "pysam/csamtools.pyx":2489
+  /* "pysam/csamtools.pyx":2668
  *         """start index of the aligned query portion of the sequence (0-based, inclusive)"""
  *         def __get__(self):
  *             return query_start(self._delegate)             # <<<<<<<<<<<<<<
@@ -23979,8 +25365,8 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_6qstart___get__(struct
  *     property qend:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __pyx_f_5pysam_9csamtools_query_start(__pyx_v_self->_delegate); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_5pysam_9csamtools_query_start(__pyx_v_self->_delegate); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2668; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -24010,7 +25396,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_4qend_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2493
+/* "pysam/csamtools.pyx":2672
  *     property qend:
  *         """end index of the aligned query portion of the sequence (0-based, exclusive)"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -24028,9 +25414,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4qend___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2493);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2672);
 
-  /* "pysam/csamtools.pyx":2494
+  /* "pysam/csamtools.pyx":2673
  *         """end index of the aligned query portion of the sequence (0-based, exclusive)"""
  *         def __get__(self):
  *             return query_end(self._delegate)             # <<<<<<<<<<<<<<
@@ -24038,8 +25424,8 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4qend___get__(struct _
  *     property qlen:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __pyx_f_5pysam_9csamtools_query_end(__pyx_v_self->_delegate); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2494; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_5pysam_9csamtools_query_end(__pyx_v_self->_delegate); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_to_py_int32_t(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2673; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __pyx_r = __pyx_t_2;
   __pyx_t_2 = 0;
@@ -24069,7 +25455,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_4qlen_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2498
+/* "pysam/csamtools.pyx":2677
  *     property qlen:
  *         """Length of the aligned query sequence"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -24090,9 +25476,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4qlen___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2498);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2677);
 
-  /* "pysam/csamtools.pyx":2500
+  /* "pysam/csamtools.pyx":2679
  *         def __get__(self):
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -24102,7 +25488,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4qlen___get__(struct _
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2501
+  /* "pysam/csamtools.pyx":2680
  *             cdef bam1_t * src
  *             src = self._delegate
  *             return query_end(src)-query_start(src)             # <<<<<<<<<<<<<<
@@ -24110,9 +25496,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4qlen___get__(struct _
  *     property tags:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_2 = __pyx_f_5pysam_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __pyx_f_5pysam_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_4 = PyInt_FromLong((__pyx_t_2 - __pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __pyx_f_5pysam_9csamtools_query_end(__pyx_v_src); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __pyx_f_5pysam_9csamtools_query_start(__pyx_v_src); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyInt_FromLong((__pyx_t_2 - __pyx_t_3)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __pyx_r = __pyx_t_4;
   __pyx_t_4 = 0;
@@ -24142,7 +25528,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_4tags_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2518
+/* "pysam/csamtools.pyx":2697
  *         multiple times.
  *         """
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -24181,9 +25567,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2518);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2697);
 
-  /* "pysam/csamtools.pyx":2527
+  /* "pysam/csamtools.pyx":2706
  *             cdef int32_t nvalues
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -24193,7 +25579,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2528
+  /* "pysam/csamtools.pyx":2707
  * 
  *             src = self._delegate
  *             if src.l_aux == 0: return []             # <<<<<<<<<<<<<<
@@ -24203,7 +25589,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
   __pyx_t_2 = (__pyx_v_src->l_aux == 0);
   if (__pyx_t_2) {
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2707; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = ((PyObject *)__pyx_t_3);
     __pyx_t_3 = 0;
@@ -24212,7 +25598,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2529
+  /* "pysam/csamtools.pyx":2708
  *             src = self._delegate
  *             if src.l_aux == 0: return []
  *             s = bam1_aux( src )             # <<<<<<<<<<<<<<
@@ -24221,19 +25607,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
  */
   __pyx_v_s = bam1_aux(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2530
+  /* "pysam/csamtools.pyx":2709
  *             if src.l_aux == 0: return []
  *             s = bam1_aux( src )
  *             result = []             # <<<<<<<<<<<<<<
  *             auxtag[2] = 0
  *             while s < (src.data + src.data_len):
  */
-  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2530; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2709; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_v_result = ((PyObject*)__pyx_t_3);
   __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":2531
+  /* "pysam/csamtools.pyx":2710
  *             s = bam1_aux( src )
  *             result = []
  *             auxtag[2] = 0             # <<<<<<<<<<<<<<
@@ -24242,7 +25628,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
  */
   (__pyx_v_auxtag[2]) = 0;
 
-  /* "pysam/csamtools.pyx":2532
+  /* "pysam/csamtools.pyx":2711
  *             result = []
  *             auxtag[2] = 0
  *             while s < (src.data + src.data_len):             # <<<<<<<<<<<<<<
@@ -24253,7 +25639,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
     __pyx_t_2 = (__pyx_v_s < (__pyx_v_src->data + __pyx_v_src->data_len));
     if (!__pyx_t_2) break;
 
-    /* "pysam/csamtools.pyx":2534
+    /* "pysam/csamtools.pyx":2713
  *             while s < (src.data + src.data_len):
  *                 # get tag
  *                 auxtag[0] = s[0]             # <<<<<<<<<<<<<<
@@ -24262,7 +25648,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
  */
     (__pyx_v_auxtag[0]) = (__pyx_v_s[0]);
 
-    /* "pysam/csamtools.pyx":2535
+    /* "pysam/csamtools.pyx":2714
  *                 # get tag
  *                 auxtag[0] = s[0]
  *                 auxtag[1] = s[1]             # <<<<<<<<<<<<<<
@@ -24271,7 +25657,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
  */
     (__pyx_v_auxtag[1]) = (__pyx_v_s[1]);
 
-    /* "pysam/csamtools.pyx":2536
+    /* "pysam/csamtools.pyx":2715
  *                 auxtag[0] = s[0]
  *                 auxtag[1] = s[1]
  *                 s += 2             # <<<<<<<<<<<<<<
@@ -24280,7 +25666,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
  */
     __pyx_v_s = (__pyx_v_s + 2);
 
-    /* "pysam/csamtools.pyx":2537
+    /* "pysam/csamtools.pyx":2716
  *                 auxtag[1] = s[1]
  *                 s += 2
  *                 auxtype = s[0]             # <<<<<<<<<<<<<<
@@ -24289,7 +25675,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
  */
     __pyx_v_auxtype = (__pyx_v_s[0]);
 
-    /* "pysam/csamtools.pyx":2538
+    /* "pysam/csamtools.pyx":2717
  *                 s += 2
  *                 auxtype = s[0]
  *                 if auxtype in ('c', 'C'):             # <<<<<<<<<<<<<<
@@ -24307,20 +25693,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
     __pyx_t_2 = __pyx_t_6;
     if (__pyx_t_2) {
 
-      /* "pysam/csamtools.pyx":2539
+      /* "pysam/csamtools.pyx":2718
  *                 auxtype = s[0]
  *                 if auxtype in ('c', 'C'):
  *                     value = <int>bam_aux2i(s)             # <<<<<<<<<<<<<<
  *                     s += 1
  *                 elif auxtype in ('s', 'S'):
  */
-      __pyx_t_3 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2539; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_XDECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_3;
       __pyx_t_3 = 0;
 
-      /* "pysam/csamtools.pyx":2540
+      /* "pysam/csamtools.pyx":2719
  *                 if auxtype in ('c', 'C'):
  *                     value = <int>bam_aux2i(s)
  *                     s += 1             # <<<<<<<<<<<<<<
@@ -24331,7 +25717,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
       goto __pyx_L6;
     }
 
-    /* "pysam/csamtools.pyx":2541
+    /* "pysam/csamtools.pyx":2720
  *                     value = <int>bam_aux2i(s)
  *                     s += 1
  *                 elif auxtype in ('s', 'S'):             # <<<<<<<<<<<<<<
@@ -24349,20 +25735,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
     __pyx_t_2 = __pyx_t_5;
     if (__pyx_t_2) {
 
-      /* "pysam/csamtools.pyx":2542
+      /* "pysam/csamtools.pyx":2721
  *                     s += 1
  *                 elif auxtype in ('s', 'S'):
  *                     value = <int>bam_aux2i(s)             # <<<<<<<<<<<<<<
  *                     s += 2
  *                 elif auxtype in ('i', 'I'):
  */
-      __pyx_t_3 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2542; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2721; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_XDECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_3;
       __pyx_t_3 = 0;
 
-      /* "pysam/csamtools.pyx":2543
+      /* "pysam/csamtools.pyx":2722
  *                 elif auxtype in ('s', 'S'):
  *                     value = <int>bam_aux2i(s)
  *                     s += 2             # <<<<<<<<<<<<<<
@@ -24373,7 +25759,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
       goto __pyx_L6;
     }
 
-    /* "pysam/csamtools.pyx":2544
+    /* "pysam/csamtools.pyx":2723
  *                     value = <int>bam_aux2i(s)
  *                     s += 2
  *                 elif auxtype in ('i', 'I'):             # <<<<<<<<<<<<<<
@@ -24391,20 +25777,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
     __pyx_t_2 = __pyx_t_6;
     if (__pyx_t_2) {
 
-      /* "pysam/csamtools.pyx":2545
+      /* "pysam/csamtools.pyx":2724
  *                     s += 2
  *                 elif auxtype in ('i', 'I'):
  *                     value = <int32_t>bam_aux2i(s)             # <<<<<<<<<<<<<<
  *                     s += 4
  *                 elif auxtype == 'f':
  */
-      __pyx_t_3 = __Pyx_PyInt_to_py_int32_t(((int32_t)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyInt_to_py_int32_t(((int32_t)bam_aux2i(__pyx_v_s))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2724; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_XDECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_3;
       __pyx_t_3 = 0;
 
-      /* "pysam/csamtools.pyx":2546
+      /* "pysam/csamtools.pyx":2725
  *                 elif auxtype in ('i', 'I'):
  *                     value = <int32_t>bam_aux2i(s)
  *                     s += 4             # <<<<<<<<<<<<<<
@@ -24415,7 +25801,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
       goto __pyx_L6;
     }
 
-    /* "pysam/csamtools.pyx":2547
+    /* "pysam/csamtools.pyx":2726
  *                     value = <int32_t>bam_aux2i(s)
  *                     s += 4
  *                 elif auxtype == 'f':             # <<<<<<<<<<<<<<
@@ -24425,20 +25811,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
     __pyx_t_2 = (__pyx_v_auxtype == 'f');
     if (__pyx_t_2) {
 
-      /* "pysam/csamtools.pyx":2548
+      /* "pysam/csamtools.pyx":2727
  *                     s += 4
  *                 elif auxtype == 'f':
  *                     value = <float>bam_aux2f(s)             # <<<<<<<<<<<<<<
  *                     s += 4
  *                 elif auxtype == 'd':
  */
-      __pyx_t_3 = PyFloat_FromDouble(((float)bam_aux2f(__pyx_v_s))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2548; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyFloat_FromDouble(((float)bam_aux2f(__pyx_v_s))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2727; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_XDECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_3;
       __pyx_t_3 = 0;
 
-      /* "pysam/csamtools.pyx":2549
+      /* "pysam/csamtools.pyx":2728
  *                 elif auxtype == 'f':
  *                     value = <float>bam_aux2f(s)
  *                     s += 4             # <<<<<<<<<<<<<<
@@ -24449,7 +25835,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
       goto __pyx_L6;
     }
 
-    /* "pysam/csamtools.pyx":2550
+    /* "pysam/csamtools.pyx":2729
  *                     value = <float>bam_aux2f(s)
  *                     s += 4
  *                 elif auxtype == 'd':             # <<<<<<<<<<<<<<
@@ -24459,20 +25845,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
     __pyx_t_2 = (__pyx_v_auxtype == 'd');
     if (__pyx_t_2) {
 
-      /* "pysam/csamtools.pyx":2551
+      /* "pysam/csamtools.pyx":2730
  *                     s += 4
  *                 elif auxtype == 'd':
  *                     value = <double>bam_aux2d(s)             # <<<<<<<<<<<<<<
  *                     s += 8
  *                 elif auxtype == 'A':
  */
-      __pyx_t_3 = PyFloat_FromDouble(((double)bam_aux2d(__pyx_v_s))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2551; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyFloat_FromDouble(((double)bam_aux2d(__pyx_v_s))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2730; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_XDECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_3;
       __pyx_t_3 = 0;
 
-      /* "pysam/csamtools.pyx":2552
+      /* "pysam/csamtools.pyx":2731
  *                 elif auxtype == 'd':
  *                     value = <double>bam_aux2d(s)
  *                     s += 8             # <<<<<<<<<<<<<<
@@ -24483,7 +25869,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
       goto __pyx_L6;
     }
 
-    /* "pysam/csamtools.pyx":2553
+    /* "pysam/csamtools.pyx":2732
  *                     value = <double>bam_aux2d(s)
  *                     s += 8
  *                 elif auxtype == 'A':             # <<<<<<<<<<<<<<
@@ -24493,23 +25879,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
     __pyx_t_2 = (__pyx_v_auxtype == 'A');
     if (__pyx_t_2) {
 
-      /* "pysam/csamtools.pyx":2554
+      /* "pysam/csamtools.pyx":2733
  *                     s += 8
  *                 elif auxtype == 'A':
  *                     value = "%c" % <char>bam_aux2A(s)             # <<<<<<<<<<<<<<
  *                     s += 1
  *                 elif auxtype in ('Z', 'H'):
  */
-      __pyx_t_3 = PyInt_FromLong(((char)bam_aux2A(__pyx_v_s))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyInt_FromLong(((char)bam_aux2A(__pyx_v_s))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_141), __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2554; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_149), __pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2733; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_7));
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __Pyx_XDECREF(__pyx_v_value);
       __pyx_v_value = ((PyObject *)__pyx_t_7);
       __pyx_t_7 = 0;
 
-      /* "pysam/csamtools.pyx":2555
+      /* "pysam/csamtools.pyx":2734
  *                 elif auxtype == 'A':
  *                     value = "%c" % <char>bam_aux2A(s)
  *                     s += 1             # <<<<<<<<<<<<<<
@@ -24520,7 +25906,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
       goto __pyx_L6;
     }
 
-    /* "pysam/csamtools.pyx":2556
+    /* "pysam/csamtools.pyx":2735
  *                     value = "%c" % <char>bam_aux2A(s)
  *                     s += 1
  *                 elif auxtype in ('Z', 'H'):             # <<<<<<<<<<<<<<
@@ -24538,32 +25924,32 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
     __pyx_t_2 = __pyx_t_5;
     if (__pyx_t_2) {
 
-      /* "pysam/csamtools.pyx":2557
+      /* "pysam/csamtools.pyx":2736
  *                     s += 1
  *                 elif auxtype in ('Z', 'H'):
  *                     value = _charptr_to_str(<char*>bam_aux2Z(s))             # <<<<<<<<<<<<<<
  *                     # +1 for NULL terminated string
  *                     s += len(value) + 1
  */
-      __pyx_t_7 = __pyx_f_5pysam_9csamtools__charptr_to_str(((char *)bam_aux2Z(__pyx_v_s))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2557; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __pyx_f_5pysam_9csamtools__charptr_to_str(((char *)bam_aux2Z(__pyx_v_s))); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2736; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_XDECREF(__pyx_v_value);
       __pyx_v_value = __pyx_t_7;
       __pyx_t_7 = 0;
 
-      /* "pysam/csamtools.pyx":2559
+      /* "pysam/csamtools.pyx":2738
  *                     value = _charptr_to_str(<char*>bam_aux2Z(s))
  *                     # +1 for NULL terminated string
  *                     s += len(value) + 1             # <<<<<<<<<<<<<<
  *                 elif auxtype == 'B':
  *                     s += 1
  */
-      __pyx_t_8 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2559; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_v_s = (__pyx_v_s + (__pyx_t_8 + 1));
       goto __pyx_L6;
     }
 
-    /* "pysam/csamtools.pyx":2560
+    /* "pysam/csamtools.pyx":2739
  *                     # +1 for NULL terminated string
  *                     s += len(value) + 1
  *                 elif auxtype == 'B':             # <<<<<<<<<<<<<<
@@ -24573,7 +25959,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
     __pyx_t_2 = (__pyx_v_auxtype == 'B');
     if (__pyx_t_2) {
 
-      /* "pysam/csamtools.pyx":2561
+      /* "pysam/csamtools.pyx":2740
  *                     s += len(value) + 1
  *                 elif auxtype == 'B':
  *                     s += 1             # <<<<<<<<<<<<<<
@@ -24582,14 +25968,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
  */
       __pyx_v_s = (__pyx_v_s + 1);
 
-      /* "pysam/csamtools.pyx":2562
+      /* "pysam/csamtools.pyx":2741
  *                 elif auxtype == 'B':
  *                     s += 1
  *                     byte_size, nvalues, value = convertBinaryTagToList( s )             # <<<<<<<<<<<<<<
  *                     # 5 for 1 char and 1 int
  *                     s += 5 + ( nvalues * byte_size) - 1
  */
-      __pyx_t_7 = __pyx_f_5pysam_9csamtools_convertBinaryTagToList(__pyx_v_s); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __pyx_f_5pysam_9csamtools_convertBinaryTagToList(__pyx_v_s); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       if ((likely(PyTuple_CheckExact(__pyx_t_7))) || (PyList_CheckExact(__pyx_t_7))) {
         PyObject* sequence = __pyx_t_7;
@@ -24601,7 +25987,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
         if (unlikely(size != 3)) {
           if (size > 3) __Pyx_RaiseTooManyValuesError(3);
           else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         #if CYTHON_COMPILING_IN_CPYTHON
         if (likely(PyTuple_CheckExact(sequence))) {
@@ -24617,18 +26003,18 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
         __Pyx_INCREF(__pyx_t_9);
         __Pyx_INCREF(__pyx_t_10);
         #else
-        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_9);
-        __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_10);
         #endif
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       } else
       {
         Py_ssize_t index = -1;
-        __pyx_t_11 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_11 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_11);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
         __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
@@ -24638,7 +26024,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
         __Pyx_GOTREF(__pyx_t_9);
         index = 2; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L7_unpacking_failed;
         __Pyx_GOTREF(__pyx_t_10);
-        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_t_12 = NULL;
         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
         goto __pyx_L8_unpacking_done;
@@ -24646,12 +26032,12 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
         __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
         __pyx_t_12 = NULL;
         if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_L8_unpacking_done:;
       }
-      __pyx_t_13 = __Pyx_PyInt_from_py_uint8_t(__pyx_t_3); if (unlikely((__pyx_t_13 == (uint8_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_13 = __Pyx_PyInt_from_py_uint8_t(__pyx_t_3); if (unlikely((__pyx_t_13 == (uint8_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_14 = __Pyx_PyInt_from_py_int32_t(__pyx_t_9); if (unlikely((__pyx_t_14 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2562; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_14 = __Pyx_PyInt_from_py_int32_t(__pyx_t_9); if (unlikely((__pyx_t_14 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2741; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
       __pyx_v_byte_size = __pyx_t_13;
       __pyx_v_nvalues = __pyx_t_14;
@@ -24659,7 +26045,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
       __pyx_v_value = __pyx_t_10;
       __pyx_t_10 = 0;
 
-      /* "pysam/csamtools.pyx":2564
+      /* "pysam/csamtools.pyx":2743
  *                     byte_size, nvalues, value = convertBinaryTagToList( s )
  *                     # 5 for 1 char and 1 int
  *                     s += 5 + ( nvalues * byte_size) - 1             # <<<<<<<<<<<<<<
@@ -24671,7 +26057,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
     }
     __pyx_L6:;
 
-    /* "pysam/csamtools.pyx":2566
+    /* "pysam/csamtools.pyx":2745
  *                     s += 5 + ( nvalues * byte_size) - 1
  * 
  *                 s += 1             # <<<<<<<<<<<<<<
@@ -24680,17 +26066,17 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
  */
     __pyx_v_s = (__pyx_v_s + 1);
 
-    /* "pysam/csamtools.pyx":2568
+    /* "pysam/csamtools.pyx":2747
  *                 s += 1
  * 
  *                 result.append( (_charptr_to_str(auxtag), value) )             # <<<<<<<<<<<<<<
  * 
  *             return result
  */
-    __pyx_t_7 = __pyx_f_5pysam_9csamtools__charptr_to_str(__pyx_v_auxtag); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __pyx_f_5pysam_9csamtools__charptr_to_str(__pyx_v_auxtag); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    if (unlikely(!__pyx_v_value)) { __Pyx_RaiseUnboundLocalError("value"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2568; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
-    __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(!__pyx_v_value)) { __Pyx_RaiseUnboundLocalError("value"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2747; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+    __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_10);
     PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7);
     __Pyx_GIVEREF(__pyx_t_7);
@@ -24698,11 +26084,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tags___get__(struct _
     PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_v_value);
     __Pyx_GIVEREF(__pyx_v_value);
     __pyx_t_7 = 0;
-    __pyx_t_15 = PyList_Append(__pyx_v_result, ((PyObject *)__pyx_t_10)); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2568; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_15 = PyList_Append(__pyx_v_result, ((PyObject *)__pyx_t_10)); if (unlikely(__pyx_t_15 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
   }
 
-  /* "pysam/csamtools.pyx":2570
+  /* "pysam/csamtools.pyx":2749
  *                 result.append( (_charptr_to_str(auxtag), value) )
  * 
  *             return result             # <<<<<<<<<<<<<<
@@ -24744,7 +26130,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_4tags_3__set__(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2572
+/* "pysam/csamtools.pyx":2751
  *             return result
  * 
  *         def __set__(self, tags):             # <<<<<<<<<<<<<<
@@ -24797,9 +26183,9 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2572);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2751);
 
-  /* "pysam/csamtools.pyx":2578
+  /* "pysam/csamtools.pyx":2757
  *             cdef char * temp
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -24809,38 +26195,38 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2580
+  /* "pysam/csamtools.pyx":2759
  *             src = self._delegate
  * 
  *             fmts, args = ["<"], []             # <<<<<<<<<<<<<<
  * 
  *             if tags != None:
  */
-  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __Pyx_INCREF(((PyObject *)__pyx_kp_s_142));
-  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_142));
-  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_142));
-  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2580; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(((PyObject *)__pyx_kp_s_150));
+  PyList_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_kp_s_150));
+  __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_150));
+  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2759; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_v_fmts = ((PyObject*)__pyx_t_2);
   __pyx_t_2 = 0;
   __pyx_v_args = ((PyObject*)__pyx_t_3);
   __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":2582
+  /* "pysam/csamtools.pyx":2761
  *             fmts, args = ["<"], []
  * 
  *             if tags != None:             # <<<<<<<<<<<<<<
  * 
  *                 # map samtools code to python.struct code and byte size
  */
-  __pyx_t_3 = PyObject_RichCompare(__pyx_v_tags, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2582; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_RichCompare(__pyx_v_tags, Py_None, Py_NE); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2761; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":2585
+    /* "pysam/csamtools.pyx":2764
  * 
  *                 # map samtools code to python.struct code and byte size
  *                 for pytag, value in tags:             # <<<<<<<<<<<<<<
@@ -24851,7 +26237,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       __pyx_t_3 = __pyx_v_tags; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
       __pyx_t_6 = NULL;
     } else {
-      __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_tags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_v_tags); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext;
     }
@@ -24859,23 +26245,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       if (!__pyx_t_6 && PyList_CheckExact(__pyx_t_3)) {
         if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else if (!__pyx_t_6 && PyTuple_CheckExact(__pyx_t_3)) {
         if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
         #if CYTHON_COMPILING_IN_CPYTHON
-        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_2); __pyx_t_5++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #else
-        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         #endif
       } else {
         __pyx_t_2 = __pyx_t_6(__pyx_t_3);
         if (unlikely(!__pyx_t_2)) {
           if (PyErr_Occurred()) {
             if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           }
           break;
         }
@@ -24891,7 +26277,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         if (unlikely(size != 2)) {
           if (size > 2) __Pyx_RaiseTooManyValuesError(2);
           else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         #if CYTHON_COMPILING_IN_CPYTHON
         if (likely(PyTuple_CheckExact(sequence))) {
@@ -24904,16 +26290,16 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         __Pyx_INCREF(__pyx_t_7);
         __Pyx_INCREF(__pyx_t_8);
         #else
-        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         #endif
         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
       } else
       {
         Py_ssize_t index = -1;
-        __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_9);
         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
         __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext;
@@ -24921,7 +26307,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         __Pyx_GOTREF(__pyx_t_7);
         index = 1; __pyx_t_8 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_8)) goto __pyx_L6_unpacking_failed;
         __Pyx_GOTREF(__pyx_t_8);
-        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_t_10 = NULL;
         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
         goto __pyx_L7_unpacking_done;
@@ -24929,7 +26315,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
         __pyx_t_10 = NULL;
         if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2585; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2764; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_L7_unpacking_done:;
       }
       __Pyx_XDECREF(__pyx_v_pytag);
@@ -24939,7 +26325,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       __pyx_v_value = __pyx_t_8;
       __pyx_t_8 = 0;
 
-      /* "pysam/csamtools.pyx":2586
+      /* "pysam/csamtools.pyx":2765
  *                 # map samtools code to python.struct code and byte size
  *                 for pytag, value in tags:
  *                     if not type(pytag) is bytes:             # <<<<<<<<<<<<<<
@@ -24950,16 +26336,16 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       __pyx_t_11 = (!__pyx_t_4);
       if (__pyx_t_11) {
 
-        /* "pysam/csamtools.pyx":2587
+        /* "pysam/csamtools.pyx":2766
  *                 for pytag, value in tags:
  *                     if not type(pytag) is bytes:
  *                         pytag = pytag.encode('ascii')             # <<<<<<<<<<<<<<
  *                     t = type(value)
  * 
  */
-        __pyx_t_2 = PyObject_GetAttr(__pyx_v_pytag, __pyx_n_s__encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyObject_GetAttr(__pyx_v_pytag, __pyx_n_s__encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
-        __pyx_t_8 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_143), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_151), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
         __Pyx_DECREF(__pyx_v_pytag);
@@ -24969,7 +26355,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       }
       __pyx_L8:;
 
-      /* "pysam/csamtools.pyx":2588
+      /* "pysam/csamtools.pyx":2767
  *                     if not type(pytag) is bytes:
  *                         pytag = pytag.encode('ascii')
  *                     t = type(value)             # <<<<<<<<<<<<<<
@@ -24980,7 +26366,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       __Pyx_XDECREF(((PyObject *)__pyx_v_t));
       __pyx_v_t = ((PyObject*)((PyObject *)Py_TYPE(__pyx_v_value)));
 
-      /* "pysam/csamtools.pyx":2590
+      /* "pysam/csamtools.pyx":2769
  *                     t = type(value)
  * 
  *                     if t is tuple or t is list:             # <<<<<<<<<<<<<<
@@ -24996,7 +26382,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       }
       if (__pyx_t_12) {
 
-        /* "pysam/csamtools.pyx":2592
+        /* "pysam/csamtools.pyx":2771
  *                     if t is tuple or t is list:
  *                         # binary tags - treat separately
  *                         pytype = 'B'             # <<<<<<<<<<<<<<
@@ -25007,20 +26393,20 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         __Pyx_XDECREF(__pyx_v_pytype);
         __pyx_v_pytype = ((PyObject *)__pyx_n_s__B);
 
-        /* "pysam/csamtools.pyx":2594
+        /* "pysam/csamtools.pyx":2773
  *                         pytype = 'B'
  *                         # get data type - first value determines type
  *                         if type(value[0]) is float:             # <<<<<<<<<<<<<<
  *                             datafmt, datatype = "f", "f"
  *                         else:
  */
-        __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_value, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2594; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = __Pyx_GetItemInt(__pyx_v_value, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_8) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __pyx_t_12 = (((PyObject *)Py_TYPE(__pyx_t_8)) == ((PyObject *)((PyObject*)(&PyFloat_Type))));
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
         if (__pyx_t_12) {
 
-          /* "pysam/csamtools.pyx":2595
+          /* "pysam/csamtools.pyx":2774
  *                         # get data type - first value determines type
  *                         if type(value[0]) is float:
  *                             datafmt, datatype = "f", "f"             # <<<<<<<<<<<<<<
@@ -25041,27 +26427,27 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         }
         /*else*/ {
 
-          /* "pysam/csamtools.pyx":2597
+          /* "pysam/csamtools.pyx":2776
  *                             datafmt, datatype = "f", "f"
  *                         else:
  *                             mi, ma = min(value), max(value)             # <<<<<<<<<<<<<<
  *                             absmax = max( abs(mi), abs(ma) )
  *                             # signed ints
  */
-          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_2);
           __Pyx_INCREF(__pyx_v_value);
           PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_value);
           __Pyx_GIVEREF(__pyx_v_value);
-          __pyx_t_8 = PyObject_Call(__pyx_builtin_min, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyObject_Call(__pyx_builtin_min, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_8);
           __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_2);
           __Pyx_INCREF(__pyx_v_value);
           PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_value);
           __Pyx_GIVEREF(__pyx_v_value);
-          __pyx_t_7 = PyObject_Call(__pyx_builtin_max, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyObject_Call(__pyx_builtin_max, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
           __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
           __Pyx_XDECREF(__pyx_v_mi);
@@ -25071,19 +26457,19 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
           __pyx_v_ma = __pyx_t_7;
           __pyx_t_7 = 0;
 
-          /* "pysam/csamtools.pyx":2598
+          /* "pysam/csamtools.pyx":2777
  *                         else:
  *                             mi, ma = min(value), max(value)
  *                             absmax = max( abs(mi), abs(ma) )             # <<<<<<<<<<<<<<
  *                             # signed ints
  *                             if mi < 0:
  */
-          __pyx_t_7 = PyNumber_Absolute(__pyx_v_ma); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyNumber_Absolute(__pyx_v_ma); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_7);
-          __pyx_t_8 = PyNumber_Absolute(__pyx_v_mi); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyNumber_Absolute(__pyx_v_mi); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_8);
-          __pyx_t_9 = PyObject_RichCompare(__pyx_t_7, __pyx_t_8, Py_GT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2598; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_9 = PyObject_RichCompare(__pyx_t_7, __pyx_t_8, Py_GT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
           if (__pyx_t_12) {
             __Pyx_INCREF(__pyx_t_7);
@@ -25101,27 +26487,27 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
           __pyx_v_absmax = __pyx_t_7;
           __pyx_t_7 = 0;
 
-          /* "pysam/csamtools.pyx":2600
+          /* "pysam/csamtools.pyx":2779
  *                             absmax = max( abs(mi), abs(ma) )
  *                             # signed ints
  *                             if mi < 0:             # <<<<<<<<<<<<<<
  *                                 if mi >= -127: datafmt, datatype = "b", 'c'
  *                                 elif mi >= -32767: datafmt, datatype = "h", 's'
  */
-          __pyx_t_7 = PyObject_RichCompare(__pyx_v_mi, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2600; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_7 = PyObject_RichCompare(__pyx_v_mi, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2779; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
           if (__pyx_t_12) {
 
-            /* "pysam/csamtools.pyx":2601
+            /* "pysam/csamtools.pyx":2780
  *                             # signed ints
  *                             if mi < 0:
  *                                 if mi >= -127: datafmt, datatype = "b", 'c'             # <<<<<<<<<<<<<<
  *                                 elif mi >= -32767: datafmt, datatype = "h", 's'
  *                                 elif absmax < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  */
-            __pyx_t_7 = PyObject_RichCompare(__pyx_v_mi, __pyx_int_neg_127, Py_GE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2601; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_7 = PyObject_RichCompare(__pyx_v_mi, __pyx_int_neg_127, Py_GE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2780; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
             if (__pyx_t_12) {
               __pyx_t_7 = ((PyObject *)__pyx_n_s__b);
@@ -25137,15 +26523,15 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
               goto __pyx_L12;
             }
 
-            /* "pysam/csamtools.pyx":2602
+            /* "pysam/csamtools.pyx":2781
  *                             if mi < 0:
  *                                 if mi >= -127: datafmt, datatype = "b", 'c'
  *                                 elif mi >= -32767: datafmt, datatype = "h", 's'             # <<<<<<<<<<<<<<
  *                                 elif absmax < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                                 else: datafmt, datatype = "i", 'i'
  */
-            __pyx_t_2 = PyObject_RichCompare(__pyx_v_mi, __pyx_int_neg_32767, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2602; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_2 = PyObject_RichCompare(__pyx_v_mi, __pyx_int_neg_32767, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
             if (__pyx_t_12) {
               __pyx_t_2 = ((PyObject *)__pyx_n_s__h);
@@ -25161,35 +26547,35 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
               goto __pyx_L12;
             }
 
-            /* "pysam/csamtools.pyx":2603
+            /* "pysam/csamtools.pyx":2782
  *                                 if mi >= -127: datafmt, datatype = "b", 'c'
  *                                 elif mi >= -32767: datafmt, datatype = "h", 's'
  *                                 elif absmax < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )             # <<<<<<<<<<<<<<
  *                                 else: datafmt, datatype = "i", 'i'
  * 
  */
-            __pyx_t_7 = PyObject_RichCompare(__pyx_v_absmax, __pyx_int_neg_2147483648, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_7 = PyObject_RichCompare(__pyx_v_absmax, __pyx_int_neg_2147483648, Py_LT); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
             if (__pyx_t_12) {
-              __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_144), __pyx_v_value); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_152), __pyx_v_value); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
               __Pyx_GOTREF(((PyObject *)__pyx_t_7));
-              __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
               __Pyx_GOTREF(__pyx_t_2);
               PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_7));
               __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
               __pyx_t_7 = 0;
-              __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              __pyx_t_7 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
               __Pyx_GOTREF(__pyx_t_7);
               __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
               __Pyx_Raise(__pyx_t_7, 0, 0, 0);
               __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
               goto __pyx_L12;
             }
             /*else*/ {
 
-              /* "pysam/csamtools.pyx":2604
+              /* "pysam/csamtools.pyx":2783
  *                                 elif mi >= -32767: datafmt, datatype = "h", 's'
  *                                 elif absmax < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                                 else: datafmt, datatype = "i", 'i'             # <<<<<<<<<<<<<<
@@ -25212,15 +26598,15 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
           }
           /*else*/ {
 
-            /* "pysam/csamtools.pyx":2608
+            /* "pysam/csamtools.pyx":2787
  *                             # unsigned ints
  *                             else:
  *                                 if absmax <= 255: datafmt, datatype = "B", 'C'             # <<<<<<<<<<<<<<
  *                                 elif absmax <= 65535: datafmt, datatype = "H", 'S'
  *                                 elif absmax > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  */
-            __pyx_t_2 = PyObject_RichCompare(__pyx_v_absmax, __pyx_int_255, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2608; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_2 = PyObject_RichCompare(__pyx_v_absmax, __pyx_int_255, Py_LE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2787; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
             if (__pyx_t_12) {
               __pyx_t_2 = ((PyObject *)__pyx_n_s__B);
@@ -25236,15 +26622,15 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
               goto __pyx_L13;
             }
 
-            /* "pysam/csamtools.pyx":2609
+            /* "pysam/csamtools.pyx":2788
  *                             else:
  *                                 if absmax <= 255: datafmt, datatype = "B", 'C'
  *                                 elif absmax <= 65535: datafmt, datatype = "H", 'S'             # <<<<<<<<<<<<<<
  *                                 elif absmax > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                                 else: datafmt, datatype = "I", 'I'
  */
-            __pyx_t_7 = PyObject_RichCompare(__pyx_v_absmax, __pyx_int_65535, Py_LE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_7 = PyObject_RichCompare(__pyx_v_absmax, __pyx_int_65535, Py_LE); __Pyx_XGOTREF(__pyx_t_7); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_7); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2788; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
             if (__pyx_t_12) {
               __pyx_t_7 = ((PyObject *)__pyx_n_s__H);
@@ -25260,35 +26646,35 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
               goto __pyx_L13;
             }
 
-            /* "pysam/csamtools.pyx":2610
+            /* "pysam/csamtools.pyx":2789
  *                                 if absmax <= 255: datafmt, datatype = "B", 'C'
  *                                 elif absmax <= 65535: datafmt, datatype = "H", 'S'
  *                                 elif absmax > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )             # <<<<<<<<<<<<<<
  *                                 else: datafmt, datatype = "I", 'I'
  * 
  */
-            __pyx_t_2 = PyObject_RichCompare(__pyx_v_absmax, __pyx_int_4294967295, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_2 = PyObject_RichCompare(__pyx_v_absmax, __pyx_int_4294967295, Py_GT); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
             if (__pyx_t_12) {
-              __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_144), __pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              __pyx_t_2 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_152), __pyx_v_value); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
               __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-              __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
               __Pyx_GOTREF(__pyx_t_7);
               PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_t_2));
               __Pyx_GIVEREF(((PyObject *)__pyx_t_2));
               __pyx_t_2 = 0;
-              __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              __pyx_t_2 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
               __Pyx_GOTREF(__pyx_t_2);
               __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
               __Pyx_Raise(__pyx_t_2, 0, 0, 0);
               __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2610; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
               goto __pyx_L13;
             }
             /*else*/ {
 
-              /* "pysam/csamtools.pyx":2611
+              /* "pysam/csamtools.pyx":2790
  *                                 elif absmax <= 65535: datafmt, datatype = "H", 'S'
  *                                 elif absmax > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                                 else: datafmt, datatype = "I", 'I'             # <<<<<<<<<<<<<<
@@ -25312,17 +26698,17 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         }
         __pyx_L10:;
 
-        /* "pysam/csamtools.pyx":2613
+        /* "pysam/csamtools.pyx":2792
  *                                 else: datafmt, datatype = "I", 'I'
  * 
  *                         datafmt = "2sccI%i%s" % (len(value), datafmt)             # <<<<<<<<<<<<<<
  *                         args.extend( [pytag[:2],
  *                                       pytype.encode('ascii'),
  */
-        __pyx_t_13 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_13 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
-        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
         PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_7);
         __Pyx_GIVEREF(__pyx_t_7);
@@ -25330,70 +26716,70 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_datafmt);
         __Pyx_GIVEREF(__pyx_v_datafmt);
         __pyx_t_7 = 0;
-        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_145), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2613; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_153), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_7));
         __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
         __Pyx_DECREF(__pyx_v_datafmt);
         __pyx_v_datafmt = ((PyObject *)__pyx_t_7);
         __pyx_t_7 = 0;
 
-        /* "pysam/csamtools.pyx":2614
+        /* "pysam/csamtools.pyx":2793
  * 
  *                         datafmt = "2sccI%i%s" % (len(value), datafmt)
  *                         args.extend( [pytag[:2],             # <<<<<<<<<<<<<<
  *                                       pytype.encode('ascii'),
  *                                       datatype.encode('ascii'),
  */
-        __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_args), __pyx_n_s__extend); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_args), __pyx_n_s__extend); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_7);
 
-        /* "pysam/csamtools.pyx":2617
+        /* "pysam/csamtools.pyx":2796
  *                                       pytype.encode('ascii'),
  *                                       datatype.encode('ascii'),
  *                                       len(value)] + list(value) )             # <<<<<<<<<<<<<<
  *                         fmts.append( datafmt )
  *                         continue
  */
-        __pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_v_pytag, 0, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_2 = __Pyx_PySequence_GetSlice(__pyx_v_pytag, 0, 2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_2);
 
-        /* "pysam/csamtools.pyx":2615
+        /* "pysam/csamtools.pyx":2794
  *                         datafmt = "2sccI%i%s" % (len(value), datafmt)
  *                         args.extend( [pytag[:2],
  *                                       pytype.encode('ascii'),             # <<<<<<<<<<<<<<
  *                                       datatype.encode('ascii'),
  *                                       len(value)] + list(value) )
  */
-        __pyx_t_8 = PyObject_GetAttr(__pyx_v_pytype, __pyx_n_s__encode); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_GetAttr(__pyx_v_pytype, __pyx_n_s__encode); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
-        __pyx_t_9 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_k_tuple_146), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_k_tuple_154), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_9);
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
-        /* "pysam/csamtools.pyx":2616
+        /* "pysam/csamtools.pyx":2795
  *                         args.extend( [pytag[:2],
  *                                       pytype.encode('ascii'),
  *                                       datatype.encode('ascii'),             # <<<<<<<<<<<<<<
  *                                       len(value)] + list(value) )
  *                         fmts.append( datafmt )
  */
-        __pyx_t_8 = PyObject_GetAttr(__pyx_v_datatype, __pyx_n_s__encode); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_GetAttr(__pyx_v_datatype, __pyx_n_s__encode); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
-        __pyx_t_14 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_k_tuple_147), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_14 = PyObject_Call(__pyx_t_8, ((PyObject *)__pyx_k_tuple_155), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_14);
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
-        /* "pysam/csamtools.pyx":2617
+        /* "pysam/csamtools.pyx":2796
  *                                       pytype.encode('ascii'),
  *                                       datatype.encode('ascii'),
  *                                       len(value)] + list(value) )             # <<<<<<<<<<<<<<
  *                         fmts.append( datafmt )
  *                         continue
  */
-        __pyx_t_13 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_13 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyInt_FromSsize_t(__pyx_t_13); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
-        __pyx_t_15 = PyList_New(4); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_15 = PyList_New(4); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_15);
         PyList_SET_ITEM(__pyx_t_15, 0, __pyx_t_2);
         __Pyx_GIVEREF(__pyx_t_2);
@@ -25407,39 +26793,39 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         __pyx_t_9 = 0;
         __pyx_t_14 = 0;
         __pyx_t_8 = 0;
-        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_INCREF(__pyx_v_value);
         PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_value);
         __Pyx_GIVEREF(__pyx_v_value);
-        __pyx_t_14 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_14 = PyObject_Call(((PyObject *)((PyObject*)(&PyList_Type))), ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_14);
         __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-        __pyx_t_8 = PyNumber_Add(((PyObject *)__pyx_t_15), __pyx_t_14); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyNumber_Add(((PyObject *)__pyx_t_15), __pyx_t_14); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2796; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(((PyObject *)__pyx_t_8));
         __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;
         __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
-        __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_14);
         PyTuple_SET_ITEM(__pyx_t_14, 0, ((PyObject *)__pyx_t_8));
         __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
         __pyx_t_8 = 0;
-        __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2614; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2793; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
         __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
 
-        /* "pysam/csamtools.pyx":2618
+        /* "pysam/csamtools.pyx":2797
  *                                       datatype.encode('ascii'),
  *                                       len(value)] + list(value) )
  *                         fmts.append( datafmt )             # <<<<<<<<<<<<<<
  *                         continue
  * 
  */
-        __pyx_t_16 = PyList_Append(__pyx_v_fmts, __pyx_v_datafmt); if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2618; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_16 = PyList_Append(__pyx_v_fmts, __pyx_v_datafmt); if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2797; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-        /* "pysam/csamtools.pyx":2619
+        /* "pysam/csamtools.pyx":2798
  *                                       len(value)] + list(value) )
  *                         fmts.append( datafmt )
  *                         continue             # <<<<<<<<<<<<<<
@@ -25451,7 +26837,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       }
       __pyx_L9:;
 
-      /* "pysam/csamtools.pyx":2621
+      /* "pysam/csamtools.pyx":2800
  *                         continue
  * 
  *                     if t is float:             # <<<<<<<<<<<<<<
@@ -25461,7 +26847,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       __pyx_t_12 = (__pyx_v_t == ((PyObject*)(&PyFloat_Type)));
       if (__pyx_t_12) {
 
-        /* "pysam/csamtools.pyx":2622
+        /* "pysam/csamtools.pyx":2801
  * 
  *                     if t is float:
  *                         fmt, pytype = "2scf", 'f'             # <<<<<<<<<<<<<<
@@ -25481,7 +26867,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         goto __pyx_L14;
       }
 
-      /* "pysam/csamtools.pyx":2623
+      /* "pysam/csamtools.pyx":2802
  *                     if t is float:
  *                         fmt, pytype = "2scf", 'f'
  *                     elif t is int:             # <<<<<<<<<<<<<<
@@ -25491,27 +26877,27 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       __pyx_t_12 = (__pyx_v_t == ((PyObject*)(&PyInt_Type)));
       if (__pyx_t_12) {
 
-        /* "pysam/csamtools.pyx":2625
+        /* "pysam/csamtools.pyx":2804
  *                     elif t is int:
  *                         # negative values
  *                         if value < 0:             # <<<<<<<<<<<<<<
  *                             if value >= -127: fmt, pytype = "2scb", 'c'
  *                             elif value >= -32767: fmt, pytype = "2sch", 's'
  */
-        __pyx_t_14 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_14 = PyObject_RichCompare(__pyx_v_value, __pyx_int_0, Py_LT); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
         if (__pyx_t_12) {
 
-          /* "pysam/csamtools.pyx":2626
+          /* "pysam/csamtools.pyx":2805
  *                         # negative values
  *                         if value < 0:
  *                             if value >= -127: fmt, pytype = "2scb", 'c'             # <<<<<<<<<<<<<<
  *                             elif value >= -32767: fmt, pytype = "2sch", 's'
  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  */
-          __pyx_t_14 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_127, Py_GE); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2626; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_14 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_127, Py_GE); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
           if (__pyx_t_12) {
             __pyx_t_14 = ((PyObject *)__pyx_kp_s__2scb);
@@ -25527,15 +26913,15 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
             goto __pyx_L16;
           }
 
-          /* "pysam/csamtools.pyx":2627
+          /* "pysam/csamtools.pyx":2806
  *                         if value < 0:
  *                             if value >= -127: fmt, pytype = "2scb", 'c'
  *                             elif value >= -32767: fmt, pytype = "2sch", 's'             # <<<<<<<<<<<<<<
  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                             else: fmt, pytype = "2sci", 'i'
  */
-          __pyx_t_8 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_32767, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2627; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_32767, Py_GE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
           if (__pyx_t_12) {
             __pyx_t_8 = ((PyObject *)__pyx_kp_s__2sch);
@@ -25551,35 +26937,35 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
             goto __pyx_L16;
           }
 
-          /* "pysam/csamtools.pyx":2628
+          /* "pysam/csamtools.pyx":2807
  *                             if value >= -127: fmt, pytype = "2scb", 'c'
  *                             elif value >= -32767: fmt, pytype = "2sch", 's'
  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )             # <<<<<<<<<<<<<<
  *                             else: fmt, pytype = "2sci", 'i'
  *                         # positive values
  */
-          __pyx_t_14 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_2147483648, Py_LT); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_14 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_2147483648, Py_LT); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
           if (__pyx_t_12) {
-            __pyx_t_14 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_144), __pyx_v_value); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_14 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_152), __pyx_v_value); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(((PyObject *)__pyx_t_14));
-            __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(__pyx_t_8);
             PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)__pyx_t_14));
             __Pyx_GIVEREF(((PyObject *)__pyx_t_14));
             __pyx_t_14 = 0;
-            __pyx_t_14 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_14 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(__pyx_t_14);
             __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
             __Pyx_Raise(__pyx_t_14, 0, 0, 0);
             __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
-            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2807; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             goto __pyx_L16;
           }
           /*else*/ {
 
-            /* "pysam/csamtools.pyx":2629
+            /* "pysam/csamtools.pyx":2808
  *                             elif value >= -32767: fmt, pytype = "2sch", 's'
  *                             elif value < -2147483648: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                             else: fmt, pytype = "2sci", 'i'             # <<<<<<<<<<<<<<
@@ -25602,15 +26988,15 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         }
         /*else*/ {
 
-          /* "pysam/csamtools.pyx":2632
+          /* "pysam/csamtools.pyx":2811
  *                         # positive values
  *                         else:
  *                             if value <= 255: fmt, pytype = "2scB", 'C'             # <<<<<<<<<<<<<<
  *                             elif value <= 65535: fmt, pytype = "2scH", 'S'
  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  */
-          __pyx_t_8 = PyObject_RichCompare(__pyx_v_value, __pyx_int_255, Py_LE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2632; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyObject_RichCompare(__pyx_v_value, __pyx_int_255, Py_LE); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2811; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
           if (__pyx_t_12) {
             __pyx_t_8 = ((PyObject *)__pyx_kp_s__2scB);
@@ -25626,15 +27012,15 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
             goto __pyx_L17;
           }
 
-          /* "pysam/csamtools.pyx":2633
+          /* "pysam/csamtools.pyx":2812
  *                         else:
  *                             if value <= 255: fmt, pytype = "2scB", 'C'
  *                             elif value <= 65535: fmt, pytype = "2scH", 'S'             # <<<<<<<<<<<<<<
  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                             else: fmt, pytype = "2scI", 'I'
  */
-          __pyx_t_14 = PyObject_RichCompare(__pyx_v_value, __pyx_int_65535, Py_LE); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2633; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_14 = PyObject_RichCompare(__pyx_v_value, __pyx_int_65535, Py_LE); __Pyx_XGOTREF(__pyx_t_14); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_14); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
           if (__pyx_t_12) {
             __pyx_t_14 = ((PyObject *)__pyx_kp_s__2scH);
@@ -25650,35 +27036,35 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
             goto __pyx_L17;
           }
 
-          /* "pysam/csamtools.pyx":2634
+          /* "pysam/csamtools.pyx":2813
  *                             if value <= 255: fmt, pytype = "2scB", 'C'
  *                             elif value <= 65535: fmt, pytype = "2scH", 'S'
  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )             # <<<<<<<<<<<<<<
  *                             else: fmt, pytype = "2scI", 'I'
  *                     else:
  */
-          __pyx_t_8 = PyObject_RichCompare(__pyx_v_value, __pyx_int_4294967295, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyObject_RichCompare(__pyx_v_value, __pyx_int_4294967295, Py_GT); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
           if (__pyx_t_12) {
-            __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_144), __pyx_v_value); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_152), __pyx_v_value); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(((PyObject *)__pyx_t_8));
-            __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_14 = PyTuple_New(1); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(__pyx_t_14);
             PyTuple_SET_ITEM(__pyx_t_14, 0, ((PyObject *)__pyx_t_8));
             __Pyx_GIVEREF(((PyObject *)__pyx_t_8));
             __pyx_t_8 = 0;
-            __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __pyx_t_8 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             __Pyx_GOTREF(__pyx_t_8);
             __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
             __Pyx_Raise(__pyx_t_8, 0, 0, 0);
             __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2634; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2813; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
             goto __pyx_L17;
           }
           /*else*/ {
 
-            /* "pysam/csamtools.pyx":2635
+            /* "pysam/csamtools.pyx":2814
  *                             elif value <= 65535: fmt, pytype = "2scH", 'S'
  *                             elif value > 4294967295: raise ValueError( "integer %i out of range of BAM/SAM specification" % value )
  *                             else: fmt, pytype = "2scI", 'I'             # <<<<<<<<<<<<<<
@@ -25703,7 +27089,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       }
       /*else*/ {
 
-        /* "pysam/csamtools.pyx":2638
+        /* "pysam/csamtools.pyx":2817
  *                     else:
  *                         # Note: hex strings (H) are not supported yet
  *                         if t is not bytes:             # <<<<<<<<<<<<<<
@@ -25713,16 +27099,16 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         __pyx_t_12 = (__pyx_v_t != ((PyObject*)(&PyBytes_Type)));
         if (__pyx_t_12) {
 
-          /* "pysam/csamtools.pyx":2639
+          /* "pysam/csamtools.pyx":2818
  *                         # Note: hex strings (H) are not supported yet
  *                         if t is not bytes:
  *                             value = value.encode('ascii')             # <<<<<<<<<<<<<<
  *                         if len(value) == 1:
  *                             fmt, pytype = "2scc", 'A'
  */
-          __pyx_t_14 = PyObject_GetAttr(__pyx_v_value, __pyx_n_s__encode); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_14 = PyObject_GetAttr(__pyx_v_value, __pyx_n_s__encode); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_14);
-          __pyx_t_8 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_k_tuple_148), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_k_tuple_156), NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_8);
           __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
           __Pyx_DECREF(__pyx_v_value);
@@ -25732,18 +27118,18 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         }
         __pyx_L18:;
 
-        /* "pysam/csamtools.pyx":2640
+        /* "pysam/csamtools.pyx":2819
  *                         if t is not bytes:
  *                             value = value.encode('ascii')
  *                         if len(value) == 1:             # <<<<<<<<<<<<<<
  *                             fmt, pytype = "2scc", 'A'
  *                         else:
  */
-        __pyx_t_13 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2640; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_13 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2819; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __pyx_t_12 = (__pyx_t_13 == 1);
         if (__pyx_t_12) {
 
-          /* "pysam/csamtools.pyx":2641
+          /* "pysam/csamtools.pyx":2820
  *                             value = value.encode('ascii')
  *                         if len(value) == 1:
  *                             fmt, pytype = "2scc", 'A'             # <<<<<<<<<<<<<<
@@ -25764,17 +27150,17 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
         }
         /*else*/ {
 
-          /* "pysam/csamtools.pyx":2643
+          /* "pysam/csamtools.pyx":2822
  *                             fmt, pytype = "2scc", 'A'
  *                         else:
  *                             fmt, pytype = "2sc%is" % (len(value)+1), 'Z'             # <<<<<<<<<<<<<<
  * 
  *                     args.extend( [pytag[:2],
  */
-          __pyx_t_13 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-          __pyx_t_14 = PyInt_FromSsize_t((__pyx_t_13 + 1)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_13 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_13 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_14 = PyInt_FromSsize_t((__pyx_t_13 + 1)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(__pyx_t_14);
-          __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_149), __pyx_t_14); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2643; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __pyx_t_8 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_157), __pyx_t_14); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
           __Pyx_GOTREF(((PyObject *)__pyx_t_8));
           __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
           __pyx_t_14 = ((PyObject *)__pyx_n_s__Z);
@@ -25790,39 +27176,39 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       }
       __pyx_L14:;
 
-      /* "pysam/csamtools.pyx":2645
+      /* "pysam/csamtools.pyx":2824
  *                             fmt, pytype = "2sc%is" % (len(value)+1), 'Z'
  * 
  *                     args.extend( [pytag[:2],             # <<<<<<<<<<<<<<
  *                                   pytype.encode('ascii'),
  *                                   value ] )
  */
-      __pyx_t_14 = PyObject_GetAttr(((PyObject *)__pyx_v_args), __pyx_n_s__extend); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_14 = PyObject_GetAttr(((PyObject *)__pyx_v_args), __pyx_n_s__extend); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_14);
-      __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_v_pytag, 0, 2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = __Pyx_PySequence_GetSlice(__pyx_v_pytag, 0, 2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
 
-      /* "pysam/csamtools.pyx":2646
+      /* "pysam/csamtools.pyx":2825
  * 
  *                     args.extend( [pytag[:2],
  *                                   pytype.encode('ascii'),             # <<<<<<<<<<<<<<
  *                                   value ] )
  * 
  */
-      __pyx_t_7 = PyObject_GetAttr(__pyx_v_pytype, __pyx_n_s__encode); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_GetAttr(__pyx_v_pytype, __pyx_n_s__encode); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_15 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_150), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_15 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_k_tuple_158), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_15);
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
-      /* "pysam/csamtools.pyx":2647
+      /* "pysam/csamtools.pyx":2826
  *                     args.extend( [pytag[:2],
  *                                   pytype.encode('ascii'),
  *                                   value ] )             # <<<<<<<<<<<<<<
  * 
  *                     fmts.append( fmt )
  */
-      __pyx_t_7 = PyList_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyList_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       PyList_SET_ITEM(__pyx_t_7, 0, __pyx_t_8);
       __Pyx_GIVEREF(__pyx_t_8);
@@ -25833,44 +27219,44 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
       __Pyx_GIVEREF(__pyx_v_value);
       __pyx_t_8 = 0;
       __pyx_t_15 = 0;
-      __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_15);
       PyTuple_SET_ITEM(__pyx_t_15, 0, ((PyObject *)__pyx_t_7));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_7));
       __pyx_t_7 = 0;
-      __pyx_t_7 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2645; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_t_14, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_14); __pyx_t_14 = 0;
       __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
-      /* "pysam/csamtools.pyx":2649
+      /* "pysam/csamtools.pyx":2828
  *                                   value ] )
  * 
  *                     fmts.append( fmt )             # <<<<<<<<<<<<<<
  * 
  *                 fmt = "".join(fmts)
  */
-      __pyx_t_16 = PyList_Append(__pyx_v_fmts, __pyx_v_fmt); if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2649; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_16 = PyList_Append(__pyx_v_fmts, __pyx_v_fmt); if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_L4_continue:;
     }
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-    /* "pysam/csamtools.pyx":2651
+    /* "pysam/csamtools.pyx":2830
  *                     fmts.append( fmt )
  * 
  *                 fmt = "".join(fmts)             # <<<<<<<<<<<<<<
  *                 total_size = struct.calcsize(fmt)
  *                 buffer = ctypes.create_string_buffer(total_size)
  */
-    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_16), __pyx_n_s__join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_16), __pyx_n_s__join); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_INCREF(((PyObject *)__pyx_v_fmts));
     PyTuple_SET_ITEM(__pyx_t_7, 0, ((PyObject *)__pyx_v_fmts));
     __Pyx_GIVEREF(((PyObject *)__pyx_v_fmts));
-    __pyx_t_15 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2651; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_15 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_7), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_15);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
@@ -25878,75 +27264,75 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
     __pyx_v_fmt = __pyx_t_15;
     __pyx_t_15 = 0;
 
-    /* "pysam/csamtools.pyx":2652
+    /* "pysam/csamtools.pyx":2831
  * 
  *                 fmt = "".join(fmts)
  *                 total_size = struct.calcsize(fmt)             # <<<<<<<<<<<<<<
  *                 buffer = ctypes.create_string_buffer(total_size)
  *                 struct.pack_into( fmt,
  */
-    __pyx_t_15 = __Pyx_GetName(__pyx_m, __pyx_n_s__struct); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_15 = __Pyx_GetName(__pyx_m, __pyx_n_s__struct); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_15);
-    __pyx_t_7 = PyObject_GetAttr(__pyx_t_15, __pyx_n_s__calcsize); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_GetAttr(__pyx_t_15, __pyx_n_s__calcsize); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-    __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_15 = PyTuple_New(1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_15);
     __Pyx_INCREF(__pyx_v_fmt);
     PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_v_fmt);
     __Pyx_GIVEREF(__pyx_v_fmt);
-    __pyx_t_3 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2652; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_7, ((PyObject *)__pyx_t_15), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2831; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;
     __pyx_v_total_size = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "pysam/csamtools.pyx":2653
+    /* "pysam/csamtools.pyx":2832
  *                 fmt = "".join(fmts)
  *                 total_size = struct.calcsize(fmt)
  *                 buffer = ctypes.create_string_buffer(total_size)             # <<<<<<<<<<<<<<
  *                 struct.pack_into( fmt,
  *                                   buffer,
  */
-    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ctypes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__ctypes); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_15 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s_151); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_15 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s_159); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_15);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_INCREF(__pyx_v_total_size);
     PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_total_size);
     __Pyx_GIVEREF(__pyx_v_total_size);
-    __pyx_t_7 = PyObject_Call(__pyx_t_15, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2653; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyObject_Call(__pyx_t_15, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
     __pyx_v_buffer = __pyx_t_7;
     __pyx_t_7 = 0;
 
-    /* "pysam/csamtools.pyx":2654
+    /* "pysam/csamtools.pyx":2833
  *                 total_size = struct.calcsize(fmt)
  *                 buffer = ctypes.create_string_buffer(total_size)
  *                 struct.pack_into( fmt,             # <<<<<<<<<<<<<<
  *                                   buffer,
  *                                   0,
  */
-    __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__struct); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = __Pyx_GetName(__pyx_m, __pyx_n_s__struct); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__pack_into); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_7, __pyx_n_s__pack_into); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
 
-    /* "pysam/csamtools.pyx":2655
+    /* "pysam/csamtools.pyx":2834
  *                 buffer = ctypes.create_string_buffer(total_size)
  *                 struct.pack_into( fmt,
  *                                   buffer,             # <<<<<<<<<<<<<<
  *                                   0,
  *                                   *args )
  */
-    __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyTuple_New(3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_INCREF(__pyx_v_fmt);
     PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_v_fmt);
@@ -25958,20 +27344,20 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
     PyTuple_SET_ITEM(__pyx_t_7, 2, __pyx_int_0);
     __Pyx_GIVEREF(__pyx_int_0);
 
-    /* "pysam/csamtools.pyx":2657
+    /* "pysam/csamtools.pyx":2836
  *                                   buffer,
  *                                   0,
  *                                   *args )             # <<<<<<<<<<<<<<
  * 
  *             # delete the old data and allocate new space.
  */
-    __pyx_t_15 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_15 = PySequence_Tuple(((PyObject *)__pyx_v_args)); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_15));
-    __pyx_t_14 = PyNumber_Add(((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_15)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_14 = PyNumber_Add(((PyObject *)__pyx_t_7), ((PyObject *)__pyx_t_15)); if (unlikely(!__pyx_t_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_14));
     __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_15)); __pyx_t_15 = 0;
-    __pyx_t_15 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2654; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_15 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_14), NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2833; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_15);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_14)); __pyx_t_14 = 0;
@@ -25980,17 +27366,17 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2664
+  /* "pysam/csamtools.pyx":2843
  *             pysam_bam_update( src,
  *                               src.l_aux,
  *                               total_size,             # <<<<<<<<<<<<<<
  *                               bam1_aux( src ) )
  * 
  */
-  if (unlikely(!__pyx_v_total_size)) { __Pyx_RaiseUnboundLocalError("total_size"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2664; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
-  __pyx_t_17 = __Pyx_PyInt_AsSize_t(__pyx_v_total_size); if (unlikely((__pyx_t_17 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2664; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__pyx_v_total_size)) { __Pyx_RaiseUnboundLocalError("total_size"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2843; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+  __pyx_t_17 = __Pyx_PyInt_AsSize_t(__pyx_v_total_size); if (unlikely((__pyx_t_17 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2843; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":2665
+  /* "pysam/csamtools.pyx":2844
  *                               src.l_aux,
  *                               total_size,
  *                               bam1_aux( src ) )             # <<<<<<<<<<<<<<
@@ -25999,29 +27385,29 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
  */
   pysam_bam_update(__pyx_v_src, __pyx_v_src->l_aux, __pyx_t_17, bam1_aux(__pyx_v_src));
 
-  /* "pysam/csamtools.pyx":2667
+  /* "pysam/csamtools.pyx":2846
  *                               bam1_aux( src ) )
  * 
  *             src.l_aux = total_size             # <<<<<<<<<<<<<<
  * 
  *             # copy data only if there is any
  */
-  __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_v_total_size); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2667; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_18 = __Pyx_PyInt_AsInt(__pyx_v_total_size); if (unlikely((__pyx_t_18 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_src->l_aux = __pyx_t_18;
 
-  /* "pysam/csamtools.pyx":2670
+  /* "pysam/csamtools.pyx":2849
  * 
  *             # copy data only if there is any
  *             if total_size != 0:             # <<<<<<<<<<<<<<
  * 
  *                 # get location of new data
  */
-  __pyx_t_15 = PyObject_RichCompare(__pyx_v_total_size, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2670; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_15 = PyObject_RichCompare(__pyx_v_total_size, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_t_15); if (unlikely(__pyx_t_12 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2849; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
   if (__pyx_t_12) {
 
-    /* "pysam/csamtools.pyx":2673
+    /* "pysam/csamtools.pyx":2852
  * 
  *                 # get location of new data
  *                 s = bam1_aux( src )             # <<<<<<<<<<<<<<
@@ -26030,37 +27416,37 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tags_2__set__(struct __pyx_
  */
     __pyx_v_s = bam1_aux(__pyx_v_src);
 
-    /* "pysam/csamtools.pyx":2676
+    /* "pysam/csamtools.pyx":2855
  * 
  *                 # check if there is direct path from buffer.raw to tmp
  *                 p = buffer.raw             # <<<<<<<<<<<<<<
  *                 # create handle to make sure buffer stays alive long
  *                 # enough for memcpy, see issue 129
  */
-    if (unlikely(!__pyx_v_buffer)) { __Pyx_RaiseUnboundLocalError("buffer"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2676; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
-    __pyx_t_15 = PyObject_GetAttr(__pyx_v_buffer, __pyx_n_s__raw); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2676; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(!__pyx_v_buffer)) { __Pyx_RaiseUnboundLocalError("buffer"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+    __pyx_t_15 = PyObject_GetAttr(__pyx_v_buffer, __pyx_n_s__raw); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2855; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_15);
     __pyx_v_p = __pyx_t_15;
     __pyx_t_15 = 0;
 
-    /* "pysam/csamtools.pyx":2679
+    /* "pysam/csamtools.pyx":2858
  *                 # create handle to make sure buffer stays alive long
  *                 # enough for memcpy, see issue 129
  *                 temp = p             # <<<<<<<<<<<<<<
  *                 memcpy( s, temp, total_size )
  * 
  */
-    __pyx_t_19 = PyBytes_AsString(__pyx_v_p); if (unlikely((!__pyx_t_19) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2679; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_19 = PyBytes_AsString(__pyx_v_p); if (unlikely((!__pyx_t_19) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_v_temp = __pyx_t_19;
 
-    /* "pysam/csamtools.pyx":2680
+    /* "pysam/csamtools.pyx":2859
  *                 # enough for memcpy, see issue 129
  *                 temp = p
  *                 memcpy( s, temp, total_size )             # <<<<<<<<<<<<<<
  * 
  *     property flag:
  */
-    __pyx_t_17 = __Pyx_PyInt_AsSize_t(__pyx_v_total_size); if (unlikely((__pyx_t_17 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2680; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_17 = __Pyx_PyInt_AsSize_t(__pyx_v_total_size); if (unlikely((__pyx_t_17 == (size_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     memcpy(__pyx_v_s, __pyx_v_temp, __pyx_t_17);
     goto __pyx_L20;
   }
@@ -26110,7 +27496,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_4flag_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2684
+/* "pysam/csamtools.pyx":2863
  *     property flag:
  *         """properties flag"""
  *         def __get__(self): return self._delegate.core.flag             # <<<<<<<<<<<<<<
@@ -26127,9 +27513,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4flag___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2684);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2863);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->_delegate->core.flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2684; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->_delegate->core.flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2863; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26159,7 +27545,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_4flag_3__set__(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2685
+/* "pysam/csamtools.pyx":2864
  *         """properties flag"""
  *         def __get__(self): return self._delegate.core.flag
  *         def __set__(self, flag): self._delegate.core.flag = flag             # <<<<<<<<<<<<<<
@@ -26176,8 +27562,8 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4flag_2__set__(struct __pyx_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2685);
-  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_flag); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2685; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2864);
+  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_flag); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_delegate->core.flag = __pyx_t_1;
 
   __pyx_r = 0;
@@ -26202,7 +27588,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_5rname_1__get__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2703
+/* "pysam/csamtools.pyx":2882
  * 
  *         """
  *         def __get__(self): return self._delegate.core.tid             # <<<<<<<<<<<<<<
@@ -26219,9 +27605,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5rname___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2703);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2882);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2703; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26251,7 +27637,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_5rname_3__set__(PyObject *__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2704
+/* "pysam/csamtools.pyx":2883
  *         """
  *         def __get__(self): return self._delegate.core.tid
  *         def __set__(self, tid): self._delegate.core.tid = tid             # <<<<<<<<<<<<<<
@@ -26268,8 +27654,8 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5rname_2__set__(struct __pyx
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2704);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_tid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2704; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2883);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_tid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2883; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_delegate->core.tid = __pyx_t_1;
 
   __pyx_r = 0;
@@ -26294,7 +27680,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_3tid_1__get__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2717
+/* "pysam/csamtools.pyx":2896
  * 
  *         """
  *         def __get__(self): return self._delegate.core.tid             # <<<<<<<<<<<<<<
@@ -26311,9 +27697,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_3tid___get__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2717);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2896);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2717; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2896; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26343,7 +27729,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_3tid_3__set__(PyObject *__py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2718
+/* "pysam/csamtools.pyx":2897
  *         """
  *         def __get__(self): return self._delegate.core.tid
  *         def __set__(self, tid): self._delegate.core.tid = tid             # <<<<<<<<<<<<<<
@@ -26360,8 +27746,8 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_3tid_2__set__(struct __pyx_o
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2718);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_tid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2718; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2897);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_tid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2897; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_delegate->core.tid = __pyx_t_1;
 
   __pyx_r = 0;
@@ -26386,7 +27772,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_3pos_1__get__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2722
+/* "pysam/csamtools.pyx":2901
  *     property pos:
  *         """0-based leftmost coordinate"""
  *         def __get__(self): return self._delegate.core.pos             # <<<<<<<<<<<<<<
@@ -26403,9 +27789,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_3pos___get__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2722);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2901);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2722; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26435,7 +27821,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_3pos_3__set__(PyObject *__py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2723
+/* "pysam/csamtools.pyx":2902
  *         """0-based leftmost coordinate"""
  *         def __get__(self): return self._delegate.core.pos
  *         def __set__(self, pos):             # <<<<<<<<<<<<<<
@@ -26454,9 +27840,9 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_3pos_2__set__(struct __pyx_o
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2723);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2902);
 
-  /* "pysam/csamtools.pyx":2726
+  /* "pysam/csamtools.pyx":2905
  *             ## setting the cigar string also updates the "bin" attribute
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -26466,7 +27852,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_3pos_2__set__(struct __pyx_o
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2727
+  /* "pysam/csamtools.pyx":2906
  *             cdef bam1_t * src
  *             src = self._delegate
  *             if src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -26475,7 +27861,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_3pos_2__set__(struct __pyx_o
  */
   if (__pyx_v_src->core.n_cigar) {
 
-    /* "pysam/csamtools.pyx":2728
+    /* "pysam/csamtools.pyx":2907
  *             src = self._delegate
  *             if src.core.n_cigar:
  *                 src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, bam1_cigar(src)) )             # <<<<<<<<<<<<<<
@@ -26487,7 +27873,7 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_3pos_2__set__(struct __pyx_o
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2730
+    /* "pysam/csamtools.pyx":2909
  *                 src.core.bin = bam_reg2bin( src.core.pos, bam_calend( &src.core, bam1_cigar(src)) )
  *             else:
  *                 src.core.bin = bam_reg2bin( src.core.pos, src.core.pos + 1)             # <<<<<<<<<<<<<<
@@ -26498,14 +27884,14 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_3pos_2__set__(struct __pyx_o
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2731
+  /* "pysam/csamtools.pyx":2910
  *             else:
  *                 src.core.bin = bam_reg2bin( src.core.pos, src.core.pos + 1)
  *             self._delegate.core.pos = pos             # <<<<<<<<<<<<<<
  *     property bin:
  *         """properties bin"""
  */
-  __pyx_t_2 = __Pyx_PyInt_from_py_int32_t(__pyx_v_pos); if (unlikely((__pyx_t_2 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2731; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyInt_from_py_int32_t(__pyx_v_pos); if (unlikely((__pyx_t_2 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_delegate->core.pos = __pyx_t_2;
 
   __pyx_r = 0;
@@ -26530,7 +27916,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_3bin_1__get__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2734
+/* "pysam/csamtools.pyx":2913
  *     property bin:
  *         """properties bin"""
  *         def __get__(self): return self._delegate.core.bin             # <<<<<<<<<<<<<<
@@ -26547,9 +27933,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_3bin___get__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2734);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2913);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->_delegate->core.bin); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2734; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->_delegate->core.bin); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26579,7 +27965,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_3bin_3__set__(PyObject *__py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2735
+/* "pysam/csamtools.pyx":2914
  *         """properties bin"""
  *         def __get__(self): return self._delegate.core.bin
  *         def __set__(self, bin): self._delegate.core.bin = bin             # <<<<<<<<<<<<<<
@@ -26596,8 +27982,8 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_3bin_2__set__(struct __pyx_o
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2735);
-  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_bin); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2735; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2914);
+  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_bin); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_delegate->core.bin = __pyx_t_1;
 
   __pyx_r = 0;
@@ -26622,7 +28008,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_4rlen_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2738
+/* "pysam/csamtools.pyx":2917
  *     property rlen:
  *         '''length of the read (read only). Returns 0 if not given.'''
  *         def __get__(self): return self._delegate.core.l_qseq             # <<<<<<<<<<<<<<
@@ -26639,9 +28025,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4rlen___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2738);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2917);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.l_qseq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2738; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.l_qseq); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26671,7 +28057,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_4aend_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2744
+/* "pysam/csamtools.pyx":2923
  *         aend points to one past the last aligned residue.
  *         Returns None if not available.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -26694,9 +28080,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4aend___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2744);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2923);
 
-  /* "pysam/csamtools.pyx":2746
+  /* "pysam/csamtools.pyx":2925
  *         def __get__(self):
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -26706,19 +28092,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4aend___get__(struct _
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2747
+  /* "pysam/csamtools.pyx":2926
  *             cdef bam1_t * src
  *             src = self._delegate
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:             # <<<<<<<<<<<<<<
  *                 return None
  *             return bam_calend(&src.core, bam1_cigar(src))
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyNumber_And(__pyx_t_2, __pyx_int_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyNumber_And(__pyx_t_2, __pyx_int_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (!__pyx_t_4) {
     __pyx_t_5 = (__pyx_v_src->core.n_cigar == 0);
@@ -26728,7 +28114,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4aend___get__(struct _
   }
   if (__pyx_t_6) {
 
-    /* "pysam/csamtools.pyx":2748
+    /* "pysam/csamtools.pyx":2927
  *             src = self._delegate
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
  *                 return None             # <<<<<<<<<<<<<<
@@ -26743,7 +28129,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4aend___get__(struct _
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2749
+  /* "pysam/csamtools.pyx":2928
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
  *                 return None
  *             return bam_calend(&src.core, bam1_cigar(src))             # <<<<<<<<<<<<<<
@@ -26751,7 +28137,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4aend___get__(struct _
  *     property alen:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2749; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src))); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2928; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -26782,7 +28168,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_4alen_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2754
+/* "pysam/csamtools.pyx":2933
  *         '''aligned length of the read on the reference genome.  Returns None if
  *         not available.'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -26805,9 +28191,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4alen___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2754);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2933);
 
-  /* "pysam/csamtools.pyx":2756
+  /* "pysam/csamtools.pyx":2935
  *         def __get__(self):
  *             cdef bam1_t * src
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -26817,19 +28203,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4alen___get__(struct _
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2757
+  /* "pysam/csamtools.pyx":2936
  *             cdef bam1_t * src
  *             src = self._delegate
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:             # <<<<<<<<<<<<<<
  *                 return None
  *             return bam_calend(&src.core,
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyNumber_And(__pyx_t_2, __pyx_int_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyNumber_And(__pyx_t_2, __pyx_int_4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
-  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2757; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if (!__pyx_t_4) {
     __pyx_t_5 = (__pyx_v_src->core.n_cigar == 0);
@@ -26839,7 +28225,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4alen___get__(struct _
   }
   if (__pyx_t_6) {
 
-    /* "pysam/csamtools.pyx":2758
+    /* "pysam/csamtools.pyx":2937
  *             src = self._delegate
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
  *                 return None             # <<<<<<<<<<<<<<
@@ -26854,7 +28240,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4alen___get__(struct _
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2759
+  /* "pysam/csamtools.pyx":2938
  *             if (self.flag & BAM_FUNMAP) or src.core.n_cigar == 0:
  *                 return None
  *             return bam_calend(&src.core,             # <<<<<<<<<<<<<<
@@ -26863,14 +28249,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4alen___get__(struct _
  */
   __Pyx_XDECREF(__pyx_r);
 
-  /* "pysam/csamtools.pyx":2761
+  /* "pysam/csamtools.pyx":2940
  *             return bam_calend(&src.core,
  *                                bam1_cigar(src)) - \
  *                                self._delegate.core.pos             # <<<<<<<<<<<<<<
  * 
  *     property mapq:
  */
-  __pyx_t_3 = PyInt_FromLong((bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src)) - __pyx_v_self->_delegate->core.pos)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2760; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong((bam_calend((&__pyx_v_src->core), bam1_cigar(__pyx_v_src)) - __pyx_v_self->_delegate->core.pos)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_r = __pyx_t_3;
   __pyx_t_3 = 0;
@@ -26901,7 +28287,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_4mapq_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2765
+/* "pysam/csamtools.pyx":2944
  *     property mapq:
  *         """mapping quality"""
  *         def __get__(self): return self._delegate.core.qual             # <<<<<<<<<<<<<<
@@ -26918,9 +28304,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4mapq___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2765);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2944);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->_delegate->core.qual); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2765; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->_delegate->core.qual); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2944; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -26950,7 +28336,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_4mapq_3__set__(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2766
+/* "pysam/csamtools.pyx":2945
  *         """mapping quality"""
  *         def __get__(self): return self._delegate.core.qual
  *         def __set__(self, qual): self._delegate.core.qual = qual             # <<<<<<<<<<<<<<
@@ -26967,8 +28353,8 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4mapq_2__set__(struct __pyx_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2766);
-  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_qual); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2945);
+  __pyx_t_1 = __Pyx_PyInt_from_py_uint32_t(__pyx_v_qual); if (unlikely((__pyx_t_1 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2945; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_delegate->core.qual = __pyx_t_1;
 
   __pyx_r = 0;
@@ -26993,7 +28379,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_4mrnm_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2772
+/* "pysam/csamtools.pyx":2951
  *         deprecated, use RNEXT instead.
  *         """
  *         def __get__(self): return self._delegate.core.mtid             # <<<<<<<<<<<<<<
@@ -27010,9 +28396,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4mrnm___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2772);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2951);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.mtid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2772; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.mtid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2951; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -27042,7 +28428,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_4mrnm_3__set__(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2773
+/* "pysam/csamtools.pyx":2952
  *         """
  *         def __get__(self): return self._delegate.core.mtid
  *         def __set__(self, mtid): self._delegate.core.mtid = mtid             # <<<<<<<<<<<<<<
@@ -27059,8 +28445,8 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4mrnm_2__set__(struct __pyx_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2773);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mtid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2773; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2952);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mtid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2952; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_delegate->core.mtid = __pyx_t_1;
 
   __pyx_r = 0;
@@ -27085,7 +28471,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_5rnext_1__get__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2776
+/* "pysam/csamtools.pyx":2955
  *     property rnext:
  *         """the :term:`reference` id of the mate """
  *         def __get__(self): return self._delegate.core.mtid             # <<<<<<<<<<<<<<
@@ -27102,9 +28488,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5rnext___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2776);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2955);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.mtid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.mtid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2955; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -27134,7 +28520,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_5rnext_3__set__(PyObject *__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2777
+/* "pysam/csamtools.pyx":2956
  *         """the :term:`reference` id of the mate """
  *         def __get__(self): return self._delegate.core.mtid
  *         def __set__(self, mtid): self._delegate.core.mtid = mtid             # <<<<<<<<<<<<<<
@@ -27151,8 +28537,8 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5rnext_2__set__(struct __pyx
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2777);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mtid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2777; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2956);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mtid); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2956; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_delegate->core.mtid = __pyx_t_1;
 
   __pyx_r = 0;
@@ -27177,7 +28563,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_4mpos_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2781
+/* "pysam/csamtools.pyx":2960
  *         """the position of the mate
  *         deprecated, use PNEXT instead."""
  *         def __get__(self): return self._delegate.core.mpos             # <<<<<<<<<<<<<<
@@ -27194,9 +28580,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4mpos___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2781);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2960);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.mpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2781; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.mpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2960; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -27226,7 +28612,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_4mpos_3__set__(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2782
+/* "pysam/csamtools.pyx":2961
  *         deprecated, use PNEXT instead."""
  *         def __get__(self): return self._delegate.core.mpos
  *         def __set__(self, mpos): self._delegate.core.mpos = mpos             # <<<<<<<<<<<<<<
@@ -27243,8 +28629,8 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4mpos_2__set__(struct __pyx_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2782);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mpos); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2782; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2961);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mpos); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2961; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_delegate->core.mpos = __pyx_t_1;
 
   __pyx_r = 0;
@@ -27269,12 +28655,12 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_5pnext_1__get__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2785
+/* "pysam/csamtools.pyx":2964
  *     property pnext:
  *         """the position of the mate"""
  *         def __get__(self): return self._delegate.core.mpos             # <<<<<<<<<<<<<<
  *         def __set__(self, mpos): self._delegate.core.mpos = mpos
- *     property isize:
+ *     #######################################################################
  */
 
 static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5pnext___get__(struct __pyx_obj_5pysam_9csamtools_AlignedRead *__pyx_v_self) {
@@ -27286,9 +28672,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5pnext___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2785);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2964);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.mpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2785; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.mpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2964; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -27318,12 +28704,12 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_5pnext_3__set__(PyObject *__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2786
+/* "pysam/csamtools.pyx":2965
  *         """the position of the mate"""
  *         def __get__(self): return self._delegate.core.mpos
  *         def __set__(self, mpos): self._delegate.core.mpos = mpos             # <<<<<<<<<<<<<<
- *     property isize:
- *         """the insert size
+ *     #######################################################################
+ *     #######################################################################
  */
 
 static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5pnext_2__set__(struct __pyx_obj_5pysam_9csamtools_AlignedRead *__pyx_v_self, PyObject *__pyx_v_mpos) {
@@ -27335,8 +28721,8 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5pnext_2__set__(struct __pyx
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2786);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mpos); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2786; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2965);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_mpos); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_delegate->core.mpos = __pyx_t_1;
 
   __pyx_r = 0;
@@ -27361,7 +28747,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_5isize_1__get__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2790
+/* "pysam/csamtools.pyx":2973
  *         """the insert size
  *         deprecated: use tlen instead"""
  *         def __get__(self): return self._delegate.core.isize             # <<<<<<<<<<<<<<
@@ -27378,9 +28764,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_5isize___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2790);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2973);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.isize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2790; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.isize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -27410,7 +28796,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_5isize_3__set__(PyObject *__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2791
+/* "pysam/csamtools.pyx":2974
  *         deprecated: use tlen instead"""
  *         def __get__(self): return self._delegate.core.isize
  *         def __set__(self, isize): self._delegate.core.isize = isize             # <<<<<<<<<<<<<<
@@ -27427,8 +28813,8 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_5isize_2__set__(struct __pyx
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2791);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_isize); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2974);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_isize); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_delegate->core.isize = __pyx_t_1;
 
   __pyx_r = 0;
@@ -27453,7 +28839,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_4tlen_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2794
+/* "pysam/csamtools.pyx":2977
  *     property tlen:
  *         """the insert size"""
  *         def __get__(self): return self._delegate.core.isize             # <<<<<<<<<<<<<<
@@ -27470,9 +28856,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_4tlen___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2794);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2977);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.isize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_delegate->core.isize); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -27502,7 +28888,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_4tlen_3__set__(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2795
+/* "pysam/csamtools.pyx":2978
  *         """the insert size"""
  *         def __get__(self): return self._delegate.core.isize
  *         def __set__(self, isize): self._delegate.core.isize = isize             # <<<<<<<<<<<<<<
@@ -27519,8 +28905,8 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_4tlen_2__set__(struct __pyx_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2795);
-  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_isize); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2978);
+  __pyx_t_1 = __Pyx_PyInt_from_py_int32_t(__pyx_v_isize); if (unlikely((__pyx_t_1 == (int32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->_delegate->core.isize = __pyx_t_1;
 
   __pyx_r = 0;
@@ -27545,7 +28931,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_9is_paired_1__get__(Py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2798
+/* "pysam/csamtools.pyx":2981
  *     property is_paired:
  *         """true if read is paired in sequencing"""
  *         def __get__(self): return (self._delegate.core.flag & BAM_FPAIRED) != 0             # <<<<<<<<<<<<<<
@@ -27562,9 +28948,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9is_paired___get__(str
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2798);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2981);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyBool_FromLong(((__pyx_v_self->_delegate->core.flag & 1) != 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyBool_FromLong(((__pyx_v_self->_delegate->core.flag & 1) != 0)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -27594,7 +28980,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_9is_paired_3__set__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2799
+/* "pysam/csamtools.pyx":2982
  *         """true if read is paired in sequencing"""
  *         def __get__(self): return (self._delegate.core.flag & BAM_FPAIRED) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -27611,23 +28997,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_9is_paired_2__set__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2799);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2982);
 
-  /* "pysam/csamtools.pyx":2800
+  /* "pysam/csamtools.pyx":2983
  *         def __get__(self): return (self._delegate.core.flag & BAM_FPAIRED) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FPAIRED             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FPAIRED
  *     property is_proper_pair:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2800; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     __pyx_v_self->_delegate->core.flag = (__pyx_v_self->_delegate->core.flag | 1);
     goto __pyx_L3;
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2801
+    /* "pysam/csamtools.pyx":2984
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FPAIRED
  *             else: self._delegate.core.flag &= ~BAM_FPAIRED             # <<<<<<<<<<<<<<
@@ -27660,7 +29046,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_14is_proper_pair_1__ge
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2804
+/* "pysam/csamtools.pyx":2987
  *     property is_proper_pair:
  *         """true if read is mapped in a proper pair"""
  *         def __get__(self): return (self.flag & BAM_FPROPER_PAIR) != 0             # <<<<<<<<<<<<<<
@@ -27678,14 +29064,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_14is_proper_pair___get
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2804);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2987);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2987; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -27716,7 +29102,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_14is_proper_pair_3__set__(Py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2805
+/* "pysam/csamtools.pyx":2988
  *         """true if read is mapped in a proper pair"""
  *         def __get__(self): return (self.flag & BAM_FPROPER_PAIR) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -27733,23 +29119,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_14is_proper_pair_2__set__(st
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2805);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2988);
 
-  /* "pysam/csamtools.pyx":2806
+  /* "pysam/csamtools.pyx":2989
  *         def __get__(self): return (self.flag & BAM_FPROPER_PAIR) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FPROPER_PAIR             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FPROPER_PAIR
  *     property is_unmapped:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2989; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     __pyx_v_self->_delegate->core.flag = (__pyx_v_self->_delegate->core.flag | 2);
     goto __pyx_L3;
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2807
+    /* "pysam/csamtools.pyx":2990
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FPROPER_PAIR
  *             else: self._delegate.core.flag &= ~BAM_FPROPER_PAIR             # <<<<<<<<<<<<<<
@@ -27782,7 +29168,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_11is_unmapped_1__get__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2810
+/* "pysam/csamtools.pyx":2993
  *     property is_unmapped:
  *         """true if read itself is unmapped"""
  *         def __get__(self): return (self.flag & BAM_FUNMAP) != 0             # <<<<<<<<<<<<<<
@@ -27800,14 +29186,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_11is_unmapped___get__(
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2810);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2993);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2810; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2993; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -27838,7 +29224,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_11is_unmapped_3__set__(PyObj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2811
+/* "pysam/csamtools.pyx":2994
  *         """true if read itself is unmapped"""
  *         def __get__(self): return (self.flag & BAM_FUNMAP) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -27855,23 +29241,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_11is_unmapped_2__set__(struc
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2811);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 2994);
 
-  /* "pysam/csamtools.pyx":2812
+  /* "pysam/csamtools.pyx":2995
  *         def __get__(self): return (self.flag & BAM_FUNMAP) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FUNMAP             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FUNMAP
  *     property mate_is_unmapped:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2812; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     __pyx_v_self->_delegate->core.flag = (__pyx_v_self->_delegate->core.flag | 4);
     goto __pyx_L3;
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2813
+    /* "pysam/csamtools.pyx":2996
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FUNMAP
  *             else: self._delegate.core.flag &= ~BAM_FUNMAP             # <<<<<<<<<<<<<<
@@ -27904,7 +29290,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_16mate_is_unmapped_1__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2816
+/* "pysam/csamtools.pyx":2999
  *     property mate_is_unmapped:
  *         """true if the mate is unmapped"""
  *         def __get__(self): return (self.flag & BAM_FMUNMAP) != 0             # <<<<<<<<<<<<<<
@@ -27922,14 +29308,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_16mate_is_unmapped___g
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2816);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 2999);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_8); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2816; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2999; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -27960,7 +29346,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_16mate_is_unmapped_3__set__(
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2817
+/* "pysam/csamtools.pyx":3000
  *         """true if the mate is unmapped"""
  *         def __get__(self): return (self.flag & BAM_FMUNMAP) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -27977,23 +29363,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_16mate_is_unmapped_2__set__(
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2817);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 3000);
 
-  /* "pysam/csamtools.pyx":2818
+  /* "pysam/csamtools.pyx":3001
  *         def __get__(self): return (self.flag & BAM_FMUNMAP) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FMUNMAP             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FMUNMAP
  *     property is_reverse:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3001; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     __pyx_v_self->_delegate->core.flag = (__pyx_v_self->_delegate->core.flag | 8);
     goto __pyx_L3;
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2819
+    /* "pysam/csamtools.pyx":3002
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FMUNMAP
  *             else: self._delegate.core.flag &= ~BAM_FMUNMAP             # <<<<<<<<<<<<<<
@@ -28026,7 +29412,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_10is_reverse_1__get__(
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2822
+/* "pysam/csamtools.pyx":3005
  *     property is_reverse:
  *         """true if read is mapped to reverse strand"""
  *         def __get__(self): return (self.flag & BAM_FREVERSE) != 0             # <<<<<<<<<<<<<<
@@ -28044,14 +29430,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10is_reverse___get__(s
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2822);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3005);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_16); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2822; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3005; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -28082,7 +29468,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_10is_reverse_3__set__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2823
+/* "pysam/csamtools.pyx":3006
  *         """true if read is mapped to reverse strand"""
  *         def __get__(self): return (self.flag & BAM_FREVERSE) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -28099,23 +29485,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_10is_reverse_2__set__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2823);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 3006);
 
-  /* "pysam/csamtools.pyx":2824
+  /* "pysam/csamtools.pyx":3007
  *         def __get__(self): return (self.flag & BAM_FREVERSE) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FREVERSE             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FREVERSE
  *     property mate_is_reverse:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3007; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     __pyx_v_self->_delegate->core.flag = (__pyx_v_self->_delegate->core.flag | 16);
     goto __pyx_L3;
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2825
+    /* "pysam/csamtools.pyx":3008
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FREVERSE
  *             else: self._delegate.core.flag &= ~BAM_FREVERSE             # <<<<<<<<<<<<<<
@@ -28148,7 +29534,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_15mate_is_reverse_1__g
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2828
+/* "pysam/csamtools.pyx":3011
  *     property mate_is_reverse:
  *         """true is read is mapped to reverse strand"""
  *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0             # <<<<<<<<<<<<<<
@@ -28166,14 +29552,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_15mate_is_reverse___ge
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2828);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3011);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_32); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2828; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -28204,7 +29590,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_15mate_is_reverse_3__set__(P
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2829
+/* "pysam/csamtools.pyx":3012
  *         """true is read is mapped to reverse strand"""
  *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -28221,23 +29607,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_15mate_is_reverse_2__set__(s
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2829);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 3012);
 
-  /* "pysam/csamtools.pyx":2830
+  /* "pysam/csamtools.pyx":3013
  *         def __get__(self): return (self.flag & BAM_FMREVERSE) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FMREVERSE             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FMREVERSE
  *     property is_read1:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2830; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3013; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     __pyx_v_self->_delegate->core.flag = (__pyx_v_self->_delegate->core.flag | 32);
     goto __pyx_L3;
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2831
+    /* "pysam/csamtools.pyx":3014
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FMREVERSE
  *             else: self._delegate.core.flag &= ~BAM_FMREVERSE             # <<<<<<<<<<<<<<
@@ -28270,7 +29656,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_8is_read1_1__get__(PyO
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2834
+/* "pysam/csamtools.pyx":3017
  *     property is_read1:
  *         """true if this is read1"""
  *         def __get__(self): return (self.flag & BAM_FREAD1) != 0             # <<<<<<<<<<<<<<
@@ -28288,14 +29674,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_8is_read1___get__(stru
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2834);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3017);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_64); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2834; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -28326,7 +29712,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_8is_read1_3__set__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2835
+/* "pysam/csamtools.pyx":3018
  *         """true if this is read1"""
  *         def __get__(self): return (self.flag & BAM_FREAD1) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -28343,23 +29729,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_8is_read1_2__set__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2835);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 3018);
 
-  /* "pysam/csamtools.pyx":2836
+  /* "pysam/csamtools.pyx":3019
  *         def __get__(self): return (self.flag & BAM_FREAD1) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FREAD1             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FREAD1
  *     property is_read2:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2836; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     __pyx_v_self->_delegate->core.flag = (__pyx_v_self->_delegate->core.flag | 64);
     goto __pyx_L3;
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2837
+    /* "pysam/csamtools.pyx":3020
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FREAD1
  *             else: self._delegate.core.flag &= ~BAM_FREAD1             # <<<<<<<<<<<<<<
@@ -28392,7 +29778,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_8is_read2_1__get__(PyO
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2840
+/* "pysam/csamtools.pyx":3023
  *     property is_read2:
  *         """true if this is read2"""
  *         def __get__(self): return (self.flag & BAM_FREAD2) != 0             # <<<<<<<<<<<<<<
@@ -28410,14 +29796,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_8is_read2___get__(stru
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2840);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3023);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_128); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_128); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3023; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -28448,7 +29834,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_8is_read2_3__set__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2841
+/* "pysam/csamtools.pyx":3024
  *         """true if this is read2"""
  *         def __get__(self): return (self.flag & BAM_FREAD2) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -28465,23 +29851,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_8is_read2_2__set__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2841);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 3024);
 
-  /* "pysam/csamtools.pyx":2842
+  /* "pysam/csamtools.pyx":3025
  *         def __get__(self): return (self.flag & BAM_FREAD2) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FREAD2             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FREAD2
  *     property is_secondary:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2842; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     __pyx_v_self->_delegate->core.flag = (__pyx_v_self->_delegate->core.flag | 128);
     goto __pyx_L3;
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2843
+    /* "pysam/csamtools.pyx":3026
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FREAD2
  *             else: self._delegate.core.flag &= ~BAM_FREAD2             # <<<<<<<<<<<<<<
@@ -28514,7 +29900,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_12is_secondary_1__get_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2846
+/* "pysam/csamtools.pyx":3029
  *     property is_secondary:
  *         """true if not primary alignment"""
  *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0             # <<<<<<<<<<<<<<
@@ -28532,14 +29918,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12is_secondary___get__
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2846);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3029);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_256); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_256); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2846; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -28570,7 +29956,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_12is_secondary_3__set__(PyOb
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2847
+/* "pysam/csamtools.pyx":3030
  *         """true if not primary alignment"""
  *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -28587,23 +29973,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_12is_secondary_2__set__(stru
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2847);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 3030);
 
-  /* "pysam/csamtools.pyx":2848
+  /* "pysam/csamtools.pyx":3031
  *         def __get__(self): return (self.flag & BAM_FSECONDARY) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FSECONDARY             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FSECONDARY
  *     property is_qcfail:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2848; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     __pyx_v_self->_delegate->core.flag = (__pyx_v_self->_delegate->core.flag | 256);
     goto __pyx_L3;
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2849
+    /* "pysam/csamtools.pyx":3032
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FSECONDARY
  *             else: self._delegate.core.flag &= ~BAM_FSECONDARY             # <<<<<<<<<<<<<<
@@ -28636,7 +30022,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_9is_qcfail_1__get__(Py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2852
+/* "pysam/csamtools.pyx":3035
  *     property is_qcfail:
  *         """true if QC failure"""
  *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0             # <<<<<<<<<<<<<<
@@ -28654,14 +30040,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9is_qcfail___get__(str
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2852);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3035);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_512); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_512); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2852; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3035; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -28692,7 +30078,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_9is_qcfail_3__set__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2853
+/* "pysam/csamtools.pyx":3036
  *         """true if QC failure"""
  *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -28709,23 +30095,23 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_9is_qcfail_2__set__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2853);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 3036);
 
-  /* "pysam/csamtools.pyx":2854
+  /* "pysam/csamtools.pyx":3037
  *         def __get__(self): return (self.flag & BAM_FQCFAIL) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FQCFAIL             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FQCFAIL
  *     property is_duplicate:
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2854; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3037; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     __pyx_v_self->_delegate->core.flag = (__pyx_v_self->_delegate->core.flag | 512);
     goto __pyx_L3;
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2855
+    /* "pysam/csamtools.pyx":3038
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FQCFAIL
  *             else: self._delegate.core.flag &= ~BAM_FQCFAIL             # <<<<<<<<<<<<<<
@@ -28758,7 +30144,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_12is_duplicate_1__get_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2858
+/* "pysam/csamtools.pyx":3041
  *     property is_duplicate:
  *         """true if optical or PCR duplicate"""
  *         def __get__(self): return (self.flag & BAM_FDUP) != 0             # <<<<<<<<<<<<<<
@@ -28776,14 +30162,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12is_duplicate___get__
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2858);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3041);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__flag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_1024); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyNumber_And(__pyx_t_1, __pyx_int_1024); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2858; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_int_0, Py_NE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -28814,7 +30200,7 @@ static int __pyx_pw_5pysam_9csamtools_11AlignedRead_12is_duplicate_3__set__(PyOb
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2859
+/* "pysam/csamtools.pyx":3042
  *         """true if optical or PCR duplicate"""
  *         def __get__(self): return (self.flag & BAM_FDUP) != 0
  *         def __set__(self,val):             # <<<<<<<<<<<<<<
@@ -28831,28 +30217,28 @@ static int __pyx_pf_5pysam_9csamtools_11AlignedRead_12is_duplicate_2__set__(stru
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 2859);
+  __Pyx_TraceCall("__set__", __pyx_f[0], 3042);
 
-  /* "pysam/csamtools.pyx":2860
+  /* "pysam/csamtools.pyx":3043
  *         def __get__(self): return (self.flag & BAM_FDUP) != 0
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FDUP             # <<<<<<<<<<<<<<
  *             else: self._delegate.core.flag &= ~BAM_FDUP
- *     property positions:
+ * 
  */
-  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2860; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_val); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
     __pyx_v_self->_delegate->core.flag = (__pyx_v_self->_delegate->core.flag | 1024);
     goto __pyx_L3;
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2861
+    /* "pysam/csamtools.pyx":3044
  *         def __set__(self,val):
  *             if val: self._delegate.core.flag |= BAM_FDUP
  *             else: self._delegate.core.flag &= ~BAM_FDUP             # <<<<<<<<<<<<<<
- *     property positions:
- *         """a list of reference positions that this read aligns to."""
+ * 
+ *     #######################################################################
  */
     __pyx_v_self->_delegate->core.flag = (__pyx_v_self->_delegate->core.flag & (~1024));
   }
@@ -28880,7 +30266,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_9positions_1__get__(Py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2864
+/* "pysam/csamtools.pyx":3052
  *     property positions:
  *         """a list of reference positions that this read aligns to."""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -28912,9 +30298,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9positions___get__(str
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2864);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3052);
 
-  /* "pysam/csamtools.pyx":2870
+  /* "pysam/csamtools.pyx":3058
  *             cdef bam1_t * src
  * 
  *             src = self._delegate             # <<<<<<<<<<<<<<
@@ -28924,7 +30310,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9positions___get__(str
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2871
+  /* "pysam/csamtools.pyx":3059
  * 
  *             src = self._delegate
  *             if src.core.n_cigar == 0: return []             # <<<<<<<<<<<<<<
@@ -28934,7 +30320,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9positions___get__(str
   __pyx_t_2 = (__pyx_v_src->core.n_cigar == 0);
   if (__pyx_t_2) {
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2871; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = ((PyObject *)__pyx_t_3);
     __pyx_t_3 = 0;
@@ -28943,19 +30329,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9positions___get__(str
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2873
+  /* "pysam/csamtools.pyx":3061
  *             if src.core.n_cigar == 0: return []
  * 
  *             result = []             # <<<<<<<<<<<<<<
  *             pos = src.core.pos
  *             cigar_p = bam1_cigar(src)
  */
-  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2873; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_v_result = ((PyObject*)__pyx_t_3);
   __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":2874
+  /* "pysam/csamtools.pyx":3062
  * 
  *             result = []
  *             pos = src.core.pos             # <<<<<<<<<<<<<<
@@ -28965,7 +30351,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9positions___get__(str
   __pyx_t_4 = __pyx_v_src->core.pos;
   __pyx_v_pos = __pyx_t_4;
 
-  /* "pysam/csamtools.pyx":2875
+  /* "pysam/csamtools.pyx":3063
  *             result = []
  *             pos = src.core.pos
  *             cigar_p = bam1_cigar(src)             # <<<<<<<<<<<<<<
@@ -28974,7 +30360,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9positions___get__(str
  */
   __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2877
+  /* "pysam/csamtools.pyx":3065
  *             cigar_p = bam1_cigar(src)
  * 
  *             for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -28984,7 +30370,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9positions___get__(str
   __pyx_t_5 = __pyx_v_src->core.n_cigar;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_5; __pyx_v_k++) {
 
-    /* "pysam/csamtools.pyx":2878
+    /* "pysam/csamtools.pyx":3066
  * 
  *             for k from 0 <= k < src.core.n_cigar:
  *                 op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
@@ -28993,20 +30379,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9positions___get__(str
  */
     __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
 
-    /* "pysam/csamtools.pyx":2879
+    /* "pysam/csamtools.pyx":3067
  *             for k from 0 <= k < src.core.n_cigar:
  *                 op = cigar_p[k] & BAM_CIGAR_MASK
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
  *                 if op == BAM_CMATCH:
  *                     for i from pos <= i < pos + l:
  */
-    __pyx_t_3 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2879; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_XDECREF(__pyx_v_l);
     __pyx_v_l = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "pysam/csamtools.pyx":2880
+    /* "pysam/csamtools.pyx":3068
  *                 op = cigar_p[k] & BAM_CIGAR_MASK
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
  *                 if op == BAM_CMATCH:             # <<<<<<<<<<<<<<
@@ -29016,39 +30402,39 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9positions___get__(str
     __pyx_t_2 = (__pyx_v_op == 0);
     if (__pyx_t_2) {
 
-      /* "pysam/csamtools.pyx":2881
+      /* "pysam/csamtools.pyx":3069
  *                 l = cigar_p[k] >> BAM_CIGAR_SHIFT
  *                 if op == BAM_CMATCH:
  *                     for i from pos <= i < pos + l:             # <<<<<<<<<<<<<<
  *                         result.append( i )
  * 
  */
-      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_6 = PyNumber_Add(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyNumber_Add(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_6); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2881; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_6); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3069; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       for (__pyx_v_i = __pyx_v_pos; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
 
-        /* "pysam/csamtools.pyx":2882
+        /* "pysam/csamtools.pyx":3070
  *                 if op == BAM_CMATCH:
  *                     for i from pos <= i < pos + l:
  *                         result.append( i )             # <<<<<<<<<<<<<<
  * 
  *                 if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
  */
-        __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_i); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        __pyx_t_8 = PyList_Append(__pyx_v_result, __pyx_t_6); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2882; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyList_Append(__pyx_v_result, __pyx_t_6); if (unlikely(__pyx_t_8 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       }
       goto __pyx_L6;
     }
     __pyx_L6:;
 
-    /* "pysam/csamtools.pyx":2884
+    /* "pysam/csamtools.pyx":3072
  *                         result.append( i )
  * 
  *                 if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:             # <<<<<<<<<<<<<<
@@ -29060,31 +30446,31 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9positions___get__(str
       case 2:
       case 3:
 
-      /* "pysam/csamtools.pyx":2885
+      /* "pysam/csamtools.pyx":3073
  * 
  *                 if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
  *                     pos += l             # <<<<<<<<<<<<<<
  * 
  *             return result
  */
-      __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
-      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_v_l); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_6, __pyx_v_l); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2885; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __pyx_v_pos = __pyx_t_7;
       break;
     }
   }
 
-  /* "pysam/csamtools.pyx":2887
+  /* "pysam/csamtools.pyx":3075
  *                     pos += l
  * 
  *             return result             # <<<<<<<<<<<<<<
  * 
- *     property aligned_pairs:
+ *     property inferred_length:
  */
   __Pyx_XDECREF(__pyx_r);
   __Pyx_INCREF(((PyObject *)__pyx_v_result));
@@ -29108,6 +30494,159 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_9positions___get__(str
 }
 
 /* Python wrapper */
+static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_15inferred_length_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_15inferred_length_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_5pysam_9csamtools_11AlignedRead_15inferred_length___get__(((struct __pyx_obj_5pysam_9csamtools_AlignedRead *)__pyx_v_self));
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "pysam/csamtools.pyx":3082
+ *         Returns 0 if CIGAR string is not present.
+ *         """
+ *         def __get__(self):             # <<<<<<<<<<<<<<
+ *            cdef uint32_t k, qpos
+ *            cdef int op
+ */
+
+static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_15inferred_length___get__(struct __pyx_obj_5pysam_9csamtools_AlignedRead *__pyx_v_self) {
+  uint32_t __pyx_v_k;
+  uint32_t __pyx_v_qpos;
+  int __pyx_v_op;
+  uint32_t *__pyx_v_cigar_p;
+  bam1_t *__pyx_v_src;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  bam1_t *__pyx_t_1;
+  int __pyx_t_2;
+  uint32_t __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_TraceDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3082);
+
+  /* "pysam/csamtools.pyx":3088
+ *            cdef bam1_t * src
+ * 
+ *            src = self._delegate             # <<<<<<<<<<<<<<
+ *            if src.core.n_cigar == 0: return 0
+ * 
+ */
+  __pyx_t_1 = __pyx_v_self->_delegate;
+  __pyx_v_src = __pyx_t_1;
+
+  /* "pysam/csamtools.pyx":3089
+ * 
+ *            src = self._delegate
+ *            if src.core.n_cigar == 0: return 0             # <<<<<<<<<<<<<<
+ * 
+ *            qpos = 0
+ */
+  __pyx_t_2 = (__pyx_v_src->core.n_cigar == 0);
+  if (__pyx_t_2) {
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(__pyx_int_0);
+    __pyx_r = __pyx_int_0;
+    goto __pyx_L0;
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "pysam/csamtools.pyx":3091
+ *            if src.core.n_cigar == 0: return 0
+ * 
+ *            qpos = 0             # <<<<<<<<<<<<<<
+ *            cigar_p = bam1_cigar(src)
+ * 
+ */
+  __pyx_v_qpos = 0;
+
+  /* "pysam/csamtools.pyx":3092
+ * 
+ *            qpos = 0
+ *            cigar_p = bam1_cigar(src)             # <<<<<<<<<<<<<<
+ * 
+ *            for k from 0 <= k < src.core.n_cigar:
+ */
+  __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
+
+  /* "pysam/csamtools.pyx":3094
+ *            cigar_p = bam1_cigar(src)
+ * 
+ *            for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
+ *                op = cigar_p[k] & BAM_CIGAR_MASK
+ * 
+ */
+  __pyx_t_3 = __pyx_v_src->core.n_cigar;
+  for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_3; __pyx_v_k++) {
+
+    /* "pysam/csamtools.pyx":3095
+ * 
+ *            for k from 0 <= k < src.core.n_cigar:
+ *                op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
+ * 
+ *                if op == BAM_CMATCH or op == BAM_CINS or op == BAM_CSOFT_CLIP:
+ */
+    __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
+
+    /* "pysam/csamtools.pyx":3097
+ *                op = cigar_p[k] & BAM_CIGAR_MASK
+ * 
+ *                if op == BAM_CMATCH or op == BAM_CINS or op == BAM_CSOFT_CLIP:             # <<<<<<<<<<<<<<
+ *                    qpos += cigar_p[k] >> BAM_CIGAR_SHIFT
+ * 
+ */
+    switch (__pyx_v_op) {
+      case 0:
+      case 1:
+      case 4:
+
+      /* "pysam/csamtools.pyx":3098
+ * 
+ *                if op == BAM_CMATCH or op == BAM_CINS or op == BAM_CSOFT_CLIP:
+ *                    qpos += cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
+ * 
+ *            return qpos
+ */
+      __pyx_v_qpos = (__pyx_v_qpos + ((__pyx_v_cigar_p[__pyx_v_k]) >> 4));
+      break;
+    }
+  }
+
+  /* "pysam/csamtools.pyx":3100
+ *                    qpos += cigar_p[k] >> BAM_CIGAR_SHIFT
+ * 
+ *            return qpos             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_4 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_qpos); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3100; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_r = __pyx_t_4;
+  __pyx_t_4 = 0;
+  goto __pyx_L0;
+
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_AddTraceback("pysam.csamtools.AlignedRead.inferred_length.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_TraceReturn(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
 static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_13aligned_pairs_1__get__(PyObject *__pyx_v_self); /*proto*/
 static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_13aligned_pairs_1__get__(PyObject *__pyx_v_self) {
   PyObject *__pyx_r = 0;
@@ -29118,7 +30657,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_13aligned_pairs_1__get
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2894
+/* "pysam/csamtools.pyx":3108
  *        Unaligned position are marked by None.
  *        """
  *        def __get__(self):             # <<<<<<<<<<<<<<
@@ -29152,9 +30691,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 2894);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3108);
 
-  /* "pysam/csamtools.pyx":2900
+  /* "pysam/csamtools.pyx":3114
  *            cdef bam1_t * src
  * 
  *            src = self._delegate             # <<<<<<<<<<<<<<
@@ -29164,7 +30703,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2901
+  /* "pysam/csamtools.pyx":3115
  * 
  *            src = self._delegate
  *            if src.core.n_cigar == 0: return []             # <<<<<<<<<<<<<<
@@ -29174,7 +30713,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
   __pyx_t_2 = (__pyx_v_src->core.n_cigar == 0);
   if (__pyx_t_2) {
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_r = ((PyObject *)__pyx_t_3);
     __pyx_t_3 = 0;
@@ -29183,19 +30722,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2903
+  /* "pysam/csamtools.pyx":3117
  *            if src.core.n_cigar == 0: return []
  * 
  *            result = []             # <<<<<<<<<<<<<<
  *            pos = src.core.pos
  *            qpos = 0
  */
-  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2903; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __pyx_v_result = ((PyObject*)__pyx_t_3);
   __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":2904
+  /* "pysam/csamtools.pyx":3118
  * 
  *            result = []
  *            pos = src.core.pos             # <<<<<<<<<<<<<<
@@ -29205,7 +30744,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
   __pyx_t_4 = __pyx_v_src->core.pos;
   __pyx_v_pos = __pyx_t_4;
 
-  /* "pysam/csamtools.pyx":2905
+  /* "pysam/csamtools.pyx":3119
  *            result = []
  *            pos = src.core.pos
  *            qpos = 0             # <<<<<<<<<<<<<<
@@ -29214,7 +30753,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
  */
   __pyx_v_qpos = 0;
 
-  /* "pysam/csamtools.pyx":2906
+  /* "pysam/csamtools.pyx":3120
  *            pos = src.core.pos
  *            qpos = 0
  *            cigar_p = bam1_cigar(src)             # <<<<<<<<<<<<<<
@@ -29223,7 +30762,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
  */
   __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2908
+  /* "pysam/csamtools.pyx":3122
  *            cigar_p = bam1_cigar(src)
  * 
  *            for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -29233,7 +30772,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
   __pyx_t_5 = __pyx_v_src->core.n_cigar;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_5; __pyx_v_k++) {
 
-    /* "pysam/csamtools.pyx":2909
+    /* "pysam/csamtools.pyx":3123
  * 
  *            for k from 0 <= k < src.core.n_cigar:
  *                op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
@@ -29242,20 +30781,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
  */
     __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
 
-    /* "pysam/csamtools.pyx":2910
+    /* "pysam/csamtools.pyx":3124
  *            for k from 0 <= k < src.core.n_cigar:
  *                op = cigar_p[k] & BAM_CIGAR_MASK
  *                l = cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
  * 
  *                if op == BAM_CMATCH:
  */
-    __pyx_t_3 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2910; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3124; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_XDECREF(__pyx_v_l);
     __pyx_v_l = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "pysam/csamtools.pyx":2923
+    /* "pysam/csamtools.pyx":3137
  *                        qpos += 1
  * 
  *                elif op == BAM_CDEL or op == BAM_CREF_SKIP:             # <<<<<<<<<<<<<<
@@ -29264,7 +30803,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
  */
     switch (__pyx_v_op) {
 
-      /* "pysam/csamtools.pyx":2912
+      /* "pysam/csamtools.pyx":3126
  *                l = cigar_p[k] >> BAM_CIGAR_SHIFT
  * 
  *                if op == BAM_CMATCH:             # <<<<<<<<<<<<<<
@@ -29273,34 +30812,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
  */
       case 0:
 
-      /* "pysam/csamtools.pyx":2913
+      /* "pysam/csamtools.pyx":3127
  * 
  *                if op == BAM_CMATCH:
  *                    for i from pos <= i < pos + l:             # <<<<<<<<<<<<<<
  *                        result.append( (qpos, i) )
  *                        qpos += 1
  */
-      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_6 = PyNumber_Add(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyNumber_Add(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_6); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2913; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_6); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       for (__pyx_v_i = __pyx_v_pos; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
 
-        /* "pysam/csamtools.pyx":2914
+        /* "pysam/csamtools.pyx":3128
  *                if op == BAM_CMATCH:
  *                    for i from pos <= i < pos + l:
  *                        result.append( (qpos, i) )             # <<<<<<<<<<<<<<
  *                        qpos += 1
  *                    pos += l
  */
-        __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_qpos); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_6 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_qpos); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_6);
-        __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_i); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
         PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6);
         __Pyx_GIVEREF(__pyx_t_6);
@@ -29308,10 +30847,10 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
         __Pyx_GIVEREF(__pyx_t_3);
         __pyx_t_6 = 0;
         __pyx_t_3 = 0;
-        __pyx_t_9 = PyList_Append(__pyx_v_result, ((PyObject *)__pyx_t_8)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2914; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyList_Append(__pyx_v_result, ((PyObject *)__pyx_t_8)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
 
-        /* "pysam/csamtools.pyx":2915
+        /* "pysam/csamtools.pyx":3129
  *                    for i from pos <= i < pos + l:
  *                        result.append( (qpos, i) )
  *                        qpos += 1             # <<<<<<<<<<<<<<
@@ -29321,24 +30860,24 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
         __pyx_v_qpos = (__pyx_v_qpos + 1);
       }
 
-      /* "pysam/csamtools.pyx":2916
+      /* "pysam/csamtools.pyx":3130
  *                        result.append( (qpos, i) )
  *                        qpos += 1
  *                    pos += l             # <<<<<<<<<<<<<<
  * 
  *                elif op == BAM_CINS:
  */
-      __pyx_t_8 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
-      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_8, __pyx_v_l); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyNumber_InPlaceAdd(__pyx_t_8, __pyx_v_l); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2916; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_3); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __pyx_v_pos = __pyx_t_7;
       break;
 
-      /* "pysam/csamtools.pyx":2918
+      /* "pysam/csamtools.pyx":3132
  *                    pos += l
  * 
  *                elif op == BAM_CINS:             # <<<<<<<<<<<<<<
@@ -29347,32 +30886,32 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
  */
       case 1:
 
-      /* "pysam/csamtools.pyx":2919
+      /* "pysam/csamtools.pyx":3133
  * 
  *                elif op == BAM_CINS:
  *                    for i from pos <= i < pos + l:             # <<<<<<<<<<<<<<
  *                        result.append( (qpos, None) )
  *                        qpos += 1
  */
-      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2919; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
       for (__pyx_v_i = __pyx_v_pos; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
 
-        /* "pysam/csamtools.pyx":2920
+        /* "pysam/csamtools.pyx":3134
  *                elif op == BAM_CINS:
  *                    for i from pos <= i < pos + l:
  *                        result.append( (qpos, None) )             # <<<<<<<<<<<<<<
  *                        qpos += 1
  * 
  */
-        __pyx_t_8 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_qpos); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_qpos); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
-        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
         PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_8);
         __Pyx_GIVEREF(__pyx_t_8);
@@ -29380,10 +30919,10 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
         PyTuple_SET_ITEM(__pyx_t_3, 1, Py_None);
         __Pyx_GIVEREF(Py_None);
         __pyx_t_8 = 0;
-        __pyx_t_9 = PyList_Append(__pyx_v_result, ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2920; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyList_Append(__pyx_v_result, ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
 
-        /* "pysam/csamtools.pyx":2921
+        /* "pysam/csamtools.pyx":3135
  *                    for i from pos <= i < pos + l:
  *                        result.append( (qpos, None) )
  *                        qpos += 1             # <<<<<<<<<<<<<<
@@ -29394,7 +30933,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
       }
       break;
 
-      /* "pysam/csamtools.pyx":2923
+      /* "pysam/csamtools.pyx":3137
  *                        qpos += 1
  * 
  *                elif op == BAM_CDEL or op == BAM_CREF_SKIP:             # <<<<<<<<<<<<<<
@@ -29404,32 +30943,32 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
       case 2:
       case 3:
 
-      /* "pysam/csamtools.pyx":2924
+      /* "pysam/csamtools.pyx":3138
  * 
  *                elif op == BAM_CDEL or op == BAM_CREF_SKIP:
  *                    for i from pos <= i < pos + l:             # <<<<<<<<<<<<<<
  *                        result.append( (None, i) )
  *                    pos += l
  */
-      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyNumber_Add(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
       for (__pyx_v_i = __pyx_v_pos; __pyx_v_i < __pyx_t_7; __pyx_v_i++) {
 
-        /* "pysam/csamtools.pyx":2925
+        /* "pysam/csamtools.pyx":3139
  *                elif op == BAM_CDEL or op == BAM_CREF_SKIP:
  *                    for i from pos <= i < pos + l:
  *                        result.append( (None, i) )             # <<<<<<<<<<<<<<
  *                    pos += l
  * 
  */
-        __pyx_t_8 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_i); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_8 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_i); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_8);
-        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_3);
         __Pyx_INCREF(Py_None);
         PyTuple_SET_ITEM(__pyx_t_3, 0, Py_None);
@@ -29437,35 +30976,35 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_13aligned_pairs___get_
         PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_8);
         __Pyx_GIVEREF(__pyx_t_8);
         __pyx_t_8 = 0;
-        __pyx_t_9 = PyList_Append(__pyx_v_result, ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2925; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = PyList_Append(__pyx_v_result, ((PyObject *)__pyx_t_3)); if (unlikely(__pyx_t_9 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
       }
 
-      /* "pysam/csamtools.pyx":2926
+      /* "pysam/csamtools.pyx":3140
  *                    for i from pos <= i < pos + l:
  *                        result.append( (None, i) )
  *                    pos += l             # <<<<<<<<<<<<<<
  * 
  *            return result
  */
-      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_8 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_v_l); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_8); if (unlikely((__pyx_t_7 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
       __pyx_v_pos = __pyx_t_7;
       break;
     }
   }
 
-  /* "pysam/csamtools.pyx":2928
+  /* "pysam/csamtools.pyx":3142
  *                    pos += l
  * 
  *            return result             # <<<<<<<<<<<<<<
  * 
- * 
+ *     #######################################################################
  */
   __Pyx_XDECREF(__pyx_r);
   __Pyx_INCREF(((PyObject *)__pyx_v_result));
@@ -29518,11 +31057,11 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_11overlap(PyObject *__
         case  1:
         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__end)) != 0)) kw_args--;
         else {
-          __Pyx_RaiseArgtupleInvalid("overlap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+          __Pyx_RaiseArgtupleInvalid("overlap", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "overlap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "overlap") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
       goto __pyx_L5_argtuple_error;
@@ -29530,12 +31069,12 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_11overlap(PyObject *__
       values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
       values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
     }
-    __pyx_v_start = __Pyx_PyInt_from_py_uint32_t(values[0]); if (unlikely((__pyx_v_start == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
-    __pyx_v_end = __Pyx_PyInt_from_py_uint32_t(values[1]); if (unlikely((__pyx_v_end == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_start = __Pyx_PyInt_from_py_uint32_t(values[0]); if (unlikely((__pyx_v_start == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_end = __Pyx_PyInt_from_py_uint32_t(values[1]); if (unlikely((__pyx_v_end == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("overlap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2931; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("overlap", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.AlignedRead.overlap", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -29546,9 +31085,9 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_11overlap(PyObject *__
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2931
- * 
- * 
+/* "pysam/csamtools.pyx":3148
+ *     ##
+ *     #######################################################################
  *     def overlap( self, uint32_t start, uint32_t end ):             # <<<<<<<<<<<<<<
  *         """return number of aligned bases of read overlapping the interval *start* and *end*
  *         on the reference sequence.
@@ -29582,9 +31121,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("overlap", 0);
-  __Pyx_TraceCall("overlap", __pyx_f[0], 2931);
+  __Pyx_TraceCall("overlap", __pyx_f[0], 3148);
 
-  /* "pysam/csamtools.pyx":2940
+  /* "pysam/csamtools.pyx":3157
  *         cdef bam1_t * src
  * 
  *         overlap = 0             # <<<<<<<<<<<<<<
@@ -29593,7 +31132,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
  */
   __pyx_v_overlap = 0;
 
-  /* "pysam/csamtools.pyx":2942
+  /* "pysam/csamtools.pyx":3159
  *         overlap = 0
  * 
  *         src = self._delegate             # <<<<<<<<<<<<<<
@@ -29603,7 +31142,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
   __pyx_t_1 = __pyx_v_self->_delegate;
   __pyx_v_src = __pyx_t_1;
 
-  /* "pysam/csamtools.pyx":2943
+  /* "pysam/csamtools.pyx":3160
  * 
  *         src = self._delegate
  *         if src.core.n_cigar == 0: return 0             # <<<<<<<<<<<<<<
@@ -29620,7 +31159,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2944
+  /* "pysam/csamtools.pyx":3161
  *         src = self._delegate
  *         if src.core.n_cigar == 0: return 0
  *         pos = src.core.pos             # <<<<<<<<<<<<<<
@@ -29630,7 +31169,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
   __pyx_t_3 = __pyx_v_src->core.pos;
   __pyx_v_pos = __pyx_t_3;
 
-  /* "pysam/csamtools.pyx":2945
+  /* "pysam/csamtools.pyx":3162
  *         if src.core.n_cigar == 0: return 0
  *         pos = src.core.pos
  *         o = 0             # <<<<<<<<<<<<<<
@@ -29639,7 +31178,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
  */
   __pyx_v_o = 0;
 
-  /* "pysam/csamtools.pyx":2947
+  /* "pysam/csamtools.pyx":3164
  *         o = 0
  * 
  *         cigar_p = bam1_cigar(src)             # <<<<<<<<<<<<<<
@@ -29648,7 +31187,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
  */
   __pyx_v_cigar_p = bam1_cigar(__pyx_v_src);
 
-  /* "pysam/csamtools.pyx":2948
+  /* "pysam/csamtools.pyx":3165
  * 
  *         cigar_p = bam1_cigar(src)
  *         for k from 0 <= k < src.core.n_cigar:             # <<<<<<<<<<<<<<
@@ -29658,7 +31197,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
   __pyx_t_4 = __pyx_v_src->core.n_cigar;
   for (__pyx_v_k = 0; __pyx_v_k < __pyx_t_4; __pyx_v_k++) {
 
-    /* "pysam/csamtools.pyx":2949
+    /* "pysam/csamtools.pyx":3166
  *         cigar_p = bam1_cigar(src)
  *         for k from 0 <= k < src.core.n_cigar:
  *             op = cigar_p[k] & BAM_CIGAR_MASK             # <<<<<<<<<<<<<<
@@ -29667,20 +31206,20 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
  */
     __pyx_v_op = ((__pyx_v_cigar_p[__pyx_v_k]) & 15);
 
-    /* "pysam/csamtools.pyx":2950
+    /* "pysam/csamtools.pyx":3167
  *         for k from 0 <= k < src.core.n_cigar:
  *             op = cigar_p[k] & BAM_CIGAR_MASK
  *             l = cigar_p[k] >> BAM_CIGAR_SHIFT             # <<<<<<<<<<<<<<
  * 
  *             if op == BAM_CMATCH:
  */
-    __pyx_t_5 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2950; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyInt_FromLong(((__pyx_v_cigar_p[__pyx_v_k]) >> 4)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_XDECREF(__pyx_v_l);
     __pyx_v_l = __pyx_t_5;
     __pyx_t_5 = 0;
 
-    /* "pysam/csamtools.pyx":2952
+    /* "pysam/csamtools.pyx":3169
  *             l = cigar_p[k] >> BAM_CIGAR_SHIFT
  * 
  *             if op == BAM_CMATCH:             # <<<<<<<<<<<<<<
@@ -29690,7 +31229,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
     __pyx_t_2 = (__pyx_v_op == 0);
     if (__pyx_t_2) {
 
-      /* "pysam/csamtools.pyx":2953
+      /* "pysam/csamtools.pyx":3170
  * 
  *             if op == BAM_CMATCH:
  *                 o = min( pos + l, end) - max( pos, start )             # <<<<<<<<<<<<<<
@@ -29698,19 +31237,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
  * 
  */
       __pyx_t_6 = __pyx_v_end;
-      __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_5);
-      __pyx_t_7 = PyNumber_Add(__pyx_t_5, __pyx_v_l); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyNumber_Add(__pyx_t_5, __pyx_v_l); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
-      __pyx_t_8 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_6); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
-      __pyx_t_9 = PyObject_RichCompare(__pyx_t_8, __pyx_t_7, Py_LT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PyObject_RichCompare(__pyx_t_8, __pyx_t_7, Py_LT); __Pyx_XGOTREF(__pyx_t_9); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
-      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_9); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
       if (__pyx_t_2) {
-        __pyx_t_9 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_9 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_6); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_9);
         __pyx_t_5 = __pyx_t_9;
         __pyx_t_9 = 0;
@@ -29726,17 +31265,17 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
       } else {
         __pyx_t_11 = __pyx_t_10;
       }
-      __pyx_t_7 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_11); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = __Pyx_PyInt_to_py_uint32_t(__pyx_t_11); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
-      __pyx_t_9 = PyNumber_Subtract(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PyNumber_Subtract(__pyx_t_5, __pyx_t_7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
       __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
-      __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_9); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2953; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_12 = __Pyx_PyInt_AsInt(__pyx_t_9); if (unlikely((__pyx_t_12 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
       __pyx_v_o = __pyx_t_12;
 
-      /* "pysam/csamtools.pyx":2954
+      /* "pysam/csamtools.pyx":3171
  *             if op == BAM_CMATCH:
  *                 o = min( pos + l, end) - max( pos, start )
  *                 if o > 0: overlap += o             # <<<<<<<<<<<<<<
@@ -29753,7 +31292,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
     }
     __pyx_L6:;
 
-    /* "pysam/csamtools.pyx":2956
+    /* "pysam/csamtools.pyx":3173
  *                 if o > 0: overlap += o
  * 
  *             if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:             # <<<<<<<<<<<<<<
@@ -29765,26 +31304,26 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
       case 2:
       case 3:
 
-      /* "pysam/csamtools.pyx":2957
+      /* "pysam/csamtools.pyx":3174
  * 
  *             if op == BAM_CMATCH or op == BAM_CDEL or op == BAM_CREF_SKIP:
  *                 pos += l             # <<<<<<<<<<<<<<
  * 
  *         return overlap
  */
-      __pyx_t_9 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_pos); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
-      __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_9, __pyx_v_l); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_9, __pyx_v_l); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
-      __pyx_t_11 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_7); if (unlikely((__pyx_t_11 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2957; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = __Pyx_PyInt_from_py_uint32_t(__pyx_t_7); if (unlikely((__pyx_t_11 == (uint32_t)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
       __pyx_v_pos = __pyx_t_11;
       break;
     }
   }
 
-  /* "pysam/csamtools.pyx":2959
+  /* "pysam/csamtools.pyx":3176
  *                 pos += l
  * 
  *         return overlap             # <<<<<<<<<<<<<<
@@ -29792,7 +31331,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_10overlap(struct __pyx
  *     def opt(self, tag):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_7 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_overlap); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_overlap); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
   __pyx_r = __pyx_t_7;
   __pyx_t_7 = 0;
@@ -29827,7 +31366,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_13opt(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2961
+/* "pysam/csamtools.pyx":3178
  *         return overlap
  * 
  *     def opt(self, tag):             # <<<<<<<<<<<<<<
@@ -29862,31 +31401,31 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("opt", 0);
-  __Pyx_TraceCall("opt", __pyx_f[0], 2961);
+  __Pyx_TraceCall("opt", __pyx_f[0], 3178);
 
-  /* "pysam/csamtools.pyx":2966
+  /* "pysam/csamtools.pyx":3183
  *         cdef uint8_t * v
  *         cdef int nvalues
  *         btag = _force_bytes(tag)             # <<<<<<<<<<<<<<
  *         v = bam_aux_get(self._delegate, btag)
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
  */
-  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_tag)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_bytes(__pyx_v_tag)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_v_btag = ((PyObject*)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":2967
+  /* "pysam/csamtools.pyx":3184
  *         cdef int nvalues
  *         btag = _force_bytes(tag)
  *         v = bam_aux_get(self._delegate, btag)             # <<<<<<<<<<<<<<
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
  *         auxtype = chr(v[0])
  */
-  __pyx_t_2 = PyBytes_AsString(((PyObject *)__pyx_v_btag)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2967; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyBytes_AsString(((PyObject *)__pyx_v_btag)); if (unlikely((!__pyx_t_2) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_v = bam_aux_get(__pyx_v_self->_delegate, __pyx_t_2);
 
-  /* "pysam/csamtools.pyx":2968
+  /* "pysam/csamtools.pyx":3185
  *         btag = _force_bytes(tag)
  *         v = bam_aux_get(self._delegate, btag)
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )             # <<<<<<<<<<<<<<
@@ -29895,64 +31434,64 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
  */
   __pyx_t_3 = (__pyx_v_v == NULL);
   if (__pyx_t_3) {
-    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_152), __pyx_v_tag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_160), __pyx_v_tag); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_t_1));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_1));
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2968; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":2969
+  /* "pysam/csamtools.pyx":3186
  *         v = bam_aux_get(self._delegate, btag)
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
  *         auxtype = chr(v[0])             # <<<<<<<<<<<<<<
  *         if auxtype == 'c' or auxtype == 'C' or auxtype == 's' or auxtype == 'S':
  *             return <int>bam_aux2i(v)
  */
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint8_t((__pyx_v_v[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint8_t((__pyx_v_v[0])); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_builtin_chr, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_builtin_chr, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
   __pyx_v_auxtype = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":2970
+  /* "pysam/csamtools.pyx":3187
  *         if v == NULL: raise KeyError( "tag '%s' not present" % tag )
  *         auxtype = chr(v[0])
  *         if auxtype == 'c' or auxtype == 'C' or auxtype == 's' or auxtype == 'S':             # <<<<<<<<<<<<<<
  *             return <int>bam_aux2i(v)
  *         elif auxtype == 'i' or auxtype == 'I':
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__c), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__c), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (!__pyx_t_3) {
-    __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__C), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__C), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     if (!__pyx_t_5) {
-      __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__s), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__s), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       if (!__pyx_t_6) {
-        __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__S), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__S), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __pyx_t_8 = __pyx_t_7;
       } else {
@@ -29968,7 +31507,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
   }
   if (__pyx_t_5) {
 
-    /* "pysam/csamtools.pyx":2971
+    /* "pysam/csamtools.pyx":3188
  *         auxtype = chr(v[0])
  *         if auxtype == 'c' or auxtype == 'C' or auxtype == 's' or auxtype == 'S':
  *             return <int>bam_aux2i(v)             # <<<<<<<<<<<<<<
@@ -29976,7 +31515,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
  *             return <int32_t>bam_aux2i(v)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_1 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_v))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2971; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromLong(((int)bam_aux2i(__pyx_v_v))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3188; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __pyx_r = __pyx_t_1;
     __pyx_t_1 = 0;
@@ -29984,19 +31523,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
     goto __pyx_L4;
   }
 
-  /* "pysam/csamtools.pyx":2972
+  /* "pysam/csamtools.pyx":3189
  *         if auxtype == 'c' or auxtype == 'C' or auxtype == 's' or auxtype == 'S':
  *             return <int>bam_aux2i(v)
  *         elif auxtype == 'i' or auxtype == 'I':             # <<<<<<<<<<<<<<
  *             return <int32_t>bam_aux2i(v)
  *         elif auxtype == 'f' or auxtype == 'F':
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__i), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__i), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (!__pyx_t_5) {
-    __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__I), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2972; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__I), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_6 = __pyx_t_3;
   } else {
@@ -30004,7 +31543,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
   }
   if (__pyx_t_6) {
 
-    /* "pysam/csamtools.pyx":2973
+    /* "pysam/csamtools.pyx":3190
  *             return <int>bam_aux2i(v)
  *         elif auxtype == 'i' or auxtype == 'I':
  *             return <int32_t>bam_aux2i(v)             # <<<<<<<<<<<<<<
@@ -30012,7 +31551,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
  *             return <float>bam_aux2f(v)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((int32_t)bam_aux2i(__pyx_v_v))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(((int32_t)bam_aux2i(__pyx_v_v))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3190; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __pyx_r = __pyx_t_1;
     __pyx_t_1 = 0;
@@ -30020,19 +31559,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
     goto __pyx_L4;
   }
 
-  /* "pysam/csamtools.pyx":2974
+  /* "pysam/csamtools.pyx":3191
  *         elif auxtype == 'i' or auxtype == 'I':
  *             return <int32_t>bam_aux2i(v)
  *         elif auxtype == 'f' or auxtype == 'F':             # <<<<<<<<<<<<<<
  *             return <float>bam_aux2f(v)
  *         elif auxtype == 'd' or auxtype == 'D':
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__f), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__f), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (!__pyx_t_6) {
-    __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__F), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2974; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__F), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_3 = __pyx_t_5;
   } else {
@@ -30040,7 +31579,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
   }
   if (__pyx_t_3) {
 
-    /* "pysam/csamtools.pyx":2975
+    /* "pysam/csamtools.pyx":3192
  *             return <int32_t>bam_aux2i(v)
  *         elif auxtype == 'f' or auxtype == 'F':
  *             return <float>bam_aux2f(v)             # <<<<<<<<<<<<<<
@@ -30048,7 +31587,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
  *             return <double>bam_aux2d(v)
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_1 = PyFloat_FromDouble(((float)bam_aux2f(__pyx_v_v))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2975; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyFloat_FromDouble(((float)bam_aux2f(__pyx_v_v))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3192; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __pyx_r = __pyx_t_1;
     __pyx_t_1 = 0;
@@ -30056,19 +31595,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
     goto __pyx_L4;
   }
 
-  /* "pysam/csamtools.pyx":2976
+  /* "pysam/csamtools.pyx":3193
  *         elif auxtype == 'f' or auxtype == 'F':
  *             return <float>bam_aux2f(v)
  *         elif auxtype == 'd' or auxtype == 'D':             # <<<<<<<<<<<<<<
  *             return <double>bam_aux2d(v)
  *         elif auxtype == 'A':
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__d), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__d), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (!__pyx_t_3) {
-    __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__D), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2976; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__D), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_6 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3193; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_t_5 = __pyx_t_6;
   } else {
@@ -30076,7 +31615,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
   }
   if (__pyx_t_5) {
 
-    /* "pysam/csamtools.pyx":2977
+    /* "pysam/csamtools.pyx":3194
  *             return <float>bam_aux2f(v)
  *         elif auxtype == 'd' or auxtype == 'D':
  *             return <double>bam_aux2d(v)             # <<<<<<<<<<<<<<
@@ -30084,7 +31623,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
  *             # there might a more efficient way
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_1 = PyFloat_FromDouble(((double)bam_aux2d(__pyx_v_v))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2977; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyFloat_FromDouble(((double)bam_aux2d(__pyx_v_v))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3194; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __pyx_r = __pyx_t_1;
     __pyx_t_1 = 0;
@@ -30092,19 +31631,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
     goto __pyx_L4;
   }
 
-  /* "pysam/csamtools.pyx":2978
+  /* "pysam/csamtools.pyx":3195
  *         elif auxtype == 'd' or auxtype == 'D':
  *             return <double>bam_aux2d(v)
  *         elif auxtype == 'A':             # <<<<<<<<<<<<<<
  *             # there might a more efficient way
  *             # to convert a char into a string
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__A), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2978; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__A), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3195; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_5) {
 
-    /* "pysam/csamtools.pyx":2981
+    /* "pysam/csamtools.pyx":3198
  *             # there might a more efficient way
  *             # to convert a char into a string
  *             return '%c' % <char>bam_aux2A(v)             # <<<<<<<<<<<<<<
@@ -30112,9 +31651,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
  *             return _charptr_to_str(<char*>bam_aux2Z(v))
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_1 = PyInt_FromLong(((char)bam_aux2A(__pyx_v_v))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyInt_FromLong(((char)bam_aux2A(__pyx_v_v))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_141), __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2981; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_149), __pyx_t_1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_r = ((PyObject *)__pyx_t_4);
@@ -30123,19 +31662,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
     goto __pyx_L4;
   }
 
-  /* "pysam/csamtools.pyx":2982
+  /* "pysam/csamtools.pyx":3199
  *             # to convert a char into a string
  *             return '%c' % <char>bam_aux2A(v)
  *         elif auxtype == 'Z':             # <<<<<<<<<<<<<<
  *             return _charptr_to_str(<char*>bam_aux2Z(v))
  *         elif auxtype == 'B':
  */
-  __pyx_t_4 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__Z), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__Z), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (__pyx_t_5) {
 
-    /* "pysam/csamtools.pyx":2983
+    /* "pysam/csamtools.pyx":3200
  *             return '%c' % <char>bam_aux2A(v)
  *         elif auxtype == 'Z':
  *             return _charptr_to_str(<char*>bam_aux2Z(v))             # <<<<<<<<<<<<<<
@@ -30143,7 +31682,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
  *             bytesize, nvalues, values = convertBinaryTagToList( v + 1 )
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_4 = __pyx_f_5pysam_9csamtools__charptr_to_str(((char *)bam_aux2Z(__pyx_v_v))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2983; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __pyx_f_5pysam_9csamtools__charptr_to_str(((char *)bam_aux2Z(__pyx_v_v))); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __pyx_r = __pyx_t_4;
     __pyx_t_4 = 0;
@@ -30151,26 +31690,26 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
     goto __pyx_L4;
   }
 
-  /* "pysam/csamtools.pyx":2984
+  /* "pysam/csamtools.pyx":3201
  *         elif auxtype == 'Z':
  *             return _charptr_to_str(<char*>bam_aux2Z(v))
  *         elif auxtype == 'B':             # <<<<<<<<<<<<<<
  *             bytesize, nvalues, values = convertBinaryTagToList( v + 1 )
  *             return values
  */
-  __pyx_t_4 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__B), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2984; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(__pyx_v_auxtype, ((PyObject *)__pyx_n_s__B), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3201; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (__pyx_t_5) {
 
-    /* "pysam/csamtools.pyx":2985
+    /* "pysam/csamtools.pyx":3202
  *             return _charptr_to_str(<char*>bam_aux2Z(v))
  *         elif auxtype == 'B':
  *             bytesize, nvalues, values = convertBinaryTagToList( v + 1 )             # <<<<<<<<<<<<<<
  *             return values
  *         else:
  */
-    __pyx_t_4 = __pyx_f_5pysam_9csamtools_convertBinaryTagToList((__pyx_v_v + 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __pyx_f_5pysam_9csamtools_convertBinaryTagToList((__pyx_v_v + 1)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
       PyObject* sequence = __pyx_t_4;
@@ -30182,7 +31721,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
       if (unlikely(size != 3)) {
         if (size > 3) __Pyx_RaiseTooManyValuesError(3);
         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #if CYTHON_COMPILING_IN_CPYTHON
       if (likely(PyTuple_CheckExact(sequence))) {
@@ -30198,18 +31737,18 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
       __Pyx_INCREF(__pyx_t_9);
       __Pyx_INCREF(__pyx_t_10);
       #else
-      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_9 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_9);
-      __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_10);
       #endif
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     } else
     {
       Py_ssize_t index = -1;
-      __pyx_t_11 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_11 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_11);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
       __pyx_t_12 = Py_TYPE(__pyx_t_11)->tp_iternext;
@@ -30219,7 +31758,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
       __Pyx_GOTREF(__pyx_t_9);
       index = 2; __pyx_t_10 = __pyx_t_12(__pyx_t_11); if (unlikely(!__pyx_t_10)) goto __pyx_L5_unpacking_failed;
       __Pyx_GOTREF(__pyx_t_10);
-      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__Pyx_IternextUnpackEndCheck(__pyx_t_12(__pyx_t_11), 3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_t_12 = NULL;
       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
       goto __pyx_L6_unpacking_done;
@@ -30227,10 +31766,10 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
       __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
       __pyx_t_12 = NULL;
       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_L6_unpacking_done:;
     }
-    __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_t_9); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2985; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_13 = __Pyx_PyInt_AsInt(__pyx_t_9); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3202; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
     __pyx_v_bytesize = __pyx_t_1;
     __pyx_t_1 = 0;
@@ -30238,7 +31777,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
     __pyx_v_values = __pyx_t_10;
     __pyx_t_10 = 0;
 
-    /* "pysam/csamtools.pyx":2986
+    /* "pysam/csamtools.pyx":3203
  *         elif auxtype == 'B':
  *             bytesize, nvalues, values = convertBinaryTagToList( v + 1 )
  *             return values             # <<<<<<<<<<<<<<
@@ -30253,26 +31792,26 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_12opt(struct __pyx_obj
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":2988
+    /* "pysam/csamtools.pyx":3205
  *             return values
  *         else:
  *             raise ValueError("unknown auxilliary type '%s'" % auxtype)             # <<<<<<<<<<<<<<
  * 
  * 
  */
-    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_153), __pyx_v_auxtype); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_161), __pyx_v_auxtype); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = PyTuple_New(1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_10);
     PyTuple_SET_ITEM(__pyx_t_10, 0, ((PyObject *)__pyx_t_4));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
     __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_t_10), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(((PyObject *)__pyx_t_10)); __pyx_t_10 = 0;
     __Pyx_Raise(__pyx_t_4, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2988; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L4:;
 
@@ -30309,7 +31848,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11AlignedRead_15fancy_str(PyObject *
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":2991
+/* "pysam/csamtools.pyx":3208
  * 
  * 
  *     def fancy_str (self):             # <<<<<<<<<<<<<<
@@ -30340,58 +31879,58 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_14fancy_str(struct __p
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("fancy_str", 0);
-  __Pyx_TraceCall("fancy_str", __pyx_f[0], 2991);
+  __Pyx_TraceCall("fancy_str", __pyx_f[0], 3208);
 
-  /* "pysam/csamtools.pyx":2994
+  /* "pysam/csamtools.pyx":3211
  *         """returns list of fieldnames/values in pretty format for debugging
  *         """
  *         ret_string = []             # <<<<<<<<<<<<<<
  *         field_names = {
  *            "tid":           "Contig index",
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2994; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3211; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_v_ret_string = ((PyObject*)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":2995
+  /* "pysam/csamtools.pyx":3212
  *         """
  *         ret_string = []
  *         field_names = {             # <<<<<<<<<<<<<<
  *            "tid":           "Contig index",
  *            "pos":           "Mapped position on contig",
  */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__tid), ((PyObject *)__pyx_kp_s_154)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__pos), ((PyObject *)__pyx_kp_s_155)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mtid), ((PyObject *)__pyx_kp_s_156)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mpos), ((PyObject *)__pyx_kp_s_157)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__isize), ((PyObject *)__pyx_kp_s_158)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__flag), ((PyObject *)__pyx_kp_s_159)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__n_cigar), ((PyObject *)__pyx_kp_s_160)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__cigar), ((PyObject *)__pyx_kp_s_161)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qual), ((PyObject *)__pyx_kp_s_162)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bin), ((PyObject *)__pyx_kp_s_163)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_qname), ((PyObject *)__pyx_kp_s_164)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qname), ((PyObject *)__pyx_kp_s_165)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_qseq), ((PyObject *)__pyx_kp_s_166)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qseq), ((PyObject *)__pyx_kp_s_167)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bqual), ((PyObject *)__pyx_kp_s_168)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_aux), ((PyObject *)__pyx_kp_s_169)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__m_data), ((PyObject *)__pyx_kp_s_170)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__data_len), ((PyObject *)__pyx_kp_s_171)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__tid), ((PyObject *)__pyx_kp_s_162)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__pos), ((PyObject *)__pyx_kp_s_163)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mtid), ((PyObject *)__pyx_kp_s_164)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__mpos), ((PyObject *)__pyx_kp_s_165)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__isize), ((PyObject *)__pyx_kp_s_166)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__flag), ((PyObject *)__pyx_kp_s_167)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__n_cigar), ((PyObject *)__pyx_kp_s_168)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__cigar), ((PyObject *)__pyx_kp_s_169)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qual), ((PyObject *)__pyx_kp_s_170)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bin), ((PyObject *)__pyx_kp_s_171)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_qname), ((PyObject *)__pyx_kp_s_172)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qname), ((PyObject *)__pyx_kp_s_173)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_qseq), ((PyObject *)__pyx_kp_s_174)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__qseq), ((PyObject *)__pyx_kp_s_175)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__bqual), ((PyObject *)__pyx_kp_s_176)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__l_aux), ((PyObject *)__pyx_kp_s_177)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__m_data), ((PyObject *)__pyx_kp_s_178)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__data_len), ((PyObject *)__pyx_kp_s_179)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3212; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_field_names = ((PyObject*)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3015
+  /* "pysam/csamtools.pyx":3232
  *            "data_len":      "Current data length",
  *            }
  *         fields_names_in_order = ["tid", "pos", "mtid", "mpos", "isize", "flag",             # <<<<<<<<<<<<<<
  *                                  "n_cigar", "cigar", "qual", "bin", "l_qname", "qname",
  *                                  "l_qseq", "qseq", "bqual", "l_aux", "m_data", "data_len"]
  */
-  __pyx_t_1 = PyList_New(18); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(18); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(((PyObject *)__pyx_n_s__tid));
   PyList_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_n_s__tid));
@@ -30450,7 +31989,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_14fancy_str(struct __p
   __pyx_v_fields_names_in_order = ((PyObject*)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3019
+  /* "pysam/csamtools.pyx":3236
  *                                  "l_qseq", "qseq", "bqual", "l_aux", "m_data", "data_len"]
  * 
  *         for f in fields_names_in_order:             # <<<<<<<<<<<<<<
@@ -30461,29 +32000,29 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_14fancy_str(struct __p
   for (;;) {
     if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_1)) break;
     #if CYTHON_COMPILING_IN_CPYTHON
-    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_2); __Pyx_INCREF(__pyx_t_3); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     #else
-    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3019; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PySequence_ITEM(__pyx_t_1, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3236; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     #endif
     __Pyx_XDECREF(__pyx_v_f);
     __pyx_v_f = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "pysam/csamtools.pyx":3020
+    /* "pysam/csamtools.pyx":3237
  * 
  *         for f in fields_names_in_order:
  *             if not f in self.__dict__:             # <<<<<<<<<<<<<<
  *                 continue
  *             ret_string.append("%-30s %-10s= %s" % (field_names[f], "(" + f + ")", self.__getattribute__(f)))
  */
-    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____dict__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____dict__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = (__Pyx_PySequence_Contains(__pyx_v_f, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3020; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = (__Pyx_PySequence_Contains(__pyx_v_f, __pyx_t_3, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_5 = (!__pyx_t_4);
     if (__pyx_t_5) {
 
-      /* "pysam/csamtools.pyx":3021
+      /* "pysam/csamtools.pyx":3238
  *         for f in fields_names_in_order:
  *             if not f in self.__dict__:
  *                 continue             # <<<<<<<<<<<<<<
@@ -30495,32 +32034,32 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_14fancy_str(struct __p
     }
     __pyx_L5:;
 
-    /* "pysam/csamtools.pyx":3022
+    /* "pysam/csamtools.pyx":3239
  *             if not f in self.__dict__:
  *                 continue
  *             ret_string.append("%-30s %-10s= %s" % (field_names[f], "(" + f + ")", self.__getattribute__(f)))             # <<<<<<<<<<<<<<
  * 
  *         for f in self.__dict__:
  */
-    __pyx_t_3 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_field_names), __pyx_v_f); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_PyDict_GetItem(((PyObject *)__pyx_v_field_names), __pyx_v_f); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_6 = PyNumber_Add(((PyObject *)__pyx_kp_s_173), __pyx_v_f); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyNumber_Add(((PyObject *)__pyx_kp_s_181), __pyx_v_f); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_7 = PyNumber_Add(__pyx_t_6, ((PyObject *)__pyx_kp_s_174)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_7 = PyNumber_Add(__pyx_t_6, ((PyObject *)__pyx_kp_s_182)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_7);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
-    __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____getattribute__); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____getattribute__); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
-    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     __Pyx_INCREF(__pyx_v_f);
     PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_f);
     __Pyx_GIVEREF(__pyx_v_f);
-    __pyx_t_9 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_8);
     PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_3);
     __Pyx_GIVEREF(__pyx_t_3);
@@ -30531,29 +32070,29 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_14fancy_str(struct __p
     __pyx_t_3 = 0;
     __pyx_t_7 = 0;
     __pyx_t_9 = 0;
-    __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_172), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_9 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_180), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_9));
     __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-    __pyx_t_10 = PyList_Append(__pyx_v_ret_string, ((PyObject *)__pyx_t_9)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = PyList_Append(__pyx_v_ret_string, ((PyObject *)__pyx_t_9)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
     __pyx_L3_continue:;
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3024
+  /* "pysam/csamtools.pyx":3241
  *             ret_string.append("%-30s %-10s= %s" % (field_names[f], "(" + f + ")", self.__getattribute__(f)))
  * 
  *         for f in self.__dict__:             # <<<<<<<<<<<<<<
  *             if not f in field_names:
  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____dict__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____dict__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   if (PyList_CheckExact(__pyx_t_1) || PyTuple_CheckExact(__pyx_t_1)) {
     __pyx_t_9 = __pyx_t_1; __Pyx_INCREF(__pyx_t_9); __pyx_t_2 = 0;
     __pyx_t_11 = NULL;
   } else {
-    __pyx_t_2 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = -1; __pyx_t_9 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_9);
     __pyx_t_11 = Py_TYPE(__pyx_t_9)->tp_iternext;
   }
@@ -30562,23 +32101,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_14fancy_str(struct __p
     if (!__pyx_t_11 && PyList_CheckExact(__pyx_t_9)) {
       if (__pyx_t_2 >= PyList_GET_SIZE(__pyx_t_9)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyList_GET_ITEM(__pyx_t_9, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_1 = PySequence_ITEM(__pyx_t_9, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PySequence_ITEM(__pyx_t_9, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else if (!__pyx_t_11 && PyTuple_CheckExact(__pyx_t_9)) {
       if (__pyx_t_2 >= PyTuple_GET_SIZE(__pyx_t_9)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_9, __pyx_t_2); __Pyx_INCREF(__pyx_t_1); __pyx_t_2++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_1 = PySequence_ITEM(__pyx_t_9, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PySequence_ITEM(__pyx_t_9, __pyx_t_2); __pyx_t_2++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else {
       __pyx_t_1 = __pyx_t_11(__pyx_t_9);
       if (unlikely(!__pyx_t_1)) {
         if (PyErr_Occurred()) {
           if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3024; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3241; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         break;
       }
@@ -30588,36 +32127,36 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_14fancy_str(struct __p
     __pyx_v_f = __pyx_t_1;
     __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":3025
+    /* "pysam/csamtools.pyx":3242
  * 
  *         for f in self.__dict__:
  *             if not f in field_names:             # <<<<<<<<<<<<<<
  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))
  *         return ret_string
  */
-    __pyx_t_5 = (__Pyx_PyDict_Contains(__pyx_v_f, ((PyObject *)__pyx_v_field_names), Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3025; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = (__Pyx_PyDict_Contains(__pyx_v_f, ((PyObject *)__pyx_v_field_names), Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3242; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_4 = (!__pyx_t_5);
     if (__pyx_t_4) {
 
-      /* "pysam/csamtools.pyx":3026
+      /* "pysam/csamtools.pyx":3243
  *         for f in self.__dict__:
  *             if not f in field_names:
  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))             # <<<<<<<<<<<<<<
  *         return ret_string
  * 
  */
-      __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____getattribute__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s____getattribute__); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       __Pyx_INCREF(__pyx_v_f);
       PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_f);
       __Pyx_GIVEREF(__pyx_v_f);
-      __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_7);
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
       __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-      __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = PyTuple_New(3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_8);
       __Pyx_INCREF(__pyx_v_f);
       PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_v_f);
@@ -30628,10 +32167,10 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_14fancy_str(struct __p
       PyTuple_SET_ITEM(__pyx_t_8, 2, __pyx_t_7);
       __Pyx_GIVEREF(__pyx_t_7);
       __pyx_t_7 = 0;
-      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_172), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_7 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_180), ((PyObject *)__pyx_t_8)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_7));
       __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-      __pyx_t_10 = PyList_Append(__pyx_v_ret_string, ((PyObject *)__pyx_t_7)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3026; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_10 = PyList_Append(__pyx_v_ret_string, ((PyObject *)__pyx_t_7)); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3243; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_DECREF(((PyObject *)__pyx_t_7)); __pyx_t_7 = 0;
       goto __pyx_L8;
     }
@@ -30639,7 +32178,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11AlignedRead_14fancy_str(struct __p
   }
   __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
 
-  /* "pysam/csamtools.pyx":3027
+  /* "pysam/csamtools.pyx":3244
  *             if not f in field_names:
  *                 ret_string.append("%-30s %-10s= %s" % (f, "", self.__getattribute__(f)))
  *         return ret_string             # <<<<<<<<<<<<<<
@@ -30687,7 +32226,7 @@ static int __pyx_pw_5pysam_9csamtools_11PileupProxy_1__init__(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3046
+/* "pysam/csamtools.pyx":3263
  *     will change.
  *     '''
  *     def __init__(self):             # <<<<<<<<<<<<<<
@@ -30704,20 +32243,20 @@ static int __pyx_pf_5pysam_9csamtools_11PileupProxy___init__(CYTHON_UNUSED struc
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__", 0);
-  __Pyx_TraceCall("__init__", __pyx_f[0], 3046);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 3263);
 
-  /* "pysam/csamtools.pyx":3047
+  /* "pysam/csamtools.pyx":3264
  *     '''
  *     def __init__(self):
  *         raise TypeError("This class cannot be instantiated from Python")             # <<<<<<<<<<<<<<
  * 
  *     def __str__(self):
  */
-  __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_176), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_184), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
   __pyx_r = 0;
   goto __pyx_L0;
@@ -30742,7 +32281,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11PileupProxy_3__str__(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3049
+/* "pysam/csamtools.pyx":3266
  *         raise TypeError("This class cannot be instantiated from Python")
  * 
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -30763,9 +32302,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11PileupProxy_2__str__(struct __pyx_
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__", 0);
-  __Pyx_TraceCall("__str__", __pyx_f[0], 3049);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 3266);
 
-  /* "pysam/csamtools.pyx":3050
+  /* "pysam/csamtools.pyx":3267
  * 
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
@@ -30774,30 +32313,30 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11PileupProxy_2__str__(struct __pyx_
  */
   __Pyx_XDECREF(__pyx_r);
 
-  /* "pysam/csamtools.pyx":3051
+  /* "pysam/csamtools.pyx":3268
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
  *             "\n" +\             # <<<<<<<<<<<<<<
  *             "\n".join( map(str, self.pileups) )
  * 
  */
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
 
-  /* "pysam/csamtools.pyx":3050
+  /* "pysam/csamtools.pyx":3267
  * 
  *     def __str__(self):
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\             # <<<<<<<<<<<<<<
  *             "\n" +\
  *             "\n".join( map(str, self.pileups) )
  */
-  __pyx_t_2 = PyInt_FromLong(__pyx_v_self->tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyInt_FromLong(__pyx_v_self->tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_self->pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__n); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
@@ -30808,7 +32347,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11PileupProxy_2__str__(struct __pyx_
   __pyx_t_2 = 0;
   __pyx_t_3 = 0;
   __pyx_t_4 = 0;
-  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
   PyTuple_SET_ITEM(__pyx_t_4, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
@@ -30816,34 +32355,34 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11PileupProxy_2__str__(struct __pyx_
   PyTuple_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_t_5));
   __Pyx_GIVEREF(((PyObject *)__pyx_t_5));
   __pyx_t_5 = 0;
-  __pyx_t_5 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5);
   __Pyx_GIVEREF(__pyx_t_5);
   __pyx_t_5 = 0;
-  __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-  __pyx_t_4 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_6)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3050; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyNumber_Add(__pyx_t_5, ((PyObject *)__pyx_kp_s_6)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
 
-  /* "pysam/csamtools.pyx":3052
+  /* "pysam/csamtools.pyx":3269
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
  *             "\n" +\
  *             "\n".join( map(str, self.pileups) )             # <<<<<<<<<<<<<<
  * 
  *     property tid:
  */
-  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_6), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_6), __pyx_n_s__join); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__pileups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__pileups); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
   PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
@@ -30851,19 +32390,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11PileupProxy_2__str__(struct __pyx_
   PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-  __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3051; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_t_1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -30899,7 +32438,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11PileupProxy_3tid_1__get__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3056
+/* "pysam/csamtools.pyx":3273
  *     property tid:
  *         '''the chromosome ID as is defined in the header'''
  *         def __get__(self): return self.tid             # <<<<<<<<<<<<<<
@@ -30916,9 +32455,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11PileupProxy_3tid___get__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3056);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3273);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3056; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -30948,7 +32487,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11PileupProxy_1n_1__get__(PyObject *
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3060
+/* "pysam/csamtools.pyx":3277
  *     property n:
  *         '''number of reads mapping to this column.'''
  *         def __get__(self): return self.n_pu             # <<<<<<<<<<<<<<
@@ -30965,9 +32504,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11PileupProxy_1n___get__(struct __py
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3060);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3277);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->n_pu); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3060; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->n_pu); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3277; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -30997,7 +32536,7 @@ static int __pyx_pw_5pysam_9csamtools_11PileupProxy_1n_3__set__(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3061
+/* "pysam/csamtools.pyx":3278
  *         '''number of reads mapping to this column.'''
  *         def __get__(self): return self.n_pu
  *         def __set__(self, n): self.n_pu = n             # <<<<<<<<<<<<<<
@@ -31014,8 +32553,8 @@ static int __pyx_pf_5pysam_9csamtools_11PileupProxy_1n_2__set__(struct __pyx_obj
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__set__", 0);
-  __Pyx_TraceCall("__set__", __pyx_f[0], 3061);
-  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_n); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_TraceCall("__set__", __pyx_f[0], 3278);
+  __pyx_t_1 = __Pyx_PyInt_AsInt(__pyx_v_n); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3278; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_self->n_pu = __pyx_t_1;
 
   __pyx_r = 0;
@@ -31040,7 +32579,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11PileupProxy_3pos_1__get__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3064
+/* "pysam/csamtools.pyx":3281
  * 
  *     property pos:
  *         def __get__(self): return self.pos             # <<<<<<<<<<<<<<
@@ -31057,9 +32596,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11PileupProxy_3pos___get__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3064);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3281);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3281; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -31089,7 +32628,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_11PileupProxy_7pileups_1__get__(PyOb
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3068
+/* "pysam/csamtools.pyx":3285
  *     property pileups:
  *         '''list of reads (:class:`pysam.PileupRead`) aligned to this column'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -31106,75 +32645,83 @@ static PyObject *__pyx_pf_5pysam_9csamtools_11PileupProxy_7pileups___get__(struc
   int __pyx_t_2;
   int __pyx_t_3;
   int __pyx_t_4;
+  int __pyx_t_5;
+  int __pyx_t_6;
   int __pyx_lineno = 0;
   const char *__pyx_filename = NULL;
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3068);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3285);
 
-  /* "pysam/csamtools.pyx":3070
+  /* "pysam/csamtools.pyx":3287
  *         def __get__(self):
  *             cdef int x
  *             pileups = []             # <<<<<<<<<<<<<<
  * 
- *             if self.plp[0] == NULL:
+ *             if self.plp == NULL or self.plp[0] == NULL:
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3070; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3287; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_v_pileups = ((PyObject*)__pyx_t_1);
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3072
+  /* "pysam/csamtools.pyx":3289
  *             pileups = []
  * 
- *             if self.plp[0] == NULL:             # <<<<<<<<<<<<<<
+ *             if self.plp == NULL or self.plp[0] == NULL:             # <<<<<<<<<<<<<<
  *                 raise ValueError("PileupProxy accessed after iterator finished")
  * 
  */
-  __pyx_t_2 = ((__pyx_v_self->plp[0]) == NULL);
-  if (__pyx_t_2) {
+  __pyx_t_2 = (__pyx_v_self->plp == NULL);
+  if (!__pyx_t_2) {
+    __pyx_t_3 = ((__pyx_v_self->plp[0]) == NULL);
+    __pyx_t_4 = __pyx_t_3;
+  } else {
+    __pyx_t_4 = __pyx_t_2;
+  }
+  if (__pyx_t_4) {
 
-    /* "pysam/csamtools.pyx":3073
+    /* "pysam/csamtools.pyx":3290
  * 
- *             if self.plp[0] == NULL:
+ *             if self.plp == NULL or self.plp[0] == NULL:
  *                 raise ValueError("PileupProxy accessed after iterator finished")             # <<<<<<<<<<<<<<
  * 
  *             # warning: there could be problems if self.n and self.buf are
  */
-    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_178), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_186), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_Raise(__pyx_t_1, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     goto __pyx_L3;
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":3077
+  /* "pysam/csamtools.pyx":3294
  *             # warning: there could be problems if self.n and self.buf are
  *             # out of sync.
  *             for x from 0 <= x < self.n_pu:             # <<<<<<<<<<<<<<
  *                 pileups.append( makePileupRead( &(self.plp[0][x])) )
  *             return pileups
  */
-  __pyx_t_3 = __pyx_v_self->n_pu;
-  for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_3; __pyx_v_x++) {
+  __pyx_t_5 = __pyx_v_self->n_pu;
+  for (__pyx_v_x = 0; __pyx_v_x < __pyx_t_5; __pyx_v_x++) {
 
-    /* "pysam/csamtools.pyx":3078
+    /* "pysam/csamtools.pyx":3295
  *             # out of sync.
  *             for x from 0 <= x < self.n_pu:
  *                 pileups.append( makePileupRead( &(self.plp[0][x])) )             # <<<<<<<<<<<<<<
  *             return pileups
  * 
  */
-    __pyx_t_1 = __pyx_f_5pysam_9csamtools_makePileupRead((&((__pyx_v_self->plp[0])[__pyx_v_x]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __pyx_f_5pysam_9csamtools_makePileupRead((&((__pyx_v_self->plp[0])[__pyx_v_x]))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_4 = PyList_Append(__pyx_v_pileups, __pyx_t_1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3078; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyList_Append(__pyx_v_pileups, __pyx_t_1); if (unlikely(__pyx_t_6 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3295; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   }
 
-  /* "pysam/csamtools.pyx":3079
+  /* "pysam/csamtools.pyx":3296
  *             for x from 0 <= x < self.n_pu:
  *                 pileups.append( makePileupRead( &(self.plp[0][x])) )
  *             return pileups             # <<<<<<<<<<<<<<
@@ -31214,7 +32761,7 @@ static int __pyx_pw_5pysam_9csamtools_10PileupRead_1__init__(PyObject *__pyx_v_s
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3085
+/* "pysam/csamtools.pyx":3302
  *     '''
  * 
  *     def __init__(self):             # <<<<<<<<<<<<<<
@@ -31231,20 +32778,20 @@ static int __pyx_pf_5pysam_9csamtools_10PileupRead___init__(CYTHON_UNUSED struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__", 0);
-  __Pyx_TraceCall("__init__", __pyx_f[0], 3085);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 3302);
 
-  /* "pysam/csamtools.pyx":3086
+  /* "pysam/csamtools.pyx":3303
  * 
  *     def __init__(self):
  *         raise TypeError("This class cannot be instantiated from Python")             # <<<<<<<<<<<<<<
  * 
  *     def __str__(self):
  */
-  __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_179), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_builtin_TypeError, ((PyObject *)__pyx_k_tuple_187), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_Raise(__pyx_t_1, 0, 0, 0);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
   __pyx_r = 0;
   goto __pyx_L0;
@@ -31269,7 +32816,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_10PileupRead_3__str__(PyObject *__py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3088
+/* "pysam/csamtools.pyx":3305
  *         raise TypeError("This class cannot be instantiated from Python")
  * 
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -31294,9 +32841,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_2__str__(struct __pyx_o
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__", 0);
-  __Pyx_TraceCall("__str__", __pyx_f[0], 3088);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 3305);
 
-  /* "pysam/csamtools.pyx":3089
+  /* "pysam/csamtools.pyx":3306
  * 
  *     def __str__(self):
  *         return "\t".join( map(str, (self.alignment, self.qpos, self.indel, self.level, self.is_del, self.is_head, self.is_tail ) ) )             # <<<<<<<<<<<<<<
@@ -31304,23 +32851,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_2__str__(struct __pyx_o
  *     property alignment:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__alignment); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__alignment); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__qpos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__qpos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__indel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__indel); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__level); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__level); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
-  __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__is_del); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__is_del); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
-  __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__is_head); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__is_head); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
-  __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__is_tail); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__is_tail); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
-  __pyx_t_9 = PyTuple_New(7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyTuple_New(7); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
   PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
@@ -31343,7 +32890,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_2__str__(struct __pyx_o
   __pyx_t_6 = 0;
   __pyx_t_7 = 0;
   __pyx_t_8 = 0;
-  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
   __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
   PyTuple_SET_ITEM(__pyx_t_8, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
@@ -31351,15 +32898,15 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_2__str__(struct __pyx_o
   PyTuple_SET_ITEM(__pyx_t_8, 1, ((PyObject *)__pyx_t_9));
   __Pyx_GIVEREF(((PyObject *)__pyx_t_9));
   __pyx_t_9 = 0;
-  __pyx_t_9 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
   __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
-  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyTuple_New(1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
   PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9);
   __Pyx_GIVEREF(__pyx_t_9);
   __pyx_t_9 = 0;
-  __pyx_t_9 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3089; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_8), NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_8)); __pyx_t_8 = 0;
@@ -31399,7 +32946,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_10PileupRead_9alignment_1__get__(PyO
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3093
+/* "pysam/csamtools.pyx":3310
  *     property alignment:
  *         """a :class:`pysam.AlignedRead` object of the aligned read"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -31412,9 +32959,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_9alignment___get__(stru
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3093);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3310);
 
-  /* "pysam/csamtools.pyx":3094
+  /* "pysam/csamtools.pyx":3311
  *         """a :class:`pysam.AlignedRead` object of the aligned read"""
  *         def __get__(self):
  *             return self._alignment             # <<<<<<<<<<<<<<
@@ -31445,7 +32992,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_10PileupRead_4qpos_1__get__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3097
+/* "pysam/csamtools.pyx":3314
  *     property qpos:
  *         """position of the read base at the pileup site, 0-based"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -31462,9 +33009,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_4qpos___get__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3097);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3314);
 
-  /* "pysam/csamtools.pyx":3098
+  /* "pysam/csamtools.pyx":3315
  *         """position of the read base at the pileup site, 0-based"""
  *         def __get__(self):
  *             return self._qpos             # <<<<<<<<<<<<<<
@@ -31472,7 +33019,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_4qpos___get__(struct __
  *         """indel length; 0 for no indel, positive for ins and negative for del"""
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_qpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3098; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_int32_t(__pyx_v_self->_qpos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -31502,7 +33049,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_10PileupRead_5indel_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3101
+/* "pysam/csamtools.pyx":3318
  *     property indel:
  *         """indel length; 0 for no indel, positive for ins and negative for del"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -31519,9 +33066,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_5indel___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3101);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3318);
 
-  /* "pysam/csamtools.pyx":3102
+  /* "pysam/csamtools.pyx":3319
  *         """indel length; 0 for no indel, positive for ins and negative for del"""
  *         def __get__(self):
  *             return self._indel             # <<<<<<<<<<<<<<
@@ -31529,7 +33076,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_5indel___get__(struct _
  *         """1 iff the base on the padded read is a deletion"""
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_indel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_indel); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3319; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -31559,7 +33106,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_10PileupRead_6is_del_1__get__(PyObje
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3105
+/* "pysam/csamtools.pyx":3322
  *     property is_del:
  *         """1 iff the base on the padded read is a deletion"""
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -31576,9 +33123,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_6is_del___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3105);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3322);
 
-  /* "pysam/csamtools.pyx":3106
+  /* "pysam/csamtools.pyx":3323
  *         """1 iff the base on the padded read is a deletion"""
  *         def __get__(self):
  *             return self._is_del             # <<<<<<<<<<<<<<
@@ -31586,7 +33133,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_6is_del___get__(struct
  *         def __get__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->_is_del); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->_is_del); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -31616,7 +33163,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_10PileupRead_7is_head_1__get__(PyObj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3108
+/* "pysam/csamtools.pyx":3325
  *             return self._is_del
  *     property is_head:
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -31633,9 +33180,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_7is_head___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3108);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3325);
 
-  /* "pysam/csamtools.pyx":3109
+  /* "pysam/csamtools.pyx":3326
  *     property is_head:
  *         def __get__(self):
  *             return self._is_head             # <<<<<<<<<<<<<<
@@ -31643,7 +33190,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_7is_head___get__(struct
  *         def __get__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->_is_head); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3109; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->_is_head); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -31673,7 +33220,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_10PileupRead_7is_tail_1__get__(PyObj
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3111
+/* "pysam/csamtools.pyx":3328
  *             return self._is_head
  *     property is_tail:
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -31690,9 +33237,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_7is_tail___get__(struct
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3111);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3328);
 
-  /* "pysam/csamtools.pyx":3112
+  /* "pysam/csamtools.pyx":3329
  *     property is_tail:
  *         def __get__(self):
  *             return self._is_tail             # <<<<<<<<<<<<<<
@@ -31700,7 +33247,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_7is_tail___get__(struct
  *         def __get__(self):
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->_is_tail); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_PyInt_to_py_uint32_t(__pyx_v_self->_is_tail); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -31730,7 +33277,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_10PileupRead_5level_1__get__(PyObjec
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3114
+/* "pysam/csamtools.pyx":3331
  *             return self._is_tail
  *     property level:
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -31747,9 +33294,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_5level___get__(struct _
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3114);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3331);
 
-  /* "pysam/csamtools.pyx":3115
+  /* "pysam/csamtools.pyx":3332
  *     property level:
  *         def __get__(self):
  *             return self._level             # <<<<<<<<<<<<<<
@@ -31757,7 +33304,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_10PileupRead_5level___get__(struct _
  * class Outs:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_level); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_level); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -31811,7 +33358,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_1__init__(PyObject *__pyx_self
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3336; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -31826,7 +33373,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_1__init__(PyObject *__pyx_self
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3336; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.Outs.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -31837,7 +33384,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_1__init__(PyObject *__pyx_self
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3119
+/* "pysam/csamtools.pyx":3336
  * class Outs:
  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
  *     def __init__(self, id = 1):             # <<<<<<<<<<<<<<
@@ -31854,28 +33401,28 @@ static PyObject *__pyx_pf_5pysam_9csamtools_4Outs___init__(CYTHON_UNUSED PyObjec
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__", 0);
-  __Pyx_TraceCall("__init__", __pyx_f[0], 3119);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 3336);
 
-  /* "pysam/csamtools.pyx":3120
+  /* "pysam/csamtools.pyx":3337
  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
  *     def __init__(self, id = 1):
  *         self.streams = []             # <<<<<<<<<<<<<<
  *         self.id = id
  * 
  */
-  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__streams, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__streams, ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3337; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3121
+  /* "pysam/csamtools.pyx":3338
  *     def __init__(self, id = 1):
  *         self.streams = []
  *         self.id = id             # <<<<<<<<<<<<<<
  * 
  *     def setdevice(self, filename):
  */
-  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__id, __pyx_v_id) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3121; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_v_self, __pyx_n_s__id, __pyx_v_id) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
   __pyx_r = Py_None; __Pyx_INCREF(Py_None);
   goto __pyx_L0;
@@ -31920,11 +33467,11 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_3setdevice(PyObject *__pyx_sel
         case  1:
         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename)) != 0)) kw_args--;
         else {
-          __Pyx_RaiseArgtupleInvalid("setdevice", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+          __Pyx_RaiseArgtupleInvalid("setdevice", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setdevice") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setdevice") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
       goto __pyx_L5_argtuple_error;
@@ -31937,7 +33484,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_3setdevice(PyObject *__pyx_sel
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("setdevice", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3123; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("setdevice", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3340; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.Outs.setdevice", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -31948,7 +33495,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_3setdevice(PyObject *__pyx_sel
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3123
+/* "pysam/csamtools.pyx":3340
  *         self.id = id
  * 
  *     def setdevice(self, filename):             # <<<<<<<<<<<<<<
@@ -31968,26 +33515,26 @@ static PyObject *__pyx_pf_5pysam_9csamtools_4Outs_2setdevice(CYTHON_UNUSED PyObj
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setdevice", 0);
-  __Pyx_TraceCall("setdevice", __pyx_f[0], 3123);
+  __Pyx_TraceCall("setdevice", __pyx_f[0], 3340);
 
-  /* "pysam/csamtools.pyx":3125
+  /* "pysam/csamtools.pyx":3342
  *     def setdevice(self, filename):
  *         '''open an existing file, like "/dev/null"'''
  *         fd = os.open(filename, os.O_WRONLY)             # <<<<<<<<<<<<<<
  *         self.setfd(fd)
  * 
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__O_WRONLY); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__O_WRONLY); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(__pyx_v_filename);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_filename);
@@ -31995,28 +33542,28 @@ static PyObject *__pyx_pf_5pysam_9csamtools_4Outs_2setdevice(CYTHON_UNUSED PyObj
   PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_3);
   __Pyx_GIVEREF(__pyx_t_3);
   __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3125; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
   __pyx_v_fd = __pyx_t_3;
   __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":3126
+  /* "pysam/csamtools.pyx":3343
  *         '''open an existing file, like "/dev/null"'''
  *         fd = os.open(filename, os.O_WRONLY)
  *         self.setfd(fd)             # <<<<<<<<<<<<<<
  * 
  *     def setfile(self, filename):
  */
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__setfd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__setfd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(__pyx_v_fd);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_fd);
   __Pyx_GIVEREF(__pyx_v_fd);
-  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
@@ -32068,11 +33615,11 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_5setfile(PyObject *__pyx_self,
         case  1:
         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__filename)) != 0)) kw_args--;
         else {
-          __Pyx_RaiseArgtupleInvalid("setfile", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+          __Pyx_RaiseArgtupleInvalid("setfile", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setfile") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setfile") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
       goto __pyx_L5_argtuple_error;
@@ -32085,7 +33632,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_5setfile(PyObject *__pyx_self,
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("setfile", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3128; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("setfile", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3345; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.Outs.setfile", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -32096,7 +33643,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_5setfile(PyObject *__pyx_self,
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3128
+/* "pysam/csamtools.pyx":3345
  *         self.setfd(fd)
  * 
  *     def setfile(self, filename):             # <<<<<<<<<<<<<<
@@ -32117,35 +33664,35 @@ static PyObject *__pyx_pf_5pysam_9csamtools_4Outs_4setfile(CYTHON_UNUSED PyObjec
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setfile", 0);
-  __Pyx_TraceCall("setfile", __pyx_f[0], 3128);
+  __Pyx_TraceCall("setfile", __pyx_f[0], 3345);
 
-  /* "pysam/csamtools.pyx":3130
+  /* "pysam/csamtools.pyx":3347
  *     def setfile(self, filename):
  *         '''open a new file.'''
  *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);             # <<<<<<<<<<<<<<
  *         self.setfd(fd)
  * 
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__open); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__O_WRONLY); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__O_WRONLY); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__O_CREAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__O_CREAT); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyNumber_Or(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyNumber_Or(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyTuple_New(3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_INCREF(__pyx_v_filename);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_filename);
@@ -32156,28 +33703,28 @@ static PyObject *__pyx_pf_5pysam_9csamtools_4Outs_4setfile(CYTHON_UNUSED PyObjec
   PyTuple_SET_ITEM(__pyx_t_4, 2, __pyx_int_0660);
   __Pyx_GIVEREF(__pyx_int_0660);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
   __pyx_v_fd = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3131
+  /* "pysam/csamtools.pyx":3348
  *         '''open a new file.'''
  *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);
  *         self.setfd(fd)             # <<<<<<<<<<<<<<
  * 
  *     def setfd(self, fd):
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__setfd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__setfd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_INCREF(__pyx_v_fd);
   PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_fd);
   __Pyx_GIVEREF(__pyx_v_fd);
-  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3348; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
@@ -32230,11 +33777,11 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_7setfd(PyObject *__pyx_self, P
         case  1:
         if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s__fd)) != 0)) kw_args--;
         else {
-          __Pyx_RaiseArgtupleInvalid("setfd", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+          __Pyx_RaiseArgtupleInvalid("setfd", 1, 2, 2, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3350; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setfd") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "setfd") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3350; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
       goto __pyx_L5_argtuple_error;
@@ -32247,7 +33794,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_7setfd(PyObject *__pyx_self, P
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("setfd", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("setfd", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3350; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.Outs.setfd", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -32258,7 +33805,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_7setfd(PyObject *__pyx_self, P
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3133
+/* "pysam/csamtools.pyx":3350
  *         self.setfd(fd)
  * 
  *     def setfd(self, fd):             # <<<<<<<<<<<<<<
@@ -32278,103 +33825,103 @@ static PyObject *__pyx_pf_5pysam_9csamtools_4Outs_6setfd(CYTHON_UNUSED PyObject
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("setfd", 0);
-  __Pyx_TraceCall("setfd", __pyx_f[0], 3133);
+  __Pyx_TraceCall("setfd", __pyx_f[0], 3350);
 
-  /* "pysam/csamtools.pyx":3134
+  /* "pysam/csamtools.pyx":3351
  * 
  *     def setfd(self, fd):
  *         ofd = os.dup(self.id)      #  Save old stream on new unit.             # <<<<<<<<<<<<<<
  *         self.streams.append(ofd)
  *         sys.stdout.flush()          #  Buffered data goes to old stream.
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__dup); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__dup); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
   __Pyx_GIVEREF(__pyx_t_1);
   __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
   __pyx_v_ofd = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3135
+  /* "pysam/csamtools.pyx":3352
  *     def setfd(self, fd):
  *         ofd = os.dup(self.id)      #  Save old stream on new unit.
  *         self.streams.append(ofd)             # <<<<<<<<<<<<<<
  *         sys.stdout.flush()          #  Buffered data goes to old stream.
  *         sys.stderr.flush()          #  Buffered data goes to old stream.
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_v_ofd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_Append(__pyx_t_1, __pyx_v_ofd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3352; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":3136
+  /* "pysam/csamtools.pyx":3353
  *         ofd = os.dup(self.id)      #  Save old stream on new unit.
  *         self.streams.append(ofd)
  *         sys.stdout.flush()          #  Buffered data goes to old stream.             # <<<<<<<<<<<<<<
  *         sys.stderr.flush()          #  Buffered data goes to old stream.
  *         os.dup2(fd, self.id)        #  Open unit 1 on new stream.
  */
-  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stdout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stdout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__flush); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__flush); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3136; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3137
+  /* "pysam/csamtools.pyx":3354
  *         self.streams.append(ofd)
  *         sys.stdout.flush()          #  Buffered data goes to old stream.
  *         sys.stderr.flush()          #  Buffered data goes to old stream.             # <<<<<<<<<<<<<<
  *         os.dup2(fd, self.id)        #  Open unit 1 on new stream.
  *         os.close(fd)                #  Close other unit (look out, caller.)
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stderr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stderr); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__flush); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__flush); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":3138
+  /* "pysam/csamtools.pyx":3355
  *         sys.stdout.flush()          #  Buffered data goes to old stream.
  *         sys.stderr.flush()          #  Buffered data goes to old stream.
  *         os.dup2(fd, self.id)        #  Open unit 1 on new stream.             # <<<<<<<<<<<<<<
  *         os.close(fd)                #  Close other unit (look out, caller.)
  * 
  */
-  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__dup2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__dup2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__id); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__id); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_INCREF(__pyx_v_fd);
   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_fd);
@@ -32382,30 +33929,30 @@ static PyObject *__pyx_pf_5pysam_9csamtools_4Outs_6setfd(CYTHON_UNUSED PyObject
   PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_t_3);
   __Pyx_GIVEREF(__pyx_t_3);
   __pyx_t_3 = 0;
-  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3355; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":3139
+  /* "pysam/csamtools.pyx":3356
  *         sys.stderr.flush()          #  Buffered data goes to old stream.
  *         os.dup2(fd, self.id)        #  Open unit 1 on new stream.
  *         os.close(fd)                #  Close other unit (look out, caller.)             # <<<<<<<<<<<<<<
  * 
  *     def restore(self):
  */
-  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_INCREF(__pyx_v_fd);
   PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_fd);
   __Pyx_GIVEREF(__pyx_v_fd);
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3139; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3356; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
@@ -32440,7 +33987,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_4Outs_9restore(PyObject *__pyx_self,
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3141
+/* "pysam/csamtools.pyx":3358
  *         os.close(fd)                #  Close other unit (look out, caller.)
  * 
  *     def restore(self):             # <<<<<<<<<<<<<<
@@ -32461,81 +34008,81 @@ static PyObject *__pyx_pf_5pysam_9csamtools_4Outs_8restore(CYTHON_UNUSED PyObjec
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("restore", 0);
-  __Pyx_TraceCall("restore", __pyx_f[0], 3141);
+  __Pyx_TraceCall("restore", __pyx_f[0], 3358);
 
-  /* "pysam/csamtools.pyx":3143
+  /* "pysam/csamtools.pyx":3360
  *     def restore(self):
  *         '''restore previous output stream'''
  *         if self.streams:             # <<<<<<<<<<<<<<
  *             # the following was not sufficient, hence flush both stderr and stdout
  *             # os.fsync( self.id )
  */
-  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3360; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":3146
+    /* "pysam/csamtools.pyx":3363
  *             # the following was not sufficient, hence flush both stderr and stdout
  *             # os.fsync( self.id )
  *             sys.stdout.flush()             # <<<<<<<<<<<<<<
  *             sys.stderr.flush()
  *             os.dup2(self.streams[-1], self.id)
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stdout); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__stdout); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__flush); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__flush); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3363; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-    /* "pysam/csamtools.pyx":3147
+    /* "pysam/csamtools.pyx":3364
  *             # os.fsync( self.id )
  *             sys.stdout.flush()
  *             sys.stderr.flush()             # <<<<<<<<<<<<<<
  *             os.dup2(self.streams[-1], self.id)
  *             os.close(self.streams[-1])
  */
-    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stderr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stderr); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__flush); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__flush); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":3148
+    /* "pysam/csamtools.pyx":3365
  *             sys.stdout.flush()
  *             sys.stderr.flush()
  *             os.dup2(self.streams[-1], self.id)             # <<<<<<<<<<<<<<
  *             os.close(self.streams[-1])
  *             del self.streams[-1]
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__dup2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__dup2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_1, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__id); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4);
     __Pyx_GIVEREF(__pyx_t_4);
@@ -32543,50 +34090,50 @@ static PyObject *__pyx_pf_5pysam_9csamtools_4Outs_8restore(CYTHON_UNUSED PyObjec
     __Pyx_GIVEREF(__pyx_t_1);
     __pyx_t_4 = 0;
     __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_t_5), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_5)); __pyx_t_5 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":3149
+    /* "pysam/csamtools.pyx":3366
  *             sys.stderr.flush()
  *             os.dup2(self.streams[-1], self.id)
  *             os.close(self.streams[-1])             # <<<<<<<<<<<<<<
  *             del self.streams[-1]
  * 
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__close); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__close); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_5);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_1, -1, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
     __Pyx_GIVEREF(__pyx_t_3);
     __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_5, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-    /* "pysam/csamtools.pyx":3150
+    /* "pysam/csamtools.pyx":3367
  *             os.dup2(self.streams[-1], self.id)
  *             os.close(self.streams[-1])
  *             del self.streams[-1]             # <<<<<<<<<<<<<<
  * 
  * def _samtools_dispatch( method,
  */
-    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_v_self, __pyx_n_s__streams); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    if (__Pyx_DelItemInt(__pyx_t_3, -1, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_DelItemInt(__pyx_t_3, -1, sizeof(long), PyInt_FromLong) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     goto __pyx_L3;
   }
@@ -32623,7 +34170,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_1_samtools_dispatch(PyObject *__pyx_
     static PyObject **__pyx_pyargnames[] = {&__pyx_n_s__method,&__pyx_n_s__args,&__pyx_n_s__catch_stdout,0};
     PyObject* values[3] = {0,0,0};
 
-    /* "pysam/csamtools.pyx":3153
+    /* "pysam/csamtools.pyx":3370
  * 
  * def _samtools_dispatch( method,
  *                         args = (),             # <<<<<<<<<<<<<<
@@ -32631,7 +34178,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_1_samtools_dispatch(PyObject *__pyx_
  *     '''call ``method`` in samtools providing arguments in args.
  */
     values[1] = ((PyObject *)__pyx_empty_tuple);
-    values[2] = __pyx_k_180;
+    values[2] = __pyx_k_188;
     if (unlikely(__pyx_kwds)) {
       Py_ssize_t kw_args;
       const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
@@ -32659,7 +34206,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_1_samtools_dispatch(PyObject *__pyx_
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_samtools_dispatch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_samtools_dispatch") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3369; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -32676,7 +34223,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_1_samtools_dispatch(PyObject *__pyx_
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("_samtools_dispatch", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3152; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("_samtools_dispatch", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3369; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools._samtools_dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
@@ -32687,7 +34234,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_1_samtools_dispatch(PyObject *__pyx_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3152
+/* "pysam/csamtools.pyx":3369
  *             del self.streams[-1]
  * 
  * def _samtools_dispatch( method,             # <<<<<<<<<<<<<<
@@ -32738,77 +34285,77 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("_samtools_dispatch", 0);
-  __Pyx_TraceCall("_samtools_dispatch", __pyx_f[0], 3152);
+  __Pyx_TraceCall("_samtools_dispatch", __pyx_f[0], 3369);
   __Pyx_INCREF(__pyx_v_method);
   __Pyx_INCREF(__pyx_v_args);
   __Pyx_INCREF(__pyx_v_catch_stdout);
 
-  /* "pysam/csamtools.pyx":3178
+  /* "pysam/csamtools.pyx":3395
  * 
  *     # some special cases
  *     if method == "index":             # <<<<<<<<<<<<<<
  *         if not os.path.exists( args[0] ):
  *             raise IOError( "No such file or directory: '%s'" % args[0] )
  */
-  __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__index), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__index), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   if (__pyx_t_2) {
 
-    /* "pysam/csamtools.pyx":3179
+    /* "pysam/csamtools.pyx":3396
  *     # some special cases
  *     if method == "index":
  *         if not os.path.exists( args[0] ):             # <<<<<<<<<<<<<<
  *             raise IOError( "No such file or directory: '%s'" % args[0] )
  * 
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__path); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__exists); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
     __Pyx_GIVEREF(__pyx_t_3);
     __pyx_t_3 = 0;
-    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_4), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
-    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
     __pyx_t_5 = (!__pyx_t_2);
     if (__pyx_t_5) {
 
-      /* "pysam/csamtools.pyx":3180
+      /* "pysam/csamtools.pyx":3397
  *     if method == "index":
  *         if not os.path.exists( args[0] ):
  *             raise IOError( "No such file or directory: '%s'" % args[0] )             # <<<<<<<<<<<<<<
  * 
  *     # redirect stderr and stdout to file
  */
-      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_args, 0, sizeof(long), PyInt_FromLong); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_181), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_189), __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(((PyObject *)__pyx_t_4));
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_t_4));
       __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
       __pyx_t_4 = 0;
-      __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyObject_Call(__pyx_builtin_IOError, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_4);
       __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
       __Pyx_Raise(__pyx_t_4, 0, 0, 0);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3397; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       goto __pyx_L4;
     }
     __pyx_L4:;
@@ -32816,19 +34363,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":3183
+  /* "pysam/csamtools.pyx":3400
  * 
  *     # redirect stderr and stdout to file
  *     stderr_h, stderr_f = tempfile.mkstemp()             # <<<<<<<<<<<<<<
  *     pysam_set_stderr( stderr_h )
  * 
  */
-  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__tempfile); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__tempfile); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__mkstemp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__mkstemp); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
   if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
@@ -32841,7 +34388,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
     if (unlikely(size != 2)) {
       if (size > 2) __Pyx_RaiseTooManyValuesError(2);
       else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #if CYTHON_COMPILING_IN_CPYTHON
     if (likely(PyTuple_CheckExact(sequence))) {
@@ -32854,16 +34401,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
     __Pyx_INCREF(__pyx_t_3);
     __Pyx_INCREF(__pyx_t_1);
     #else
-    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
-    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     #endif
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   } else
   {
     Py_ssize_t index = -1;
-    __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_6);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
@@ -32871,7 +34418,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
     __Pyx_GOTREF(__pyx_t_3);
     index = 1; __pyx_t_1 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_1)) goto __pyx_L5_unpacking_failed;
     __Pyx_GOTREF(__pyx_t_1);
-    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_t_7 = NULL;
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     goto __pyx_L6_unpacking_done;
@@ -32879,7 +34426,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
     __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
     __pyx_t_7 = NULL;
     if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3400; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_L6_unpacking_done:;
   }
   __pyx_v_stderr_h = __pyx_t_3;
@@ -32887,39 +34434,39 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
   __pyx_v_stderr_f = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3184
+  /* "pysam/csamtools.pyx":3401
  *     # redirect stderr and stdout to file
  *     stderr_h, stderr_f = tempfile.mkstemp()
  *     pysam_set_stderr( stderr_h )             # <<<<<<<<<<<<<<
  * 
  *     if catch_stdout:
  */
-  __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_v_stderr_h); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = __Pyx_PyInt_AsInt(__pyx_v_stderr_h); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3401; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   pysam_set_stderr(__pyx_t_8);
 
-  /* "pysam/csamtools.pyx":3186
+  /* "pysam/csamtools.pyx":3403
  *     pysam_set_stderr( stderr_h )
  * 
  *     if catch_stdout:             # <<<<<<<<<<<<<<
  *         stdout_h, stdout_f = tempfile.mkstemp()
  *         try:
  */
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stdout); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stdout); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3403; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_5) {
 
-    /* "pysam/csamtools.pyx":3187
+    /* "pysam/csamtools.pyx":3404
  * 
  *     if catch_stdout:
  *         stdout_h, stdout_f = tempfile.mkstemp()             # <<<<<<<<<<<<<<
  *         try:
  *             stdout_save = Outs( sys.stdout.fileno() )
  */
-    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__tempfile); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__tempfile); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__mkstemp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_GetAttr(__pyx_t_4, __pyx_n_s__mkstemp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) {
@@ -32932,7 +34479,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       if (unlikely(size != 2)) {
         if (size > 2) __Pyx_RaiseTooManyValuesError(2);
         else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       }
       #if CYTHON_COMPILING_IN_CPYTHON
       if (likely(PyTuple_CheckExact(sequence))) {
@@ -32945,16 +34492,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __Pyx_INCREF(__pyx_t_1);
       __Pyx_INCREF(__pyx_t_3);
       #else
-      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       #endif
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     } else
     {
       Py_ssize_t index = -1;
-      __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_6 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_6);
       __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
       __pyx_t_7 = Py_TYPE(__pyx_t_6)->tp_iternext;
@@ -32962,7 +34509,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __Pyx_GOTREF(__pyx_t_1);
       index = 1; __pyx_t_3 = __pyx_t_7(__pyx_t_6); if (unlikely(!__pyx_t_3)) goto __pyx_L8_unpacking_failed;
       __Pyx_GOTREF(__pyx_t_3);
-      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__Pyx_IternextUnpackEndCheck(__pyx_t_7(__pyx_t_6), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_t_7 = NULL;
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       goto __pyx_L9_unpacking_done;
@@ -32970,7 +34517,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
       __pyx_t_7 = NULL;
       if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3404; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __pyx_L9_unpacking_done:;
     }
     __pyx_v_stdout_h = __pyx_t_1;
@@ -32978,7 +34525,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
     __pyx_v_stdout_f = __pyx_t_3;
     __pyx_t_3 = 0;
 
-    /* "pysam/csamtools.pyx":3188
+    /* "pysam/csamtools.pyx":3405
  *     if catch_stdout:
  *         stdout_h, stdout_f = tempfile.mkstemp()
  *         try:             # <<<<<<<<<<<<<<
@@ -32992,53 +34539,53 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __Pyx_XGOTREF(__pyx_t_11);
       /*try:*/ {
 
-        /* "pysam/csamtools.pyx":3189
+        /* "pysam/csamtools.pyx":3406
  *         stdout_h, stdout_f = tempfile.mkstemp()
  *         try:
  *             stdout_save = Outs( sys.stdout.fileno() )             # <<<<<<<<<<<<<<
  *             stdout_save.setfd( stdout_h )
  *         except AttributeError:
  */
-        __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+        __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__Outs); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3406; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
         __Pyx_GOTREF(__pyx_t_4);
-        __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+        __pyx_t_3 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3406; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
         __Pyx_GOTREF(__pyx_t_3);
-        __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stdout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+        __pyx_t_1 = PyObject_GetAttr(__pyx_t_3, __pyx_n_s__stdout); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3406; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-        __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fileno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+        __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__fileno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3406; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
         __Pyx_GOTREF(__pyx_t_3);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+        __pyx_t_1 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3406; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
-        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3406; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
         __Pyx_GOTREF(__pyx_t_3);
         PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_1);
         __Pyx_GIVEREF(__pyx_t_1);
         __pyx_t_1 = 0;
-        __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3189; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+        __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3406; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
         __pyx_v_stdout_save = __pyx_t_1;
         __pyx_t_1 = 0;
 
-        /* "pysam/csamtools.pyx":3190
+        /* "pysam/csamtools.pyx":3407
  *         try:
  *             stdout_save = Outs( sys.stdout.fileno() )
  *             stdout_save.setfd( stdout_h )             # <<<<<<<<<<<<<<
  *         except AttributeError:
  *             # stdout has already been redirected
  */
-        __pyx_t_1 = PyObject_GetAttr(__pyx_v_stdout_save, __pyx_n_s__setfd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3190; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+        __pyx_t_1 = PyObject_GetAttr(__pyx_v_stdout_save, __pyx_n_s__setfd); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3407; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
         __Pyx_GOTREF(__pyx_t_1);
-        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3190; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+        __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3407; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
         __Pyx_GOTREF(__pyx_t_3);
         __Pyx_INCREF(__pyx_v_stdout_h);
         PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_stdout_h);
         __Pyx_GIVEREF(__pyx_v_stdout_h);
-        __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3190; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
+        __pyx_t_4 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3407; __pyx_clineno = __LINE__; goto __pyx_L10_error;}
         __Pyx_GOTREF(__pyx_t_4);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
         __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
@@ -33054,7 +34601,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-      /* "pysam/csamtools.pyx":3191
+      /* "pysam/csamtools.pyx":3408
  *             stdout_save = Outs( sys.stdout.fileno() )
  *             stdout_save.setfd( stdout_h )
  *         except AttributeError:             # <<<<<<<<<<<<<<
@@ -33064,19 +34611,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_AttributeError);
       if (__pyx_t_8) {
         __Pyx_AddTraceback("pysam.csamtools._samtools_dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
-        if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3191; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+        if (__Pyx_GetException(&__pyx_t_4, &__pyx_t_3, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3408; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
         __Pyx_GOTREF(__pyx_t_4);
         __Pyx_GOTREF(__pyx_t_3);
         __Pyx_GOTREF(__pyx_t_1);
 
-        /* "pysam/csamtools.pyx":3193
+        /* "pysam/csamtools.pyx":3410
  *         except AttributeError:
  *             # stdout has already been redirected
  *             catch_stdout = False             # <<<<<<<<<<<<<<
  * 
  *         # patch for `samtools view`
  */
-        __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3193; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
+        __pyx_t_6 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3410; __pyx_clineno = __LINE__; goto __pyx_L12_except_error;}
         __Pyx_GOTREF(__pyx_t_6);
         __Pyx_DECREF(__pyx_v_catch_stdout);
         __pyx_v_catch_stdout = __pyx_t_6;
@@ -33100,52 +34647,52 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __pyx_L17_try_end:;
     }
 
-    /* "pysam/csamtools.pyx":3198
+    /* "pysam/csamtools.pyx":3415
  *         # samtools `view` closes stdout, from which I can not
  *         # recover. Thus redirect output to file with -o option.
  *         if method == "view":             # <<<<<<<<<<<<<<
  *             if "-o" in args: raise ValueError("option -o is forbidden in samtools view")
  *             args = ( "-o", stdout_f ) + args
  */
-    __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__view), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3198; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_RichCompare(__pyx_v_method, ((PyObject *)__pyx_n_s__view), Py_EQ); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3415; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     if (__pyx_t_5) {
 
-      /* "pysam/csamtools.pyx":3199
+      /* "pysam/csamtools.pyx":3416
  *         # recover. Thus redirect output to file with -o option.
  *         if method == "view":
  *             if "-o" in args: raise ValueError("option -o is forbidden in samtools view")             # <<<<<<<<<<<<<<
  *             args = ( "-o", stdout_f ) + args
  * 
  */
-      __pyx_t_5 = (__Pyx_PySequence_Contains(((PyObject *)__pyx_kp_s_182), __pyx_v_args, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_5 = (__Pyx_PySequence_Contains(((PyObject *)__pyx_kp_s_190), __pyx_v_args, Py_EQ)); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       if (__pyx_t_5) {
-        __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_184), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_1 = PyObject_Call(__pyx_builtin_ValueError, ((PyObject *)__pyx_k_tuple_192), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         __Pyx_GOTREF(__pyx_t_1);
         __Pyx_Raise(__pyx_t_1, 0, 0, 0);
         __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         goto __pyx_L21;
       }
       __pyx_L21:;
 
-      /* "pysam/csamtools.pyx":3200
+      /* "pysam/csamtools.pyx":3417
  *         if method == "view":
  *             if "-o" in args: raise ValueError("option -o is forbidden in samtools view")
  *             args = ( "-o", stdout_f ) + args             # <<<<<<<<<<<<<<
  * 
  *     # do the function call to samtools
  */
-      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __Pyx_INCREF(((PyObject *)__pyx_kp_s_182));
-      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_182));
-      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_182));
+      __Pyx_INCREF(((PyObject *)__pyx_kp_s_190));
+      PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)__pyx_kp_s_190));
+      __Pyx_GIVEREF(((PyObject *)__pyx_kp_s_190));
       __Pyx_INCREF(__pyx_v_stdout_f);
       PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_v_stdout_f);
       __Pyx_GIVEREF(__pyx_v_stdout_f);
-      __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_t_1), __pyx_v_args); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3200; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyNumber_Add(((PyObject *)__pyx_t_1), __pyx_v_args); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
       __Pyx_DECREF(__pyx_v_args);
@@ -33158,43 +34705,43 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
   }
   __pyx_L7:;
 
-  /* "pysam/csamtools.pyx":3206
+  /* "pysam/csamtools.pyx":3423
  *     cdef int i, n, retval
  * 
  *     n = len(args)             # <<<<<<<<<<<<<<
  *     method = _force_cmdline_bytes(method)
  *     args = [ _force_cmdline_bytes(a) for a in args ]
  */
-  __pyx_t_12 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3206; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_12 = PyObject_Length(__pyx_v_args); if (unlikely(__pyx_t_12 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_v_n = __pyx_t_12;
 
-  /* "pysam/csamtools.pyx":3207
+  /* "pysam/csamtools.pyx":3424
  * 
  *     n = len(args)
  *     method = _force_cmdline_bytes(method)             # <<<<<<<<<<<<<<
  *     args = [ _force_cmdline_bytes(a) for a in args ]
  * 
  */
-  __pyx_t_3 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_cmdline_bytes(__pyx_v_method)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_cmdline_bytes(__pyx_v_method)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_v_method);
   __pyx_v_method = __pyx_t_3;
   __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":3208
+  /* "pysam/csamtools.pyx":3425
  *     n = len(args)
  *     method = _force_cmdline_bytes(method)
  *     args = [ _force_cmdline_bytes(a) for a in args ]             # <<<<<<<<<<<<<<
  * 
  *     # allocate two more for first (dummy) argument (contains command)
  */
-  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   if (PyList_CheckExact(__pyx_v_args) || PyTuple_CheckExact(__pyx_v_args)) {
     __pyx_t_1 = __pyx_v_args; __Pyx_INCREF(__pyx_t_1); __pyx_t_12 = 0;
     __pyx_t_13 = NULL;
   } else {
-    __pyx_t_12 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_12 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_args); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __pyx_t_13 = Py_TYPE(__pyx_t_1)->tp_iternext;
   }
@@ -33202,23 +34749,23 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
     if (!__pyx_t_13 && PyList_CheckExact(__pyx_t_1)) {
       if (__pyx_t_12 >= PyList_GET_SIZE(__pyx_t_1)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_4); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_4); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else if (!__pyx_t_13 && PyTuple_CheckExact(__pyx_t_1)) {
       if (__pyx_t_12 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
       #if CYTHON_COMPILING_IN_CPYTHON
-      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_4); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_12); __Pyx_INCREF(__pyx_t_4); __pyx_t_12++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #else
-      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_12); __pyx_t_12++; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       #endif
     } else {
       __pyx_t_4 = __pyx_t_13(__pyx_t_1);
       if (unlikely(!__pyx_t_4)) {
         if (PyErr_Occurred()) {
           if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) PyErr_Clear();
-          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
         }
         break;
       }
@@ -33227,9 +34774,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
     __Pyx_XDECREF(__pyx_v_a);
     __pyx_v_a = __pyx_t_4;
     __pyx_t_4 = 0;
-    __pyx_t_4 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_cmdline_bytes(__pyx_v_a)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = ((PyObject *)__pyx_f_5pysam_9csamtools__force_cmdline_bytes(__pyx_v_a)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    if (unlikely(__Pyx_PyList_Append(__pyx_t_3, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3208; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(__Pyx_PyList_Append(__pyx_t_3, (PyObject*)__pyx_t_4))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3425; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   }
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -33240,7 +34787,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
   __pyx_v_args = __pyx_t_1;
   __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3211
+  /* "pysam/csamtools.pyx":3428
  * 
  *     # allocate two more for first (dummy) argument (contains command)
  *     cargs = <char**>calloc( n+2, sizeof( char *) )             # <<<<<<<<<<<<<<
@@ -33249,7 +34796,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  */
   __pyx_v_cargs = ((char **)calloc((__pyx_v_n + 2), (sizeof(char *))));
 
-  /* "pysam/csamtools.pyx":3212
+  /* "pysam/csamtools.pyx":3429
  *     # allocate two more for first (dummy) argument (contains command)
  *     cargs = <char**>calloc( n+2, sizeof( char *) )
  *     cargs[0] = "samtools"             # <<<<<<<<<<<<<<
@@ -33258,17 +34805,17 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  */
   (__pyx_v_cargs[0]) = __pyx_k__samtools;
 
-  /* "pysam/csamtools.pyx":3213
+  /* "pysam/csamtools.pyx":3430
  *     cargs = <char**>calloc( n+2, sizeof( char *) )
  *     cargs[0] = "samtools"
  *     cargs[1] = method             # <<<<<<<<<<<<<<
  *     for i from 0 <= i < n: cargs[i+2] = args[i]
  * 
  */
-  __pyx_t_14 = PyBytes_AsString(__pyx_v_method); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3213; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_14 = PyBytes_AsString(__pyx_v_method); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3430; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   (__pyx_v_cargs[1]) = __pyx_t_14;
 
-  /* "pysam/csamtools.pyx":3214
+  /* "pysam/csamtools.pyx":3431
  *     cargs[0] = "samtools"
  *     cargs[1] = method
  *     for i from 0 <= i < n: cargs[i+2] = args[i]             # <<<<<<<<<<<<<<
@@ -33277,14 +34824,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  */
   __pyx_t_8 = __pyx_v_n;
   for (__pyx_v_i = 0; __pyx_v_i < __pyx_t_8; __pyx_v_i++) {
-    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_args, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_args, __pyx_v_i, sizeof(int), PyInt_FromLong); if (!__pyx_t_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_14 = PyBytes_AsString(__pyx_t_1); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_14 = PyBytes_AsString(__pyx_t_1); if (unlikely((!__pyx_t_14) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     (__pyx_v_cargs[(__pyx_v_i + 2)]) = __pyx_t_14;
   }
 
-  /* "pysam/csamtools.pyx":3216
+  /* "pysam/csamtools.pyx":3433
  *     for i from 0 <= i < n: cargs[i+2] = args[i]
  * 
  *     retval = pysam_dispatch(n+2, cargs)             # <<<<<<<<<<<<<<
@@ -33293,7 +34840,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  */
   __pyx_v_retval = pysam_dispatch((__pyx_v_n + 2), __pyx_v_cargs);
 
-  /* "pysam/csamtools.pyx":3217
+  /* "pysam/csamtools.pyx":3434
  * 
  *     retval = pysam_dispatch(n+2, cargs)
  *     free( cargs )             # <<<<<<<<<<<<<<
@@ -33302,32 +34849,32 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  */
   free(__pyx_v_cargs);
 
-  /* "pysam/csamtools.pyx":3221
+  /* "pysam/csamtools.pyx":3438
  *     # restore stdout/stderr. This will also flush, so
  *     # needs to be before reading back the file contents
  *     if catch_stdout:             # <<<<<<<<<<<<<<
  *         stdout_save.restore()
  *         try:
  */
-  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stdout); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3221; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_catch_stdout); if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_5) {
 
-    /* "pysam/csamtools.pyx":3222
+    /* "pysam/csamtools.pyx":3439
  *     # needs to be before reading back the file contents
  *     if catch_stdout:
  *         stdout_save.restore()             # <<<<<<<<<<<<<<
  *         try:
  *             with open( stdout_f, "r") as inf:
  */
-    if (unlikely(!__pyx_v_stdout_save)) { __Pyx_RaiseUnboundLocalError("stdout_save"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3222; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
-    __pyx_t_1 = PyObject_GetAttr(__pyx_v_stdout_save, __pyx_n_s__restore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (unlikely(!__pyx_v_stdout_save)) { __Pyx_RaiseUnboundLocalError("stdout_save"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3439; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+    __pyx_t_1 = PyObject_GetAttr(__pyx_v_stdout_save, __pyx_n_s__restore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3222; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3439; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-    /* "pysam/csamtools.pyx":3223
+    /* "pysam/csamtools.pyx":3440
  *     if catch_stdout:
  *         stdout_save.restore()
  *         try:             # <<<<<<<<<<<<<<
@@ -33341,7 +34888,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __Pyx_XGOTREF(__pyx_t_9);
       /*try:*/ {
 
-        /* "pysam/csamtools.pyx":3224
+        /* "pysam/csamtools.pyx":3441
  *         stdout_save.restore()
  *         try:
  *             with open( stdout_f, "r") as inf:             # <<<<<<<<<<<<<<
@@ -33349,8 +34896,8 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  *         except UnicodeDecodeError:
  */
         /*with:*/ {
-          if (unlikely(!__pyx_v_stdout_f)) { __Pyx_RaiseUnboundLocalError("stdout_f"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L27_error;} }
-          __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L27_error;}
+          if (unlikely(!__pyx_v_stdout_f)) { __Pyx_RaiseUnboundLocalError("stdout_f"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L27_error;} }
+          __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L27_error;}
           __Pyx_GOTREF(__pyx_t_3);
           __Pyx_INCREF(__pyx_v_stdout_f);
           PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_stdout_f);
@@ -33358,14 +34905,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
           __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
           PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__r));
           __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
-          __pyx_t_1 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L27_error;}
+          __pyx_t_1 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L27_error;}
           __Pyx_GOTREF(__pyx_t_1);
           __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-          __pyx_t_15 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____exit__); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L27_error;}
+          __pyx_t_15 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____exit__); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L27_error;}
           __Pyx_GOTREF(__pyx_t_15);
-          __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____enter__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L35_error;}
+          __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____enter__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L35_error;}
           __Pyx_GOTREF(__pyx_t_3);
-          __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L35_error;}
+          __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L35_error;}
           __Pyx_GOTREF(__pyx_t_4);
           __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -33380,16 +34927,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
                 __pyx_v_inf = __pyx_t_4;
                 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-                /* "pysam/csamtools.pyx":3225
+                /* "pysam/csamtools.pyx":3442
  *         try:
  *             with open( stdout_f, "r") as inf:
  *                 out_stdout = inf.readlines()             # <<<<<<<<<<<<<<
  *         except UnicodeDecodeError:
  *             with open( stdout_f, "rb") as inf:
  */
-                __pyx_t_4 = PyObject_GetAttr(__pyx_v_inf, __pyx_n_s__readlines); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3225; __pyx_clineno = __LINE__; goto __pyx_L41_error;}
+                __pyx_t_4 = PyObject_GetAttr(__pyx_v_inf, __pyx_n_s__readlines); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3442; __pyx_clineno = __LINE__; goto __pyx_L41_error;}
                 __Pyx_GOTREF(__pyx_t_4);
-                __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3225; __pyx_clineno = __LINE__; goto __pyx_L41_error;}
+                __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3442; __pyx_clineno = __LINE__; goto __pyx_L41_error;}
                 __Pyx_GOTREF(__pyx_t_1);
                 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                 __pyx_v_out_stdout = __pyx_t_1;
@@ -33405,7 +34952,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
               __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
               __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-              /* "pysam/csamtools.pyx":3224
+              /* "pysam/csamtools.pyx":3441
  *         stdout_save.restore()
  *         try:
  *             with open( stdout_f, "r") as inf:             # <<<<<<<<<<<<<<
@@ -33414,11 +34961,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  */
               /*except:*/ {
                 __Pyx_AddTraceback("pysam.csamtools._samtools_dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
-                if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L43_except_error;}
+                if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L43_except_error;}
                 __Pyx_GOTREF(__pyx_t_1);
                 __Pyx_GOTREF(__pyx_t_4);
                 __Pyx_GOTREF(__pyx_t_3);
-                __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L43_except_error;}
+                __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L43_except_error;}
                 __Pyx_GOTREF(__pyx_t_6);
                 __Pyx_INCREF(__pyx_t_1);
                 PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
@@ -33431,11 +34978,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
                 __Pyx_GIVEREF(__pyx_t_3);
                 __pyx_t_19 = PyObject_Call(__pyx_t_15, __pyx_t_6, NULL);
                 __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-                if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L43_except_error;}
+                if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L43_except_error;}
                 __Pyx_GOTREF(__pyx_t_19);
                 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_19);
                 __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
-                if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L43_except_error;}
+                if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L43_except_error;}
                 __pyx_t_2 = (!__pyx_t_5);
                 if (__pyx_t_2) {
                   __Pyx_GIVEREF(__pyx_t_1);
@@ -33443,7 +34990,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
                   __Pyx_GIVEREF(__pyx_t_3);
                   __Pyx_ErrRestore(__pyx_t_1, __pyx_t_4, __pyx_t_3);
                   __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_3 = 0; 
-                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L43_except_error;}
+                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L43_except_error;}
                   goto __pyx_L52;
                 }
                 __pyx_L52:;
@@ -33469,13 +35016,13 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
           }
           /*finally:*/ {
             if (__pyx_t_15) {
-              __pyx_t_18 = PyObject_Call(__pyx_t_15, __pyx_k_tuple_185, NULL);
+              __pyx_t_18 = PyObject_Call(__pyx_t_15, __pyx_k_tuple_193, NULL);
               __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-              if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L27_error;}
+              if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L27_error;}
               __Pyx_GOTREF(__pyx_t_18);
               __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_18);
               __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
-              if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L27_error;}
+              if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L27_error;}
             }
           }
           goto __pyx_L53;
@@ -33495,7 +35042,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-      /* "pysam/csamtools.pyx":3226
+      /* "pysam/csamtools.pyx":3443
  *             with open( stdout_f, "r") as inf:
  *                 out_stdout = inf.readlines()
  *         except UnicodeDecodeError:             # <<<<<<<<<<<<<<
@@ -33505,12 +35052,12 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
       if (__pyx_t_8) {
         __Pyx_AddTraceback("pysam.csamtools._samtools_dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
-        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L29_except_error;}
+        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3443; __pyx_clineno = __LINE__; goto __pyx_L29_except_error;}
         __Pyx_GOTREF(__pyx_t_3);
         __Pyx_GOTREF(__pyx_t_4);
         __Pyx_GOTREF(__pyx_t_1);
 
-        /* "pysam/csamtools.pyx":3227
+        /* "pysam/csamtools.pyx":3444
  *                 out_stdout = inf.readlines()
  *         except UnicodeDecodeError:
  *             with open( stdout_f, "rb") as inf:             # <<<<<<<<<<<<<<
@@ -33518,7 +35065,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  *                 out_stdout = inf.read()
  */
         /*with:*/ {
-          __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L29_except_error;}
+          __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L29_except_error;}
           __Pyx_GOTREF(__pyx_t_6);
           __Pyx_INCREF(__pyx_v_stdout_f);
           PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_stdout_f);
@@ -33526,14 +35073,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
           __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
           PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_n_s__rb));
           __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rb));
-          __pyx_t_20 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L29_except_error;}
+          __pyx_t_20 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L29_except_error;}
           __Pyx_GOTREF(__pyx_t_20);
           __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-          __pyx_t_15 = PyObject_GetAttr(__pyx_t_20, __pyx_n_s____exit__); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L29_except_error;}
+          __pyx_t_15 = PyObject_GetAttr(__pyx_t_20, __pyx_n_s____exit__); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L29_except_error;}
           __Pyx_GOTREF(__pyx_t_15);
-          __pyx_t_6 = PyObject_GetAttr(__pyx_t_20, __pyx_n_s____enter__); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L56_error;}
+          __pyx_t_6 = PyObject_GetAttr(__pyx_t_20, __pyx_n_s____enter__); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L56_error;}
           __Pyx_GOTREF(__pyx_t_6);
-          __pyx_t_21 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L56_error;}
+          __pyx_t_21 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L56_error;}
           __Pyx_GOTREF(__pyx_t_21);
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
@@ -33549,16 +35096,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
                 __pyx_v_inf = __pyx_t_21;
                 __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
 
-                /* "pysam/csamtools.pyx":3229
+                /* "pysam/csamtools.pyx":3446
  *             with open( stdout_f, "rb") as inf:
  *                 # read binary output
  *                 out_stdout = inf.read()             # <<<<<<<<<<<<<<
  *         os.remove( stdout_f )
  *     else:
  */
-                __pyx_t_21 = PyObject_GetAttr(__pyx_v_inf, __pyx_n_s__read); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3229; __pyx_clineno = __LINE__; goto __pyx_L62_error;}
+                __pyx_t_21 = PyObject_GetAttr(__pyx_v_inf, __pyx_n_s__read); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3446; __pyx_clineno = __LINE__; goto __pyx_L62_error;}
                 __Pyx_GOTREF(__pyx_t_21);
-                __pyx_t_20 = PyObject_Call(__pyx_t_21, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3229; __pyx_clineno = __LINE__; goto __pyx_L62_error;}
+                __pyx_t_20 = PyObject_Call(__pyx_t_21, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3446; __pyx_clineno = __LINE__; goto __pyx_L62_error;}
                 __Pyx_GOTREF(__pyx_t_20);
                 __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
                 __Pyx_XDECREF(__pyx_v_out_stdout);
@@ -33574,7 +35121,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
               __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
               __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
 
-              /* "pysam/csamtools.pyx":3227
+              /* "pysam/csamtools.pyx":3444
  *                 out_stdout = inf.readlines()
  *         except UnicodeDecodeError:
  *             with open( stdout_f, "rb") as inf:             # <<<<<<<<<<<<<<
@@ -33583,11 +35130,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  */
               /*except:*/ {
                 __Pyx_AddTraceback("pysam.csamtools._samtools_dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
-                if (__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L64_except_error;}
+                if (__Pyx_GetException(&__pyx_t_20, &__pyx_t_21, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L64_except_error;}
                 __Pyx_GOTREF(__pyx_t_20);
                 __Pyx_GOTREF(__pyx_t_21);
                 __Pyx_GOTREF(__pyx_t_6);
-                __pyx_t_22 = PyTuple_New(3); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L64_except_error;}
+                __pyx_t_22 = PyTuple_New(3); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L64_except_error;}
                 __Pyx_GOTREF(__pyx_t_22);
                 __Pyx_INCREF(__pyx_t_20);
                 PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_20);
@@ -33600,11 +35147,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
                 __Pyx_GIVEREF(__pyx_t_6);
                 __pyx_t_19 = PyObject_Call(__pyx_t_15, __pyx_t_22, NULL);
                 __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-                if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L64_except_error;}
+                if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L64_except_error;}
                 __Pyx_GOTREF(__pyx_t_19);
                 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_19);
                 __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
-                if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L64_except_error;}
+                if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L64_except_error;}
                 __pyx_t_5 = (!__pyx_t_2);
                 if (__pyx_t_5) {
                   __Pyx_GIVEREF(__pyx_t_20);
@@ -33612,7 +35159,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
                   __Pyx_GIVEREF(__pyx_t_6);
                   __Pyx_ErrRestore(__pyx_t_20, __pyx_t_21, __pyx_t_6);
                   __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_t_6 = 0; 
-                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L64_except_error;}
+                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L64_except_error;}
                   goto __pyx_L73;
                 }
                 __pyx_L73:;
@@ -33638,13 +35185,13 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
           }
           /*finally:*/ {
             if (__pyx_t_15) {
-              __pyx_t_16 = PyObject_Call(__pyx_t_15, __pyx_k_tuple_186, NULL);
+              __pyx_t_16 = PyObject_Call(__pyx_t_15, __pyx_k_tuple_194, NULL);
               __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-              if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L29_except_error;}
+              if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L29_except_error;}
               __Pyx_GOTREF(__pyx_t_16);
               __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_16);
               __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
-              if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L29_except_error;}
+              if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L29_except_error;}
             }
           }
           goto __pyx_L74;
@@ -33672,24 +35219,24 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __pyx_L34_try_end:;
     }
 
-    /* "pysam/csamtools.pyx":3230
+    /* "pysam/csamtools.pyx":3447
  *                 # read binary output
  *                 out_stdout = inf.read()
  *         os.remove( stdout_f )             # <<<<<<<<<<<<<<
  *     else:
  *         out_stdout = []
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__remove); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__remove); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_INCREF(__pyx_v_stdout_f);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_stdout_f);
     __Pyx_GIVEREF(__pyx_v_stdout_f);
-    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3230; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3447; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
@@ -33698,21 +35245,21 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":3232
+    /* "pysam/csamtools.pyx":3449
  *         os.remove( stdout_f )
  *     else:
  *         out_stdout = []             # <<<<<<<<<<<<<<
  * 
  *     # get error messages
  */
-    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3232; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __pyx_v_out_stdout = ((PyObject *)__pyx_t_3);
     __pyx_t_3 = 0;
   }
   __pyx_L26:;
 
-  /* "pysam/csamtools.pyx":3235
+  /* "pysam/csamtools.pyx":3452
  * 
  *     # get error messages
  *     pysam_unset_stderr()             # <<<<<<<<<<<<<<
@@ -33721,7 +35268,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  */
   pysam_unset_stderr();
 
-  /* "pysam/csamtools.pyx":3236
+  /* "pysam/csamtools.pyx":3453
  *     # get error messages
  *     pysam_unset_stderr()
  *     try:             # <<<<<<<<<<<<<<
@@ -33736,7 +35283,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __Pyx_XGOTREF(__pyx_t_11);
       /*try:*/ {
 
-        /* "pysam/csamtools.pyx":3237
+        /* "pysam/csamtools.pyx":3454
  *     pysam_unset_stderr()
  *     try:
  *         with open( stderr_f, "r") as inf:             # <<<<<<<<<<<<<<
@@ -33744,7 +35291,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  *     except UnicodeDecodeError:
  */
         /*with:*/ {
-          __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L78_error;}
+          __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L78_error;}
           __Pyx_GOTREF(__pyx_t_3);
           __Pyx_INCREF(__pyx_v_stderr_f);
           PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_stderr_f);
@@ -33752,14 +35299,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
           __Pyx_INCREF(((PyObject *)__pyx_n_s__r));
           PyTuple_SET_ITEM(__pyx_t_3, 1, ((PyObject *)__pyx_n_s__r));
           __Pyx_GIVEREF(((PyObject *)__pyx_n_s__r));
-          __pyx_t_1 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L78_error;}
+          __pyx_t_1 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_3), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L78_error;}
           __Pyx_GOTREF(__pyx_t_1);
           __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
-          __pyx_t_15 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____exit__); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L78_error;}
+          __pyx_t_15 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____exit__); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L78_error;}
           __Pyx_GOTREF(__pyx_t_15);
-          __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____enter__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L86_error;}
+          __pyx_t_3 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s____enter__); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L86_error;}
           __Pyx_GOTREF(__pyx_t_3);
-          __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L86_error;}
+          __pyx_t_4 = PyObject_Call(__pyx_t_3, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L86_error;}
           __Pyx_GOTREF(__pyx_t_4);
           __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
           __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -33775,16 +35322,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
                 __pyx_v_inf = __pyx_t_4;
                 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-                /* "pysam/csamtools.pyx":3238
+                /* "pysam/csamtools.pyx":3455
  *     try:
  *         with open( stderr_f, "r") as inf:
  *             out_stderr = inf.readlines()             # <<<<<<<<<<<<<<
  *     except UnicodeDecodeError:
  *         with open( stderr_f, "rb") as inf:
  */
-                __pyx_t_4 = PyObject_GetAttr(__pyx_v_inf, __pyx_n_s__readlines); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3238; __pyx_clineno = __LINE__; goto __pyx_L92_error;}
+                __pyx_t_4 = PyObject_GetAttr(__pyx_v_inf, __pyx_n_s__readlines); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3455; __pyx_clineno = __LINE__; goto __pyx_L92_error;}
                 __Pyx_GOTREF(__pyx_t_4);
-                __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3238; __pyx_clineno = __LINE__; goto __pyx_L92_error;}
+                __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3455; __pyx_clineno = __LINE__; goto __pyx_L92_error;}
                 __Pyx_GOTREF(__pyx_t_1);
                 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
                 __pyx_v_out_stderr = __pyx_t_1;
@@ -33803,7 +35350,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
               __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
               __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-              /* "pysam/csamtools.pyx":3237
+              /* "pysam/csamtools.pyx":3454
  *     pysam_unset_stderr()
  *     try:
  *         with open( stderr_f, "r") as inf:             # <<<<<<<<<<<<<<
@@ -33812,11 +35359,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  */
               /*except:*/ {
                 __Pyx_AddTraceback("pysam.csamtools._samtools_dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
-                if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L94_except_error;}
+                if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_4, &__pyx_t_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L94_except_error;}
                 __Pyx_GOTREF(__pyx_t_1);
                 __Pyx_GOTREF(__pyx_t_4);
                 __Pyx_GOTREF(__pyx_t_3);
-                __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L94_except_error;}
+                __pyx_t_6 = PyTuple_New(3); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L94_except_error;}
                 __Pyx_GOTREF(__pyx_t_6);
                 __Pyx_INCREF(__pyx_t_1);
                 PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_1);
@@ -33829,11 +35376,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
                 __Pyx_GIVEREF(__pyx_t_3);
                 __pyx_t_19 = PyObject_Call(__pyx_t_15, __pyx_t_6, NULL);
                 __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-                if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L94_except_error;}
+                if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L94_except_error;}
                 __Pyx_GOTREF(__pyx_t_19);
                 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_19);
                 __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
-                if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L94_except_error;}
+                if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L94_except_error;}
                 __pyx_t_2 = (!__pyx_t_5);
                 if (__pyx_t_2) {
                   __Pyx_GIVEREF(__pyx_t_1);
@@ -33841,7 +35388,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
                   __Pyx_GIVEREF(__pyx_t_3);
                   __Pyx_ErrRestore(__pyx_t_1, __pyx_t_4, __pyx_t_3);
                   __pyx_t_1 = 0; __pyx_t_4 = 0; __pyx_t_3 = 0; 
-                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L94_except_error;}
+                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L94_except_error;}
                   goto __pyx_L103;
                 }
                 __pyx_L103:;
@@ -33867,13 +35414,13 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
           }
           /*finally:*/ {
             if (__pyx_t_15) {
-              __pyx_t_18 = PyObject_Call(__pyx_t_15, __pyx_k_tuple_187, NULL);
+              __pyx_t_18 = PyObject_Call(__pyx_t_15, __pyx_k_tuple_195, NULL);
               __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-              if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L78_error;}
+              if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L78_error;}
               __Pyx_GOTREF(__pyx_t_18);
               __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_18);
               __Pyx_DECREF(__pyx_t_18); __pyx_t_18 = 0;
-              if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L78_error;}
+              if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L78_error;}
             }
           }
           goto __pyx_L104;
@@ -33885,14 +35432,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       }
       /*else:*/ {
 
-        /* "pysam/csamtools.pyx":3244
+        /* "pysam/csamtools.pyx":3461
  *             out_stderr = inf.read()
  *     else:
  *         out_stderr = []             # <<<<<<<<<<<<<<
  *     finally:
  *         os.remove( stderr_f )
  */
-        __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3244; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
+        __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3461; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
         __Pyx_GOTREF(__pyx_t_3);
         __Pyx_XDECREF(__pyx_v_out_stderr);
         __pyx_v_out_stderr = ((PyObject *)__pyx_t_3);
@@ -33911,7 +35458,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
       __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
 
-      /* "pysam/csamtools.pyx":3239
+      /* "pysam/csamtools.pyx":3456
  *         with open( stderr_f, "r") as inf:
  *             out_stderr = inf.readlines()
  *     except UnicodeDecodeError:             # <<<<<<<<<<<<<<
@@ -33921,12 +35468,12 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       __pyx_t_8 = PyErr_ExceptionMatches(__pyx_builtin_UnicodeDecodeError);
       if (__pyx_t_8) {
         __Pyx_AddTraceback("pysam.csamtools._samtools_dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
-        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3239; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
+        if (__Pyx_GetException(&__pyx_t_3, &__pyx_t_4, &__pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3456; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
         __Pyx_GOTREF(__pyx_t_3);
         __Pyx_GOTREF(__pyx_t_4);
         __Pyx_GOTREF(__pyx_t_1);
 
-        /* "pysam/csamtools.pyx":3240
+        /* "pysam/csamtools.pyx":3457
  *             out_stderr = inf.readlines()
  *     except UnicodeDecodeError:
  *         with open( stderr_f, "rb") as inf:             # <<<<<<<<<<<<<<
@@ -33934,7 +35481,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  *             out_stderr = inf.read()
  */
         /*with:*/ {
-          __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
+          __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
           __Pyx_GOTREF(__pyx_t_6);
           __Pyx_INCREF(__pyx_v_stderr_f);
           PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_stderr_f);
@@ -33942,14 +35489,14 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
           __Pyx_INCREF(((PyObject *)__pyx_n_s__rb));
           PyTuple_SET_ITEM(__pyx_t_6, 1, ((PyObject *)__pyx_n_s__rb));
           __Pyx_GIVEREF(((PyObject *)__pyx_n_s__rb));
-          __pyx_t_21 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
+          __pyx_t_21 = PyObject_Call(__pyx_builtin_open, ((PyObject *)__pyx_t_6), NULL); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
           __Pyx_GOTREF(__pyx_t_21);
           __Pyx_DECREF(((PyObject *)__pyx_t_6)); __pyx_t_6 = 0;
-          __pyx_t_15 = PyObject_GetAttr(__pyx_t_21, __pyx_n_s____exit__); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
+          __pyx_t_15 = PyObject_GetAttr(__pyx_t_21, __pyx_n_s____exit__); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
           __Pyx_GOTREF(__pyx_t_15);
-          __pyx_t_6 = PyObject_GetAttr(__pyx_t_21, __pyx_n_s____enter__); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L107_error;}
+          __pyx_t_6 = PyObject_GetAttr(__pyx_t_21, __pyx_n_s____enter__); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L107_error;}
           __Pyx_GOTREF(__pyx_t_6);
-          __pyx_t_20 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L107_error;}
+          __pyx_t_20 = PyObject_Call(__pyx_t_6, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L107_error;}
           __Pyx_GOTREF(__pyx_t_20);
           __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
           __Pyx_DECREF(__pyx_t_21); __pyx_t_21 = 0;
@@ -33965,16 +35512,16 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
                 __pyx_v_inf = __pyx_t_20;
                 __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
 
-                /* "pysam/csamtools.pyx":3242
+                /* "pysam/csamtools.pyx":3459
  *         with open( stderr_f, "rb") as inf:
  *             # read binary output
  *             out_stderr = inf.read()             # <<<<<<<<<<<<<<
  *     else:
  *         out_stderr = []
  */
-                __pyx_t_20 = PyObject_GetAttr(__pyx_v_inf, __pyx_n_s__read); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3242; __pyx_clineno = __LINE__; goto __pyx_L113_error;}
+                __pyx_t_20 = PyObject_GetAttr(__pyx_v_inf, __pyx_n_s__read); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3459; __pyx_clineno = __LINE__; goto __pyx_L113_error;}
                 __Pyx_GOTREF(__pyx_t_20);
-                __pyx_t_21 = PyObject_Call(__pyx_t_20, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3242; __pyx_clineno = __LINE__; goto __pyx_L113_error;}
+                __pyx_t_21 = PyObject_Call(__pyx_t_20, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3459; __pyx_clineno = __LINE__; goto __pyx_L113_error;}
                 __Pyx_GOTREF(__pyx_t_21);
                 __Pyx_DECREF(__pyx_t_20); __pyx_t_20 = 0;
                 __Pyx_XDECREF(__pyx_v_out_stderr);
@@ -33991,7 +35538,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
               __Pyx_XDECREF(__pyx_t_20); __pyx_t_20 = 0;
               __Pyx_XDECREF(__pyx_t_21); __pyx_t_21 = 0;
 
-              /* "pysam/csamtools.pyx":3240
+              /* "pysam/csamtools.pyx":3457
  *             out_stderr = inf.readlines()
  *     except UnicodeDecodeError:
  *         with open( stderr_f, "rb") as inf:             # <<<<<<<<<<<<<<
@@ -34000,11 +35547,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  */
               /*except:*/ {
                 __Pyx_AddTraceback("pysam.csamtools._samtools_dispatch", __pyx_clineno, __pyx_lineno, __pyx_filename);
-                if (__Pyx_GetException(&__pyx_t_21, &__pyx_t_20, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L115_except_error;}
+                if (__Pyx_GetException(&__pyx_t_21, &__pyx_t_20, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L115_except_error;}
                 __Pyx_GOTREF(__pyx_t_21);
                 __Pyx_GOTREF(__pyx_t_20);
                 __Pyx_GOTREF(__pyx_t_6);
-                __pyx_t_22 = PyTuple_New(3); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L115_except_error;}
+                __pyx_t_22 = PyTuple_New(3); if (unlikely(!__pyx_t_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L115_except_error;}
                 __Pyx_GOTREF(__pyx_t_22);
                 __Pyx_INCREF(__pyx_t_21);
                 PyTuple_SET_ITEM(__pyx_t_22, 0, __pyx_t_21);
@@ -34017,11 +35564,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
                 __Pyx_GIVEREF(__pyx_t_6);
                 __pyx_t_19 = PyObject_Call(__pyx_t_15, __pyx_t_22, NULL);
                 __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-                if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L115_except_error;}
+                if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L115_except_error;}
                 __Pyx_GOTREF(__pyx_t_19);
                 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_19);
                 __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0;
-                if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L115_except_error;}
+                if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L115_except_error;}
                 __pyx_t_5 = (!__pyx_t_2);
                 if (__pyx_t_5) {
                   __Pyx_GIVEREF(__pyx_t_21);
@@ -34029,7 +35576,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
                   __Pyx_GIVEREF(__pyx_t_6);
                   __Pyx_ErrRestore(__pyx_t_21, __pyx_t_20, __pyx_t_6);
                   __pyx_t_21 = 0; __pyx_t_20 = 0; __pyx_t_6 = 0; 
-                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L115_except_error;}
+                  {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L115_except_error;}
                   goto __pyx_L124;
                 }
                 __pyx_L124:;
@@ -34055,13 +35602,13 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
           }
           /*finally:*/ {
             if (__pyx_t_15) {
-              __pyx_t_16 = PyObject_Call(__pyx_t_15, __pyx_k_tuple_188, NULL);
+              __pyx_t_16 = PyObject_Call(__pyx_t_15, __pyx_k_tuple_196, NULL);
               __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
-              if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
+              if (unlikely(!__pyx_t_16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
               __Pyx_GOTREF(__pyx_t_16);
               __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_16);
               __Pyx_DECREF(__pyx_t_16); __pyx_t_16 = 0;
-              if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
+              if (unlikely(__pyx_t_5 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L80_except_error;}
             }
           }
           goto __pyx_L125;
@@ -34090,7 +35637,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
     }
   }
 
-  /* "pysam/csamtools.pyx":3246
+  /* "pysam/csamtools.pyx":3463
  *         out_stderr = []
  *     finally:
  *         os.remove( stderr_f )             # <<<<<<<<<<<<<<
@@ -34117,17 +35664,17 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
       goto __pyx_L77;
     }
     __pyx_L77:;
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3246; __pyx_clineno = __LINE__; goto __pyx_L126_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__os); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3463; __pyx_clineno = __LINE__; goto __pyx_L126_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__remove); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3246; __pyx_clineno = __LINE__; goto __pyx_L126_error;}
+    __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__remove); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3463; __pyx_clineno = __LINE__; goto __pyx_L126_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3246; __pyx_clineno = __LINE__; goto __pyx_L126_error;}
+    __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3463; __pyx_clineno = __LINE__; goto __pyx_L126_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_INCREF(__pyx_v_stderr_f);
     PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_stderr_f);
     __Pyx_GIVEREF(__pyx_v_stderr_f);
-    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3246; __pyx_clineno = __LINE__; goto __pyx_L126_error;}
+    __pyx_t_3 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3463; __pyx_clineno = __LINE__; goto __pyx_L126_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
@@ -34153,7 +35700,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
     }
   }
 
-  /* "pysam/csamtools.pyx":3248
+  /* "pysam/csamtools.pyx":3465
  *         os.remove( stderr_f )
  * 
  *     return retval, out_stderr, out_stdout             # <<<<<<<<<<<<<<
@@ -34161,11 +35708,11 @@ static PyObject *__pyx_pf_5pysam_9csamtools__samtools_dispatch(CYTHON_UNUSED PyO
  * cdef class SNPCall:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_3 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyInt_FromLong(__pyx_v_retval); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
-  if (unlikely(!__pyx_v_out_stderr)) { __Pyx_RaiseUnboundLocalError("out_stderr"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
-  if (unlikely(!__pyx_v_out_stdout)) { __Pyx_RaiseUnboundLocalError("out_stdout"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3248; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
-  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3248; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__pyx_v_out_stderr)) { __Pyx_RaiseUnboundLocalError("out_stderr"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+  if (unlikely(!__pyx_v_out_stdout)) { __Pyx_RaiseUnboundLocalError("out_stdout"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3465; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+  __pyx_t_1 = PyTuple_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3465; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_3);
   __Pyx_GIVEREF(__pyx_t_3);
@@ -34222,7 +35769,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7SNPCall_3tid_1__get__(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3263
+/* "pysam/csamtools.pyx":3480
  *     property tid:
  *         '''the chromosome ID as is defined in the header'''
  *         def __get__(self):             # <<<<<<<<<<<<<<
@@ -34239,9 +35786,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall_3tid___get__(struct __pyx_o
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3263);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3480);
 
-  /* "pysam/csamtools.pyx":3264
+  /* "pysam/csamtools.pyx":3481
  *         '''the chromosome ID as is defined in the header'''
  *         def __get__(self):
  *             return self._tid             # <<<<<<<<<<<<<<
@@ -34249,7 +35796,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall_3tid___get__(struct __pyx_o
  *     property pos:
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_tid); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -34279,7 +35826,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7SNPCall_3pos_1__get__(PyObject *__p
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3268
+/* "pysam/csamtools.pyx":3485
  *     property pos:
  *        '''nucleotide position of SNP.'''
  *        def __get__(self): return self._pos             # <<<<<<<<<<<<<<
@@ -34296,9 +35843,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall_3pos___get__(struct __pyx_o
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3268);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3485);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3485; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -34328,7 +35875,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7SNPCall_14reference_base_1__get__(P
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3272
+/* "pysam/csamtools.pyx":3489
  *     property reference_base:
  *        '''reference base at pos. ``N`` if no reference sequence supplied.'''
  *        def __get__(self): return from_string_and_size( &self._reference_base, 1 )             # <<<<<<<<<<<<<<
@@ -34345,9 +35892,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall_14reference_base___get__(st
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3272);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3489);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __pyx_f_5pysam_9csamtools_from_string_and_size((&__pyx_v_self->_reference_base), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3272; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_5pysam_9csamtools_from_string_and_size((&__pyx_v_self->_reference_base), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -34377,7 +35924,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7SNPCall_8genotype_1__get__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3276
+/* "pysam/csamtools.pyx":3493
  *     property genotype:
  *        '''the genotype called.'''
  *        def __get__(self): return from_string_and_size( &self._genotype, 1 )             # <<<<<<<<<<<<<<
@@ -34394,9 +35941,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall_8genotype___get__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3276);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3493);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = __pyx_f_5pysam_9csamtools_from_string_and_size((&__pyx_v_self->_genotype), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3276; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_f_5pysam_9csamtools_from_string_and_size((&__pyx_v_self->_genotype), 1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3493; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -34426,7 +35973,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7SNPCall_17consensus_quality_1__get_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3280
+/* "pysam/csamtools.pyx":3497
  *     property consensus_quality:
  *        '''the genotype quality (Phred-scaled).'''
  *        def __get__(self): return self._consensus_quality             # <<<<<<<<<<<<<<
@@ -34443,9 +35990,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall_17consensus_quality___get__
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3280);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3497);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_consensus_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3280; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_consensus_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3497; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -34475,7 +36022,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7SNPCall_11snp_quality_1__get__(PyOb
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3284
+/* "pysam/csamtools.pyx":3501
  *     property snp_quality:
  *        '''the snp quality (Phred scaled) - probability of consensus being identical to reference sequence.'''
  *        def __get__(self): return self._snp_quality             # <<<<<<<<<<<<<<
@@ -34492,9 +36039,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall_11snp_quality___get__(struc
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3284);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3501);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_snp_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_snp_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3501; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -34524,7 +36071,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7SNPCall_15mapping_quality_1__get__(
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3288
+/* "pysam/csamtools.pyx":3505
  *     property mapping_quality:
  *        '''the root mean square (rms) of the mapping quality of all reads involved in the call.'''
  *        def __get__(self): return self._rms_mapping_quality             # <<<<<<<<<<<<<<
@@ -34541,9 +36088,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall_15mapping_quality___get__(s
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3288);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3505);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_rms_mapping_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3288; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_rms_mapping_quality); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3505; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -34573,7 +36120,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7SNPCall_8coverage_1__get__(PyObject
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3292
+/* "pysam/csamtools.pyx":3509
  *     property coverage:
  *        '''coverage or read depth - the number of reads involved in the call.'''
  *        def __get__(self): return self._coverage             # <<<<<<<<<<<<<<
@@ -34590,9 +36137,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall_8coverage___get__(struct __
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__get__", 0);
-  __Pyx_TraceCall("__get__", __pyx_f[0], 3292);
+  __Pyx_TraceCall("__get__", __pyx_f[0], 3509);
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_coverage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3292; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyInt_FromLong(__pyx_v_self->_coverage); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3509; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __pyx_r = __pyx_t_1;
   __pyx_t_1 = 0;
@@ -34622,7 +36169,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_7SNPCall_1__str__(PyObject *__pyx_v_
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3294
+/* "pysam/csamtools.pyx":3511
  *        def __get__(self): return self._coverage
  * 
  *     def __str__(self):             # <<<<<<<<<<<<<<
@@ -34648,9 +36195,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall___str__(struct __pyx_obj_5p
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__str__", 0);
-  __Pyx_TraceCall("__str__", __pyx_f[0], 3294);
+  __Pyx_TraceCall("__str__", __pyx_f[0], 3511);
 
-  /* "pysam/csamtools.pyx":3296
+  /* "pysam/csamtools.pyx":3513
  *     def __str__(self):
  * 
  *         return "\t".join( map(str, (             # <<<<<<<<<<<<<<
@@ -34658,89 +36205,89 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall___str__(struct __pyx_obj_5p
  *                     self.pos,
  */
   __Pyx_XDECREF(__pyx_r);
-  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_GetAttr(((PyObject *)__pyx_kp_s_5), __pyx_n_s__join); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
 
-  /* "pysam/csamtools.pyx":3297
+  /* "pysam/csamtools.pyx":3514
  * 
  *         return "\t".join( map(str, (
  *                     self.tid,             # <<<<<<<<<<<<<<
  *                     self.pos,
  *                     self.reference_base,
  */
-  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__tid); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
 
-  /* "pysam/csamtools.pyx":3298
+  /* "pysam/csamtools.pyx":3515
  *         return "\t".join( map(str, (
  *                     self.tid,
  *                     self.pos,             # <<<<<<<<<<<<<<
  *                     self.reference_base,
  *                     self.genotype,
  */
-  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__pos); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3515; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
 
-  /* "pysam/csamtools.pyx":3299
+  /* "pysam/csamtools.pyx":3516
  *                     self.tid,
  *                     self.pos,
  *                     self.reference_base,             # <<<<<<<<<<<<<<
  *                     self.genotype,
  *                     self.consensus_quality,
  */
-  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__reference_base); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3299; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__reference_base); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3516; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
 
-  /* "pysam/csamtools.pyx":3300
+  /* "pysam/csamtools.pyx":3517
  *                     self.pos,
  *                     self.reference_base,
  *                     self.genotype,             # <<<<<<<<<<<<<<
  *                     self.consensus_quality,
  *                     self.snp_quality,
  */
-  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__genotype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3300; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__genotype); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3517; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_5);
 
-  /* "pysam/csamtools.pyx":3301
+  /* "pysam/csamtools.pyx":3518
  *                     self.reference_base,
  *                     self.genotype,
  *                     self.consensus_quality,             # <<<<<<<<<<<<<<
  *                     self.snp_quality,
  *                     self.mapping_quality,
  */
-  __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__consensus_quality); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3301; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_6 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__consensus_quality); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_6);
 
-  /* "pysam/csamtools.pyx":3302
+  /* "pysam/csamtools.pyx":3519
  *                     self.genotype,
  *                     self.consensus_quality,
  *                     self.snp_quality,             # <<<<<<<<<<<<<<
  *                     self.mapping_quality,
  *                     self.coverage ) ) )
  */
-  __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__snp_quality); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3302; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_7 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__snp_quality); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3519; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_7);
 
-  /* "pysam/csamtools.pyx":3303
+  /* "pysam/csamtools.pyx":3520
  *                     self.consensus_quality,
  *                     self.snp_quality,
  *                     self.mapping_quality,             # <<<<<<<<<<<<<<
  *                     self.coverage ) ) )
  * 
  */
-  __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__mapping_quality); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_8 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__mapping_quality); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3520; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_8);
 
-  /* "pysam/csamtools.pyx":3304
+  /* "pysam/csamtools.pyx":3521
  *                     self.snp_quality,
  *                     self.mapping_quality,
  *                     self.coverage ) ) )             # <<<<<<<<<<<<<<
  * 
  * 
  */
-  __pyx_t_9 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__coverage); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyObject_GetAttr(((PyObject *)__pyx_v_self), __pyx_n_s__coverage); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3521; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
-  __pyx_t_10 = PyTuple_New(8); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3297; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyTuple_New(8); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3514; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_10);
   PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_2);
   __Pyx_GIVEREF(__pyx_t_2);
@@ -34766,7 +36313,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall___str__(struct __pyx_obj_5p
   __pyx_t_7 = 0;
   __pyx_t_8 = 0;
   __pyx_t_9 = 0;
-  __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
   __Pyx_INCREF(((PyObject *)((PyObject*)(&PyString_Type))));
   PyTuple_SET_ITEM(__pyx_t_9, 0, ((PyObject *)((PyObject*)(&PyString_Type))));
@@ -34774,15 +36321,15 @@ static PyObject *__pyx_pf_5pysam_9csamtools_7SNPCall___str__(struct __pyx_obj_5p
   PyTuple_SET_ITEM(__pyx_t_9, 1, ((PyObject *)__pyx_t_10));
   __Pyx_GIVEREF(((PyObject *)__pyx_t_10));
   __pyx_t_10 = 0;
-  __pyx_t_10 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyObject_Call(__pyx_builtin_map, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_10);
   __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
-  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_9);
   PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10);
   __Pyx_GIVEREF(__pyx_t_10);
   __pyx_t_10 = 0;
-  __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3296; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_10 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_t_9), NULL); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3513; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_10);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_9)); __pyx_t_9 = 0;
@@ -34844,7 +36391,7 @@ static int __pyx_pw_5pysam_9csamtools_12IndexedReads_1__init__(PyObject *__pyx_v
         }
       }
       if (unlikely(kw_args > 0)) {
-        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3814; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4031; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
       }
     } else {
       switch (PyTuple_GET_SIZE(__pyx_args)) {
@@ -34856,10 +36403,10 @@ static int __pyx_pw_5pysam_9csamtools_12IndexedReads_1__init__(PyObject *__pyx_v
     }
     __pyx_v_samfile = ((struct __pyx_obj_5pysam_9csamtools_Samfile *)values[0]);
     if (values[1]) {
-      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3814; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      __pyx_v_reopen = __Pyx_PyInt_AsInt(values[1]); if (unlikely((__pyx_v_reopen == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4031; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
     } else {
 
-      /* "pysam/csamtools.pyx":3814
+      /* "pysam/csamtools.pyx":4031
  *     """
  * 
  *     def __init__(self, Samfile samfile, int reopen = True ):             # <<<<<<<<<<<<<<
@@ -34871,13 +36418,13 @@ static int __pyx_pw_5pysam_9csamtools_12IndexedReads_1__init__(PyObject *__pyx_v
   }
   goto __pyx_L4_argument_unpacking_done;
   __pyx_L5_argtuple_error:;
-  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3814; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __Pyx_RaiseArgtupleInvalid("__init__", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4031; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
   __pyx_L3_error:;
   __Pyx_AddTraceback("pysam.csamtools.IndexedReads.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
   __Pyx_RefNannyFinishContext();
   return -1;
   __pyx_L4_argument_unpacking_done:;
-  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3814; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_samfile), __pyx_ptype_5pysam_9csamtools_Samfile, 1, "samfile", 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4031; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_r = __pyx_pf_5pysam_9csamtools_12IndexedReads___init__(((struct __pyx_obj_5pysam_9csamtools_IndexedReads *)__pyx_v_self), __pyx_v_samfile, __pyx_v_reopen);
   goto __pyx_L0;
   __pyx_L1_error:;
@@ -34901,9 +36448,9 @@ static int __pyx_pf_5pysam_9csamtools_12IndexedReads___init__(struct __pyx_obj_5
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__init__", 0);
-  __Pyx_TraceCall("__init__", __pyx_f[0], 3814);
+  __Pyx_TraceCall("__init__", __pyx_f[0], 4031);
 
-  /* "pysam/csamtools.pyx":3815
+  /* "pysam/csamtools.pyx":4032
  * 
  *     def __init__(self, Samfile samfile, int reopen = True ):
  *         self.samfile = samfile             # <<<<<<<<<<<<<<
@@ -34916,7 +36463,7 @@ static int __pyx_pf_5pysam_9csamtools_12IndexedReads___init__(struct __pyx_obj_5
   __Pyx_DECREF(((PyObject *)__pyx_v_self->samfile));
   __pyx_v_self->samfile = __pyx_v_samfile;
 
-  /* "pysam/csamtools.pyx":3817
+  /* "pysam/csamtools.pyx":4034
  *         self.samfile = samfile
  * 
  *         if samfile.isbam: mode = b"rb"             # <<<<<<<<<<<<<<
@@ -34930,7 +36477,7 @@ static int __pyx_pf_5pysam_9csamtools_12IndexedReads___init__(struct __pyx_obj_5
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":3818
+    /* "pysam/csamtools.pyx":4035
  * 
  *         if samfile.isbam: mode = b"rb"
  *         else: mode = b"r"             # <<<<<<<<<<<<<<
@@ -34942,7 +36489,7 @@ static int __pyx_pf_5pysam_9csamtools_12IndexedReads___init__(struct __pyx_obj_5
   }
   __pyx_L3:;
 
-  /* "pysam/csamtools.pyx":3822
+  /* "pysam/csamtools.pyx":4039
  *         # reopen the file - note that this makes the iterator
  *         # slow and causes pileup to slow down significantly.
  *         if reopen:             # <<<<<<<<<<<<<<
@@ -34951,46 +36498,46 @@ static int __pyx_pf_5pysam_9csamtools_12IndexedReads___init__(struct __pyx_obj_5
  */
   if (__pyx_v_reopen) {
 
-    /* "pysam/csamtools.pyx":3823
+    /* "pysam/csamtools.pyx":4040
  *         # slow and causes pileup to slow down significantly.
  *         if reopen:
  *             store = StderrStore()             # <<<<<<<<<<<<<<
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  */
-    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStore); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
-    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3823; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_Call(__pyx_t_1, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4040; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
     __pyx_v_store = __pyx_t_2;
     __pyx_t_2 = 0;
 
-    /* "pysam/csamtools.pyx":3824
+    /* "pysam/csamtools.pyx":4041
  *         if reopen:
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )             # <<<<<<<<<<<<<<
  *             store.release()
  *             assert self.fp != NULL
  */
-    __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_mode)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3824; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyBytes_AsString(((PyObject *)__pyx_v_mode)); if (unlikely((!__pyx_t_3) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4041; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __pyx_v_self->fp = samopen(__pyx_v_samfile->_filename, __pyx_t_3, NULL);
 
-    /* "pysam/csamtools.pyx":3825
+    /* "pysam/csamtools.pyx":4042
  *             store = StderrStore()
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()             # <<<<<<<<<<<<<<
  *             assert self.fp != NULL
  *             self.owns_samfile = True
  */
-    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetAttr(__pyx_v_store, __pyx_n_s__release); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4042; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_1);
     __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
     __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-    /* "pysam/csamtools.pyx":3826
+    /* "pysam/csamtools.pyx":4043
  *             self.fp = samopen( samfile._filename, mode, NULL )
  *             store.release()
  *             assert self.fp != NULL             # <<<<<<<<<<<<<<
@@ -35000,11 +36547,11 @@ static int __pyx_pf_5pysam_9csamtools_12IndexedReads___init__(struct __pyx_obj_5
     #ifndef CYTHON_WITHOUT_ASSERTIONS
     if (unlikely(!(__pyx_v_self->fp != NULL))) {
       PyErr_SetNone(PyExc_AssertionError);
-      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3826; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4043; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     }
     #endif
 
-    /* "pysam/csamtools.pyx":3827
+    /* "pysam/csamtools.pyx":4044
  *             store.release()
  *             assert self.fp != NULL
  *             self.owns_samfile = True             # <<<<<<<<<<<<<<
@@ -35016,7 +36563,7 @@ static int __pyx_pf_5pysam_9csamtools_12IndexedReads___init__(struct __pyx_obj_5
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":3829
+    /* "pysam/csamtools.pyx":4046
  *             self.owns_samfile = True
  *         else:
  *             self.fp = samfile.samfile             # <<<<<<<<<<<<<<
@@ -35026,7 +36573,7 @@ static int __pyx_pf_5pysam_9csamtools_12IndexedReads___init__(struct __pyx_obj_5
     __pyx_t_4 = __pyx_v_samfile->samfile;
     __pyx_v_self->fp = __pyx_t_4;
 
-    /* "pysam/csamtools.pyx":3830
+    /* "pysam/csamtools.pyx":4047
  *         else:
  *             self.fp = samfile.samfile
  *             self.owns_samfile = False             # <<<<<<<<<<<<<<
@@ -35037,7 +36584,7 @@ static int __pyx_pf_5pysam_9csamtools_12IndexedReads___init__(struct __pyx_obj_5
   }
   __pyx_L4:;
 
-  /* "pysam/csamtools.pyx":3832
+  /* "pysam/csamtools.pyx":4049
  *             self.owns_samfile = False
  * 
  *         assert samfile.isbam, "can only IndexReads on bam files"             # <<<<<<<<<<<<<<
@@ -35046,8 +36593,8 @@ static int __pyx_pf_5pysam_9csamtools_12IndexedReads___init__(struct __pyx_obj_5
  */
   #ifndef CYTHON_WITHOUT_ASSERTIONS
   if (unlikely(!__pyx_v_samfile->isbam)) {
-    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_189));
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3832; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyErr_SetObject(PyExc_AssertionError, ((PyObject *)__pyx_kp_s_197));
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   #endif
 
@@ -35078,7 +36625,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_12IndexedReads_3build(PyObject *__py
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3834
+/* "pysam/csamtools.pyx":4051
  *         assert samfile.isbam, "can only IndexReads on bam files"
  * 
  *     def build( self ):             # <<<<<<<<<<<<<<
@@ -35102,26 +36649,26 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_2build(struct __pyx_o
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("build", 0);
-  __Pyx_TraceCall("build", __pyx_f[0], 3834);
+  __Pyx_TraceCall("build", __pyx_f[0], 4051);
 
-  /* "pysam/csamtools.pyx":3837
+  /* "pysam/csamtools.pyx":4054
  *         '''build index.'''
  * 
  *         self.index = collections.defaultdict( list )             # <<<<<<<<<<<<<<
  * 
  *         # this method will start indexing from the current file position
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__collections); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__collections); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__defaultdict); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_INCREF(((PyObject *)((PyObject*)(&PyList_Type))));
   PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)(&PyList_Type))));
   __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyList_Type))));
-  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3837; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_t_1), NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4054; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_3);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
@@ -35131,7 +36678,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_2build(struct __pyx_o
   __pyx_v_self->index = __pyx_t_3;
   __pyx_t_3 = 0;
 
-  /* "pysam/csamtools.pyx":3841
+  /* "pysam/csamtools.pyx":4058
  *         # this method will start indexing from the current file position
  *         # if you decide
  *         cdef int ret = 1             # <<<<<<<<<<<<<<
@@ -35140,7 +36687,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_2build(struct __pyx_o
  */
   __pyx_v_ret = 1;
 
-  /* "pysam/csamtools.pyx":3842
+  /* "pysam/csamtools.pyx":4059
  *         # if you decide
  *         cdef int ret = 1
  *         cdef bam1_t * b = <bam1_t*> calloc(1, sizeof( bam1_t) )             # <<<<<<<<<<<<<<
@@ -35149,7 +36696,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_2build(struct __pyx_o
  */
   __pyx_v_b = ((bam1_t *)calloc(1, (sizeof(bam1_t))));
 
-  /* "pysam/csamtools.pyx":3846
+  /* "pysam/csamtools.pyx":4063
  *         cdef uint64_t pos
  * 
  *         while ret > 0:             # <<<<<<<<<<<<<<
@@ -35160,7 +36707,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_2build(struct __pyx_o
     __pyx_t_4 = (__pyx_v_ret > 0);
     if (!__pyx_t_4) break;
 
-    /* "pysam/csamtools.pyx":3847
+    /* "pysam/csamtools.pyx":4064
  * 
  *         while ret > 0:
  *             pos = bam_tell( self.fp.x.bam )             # <<<<<<<<<<<<<<
@@ -35169,7 +36716,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_2build(struct __pyx_o
  */
     __pyx_v_pos = bam_tell(__pyx_v_self->fp->x.bam);
 
-    /* "pysam/csamtools.pyx":3848
+    /* "pysam/csamtools.pyx":4065
  *         while ret > 0:
  *             pos = bam_tell( self.fp.x.bam )
  *             ret = samread( self.fp, b)             # <<<<<<<<<<<<<<
@@ -35178,7 +36725,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_2build(struct __pyx_o
  */
     __pyx_v_ret = samread(__pyx_v_self->fp, __pyx_v_b);
 
-    /* "pysam/csamtools.pyx":3849
+    /* "pysam/csamtools.pyx":4066
  *             pos = bam_tell( self.fp.x.bam )
  *             ret = samread( self.fp, b)
  *             if ret > 0:             # <<<<<<<<<<<<<<
@@ -35188,31 +36735,31 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_2build(struct __pyx_o
     __pyx_t_4 = (__pyx_v_ret > 0);
     if (__pyx_t_4) {
 
-      /* "pysam/csamtools.pyx":3850
+      /* "pysam/csamtools.pyx":4067
  *             ret = samread( self.fp, b)
  *             if ret > 0:
  *                 qname = _charptr_to_str(bam1_qname( b ))             # <<<<<<<<<<<<<<
  *                 self.index[qname].append( pos )
  * 
  */
-      __pyx_t_3 = __pyx_f_5pysam_9csamtools__charptr_to_str(bam1_qname(__pyx_v_b)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3850; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __pyx_f_5pysam_9csamtools__charptr_to_str(bam1_qname(__pyx_v_b)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4067; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
       __Pyx_XDECREF(__pyx_v_qname);
       __pyx_v_qname = __pyx_t_3;
       __pyx_t_3 = 0;
 
-      /* "pysam/csamtools.pyx":3851
+      /* "pysam/csamtools.pyx":4068
  *             if ret > 0:
  *                 qname = _charptr_to_str(bam1_qname( b ))
  *                 self.index[qname].append( pos )             # <<<<<<<<<<<<<<
  * 
  *         bam_destroy1( b )
  */
-      __pyx_t_3 = PyObject_GetItem(__pyx_v_self->index, __pyx_v_qname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = PyObject_GetItem(__pyx_v_self->index, __pyx_v_qname); if (!__pyx_t_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_3);
-      __pyx_t_1 = __Pyx_PyInt_to_py_uint64_t(__pyx_v_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_1 = __Pyx_PyInt_to_py_uint64_t(__pyx_v_pos); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_1);
-      __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3851; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_2 = __Pyx_PyObject_Append(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4068; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
       __Pyx_GOTREF(__pyx_t_2);
       __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
       __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
@@ -35222,7 +36769,7 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_2build(struct __pyx_o
     __pyx_L5:;
   }
 
-  /* "pysam/csamtools.pyx":3853
+  /* "pysam/csamtools.pyx":4070
  *                 self.index[qname].append( pos )
  * 
  *         bam_destroy1( b )             # <<<<<<<<<<<<<<
@@ -35259,7 +36806,7 @@ static PyObject *__pyx_pw_5pysam_9csamtools_12IndexedReads_5find(PyObject *__pyx
   return __pyx_r;
 }
 
-/* "pysam/csamtools.pyx":3855
+/* "pysam/csamtools.pyx":4072
  *         bam_destroy1( b )
  * 
  *     def find( self, qname ):             # <<<<<<<<<<<<<<
@@ -35279,19 +36826,19 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_4find(struct __pyx_ob
   int __pyx_clineno = 0;
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("find", 0);
-  __Pyx_TraceCall("find", __pyx_f[0], 3855);
+  __Pyx_TraceCall("find", __pyx_f[0], 4072);
 
-  /* "pysam/csamtools.pyx":3856
+  /* "pysam/csamtools.pyx":4073
  * 
  *     def find( self, qname ):
  *         if qname in self.index:             # <<<<<<<<<<<<<<
  *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
  *         else:
  */
-  __pyx_t_1 = (__Pyx_PySequence_Contains(__pyx_v_qname, __pyx_v_self->index, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = (__Pyx_PySequence_Contains(__pyx_v_qname, __pyx_v_self->index, Py_EQ)); if (unlikely(__pyx_t_1 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   if (__pyx_t_1) {
 
-    /* "pysam/csamtools.pyx":3857
+    /* "pysam/csamtools.pyx":4074
  *     def find( self, qname ):
  *         if qname in self.index:
  *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )             # <<<<<<<<<<<<<<
@@ -35299,9 +36846,9 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_4find(struct __pyx_ob
  *             raise KeyError( "read %s not found" % qname )
  */
     __Pyx_XDECREF(__pyx_r);
-    __pyx_t_2 = PyObject_GetItem(__pyx_v_self->index, __pyx_v_qname); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyObject_GetItem(__pyx_v_self->index, __pyx_v_qname); if (!__pyx_t_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
-    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_3);
     __Pyx_INCREF(((PyObject *)__pyx_v_self->samfile));
     PyTuple_SET_ITEM(__pyx_t_3, 0, ((PyObject *)__pyx_v_self->samfile));
@@ -35309,13 +36856,13 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_4find(struct __pyx_ob
     PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_t_2);
     __Pyx_GIVEREF(__pyx_t_2);
     __pyx_t_2 = 0;
-    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_2));
-    __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__reopen), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyDict_SetItem(__pyx_t_2, ((PyObject *)__pyx_n_s__reopen), __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowSelection)), ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3857; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_5pysam_9csamtools_IteratorRowSelection)), ((PyObject *)__pyx_t_3), ((PyObject *)__pyx_t_2)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4074; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(((PyObject *)__pyx_t_3)); __pyx_t_3 = 0;
     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
@@ -35326,26 +36873,26 @@ static PyObject *__pyx_pf_5pysam_9csamtools_12IndexedReads_4find(struct __pyx_ob
   }
   /*else*/ {
 
-    /* "pysam/csamtools.pyx":3859
+    /* "pysam/csamtools.pyx":4076
  *             return IteratorRowSelection( self.samfile, self.index[qname], reopen = False )
  *         else:
  *             raise KeyError( "read %s not found" % qname )             # <<<<<<<<<<<<<<
  * 
  *     def __dealloc__(self):
  */
-    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_190), __pyx_v_qname); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyNumber_Remainder(((PyObject *)__pyx_kp_s_198), __pyx_v_qname); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_2);
     PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)__pyx_t_4));
     __Pyx_GIVEREF(((PyObject *)__pyx_t_4));
     __pyx_t_4 = 0;
-    __pyx_t_4 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = PyObject_Call(__pyx_builtin_KeyError, ((PyObject *)__pyx_t_2), NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
     __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
     __Pyx_Raise(__pyx_t_4, 0, 0, 0);
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3859; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4076; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   }
   __pyx_L3:;
 
@@ -35373,7 +36920,7 @@ static void __pyx_pw_5pysam_9csamtools_12IndexedReads_7__dealloc__(PyObject *__p
   __Pyx_RefNannyFinishContext();
 }
 
-/* "pysam/csamtools.pyx":3861
+/* "pysam/csamtools.pyx":4078
  *             raise KeyError( "read %s not found" % qname )
  * 
  *     def __dealloc__(self):             # <<<<<<<<<<<<<<
@@ -35385,9 +36932,9 @@ static void __pyx_pf_5pysam_9csamtools_12IndexedReads_6__dealloc__(struct __pyx_
   __Pyx_RefNannyDeclarations
   __Pyx_TraceDeclarations
   __Pyx_RefNannySetupContext("__dealloc__", 0);
-  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 3861);
+  __Pyx_TraceCall("__dealloc__", __pyx_f[0], 4078);
 
-  /* "pysam/csamtools.pyx":3862
+  /* "pysam/csamtools.pyx":4079
  * 
  *     def __dealloc__(self):
  *         if self.owns_samfile: samclose( self.fp )             # <<<<<<<<<<<<<<
@@ -35443,7 +36990,7 @@ static PyMethodDef __pyx_methods_5pysam_9csamtools_Fastafile[] = {
 };
 
 static struct PyGetSetDef __pyx_getsets_5pysam_9csamtools_Fastafile[] = {
-  {(char *)"filename", __pyx_getprop_5pysam_9csamtools_9Fastafile_filename, 0, __Pyx_DOCSTR(__pyx_k_191), 0},
+  {(char *)"filename", __pyx_getprop_5pysam_9csamtools_9Fastafile_filename, 0, __Pyx_DOCSTR(__pyx_k_199), 0},
   {0, 0, 0, 0, 0}
 };
 
@@ -35505,8 +37052,398 @@ static PyNumberMethods __pyx_tp_as_number_Fastafile = {
   #endif
 };
 
-static PySequenceMethods __pyx_tp_as_sequence_Fastafile = {
-  __pyx_pw_5pysam_9csamtools_9Fastafile_5__len__, /*sq_length*/
+static PySequenceMethods __pyx_tp_as_sequence_Fastafile = {
+  __pyx_pw_5pysam_9csamtools_9Fastafile_5__len__, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_Fastafile = {
+  __pyx_pw_5pysam_9csamtools_9Fastafile_5__len__, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_Fastafile = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+static PyTypeObject __pyx_type_5pysam_9csamtools_Fastafile = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("pysam.csamtools.Fastafile"), /*tp_name*/
+  sizeof(struct __pyx_obj_5pysam_9csamtools_Fastafile), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_5pysam_9csamtools_Fastafile, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_Fastafile, /*tp_as_number*/
+  &__pyx_tp_as_sequence_Fastafile, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_Fastafile, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_Fastafile, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+  __Pyx_DOCSTR("*(filename)*\n\n    A *FASTA* file. The file is automatically opened.\n\n    The file expects an indexed fasta file.\n\n    TODO:\n        add automatic indexing.\n        add function to get sequence names.\n    "), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_5pysam_9csamtools_Fastafile, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_5pysam_9csamtools_Fastafile, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_5pysam_9csamtools_Fastafile, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+
+static PyObject *__pyx_tp_new_5pysam_9csamtools_FastqProxy(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  return o;
+}
+
+static void __pyx_tp_dealloc_5pysam_9csamtools_FastqProxy(PyObject *o) {
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_5pysam_9csamtools_10FastqProxy_name(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_5pysam_9csamtools_10FastqProxy_4name_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5pysam_9csamtools_10FastqProxy_sequence(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_5pysam_9csamtools_10FastqProxy_8sequence_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5pysam_9csamtools_10FastqProxy_comment(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_5pysam_9csamtools_10FastqProxy_7comment_1__get__(o);
+}
+
+static PyObject *__pyx_getprop_5pysam_9csamtools_10FastqProxy_quality(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_5pysam_9csamtools_10FastqProxy_7quality_1__get__(o);
+}
+
+static PyMethodDef __pyx_methods_5pysam_9csamtools_FastqProxy[] = {
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_5pysam_9csamtools_FastqProxy[] = {
+  {(char *)"name", __pyx_getprop_5pysam_9csamtools_10FastqProxy_name, 0, 0, 0},
+  {(char *)"sequence", __pyx_getprop_5pysam_9csamtools_10FastqProxy_sequence, 0, 0, 0},
+  {(char *)"comment", __pyx_getprop_5pysam_9csamtools_10FastqProxy_comment, 0, 0, 0},
+  {(char *)"quality", __pyx_getprop_5pysam_9csamtools_10FastqProxy_quality, 0, 0, 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_FastqProxy = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_FastqProxy = {
+  0, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  0, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_FastqProxy = {
+  0, /*mp_length*/
+  0, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyBufferProcs __pyx_tp_as_buffer_FastqProxy = {
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getreadbuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getwritebuffer*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getsegcount*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*bf_getcharbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_getbuffer*/
+  #endif
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*bf_releasebuffer*/
+  #endif
+};
+
+static PyTypeObject __pyx_type_5pysam_9csamtools_FastqProxy = {
+  PyVarObject_HEAD_INIT(0, 0)
+  __Pyx_NAMESTR("pysam.csamtools.FastqProxy"), /*tp_name*/
+  sizeof(struct __pyx_obj_5pysam_9csamtools_FastqProxy), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_5pysam_9csamtools_FastqProxy, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  &__pyx_tp_as_number_FastqProxy, /*tp_as_number*/
+  &__pyx_tp_as_sequence_FastqProxy, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_FastqProxy, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  &__pyx_tp_as_buffer_FastqProxy, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+  __Pyx_DOCSTR("FastqProxy()"), /*tp_doc*/
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_5pysam_9csamtools_FastqProxy, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_5pysam_9csamtools_FastqProxy, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_pw_5pysam_9csamtools_10FastqProxy_1__init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_5pysam_9csamtools_FastqProxy, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  #if PY_VERSION_HEX >= 0x02060000
+  0, /*tp_version_tag*/
+  #endif
+};
+static struct __pyx_vtabstruct_5pysam_9csamtools_Fastqfile __pyx_vtable_5pysam_9csamtools_Fastqfile;
+
+static PyObject *__pyx_tp_new_5pysam_9csamtools_Fastqfile(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_5pysam_9csamtools_Fastqfile *p;
+  PyObject *o = (*t->tp_alloc)(t, 0);
+  if (!o) return 0;
+  p = ((struct __pyx_obj_5pysam_9csamtools_Fastqfile *)o);
+  p->__pyx_vtab = __pyx_vtabptr_5pysam_9csamtools_Fastqfile;
+  if (__pyx_pw_5pysam_9csamtools_9Fastqfile_1__cinit__(o, a, k) < 0) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_5pysam_9csamtools_Fastqfile(PyObject *o) {
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pw_5pysam_9csamtools_9Fastqfile_9__dealloc__(o);
+    if (PyErr_Occurred()) PyErr_WriteUnraisable(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_5pysam_9csamtools_9Fastqfile_filename(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_5pysam_9csamtools_9Fastqfile_8filename_1__get__(o);
+}
+
+static PyMethodDef __pyx_methods_5pysam_9csamtools_Fastqfile[] = {
+  {__Pyx_NAMESTR("_isOpen"), (PyCFunction)__pyx_pw_5pysam_9csamtools_9Fastqfile_3_isOpen, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5pysam_9csamtools_9Fastqfile_2_isOpen)},
+  {__Pyx_NAMESTR("_open"), (PyCFunction)__pyx_pw_5pysam_9csamtools_9Fastqfile_5_open, METH_O, __Pyx_DOCSTR(__pyx_doc_5pysam_9csamtools_9Fastqfile_4_open)},
+  {__Pyx_NAMESTR("close"), (PyCFunction)__pyx_pw_5pysam_9csamtools_9Fastqfile_7close, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5pysam_9csamtools_9Fastqfile_6close)},
+  {__Pyx_NAMESTR("__next__"), (PyCFunction)__pyx_pw_5pysam_9csamtools_9Fastqfile_13__next__, METH_NOARGS|METH_COEXIST, __Pyx_DOCSTR(__pyx_doc_5pysam_9csamtools_9Fastqfile_12__next__)},
+  {__Pyx_NAMESTR("test"), (PyCFunction)__pyx_pw_5pysam_9csamtools_9Fastqfile_15test, METH_NOARGS, __Pyx_DOCSTR(__pyx_doc_5pysam_9csamtools_9Fastqfile_14test)},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_5pysam_9csamtools_Fastqfile[] = {
+  {(char *)"filename", __pyx_getprop_5pysam_9csamtools_9Fastqfile_filename, 0, __Pyx_DOCSTR(__pyx_k_199), 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyNumberMethods __pyx_tp_as_number_Fastqfile = {
+  0, /*nb_add*/
+  0, /*nb_subtract*/
+  0, /*nb_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_divide*/
+  #endif
+  0, /*nb_remainder*/
+  0, /*nb_divmod*/
+  0, /*nb_power*/
+  0, /*nb_negative*/
+  0, /*nb_positive*/
+  0, /*nb_absolute*/
+  0, /*nb_nonzero*/
+  0, /*nb_invert*/
+  0, /*nb_lshift*/
+  0, /*nb_rshift*/
+  0, /*nb_and*/
+  0, /*nb_xor*/
+  0, /*nb_or*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_coerce*/
+  #endif
+  0, /*nb_int*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_long*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*nb_float*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_oct*/
+  #endif
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_hex*/
+  #endif
+  0, /*nb_inplace_add*/
+  0, /*nb_inplace_subtract*/
+  0, /*nb_inplace_multiply*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*nb_inplace_divide*/
+  #endif
+  0, /*nb_inplace_remainder*/
+  0, /*nb_inplace_power*/
+  0, /*nb_inplace_lshift*/
+  0, /*nb_inplace_rshift*/
+  0, /*nb_inplace_and*/
+  0, /*nb_inplace_xor*/
+  0, /*nb_inplace_or*/
+  0, /*nb_floor_divide*/
+  0, /*nb_true_divide*/
+  0, /*nb_inplace_floor_divide*/
+  0, /*nb_inplace_true_divide*/
+  #if PY_VERSION_HEX >= 0x02050000
+  0, /*nb_index*/
+  #endif
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_Fastqfile = {
+  0, /*sq_length*/
   0, /*sq_concat*/
   0, /*sq_repeat*/
   0, /*sq_item*/
@@ -35518,13 +37455,13 @@ static PySequenceMethods __pyx_tp_as_sequence_Fastafile = {
   0, /*sq_inplace_repeat*/
 };
 
-static PyMappingMethods __pyx_tp_as_mapping_Fastafile = {
-  __pyx_pw_5pysam_9csamtools_9Fastafile_5__len__, /*mp_length*/
+static PyMappingMethods __pyx_tp_as_mapping_Fastqfile = {
+  0, /*mp_length*/
   0, /*mp_subscript*/
   0, /*mp_ass_subscript*/
 };
 
-static PyBufferProcs __pyx_tp_as_buffer_Fastafile = {
+static PyBufferProcs __pyx_tp_as_buffer_Fastqfile = {
   #if PY_MAJOR_VERSION < 3
   0, /*bf_getreadbuffer*/
   #endif
@@ -35545,12 +37482,12 @@ static PyBufferProcs __pyx_tp_as_buffer_Fastafile = {
   #endif
 };
 
-static PyTypeObject __pyx_type_5pysam_9csamtools_Fastafile = {
+static PyTypeObject __pyx_type_5pysam_9csamtools_Fastqfile = {
   PyVarObject_HEAD_INIT(0, 0)
-  __Pyx_NAMESTR("pysam.csamtools.Fastafile"), /*tp_name*/
-  sizeof(struct __pyx_obj_5pysam_9csamtools_Fastafile), /*tp_basicsize*/
+  __Pyx_NAMESTR("pysam.csamtools.Fastqfile"), /*tp_name*/
+  sizeof(struct __pyx_obj_5pysam_9csamtools_Fastqfile), /*tp_basicsize*/
   0, /*tp_itemsize*/
-  __pyx_tp_dealloc_5pysam_9csamtools_Fastafile, /*tp_dealloc*/
+  __pyx_tp_dealloc_5pysam_9csamtools_Fastqfile, /*tp_dealloc*/
   0, /*tp_print*/
   0, /*tp_getattr*/
   0, /*tp_setattr*/
@@ -35560,26 +37497,26 @@ static PyTypeObject __pyx_type_5pysam_9csamtools_Fastafile = {
   0, /*reserved*/
   #endif
   0, /*tp_repr*/
-  &__pyx_tp_as_number_Fastafile, /*tp_as_number*/
-  &__pyx_tp_as_sequence_Fastafile, /*tp_as_sequence*/
-  &__pyx_tp_as_mapping_Fastafile, /*tp_as_mapping*/
+  &__pyx_tp_as_number_Fastqfile, /*tp_as_number*/
+  &__pyx_tp_as_sequence_Fastqfile, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_Fastqfile, /*tp_as_mapping*/
   0, /*tp_hash*/
   0, /*tp_call*/
   0, /*tp_str*/
   0, /*tp_getattro*/
   0, /*tp_setattro*/
-  &__pyx_tp_as_buffer_Fastafile, /*tp_as_buffer*/
+  &__pyx_tp_as_buffer_Fastqfile, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
-  __Pyx_DOCSTR("*(filename)*\n\n    A *FASTA* file. The file is automatically opened.\n\n    The file expects an indexed fasta file.\n\n    TODO:\n        add automatic indexing.\n        add function to get sequence names.\n    "), /*tp_doc*/
+  __Pyx_DOCSTR("*(filename)*\n\n    A *FASTQ* file. The file is automatically opened.\n\n    "), /*tp_doc*/
   0, /*tp_traverse*/
   0, /*tp_clear*/
   0, /*tp_richcompare*/
   0, /*tp_weaklistoffset*/
-  0, /*tp_iter*/
-  0, /*tp_iternext*/
-  __pyx_methods_5pysam_9csamtools_Fastafile, /*tp_methods*/
+  __pyx_pw_5pysam_9csamtools_9Fastqfile_11__iter__, /*tp_iter*/
+  __pyx_pw_5pysam_9csamtools_9Fastqfile_13__next__, /*tp_iternext*/
+  __pyx_methods_5pysam_9csamtools_Fastqfile, /*tp_methods*/
   0, /*tp_members*/
-  __pyx_getsets_5pysam_9csamtools_Fastafile, /*tp_getset*/
+  __pyx_getsets_5pysam_9csamtools_Fastqfile, /*tp_getset*/
   0, /*tp_base*/
   0, /*tp_dict*/
   0, /*tp_descr_get*/
@@ -35587,7 +37524,7 @@ static PyTypeObject __pyx_type_5pysam_9csamtools_Fastafile = {
   0, /*tp_dictoffset*/
   0, /*tp_init*/
   0, /*tp_alloc*/
-  __pyx_tp_new_5pysam_9csamtools_Fastafile, /*tp_new*/
+  __pyx_tp_new_5pysam_9csamtools_Fastqfile, /*tp_new*/
   0, /*tp_free*/
   0, /*tp_is_gc*/
   0, /*tp_bases*/
@@ -36062,6 +37999,10 @@ static PyObject *__pyx_getprop_5pysam_9csamtools_11AlignedRead_positions(PyObjec
   return __pyx_pw_5pysam_9csamtools_11AlignedRead_9positions_1__get__(o);
 }
 
+static PyObject *__pyx_getprop_5pysam_9csamtools_11AlignedRead_inferred_length(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_5pysam_9csamtools_11AlignedRead_15inferred_length_1__get__(o);
+}
+
 static PyObject *__pyx_getprop_5pysam_9csamtools_11AlignedRead_aligned_pairs(PyObject *o, CYTHON_UNUSED void *x) {
   return __pyx_pw_5pysam_9csamtools_11AlignedRead_13aligned_pairs_1__get__(o);
 }
@@ -36075,45 +38016,46 @@ static PyMethodDef __pyx_methods_5pysam_9csamtools_AlignedRead[] = {
 };
 
 static struct PyGetSetDef __pyx_getsets_5pysam_9csamtools_AlignedRead[] = {
-  {(char *)"qname", __pyx_getprop_5pysam_9csamtools_11AlignedRead_qname, __pyx_setprop_5pysam_9csamtools_11AlignedRead_qname, __Pyx_DOCSTR(__pyx_k_192), 0},
-  {(char *)"cigar", __pyx_getprop_5pysam_9csamtools_11AlignedRead_cigar, __pyx_setprop_5pysam_9csamtools_11AlignedRead_cigar, __Pyx_DOCSTR(__pyx_k_193), 0},
-  {(char *)"cigarstring", __pyx_getprop_5pysam_9csamtools_11AlignedRead_cigarstring, __pyx_setprop_5pysam_9csamtools_11AlignedRead_cigarstring, __Pyx_DOCSTR(__pyx_k_194), 0},
-  {(char *)"seq", __pyx_getprop_5pysam_9csamtools_11AlignedRead_seq, __pyx_setprop_5pysam_9csamtools_11AlignedRead_seq, __Pyx_DOCSTR(__pyx_k_195), 0},
-  {(char *)"qual", __pyx_getprop_5pysam_9csamtools_11AlignedRead_qual, __pyx_setprop_5pysam_9csamtools_11AlignedRead_qual, __Pyx_DOCSTR(__pyx_k_196), 0},
-  {(char *)"query", __pyx_getprop_5pysam_9csamtools_11AlignedRead_query, 0, __Pyx_DOCSTR(__pyx_k_197), 0},
-  {(char *)"qqual", __pyx_getprop_5pysam_9csamtools_11AlignedRead_qqual, 0, __Pyx_DOCSTR(__pyx_k_198), 0},
-  {(char *)"qstart", __pyx_getprop_5pysam_9csamtools_11AlignedRead_qstart, 0, __Pyx_DOCSTR(__pyx_k_199), 0},
-  {(char *)"qend", __pyx_getprop_5pysam_9csamtools_11AlignedRead_qend, 0, __Pyx_DOCSTR(__pyx_k_200), 0},
-  {(char *)"qlen", __pyx_getprop_5pysam_9csamtools_11AlignedRead_qlen, 0, __Pyx_DOCSTR(__pyx_k_201), 0},
-  {(char *)"tags", __pyx_getprop_5pysam_9csamtools_11AlignedRead_tags, __pyx_setprop_5pysam_9csamtools_11AlignedRead_tags, __Pyx_DOCSTR(__pyx_k_202), 0},
-  {(char *)"flag", __pyx_getprop_5pysam_9csamtools_11AlignedRead_flag, __pyx_setprop_5pysam_9csamtools_11AlignedRead_flag, __Pyx_DOCSTR(__pyx_k_203), 0},
-  {(char *)"rname", __pyx_getprop_5pysam_9csamtools_11AlignedRead_rname, __pyx_setprop_5pysam_9csamtools_11AlignedRead_rname, __Pyx_DOCSTR(__pyx_k_204), 0},
-  {(char *)"tid", __pyx_getprop_5pysam_9csamtools_11AlignedRead_tid, __pyx_setprop_5pysam_9csamtools_11AlignedRead_tid, __Pyx_DOCSTR(__pyx_k_205), 0},
-  {(char *)"pos", __pyx_getprop_5pysam_9csamtools_11AlignedRead_pos, __pyx_setprop_5pysam_9csamtools_11AlignedRead_pos, __Pyx_DOCSTR(__pyx_k_206), 0},
-  {(char *)"bin", __pyx_getprop_5pysam_9csamtools_11AlignedRead_bin, __pyx_setprop_5pysam_9csamtools_11AlignedRead_bin, __Pyx_DOCSTR(__pyx_k_207), 0},
-  {(char *)"rlen", __pyx_getprop_5pysam_9csamtools_11AlignedRead_rlen, 0, __Pyx_DOCSTR(__pyx_k_208), 0},
-  {(char *)"aend", __pyx_getprop_5pysam_9csamtools_11AlignedRead_aend, 0, __Pyx_DOCSTR(__pyx_k_209), 0},
-  {(char *)"alen", __pyx_getprop_5pysam_9csamtools_11AlignedRead_alen, 0, __Pyx_DOCSTR(__pyx_k_210), 0},
-  {(char *)"mapq", __pyx_getprop_5pysam_9csamtools_11AlignedRead_mapq, __pyx_setprop_5pysam_9csamtools_11AlignedRead_mapq, __Pyx_DOCSTR(__pyx_k_211), 0},
-  {(char *)"mrnm", __pyx_getprop_5pysam_9csamtools_11AlignedRead_mrnm, __pyx_setprop_5pysam_9csamtools_11AlignedRead_mrnm, __Pyx_DOCSTR(__pyx_k_212), 0},
-  {(char *)"rnext", __pyx_getprop_5pysam_9csamtools_11AlignedRead_rnext, __pyx_setprop_5pysam_9csamtools_11AlignedRead_rnext, __Pyx_DOCSTR(__pyx_k_213), 0},
-  {(char *)"mpos", __pyx_getprop_5pysam_9csamtools_11AlignedRead_mpos, __pyx_setprop_5pysam_9csamtools_11AlignedRead_mpos, __Pyx_DOCSTR(__pyx_k_214), 0},
-  {(char *)"pnext", __pyx_getprop_5pysam_9csamtools_11AlignedRead_pnext, __pyx_setprop_5pysam_9csamtools_11AlignedRead_pnext, __Pyx_DOCSTR(__pyx_k_215), 0},
-  {(char *)"isize", __pyx_getprop_5pysam_9csamtools_11AlignedRead_isize, __pyx_setprop_5pysam_9csamtools_11AlignedRead_isize, __Pyx_DOCSTR(__pyx_k_216), 0},
-  {(char *)"tlen", __pyx_getprop_5pysam_9csamtools_11AlignedRead_tlen, __pyx_setprop_5pysam_9csamtools_11AlignedRead_tlen, __Pyx_DOCSTR(__pyx_k_217), 0},
-  {(char *)"is_paired", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_paired, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_paired, __Pyx_DOCSTR(__pyx_k_218), 0},
-  {(char *)"is_proper_pair", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_proper_pair, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_proper_pair, __Pyx_DOCSTR(__pyx_k_219), 0},
-  {(char *)"is_unmapped", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_unmapped, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_unmapped, __Pyx_DOCSTR(__pyx_k_220), 0},
-  {(char *)"mate_is_unmapped", __pyx_getprop_5pysam_9csamtools_11AlignedRead_mate_is_unmapped, __pyx_setprop_5pysam_9csamtools_11AlignedRead_mate_is_unmapped, __Pyx_DOCSTR(__pyx_k_221), 0},
-  {(char *)"is_reverse", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_reverse, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_reverse, __Pyx_DOCSTR(__pyx_k_222), 0},
-  {(char *)"mate_is_reverse", __pyx_getprop_5pysam_9csamtools_11AlignedRead_mate_is_reverse, __pyx_setprop_5pysam_9csamtools_11AlignedRead_mate_is_reverse, __Pyx_DOCSTR(__pyx_k_223), 0},
-  {(char *)"is_read1", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_read1, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_read1, __Pyx_DOCSTR(__pyx_k_224), 0},
-  {(char *)"is_read2", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_read2, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_read2, __Pyx_DOCSTR(__pyx_k_225), 0},
-  {(char *)"is_secondary", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_secondary, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_secondary, __Pyx_DOCSTR(__pyx_k_226), 0},
-  {(char *)"is_qcfail", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_qcfail, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_qcfail, __Pyx_DOCSTR(__pyx_k_227), 0},
-  {(char *)"is_duplicate", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_duplicate, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_duplicate, __Pyx_DOCSTR(__pyx_k_228), 0},
-  {(char *)"positions", __pyx_getprop_5pysam_9csamtools_11AlignedRead_positions, 0, __Pyx_DOCSTR(__pyx_k_229), 0},
-  {(char *)"aligned_pairs", __pyx_getprop_5pysam_9csamtools_11AlignedRead_aligned_pairs, 0, __Pyx_DOCSTR(__pyx_k_230), 0},
+  {(char *)"qname", __pyx_getprop_5pysam_9csamtools_11AlignedRead_qname, __pyx_setprop_5pysam_9csamtools_11AlignedRead_qname, __Pyx_DOCSTR(__pyx_k_200), 0},
+  {(char *)"cigar", __pyx_getprop_5pysam_9csamtools_11AlignedRead_cigar, __pyx_setprop_5pysam_9csamtools_11AlignedRead_cigar, __Pyx_DOCSTR(__pyx_k_201), 0},
+  {(char *)"cigarstring", __pyx_getprop_5pysam_9csamtools_11AlignedRead_cigarstring, __pyx_setprop_5pysam_9csamtools_11AlignedRead_cigarstring, __Pyx_DOCSTR(__pyx_k_202), 0},
+  {(char *)"seq", __pyx_getprop_5pysam_9csamtools_11AlignedRead_seq, __pyx_setprop_5pysam_9csamtools_11AlignedRead_seq, __Pyx_DOCSTR(__pyx_k_203), 0},
+  {(char *)"qual", __pyx_getprop_5pysam_9csamtools_11AlignedRead_qual, __pyx_setprop_5pysam_9csamtools_11AlignedRead_qual, __Pyx_DOCSTR(__pyx_k_204), 0},
+  {(char *)"query", __pyx_getprop_5pysam_9csamtools_11AlignedRead_query, 0, __Pyx_DOCSTR(__pyx_k_205), 0},
+  {(char *)"qqual", __pyx_getprop_5pysam_9csamtools_11AlignedRead_qqual, 0, __Pyx_DOCSTR(__pyx_k_206), 0},
+  {(char *)"qstart", __pyx_getprop_5pysam_9csamtools_11AlignedRead_qstart, 0, __Pyx_DOCSTR(__pyx_k_207), 0},
+  {(char *)"qend", __pyx_getprop_5pysam_9csamtools_11AlignedRead_qend, 0, __Pyx_DOCSTR(__pyx_k_208), 0},
+  {(char *)"qlen", __pyx_getprop_5pysam_9csamtools_11AlignedRead_qlen, 0, __Pyx_DOCSTR(__pyx_k_209), 0},
+  {(char *)"tags", __pyx_getprop_5pysam_9csamtools_11AlignedRead_tags, __pyx_setprop_5pysam_9csamtools_11AlignedRead_tags, __Pyx_DOCSTR(__pyx_k_210), 0},
+  {(char *)"flag", __pyx_getprop_5pysam_9csamtools_11AlignedRead_flag, __pyx_setprop_5pysam_9csamtools_11AlignedRead_flag, __Pyx_DOCSTR(__pyx_k_211), 0},
+  {(char *)"rname", __pyx_getprop_5pysam_9csamtools_11AlignedRead_rname, __pyx_setprop_5pysam_9csamtools_11AlignedRead_rname, __Pyx_DOCSTR(__pyx_k_212), 0},
+  {(char *)"tid", __pyx_getprop_5pysam_9csamtools_11AlignedRead_tid, __pyx_setprop_5pysam_9csamtools_11AlignedRead_tid, __Pyx_DOCSTR(__pyx_k_213), 0},
+  {(char *)"pos", __pyx_getprop_5pysam_9csamtools_11AlignedRead_pos, __pyx_setprop_5pysam_9csamtools_11AlignedRead_pos, __Pyx_DOCSTR(__pyx_k_214), 0},
+  {(char *)"bin", __pyx_getprop_5pysam_9csamtools_11AlignedRead_bin, __pyx_setprop_5pysam_9csamtools_11AlignedRead_bin, __Pyx_DOCSTR(__pyx_k_215), 0},
+  {(char *)"rlen", __pyx_getprop_5pysam_9csamtools_11AlignedRead_rlen, 0, __Pyx_DOCSTR(__pyx_k_216), 0},
+  {(char *)"aend", __pyx_getprop_5pysam_9csamtools_11AlignedRead_aend, 0, __Pyx_DOCSTR(__pyx_k_217), 0},
+  {(char *)"alen", __pyx_getprop_5pysam_9csamtools_11AlignedRead_alen, 0, __Pyx_DOCSTR(__pyx_k_218), 0},
+  {(char *)"mapq", __pyx_getprop_5pysam_9csamtools_11AlignedRead_mapq, __pyx_setprop_5pysam_9csamtools_11AlignedRead_mapq, __Pyx_DOCSTR(__pyx_k_219), 0},
+  {(char *)"mrnm", __pyx_getprop_5pysam_9csamtools_11AlignedRead_mrnm, __pyx_setprop_5pysam_9csamtools_11AlignedRead_mrnm, __Pyx_DOCSTR(__pyx_k_220), 0},
+  {(char *)"rnext", __pyx_getprop_5pysam_9csamtools_11AlignedRead_rnext, __pyx_setprop_5pysam_9csamtools_11AlignedRead_rnext, __Pyx_DOCSTR(__pyx_k_221), 0},
+  {(char *)"mpos", __pyx_getprop_5pysam_9csamtools_11AlignedRead_mpos, __pyx_setprop_5pysam_9csamtools_11AlignedRead_mpos, __Pyx_DOCSTR(__pyx_k_222), 0},
+  {(char *)"pnext", __pyx_getprop_5pysam_9csamtools_11AlignedRead_pnext, __pyx_setprop_5pysam_9csamtools_11AlignedRead_pnext, __Pyx_DOCSTR(__pyx_k_223), 0},
+  {(char *)"isize", __pyx_getprop_5pysam_9csamtools_11AlignedRead_isize, __pyx_setprop_5pysam_9csamtools_11AlignedRead_isize, __Pyx_DOCSTR(__pyx_k_224), 0},
+  {(char *)"tlen", __pyx_getprop_5pysam_9csamtools_11AlignedRead_tlen, __pyx_setprop_5pysam_9csamtools_11AlignedRead_tlen, __Pyx_DOCSTR(__pyx_k_225), 0},
+  {(char *)"is_paired", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_paired, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_paired, __Pyx_DOCSTR(__pyx_k_226), 0},
+  {(char *)"is_proper_pair", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_proper_pair, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_proper_pair, __Pyx_DOCSTR(__pyx_k_227), 0},
+  {(char *)"is_unmapped", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_unmapped, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_unmapped, __Pyx_DOCSTR(__pyx_k_228), 0},
+  {(char *)"mate_is_unmapped", __pyx_getprop_5pysam_9csamtools_11AlignedRead_mate_is_unmapped, __pyx_setprop_5pysam_9csamtools_11AlignedRead_mate_is_unmapped, __Pyx_DOCSTR(__pyx_k_229), 0},
+  {(char *)"is_reverse", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_reverse, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_reverse, __Pyx_DOCSTR(__pyx_k_230), 0},
+  {(char *)"mate_is_reverse", __pyx_getprop_5pysam_9csamtools_11AlignedRead_mate_is_reverse, __pyx_setprop_5pysam_9csamtools_11AlignedRead_mate_is_reverse, __Pyx_DOCSTR(__pyx_k_231), 0},
+  {(char *)"is_read1", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_read1, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_read1, __Pyx_DOCSTR(__pyx_k_232), 0},
+  {(char *)"is_read2", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_read2, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_read2, __Pyx_DOCSTR(__pyx_k_233), 0},
+  {(char *)"is_secondary", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_secondary, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_secondary, __Pyx_DOCSTR(__pyx_k_234), 0},
+  {(char *)"is_qcfail", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_qcfail, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_qcfail, __Pyx_DOCSTR(__pyx_k_235), 0},
+  {(char *)"is_duplicate", __pyx_getprop_5pysam_9csamtools_11AlignedRead_is_duplicate, __pyx_setprop_5pysam_9csamtools_11AlignedRead_is_duplicate, __Pyx_DOCSTR(__pyx_k_236), 0},
+  {(char *)"positions", __pyx_getprop_5pysam_9csamtools_11AlignedRead_positions, 0, __Pyx_DOCSTR(__pyx_k_237), 0},
+  {(char *)"inferred_length", __pyx_getprop_5pysam_9csamtools_11AlignedRead_inferred_length, 0, __Pyx_DOCSTR(__pyx_k_238), 0},
+  {(char *)"aligned_pairs", __pyx_getprop_5pysam_9csamtools_11AlignedRead_aligned_pairs, 0, __Pyx_DOCSTR(__pyx_k_239), 0},
   {0, 0, 0, 0, 0}
 };
 
@@ -36353,14 +38295,14 @@ static PyMethodDef __pyx_methods_5pysam_9csamtools_Samfile[] = {
 };
 
 static struct PyGetSetDef __pyx_getsets_5pysam_9csamtools_Samfile[] = {
-  {(char *)"filename", __pyx_getprop_5pysam_9csamtools_7Samfile_filename, 0, __Pyx_DOCSTR(__pyx_k_191), 0},
-  {(char *)"nreferences", __pyx_getprop_5pysam_9csamtools_7Samfile_nreferences, 0, __Pyx_DOCSTR(__pyx_k_231), 0},
-  {(char *)"references", __pyx_getprop_5pysam_9csamtools_7Samfile_references, 0, __Pyx_DOCSTR(__pyx_k_232), 0},
-  {(char *)"lengths", __pyx_getprop_5pysam_9csamtools_7Samfile_lengths, 0, __Pyx_DOCSTR(__pyx_k_233), 0},
-  {(char *)"mapped", __pyx_getprop_5pysam_9csamtools_7Samfile_mapped, 0, __Pyx_DOCSTR(__pyx_k_234), 0},
-  {(char *)"unmapped", __pyx_getprop_5pysam_9csamtools_7Samfile_unmapped, 0, __Pyx_DOCSTR(__pyx_k_235), 0},
-  {(char *)"text", __pyx_getprop_5pysam_9csamtools_7Samfile_text, 0, __Pyx_DOCSTR(__pyx_k_236), 0},
-  {(char *)"header", __pyx_getprop_5pysam_9csamtools_7Samfile_header, 0, __Pyx_DOCSTR(__pyx_k_237), 0},
+  {(char *)"filename", __pyx_getprop_5pysam_9csamtools_7Samfile_filename, 0, __Pyx_DOCSTR(__pyx_k_199), 0},
+  {(char *)"nreferences", __pyx_getprop_5pysam_9csamtools_7Samfile_nreferences, 0, __Pyx_DOCSTR(__pyx_k_240), 0},
+  {(char *)"references", __pyx_getprop_5pysam_9csamtools_7Samfile_references, 0, __Pyx_DOCSTR(__pyx_k_241), 0},
+  {(char *)"lengths", __pyx_getprop_5pysam_9csamtools_7Samfile_lengths, 0, __Pyx_DOCSTR(__pyx_k_242), 0},
+  {(char *)"mapped", __pyx_getprop_5pysam_9csamtools_7Samfile_mapped, 0, __Pyx_DOCSTR(__pyx_k_243), 0},
+  {(char *)"unmapped", __pyx_getprop_5pysam_9csamtools_7Samfile_unmapped, 0, __Pyx_DOCSTR(__pyx_k_244), 0},
+  {(char *)"text", __pyx_getprop_5pysam_9csamtools_7Samfile_text, 0, __Pyx_DOCSTR(__pyx_k_245), 0},
+  {(char *)"header", __pyx_getprop_5pysam_9csamtools_7Samfile_header, 0, __Pyx_DOCSTR(__pyx_k_246), 0},
   {0, 0, 0, 0, 0}
 };
 
@@ -36559,10 +38501,10 @@ static PyMethodDef __pyx_methods_5pysam_9csamtools_PileupProxy[] = {
 };
 
 static struct PyGetSetDef __pyx_getsets_5pysam_9csamtools_PileupProxy[] = {
-  {(char *)"tid", __pyx_getprop_5pysam_9csamtools_11PileupProxy_tid, 0, __Pyx_DOCSTR(__pyx_k_238), 0},
-  {(char *)"n", __pyx_getprop_5pysam_9csamtools_11PileupProxy_n, __pyx_setprop_5pysam_9csamtools_11PileupProxy_n, __Pyx_DOCSTR(__pyx_k_239), 0},
+  {(char *)"tid", __pyx_getprop_5pysam_9csamtools_11PileupProxy_tid, 0, __Pyx_DOCSTR(__pyx_k_247), 0},
+  {(char *)"n", __pyx_getprop_5pysam_9csamtools_11PileupProxy_n, __pyx_setprop_5pysam_9csamtools_11PileupProxy_n, __Pyx_DOCSTR(__pyx_k_248), 0},
   {(char *)"pos", __pyx_getprop_5pysam_9csamtools_11PileupProxy_pos, 0, 0, 0},
-  {(char *)"pileups", __pyx_getprop_5pysam_9csamtools_11PileupProxy_pileups, 0, __Pyx_DOCSTR(__pyx_k_240), 0},
+  {(char *)"pileups", __pyx_getprop_5pysam_9csamtools_11PileupProxy_pileups, 0, __Pyx_DOCSTR(__pyx_k_249), 0},
   {0, 0, 0, 0, 0}
 };
 
@@ -36788,10 +38730,10 @@ static PyMethodDef __pyx_methods_5pysam_9csamtools_PileupRead[] = {
 };
 
 static struct PyGetSetDef __pyx_getsets_5pysam_9csamtools_PileupRead[] = {
-  {(char *)"alignment", __pyx_getprop_5pysam_9csamtools_10PileupRead_alignment, 0, __Pyx_DOCSTR(__pyx_k_241), 0},
-  {(char *)"qpos", __pyx_getprop_5pysam_9csamtools_10PileupRead_qpos, 0, __Pyx_DOCSTR(__pyx_k_242), 0},
-  {(char *)"indel", __pyx_getprop_5pysam_9csamtools_10PileupRead_indel, 0, __Pyx_DOCSTR(__pyx_k_243), 0},
-  {(char *)"is_del", __pyx_getprop_5pysam_9csamtools_10PileupRead_is_del, 0, __Pyx_DOCSTR(__pyx_k_244), 0},
+  {(char *)"alignment", __pyx_getprop_5pysam_9csamtools_10PileupRead_alignment, 0, __Pyx_DOCSTR(__pyx_k_250), 0},
+  {(char *)"qpos", __pyx_getprop_5pysam_9csamtools_10PileupRead_qpos, 0, __Pyx_DOCSTR(__pyx_k_251), 0},
+  {(char *)"indel", __pyx_getprop_5pysam_9csamtools_10PileupRead_indel, 0, __Pyx_DOCSTR(__pyx_k_252), 0},
+  {(char *)"is_del", __pyx_getprop_5pysam_9csamtools_10PileupRead_is_del, 0, __Pyx_DOCSTR(__pyx_k_253), 0},
   {(char *)"is_head", __pyx_getprop_5pysam_9csamtools_10PileupRead_is_head, 0, 0, 0},
   {(char *)"is_tail", __pyx_getprop_5pysam_9csamtools_10PileupRead_is_tail, 0, 0, 0},
   {(char *)"level", __pyx_getprop_5pysam_9csamtools_10PileupRead_level, 0, 0, 0},
@@ -37089,7 +39031,7 @@ static PyTypeObject __pyx_type_5pysam_9csamtools_IteratorRow = {
   0, /*tp_setattro*/
   &__pyx_tp_as_buffer_IteratorRow, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
-  __Pyx_DOCSTR("abstract base class for iterators over mapped reads.\n\n    Various iterators implement different behaviours for wrapping around\n    contig boundaries. Examples include:\n\n    :class:`pysam.IteratorRowRegion`\n        iterate within a single contig and a defined region.\n\n    :class:`pysam.IteratorRowAll`\n        iterate until EOF. This iterator will also include unmapped reads.\n\n    :class:`pysam.IteratorRowAllRefs`\n        iterate over all reads in all reference  [...]
+  __Pyx_DOCSTR("abstract base class for iterators over mapped reads.\n\n    Various iterators implement different behaviours for wrapping around\n    contig boundaries. Examples include:\n\n    :class:`pysam.IteratorRowRegion`\n        iterate within a single contig and a defined region.\n\n    :class:`pysam.IteratorRowAll`\n        iterate until EOF. This iterator will also include unmapped reads.\n\n    :class:`pysam.IteratorRowAllRefs`\n        iterate over all reads in all reference  [...]
   0, /*tp_traverse*/
   0, /*tp_clear*/
   0, /*tp_richcompare*/
@@ -37299,7 +39241,7 @@ static PyTypeObject __pyx_type_5pysam_9csamtools_IteratorRowRegion = {
   0, /*tp_setattro*/
   &__pyx_tp_as_buffer_IteratorRowRegion, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("*(Samfile samfile, int tid, int beg, int end, int reopen = True )*\n\n    iterate over mapped reads in a region.\n\n    By default, the file is re-openend to avoid conflicts between\n    multiple iterators working on the same file. Set *reopen* = False\n    to not re-open *samfile*.\n\n    The samtools iterators assume that the file\n    position between iterations do not change.\n    As a consequence, no two iterators can work\n    on the same file. To permit this, each  [...]
+  __Pyx_DOCSTR("*(Samfile samfile, int tid, int beg, int end, int reopen = True )*\n\n    iterate over mapped reads in a region.\n\n    By default, the file is re-openend to avoid conflicts between\n    multiple iterators working on the same file. Set *reopen* = False\n    to not re-open *samfile*.\n\n    The samtools iterators assume that the file\n    position between iterations do not change.\n    As a consequence, no two iterators can work\n    on the same file. To permit this, each  [...]
   __pyx_tp_traverse_5pysam_9csamtools_IteratorRowRegion, /*tp_traverse*/
   __pyx_tp_clear_5pysam_9csamtools_IteratorRowRegion, /*tp_clear*/
   0, /*tp_richcompare*/
@@ -37484,7 +39426,7 @@ static PyTypeObject __pyx_type_5pysam_9csamtools_IteratorRowAll = {
   0, /*tp_setattro*/
   &__pyx_tp_as_buffer_IteratorRowAll, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
-  __Pyx_DOCSTR("*(Samfile samfile, int reopen = True)*\n\n    iterate over all reads in *samfile*\n\n    By default, the file is re-openend to avoid conflicts between\n    multiple iterators working on the same file. Set *reopen* = False\n    to not re-open *samfile*.\n    "), /*tp_doc*/
+  __Pyx_DOCSTR("*(Samfile samfile, int reopen = True)*\n\n    iterate over all reads in *samfile*\n\n    By default, the file is re-openend to avoid conflicts between\n    multiple iterators working on the same file. Set *reopen* = False\n    to not re-open *samfile*.\n\n    .. note::\n        It is usually not necessary to create an object of this class\n        explicitely. It is returned as a result of call to a :meth:`Samfile.fetch`.\n        \n\n    "), /*tp_doc*/
   0, /*tp_traverse*/
   0, /*tp_clear*/
   0, /*tp_richcompare*/
@@ -37692,7 +39634,7 @@ static PyTypeObject __pyx_type_5pysam_9csamtools_IteratorRowAllRefs = {
   0, /*tp_setattro*/
   &__pyx_tp_as_buffer_IteratorRowAllRefs, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("iterates over all mapped reads by chaining iterators over each reference\n    "), /*tp_doc*/
+  __Pyx_DOCSTR("iterates over all mapped reads by chaining iterators over each reference\n\n    .. note::\n        It is usually not necessary to create an object of this class\n        explicitely. It is returned as a result of call to a :meth:`Samfile.fetch`.\n    "), /*tp_doc*/
   __pyx_tp_traverse_5pysam_9csamtools_IteratorRowAllRefs, /*tp_traverse*/
   __pyx_tp_clear_5pysam_9csamtools_IteratorRowAllRefs, /*tp_clear*/
   0, /*tp_richcompare*/
@@ -37902,7 +39844,7 @@ static PyTypeObject __pyx_type_5pysam_9csamtools_IteratorRowSelection = {
   0, /*tp_setattro*/
   &__pyx_tp_as_buffer_IteratorRowSelection, /*tp_as_buffer*/
   Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
-  __Pyx_DOCSTR("*(Samfile samfile)*\n\n    iterate over reads in *samfile* at a given list of file positions.\n    "), /*tp_doc*/
+  __Pyx_DOCSTR("*(Samfile samfile)*\n\n    iterate over reads in *samfile* at a given list of file positions.\n\n    .. note::\n        It is usually not necessary to create an object of this class\n        explicitely. It is returned as a result of call to a :meth:`Samfile.fetch`.\n    "), /*tp_doc*/
   __pyx_tp_traverse_5pysam_9csamtools_IteratorRowSelection, /*tp_traverse*/
   __pyx_tp_clear_5pysam_9csamtools_IteratorRowSelection, /*tp_clear*/
   0, /*tp_richcompare*/
@@ -38017,7 +39959,7 @@ static PyMethodDef __pyx_methods_5pysam_9csamtools_IteratorColumn[] = {
 };
 
 static struct PyGetSetDef __pyx_getsets_5pysam_9csamtools_IteratorColumn[] = {
-  {(char *)"seq_len", __pyx_getprop_5pysam_9csamtools_14IteratorColumn_seq_len, 0, __Pyx_DOCSTR(__pyx_k_245), 0},
+  {(char *)"seq_len", __pyx_getprop_5pysam_9csamtools_14IteratorColumn_seq_len, 0, __Pyx_DOCSTR(__pyx_k_254), 0},
   {0, 0, 0, 0, 0}
 };
 
@@ -38786,14 +40728,14 @@ static PyMethodDef __pyx_methods_5pysam_9csamtools_SNPCall[] = {
 };
 
 static struct PyGetSetDef __pyx_getsets_5pysam_9csamtools_SNPCall[] = {
-  {(char *)"tid", __pyx_getprop_5pysam_9csamtools_7SNPCall_tid, 0, __Pyx_DOCSTR(__pyx_k_238), 0},
-  {(char *)"pos", __pyx_getprop_5pysam_9csamtools_7SNPCall_pos, 0, __Pyx_DOCSTR(__pyx_k_246), 0},
-  {(char *)"reference_base", __pyx_getprop_5pysam_9csamtools_7SNPCall_reference_base, 0, __Pyx_DOCSTR(__pyx_k_247), 0},
-  {(char *)"genotype", __pyx_getprop_5pysam_9csamtools_7SNPCall_genotype, 0, __Pyx_DOCSTR(__pyx_k_248), 0},
-  {(char *)"consensus_quality", __pyx_getprop_5pysam_9csamtools_7SNPCall_consensus_quality, 0, __Pyx_DOCSTR(__pyx_k_249), 0},
-  {(char *)"snp_quality", __pyx_getprop_5pysam_9csamtools_7SNPCall_snp_quality, 0, __Pyx_DOCSTR(__pyx_k_250), 0},
-  {(char *)"mapping_quality", __pyx_getprop_5pysam_9csamtools_7SNPCall_mapping_quality, 0, __Pyx_DOCSTR(__pyx_k_251), 0},
-  {(char *)"coverage", __pyx_getprop_5pysam_9csamtools_7SNPCall_coverage, 0, __Pyx_DOCSTR(__pyx_k_252), 0},
+  {(char *)"tid", __pyx_getprop_5pysam_9csamtools_7SNPCall_tid, 0, __Pyx_DOCSTR(__pyx_k_247), 0},
+  {(char *)"pos", __pyx_getprop_5pysam_9csamtools_7SNPCall_pos, 0, __Pyx_DOCSTR(__pyx_k_255), 0},
+  {(char *)"reference_base", __pyx_getprop_5pysam_9csamtools_7SNPCall_reference_base, 0, __Pyx_DOCSTR(__pyx_k_256), 0},
+  {(char *)"genotype", __pyx_getprop_5pysam_9csamtools_7SNPCall_genotype, 0, __Pyx_DOCSTR(__pyx_k_257), 0},
+  {(char *)"consensus_quality", __pyx_getprop_5pysam_9csamtools_7SNPCall_consensus_quality, 0, __Pyx_DOCSTR(__pyx_k_258), 0},
+  {(char *)"snp_quality", __pyx_getprop_5pysam_9csamtools_7SNPCall_snp_quality, 0, __Pyx_DOCSTR(__pyx_k_259), 0},
+  {(char *)"mapping_quality", __pyx_getprop_5pysam_9csamtools_7SNPCall_mapping_quality, 0, __Pyx_DOCSTR(__pyx_k_260), 0},
+  {(char *)"coverage", __pyx_getprop_5pysam_9csamtools_7SNPCall_coverage, 0, __Pyx_DOCSTR(__pyx_k_261), 0},
   {0, 0, 0, 0, 0}
 };
 
@@ -39410,41 +41352,36 @@ static struct PyModuleDef __pyx_moduledef = {
 static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_kp_u_1, __pyx_k_1, sizeof(__pyx_k_1), 0, 1, 0, 0},
   {&__pyx_kp_s_10, __pyx_k_10, sizeof(__pyx_k_10), 0, 0, 1, 0},
+  {&__pyx_kp_s_100, __pyx_k_100, sizeof(__pyx_k_100), 0, 0, 1, 0},
   {&__pyx_kp_s_102, __pyx_k_102, sizeof(__pyx_k_102), 0, 0, 1, 0},
-  {&__pyx_kp_s_104, __pyx_k_104, sizeof(__pyx_k_104), 0, 0, 1, 0},
-  {&__pyx_kp_s_106, __pyx_k_106, sizeof(__pyx_k_106), 0, 0, 1, 0},
-  {&__pyx_kp_s_107, __pyx_k_107, sizeof(__pyx_k_107), 0, 0, 1, 0},
-  {&__pyx_kp_s_108, __pyx_k_108, sizeof(__pyx_k_108), 0, 0, 1, 0},
-  {&__pyx_kp_s_111, __pyx_k_111, sizeof(__pyx_k_111), 0, 0, 1, 0},
+  {&__pyx_kp_s_105, __pyx_k_105, sizeof(__pyx_k_105), 0, 0, 1, 0},
+  {&__pyx_kp_s_110, __pyx_k_110, sizeof(__pyx_k_110), 0, 0, 1, 0},
   {&__pyx_kp_s_112, __pyx_k_112, sizeof(__pyx_k_112), 0, 0, 1, 0},
-  {&__pyx_kp_s_113, __pyx_k_113, sizeof(__pyx_k_113), 0, 0, 1, 0},
   {&__pyx_kp_s_114, __pyx_k_114, sizeof(__pyx_k_114), 0, 0, 1, 0},
   {&__pyx_kp_s_115, __pyx_k_115, sizeof(__pyx_k_115), 0, 0, 1, 0},
-  {&__pyx_kp_s_117, __pyx_k_117, sizeof(__pyx_k_117), 0, 0, 1, 0},
+  {&__pyx_kp_s_116, __pyx_k_116, sizeof(__pyx_k_116), 0, 0, 1, 0},
+  {&__pyx_kp_s_119, __pyx_k_119, sizeof(__pyx_k_119), 0, 0, 1, 0},
   {&__pyx_kp_s_120, __pyx_k_120, sizeof(__pyx_k_120), 0, 0, 1, 0},
+  {&__pyx_kp_s_121, __pyx_k_121, sizeof(__pyx_k_121), 0, 0, 1, 0},
+  {&__pyx_kp_s_122, __pyx_k_122, sizeof(__pyx_k_122), 0, 0, 1, 0},
   {&__pyx_kp_s_123, __pyx_k_123, sizeof(__pyx_k_123), 0, 0, 1, 0},
-  {&__pyx_kp_s_129, __pyx_k_129, sizeof(__pyx_k_129), 0, 0, 1, 0},
+  {&__pyx_kp_s_125, __pyx_k_125, sizeof(__pyx_k_125), 0, 0, 1, 0},
+  {&__pyx_kp_s_128, __pyx_k_128, sizeof(__pyx_k_128), 0, 0, 1, 0},
   {&__pyx_kp_s_13, __pyx_k_13, sizeof(__pyx_k_13), 0, 0, 1, 0},
-  {&__pyx_kp_s_130, __pyx_k_130, sizeof(__pyx_k_130), 0, 0, 1, 0},
   {&__pyx_kp_s_131, __pyx_k_131, sizeof(__pyx_k_131), 0, 0, 1, 0},
-  {&__pyx_kp_s_133, __pyx_k_133, sizeof(__pyx_k_133), 0, 0, 1, 0},
+  {&__pyx_kp_s_137, __pyx_k_137, sizeof(__pyx_k_137), 0, 0, 1, 0},
+  {&__pyx_kp_s_138, __pyx_k_138, sizeof(__pyx_k_138), 0, 0, 1, 0},
   {&__pyx_kp_s_139, __pyx_k_139, sizeof(__pyx_k_139), 0, 0, 1, 0},
-  {&__pyx_kp_s_140, __pyx_k_140, sizeof(__pyx_k_140), 0, 0, 1, 0},
   {&__pyx_kp_s_141, __pyx_k_141, sizeof(__pyx_k_141), 0, 0, 1, 0},
-  {&__pyx_kp_s_142, __pyx_k_142, sizeof(__pyx_k_142), 0, 0, 1, 0},
-  {&__pyx_kp_s_144, __pyx_k_144, sizeof(__pyx_k_144), 0, 0, 1, 0},
-  {&__pyx_kp_s_145, __pyx_k_145, sizeof(__pyx_k_145), 0, 0, 1, 0},
+  {&__pyx_kp_s_147, __pyx_k_147, sizeof(__pyx_k_147), 0, 0, 1, 0},
+  {&__pyx_kp_s_148, __pyx_k_148, sizeof(__pyx_k_148), 0, 0, 1, 0},
   {&__pyx_kp_s_149, __pyx_k_149, sizeof(__pyx_k_149), 0, 0, 1, 0},
   {&__pyx_kp_s_15, __pyx_k_15, sizeof(__pyx_k_15), 0, 0, 1, 0},
-  {&__pyx_n_s_151, __pyx_k_151, sizeof(__pyx_k_151), 0, 0, 1, 1},
+  {&__pyx_kp_s_150, __pyx_k_150, sizeof(__pyx_k_150), 0, 0, 1, 0},
   {&__pyx_kp_s_152, __pyx_k_152, sizeof(__pyx_k_152), 0, 0, 1, 0},
   {&__pyx_kp_s_153, __pyx_k_153, sizeof(__pyx_k_153), 0, 0, 1, 0},
-  {&__pyx_kp_s_154, __pyx_k_154, sizeof(__pyx_k_154), 0, 0, 1, 0},
-  {&__pyx_kp_s_155, __pyx_k_155, sizeof(__pyx_k_155), 0, 0, 1, 0},
-  {&__pyx_kp_s_156, __pyx_k_156, sizeof(__pyx_k_156), 0, 0, 1, 0},
   {&__pyx_kp_s_157, __pyx_k_157, sizeof(__pyx_k_157), 0, 0, 1, 0},
-  {&__pyx_kp_s_158, __pyx_k_158, sizeof(__pyx_k_158), 0, 0, 1, 0},
-  {&__pyx_kp_s_159, __pyx_k_159, sizeof(__pyx_k_159), 0, 0, 1, 0},
+  {&__pyx_n_s_159, __pyx_k_159, sizeof(__pyx_k_159), 0, 0, 1, 1},
   {&__pyx_kp_b_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 0, 0},
   {&__pyx_kp_s_16, __pyx_k_16, sizeof(__pyx_k_16), 0, 0, 1, 0},
   {&__pyx_kp_s_160, __pyx_k_160, sizeof(__pyx_k_160), 0, 0, 1, 0},
@@ -39464,73 +41401,79 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_kp_s_173, __pyx_k_173, sizeof(__pyx_k_173), 0, 0, 1, 0},
   {&__pyx_kp_s_174, __pyx_k_174, sizeof(__pyx_k_174), 0, 0, 1, 0},
   {&__pyx_kp_s_175, __pyx_k_175, sizeof(__pyx_k_175), 0, 0, 1, 0},
+  {&__pyx_kp_s_176, __pyx_k_176, sizeof(__pyx_k_176), 0, 0, 1, 0},
   {&__pyx_kp_s_177, __pyx_k_177, sizeof(__pyx_k_177), 0, 0, 1, 0},
+  {&__pyx_kp_s_178, __pyx_k_178, sizeof(__pyx_k_178), 0, 0, 1, 0},
+  {&__pyx_kp_s_179, __pyx_k_179, sizeof(__pyx_k_179), 0, 0, 1, 0},
   {&__pyx_kp_s_18, __pyx_k_18, sizeof(__pyx_k_18), 0, 0, 1, 0},
+  {&__pyx_kp_s_180, __pyx_k_180, sizeof(__pyx_k_180), 0, 0, 1, 0},
   {&__pyx_kp_s_181, __pyx_k_181, sizeof(__pyx_k_181), 0, 0, 1, 0},
   {&__pyx_kp_s_182, __pyx_k_182, sizeof(__pyx_k_182), 0, 0, 1, 0},
   {&__pyx_kp_s_183, __pyx_k_183, sizeof(__pyx_k_183), 0, 0, 1, 0},
+  {&__pyx_kp_s_185, __pyx_k_185, sizeof(__pyx_k_185), 0, 0, 1, 0},
   {&__pyx_kp_s_189, __pyx_k_189, sizeof(__pyx_k_189), 0, 0, 1, 0},
   {&__pyx_kp_s_19, __pyx_k_19, sizeof(__pyx_k_19), 0, 0, 1, 0},
   {&__pyx_kp_s_190, __pyx_k_190, sizeof(__pyx_k_190), 0, 0, 1, 0},
-  {&__pyx_kp_s_24, __pyx_k_24, sizeof(__pyx_k_24), 0, 0, 1, 0},
-  {&__pyx_n_s_253, __pyx_k_253, sizeof(__pyx_k_253), 0, 0, 1, 1},
-  {&__pyx_kp_s_255, __pyx_k_255, sizeof(__pyx_k_255), 0, 0, 1, 0},
-  {&__pyx_kp_s_260, __pyx_k_260, sizeof(__pyx_k_260), 0, 0, 1, 0},
-  {&__pyx_n_s_261, __pyx_k_261, sizeof(__pyx_k_261), 0, 0, 1, 1},
+  {&__pyx_kp_s_191, __pyx_k_191, sizeof(__pyx_k_191), 0, 0, 1, 0},
+  {&__pyx_kp_s_197, __pyx_k_197, sizeof(__pyx_k_197), 0, 0, 1, 0},
+  {&__pyx_kp_s_198, __pyx_k_198, sizeof(__pyx_k_198), 0, 0, 1, 0},
+  {&__pyx_kp_s_21, __pyx_k_21, sizeof(__pyx_k_21), 0, 0, 1, 0},
   {&__pyx_n_s_262, __pyx_k_262, sizeof(__pyx_k_262), 0, 0, 1, 1},
-  {&__pyx_kp_s_263, __pyx_k_263, sizeof(__pyx_k_263), 0, 0, 1, 0},
-  {&__pyx_n_s_266, __pyx_k_266, sizeof(__pyx_k_266), 0, 0, 1, 1},
-  {&__pyx_n_s_269, __pyx_k_269, sizeof(__pyx_k_269), 0, 0, 1, 1},
-  {&__pyx_n_s_272, __pyx_k_272, sizeof(__pyx_k_272), 0, 0, 1, 1},
+  {&__pyx_kp_s_264, __pyx_k_264, sizeof(__pyx_k_264), 0, 0, 1, 0},
+  {&__pyx_kp_s_269, __pyx_k_269, sizeof(__pyx_k_269), 0, 0, 1, 0},
+  {&__pyx_n_s_270, __pyx_k_270, sizeof(__pyx_k_270), 0, 0, 1, 1},
+  {&__pyx_n_s_271, __pyx_k_271, sizeof(__pyx_k_271), 0, 0, 1, 1},
+  {&__pyx_kp_s_272, __pyx_k_272, sizeof(__pyx_k_272), 0, 0, 1, 0},
   {&__pyx_n_s_275, __pyx_k_275, sizeof(__pyx_k_275), 0, 0, 1, 1},
-  {&__pyx_kp_s_276, __pyx_k_276, sizeof(__pyx_k_276), 0, 0, 1, 0},
-  {&__pyx_n_s_279, __pyx_k_279, sizeof(__pyx_k_279), 0, 0, 1, 1},
-  {&__pyx_n_s_282, __pyx_k_282, sizeof(__pyx_k_282), 0, 0, 1, 1},
-  {&__pyx_n_s_285, __pyx_k_285, sizeof(__pyx_k_285), 0, 0, 1, 1},
-  {&__pyx_kp_s_286, __pyx_k_286, sizeof(__pyx_k_286), 0, 0, 1, 0},
-  {&__pyx_kp_s_29, __pyx_k_29, sizeof(__pyx_k_29), 0, 0, 1, 0},
-  {&__pyx_n_s_295, __pyx_k_295, sizeof(__pyx_k_295), 0, 0, 1, 1},
-  {&__pyx_n_s_298, __pyx_k_298, sizeof(__pyx_k_298), 0, 0, 1, 1},
+  {&__pyx_n_s_278, __pyx_k_278, sizeof(__pyx_k_278), 0, 0, 1, 1},
+  {&__pyx_n_s_281, __pyx_k_281, sizeof(__pyx_k_281), 0, 0, 1, 1},
+  {&__pyx_n_s_284, __pyx_k_284, sizeof(__pyx_k_284), 0, 0, 1, 1},
+  {&__pyx_kp_s_285, __pyx_k_285, sizeof(__pyx_k_285), 0, 0, 1, 0},
+  {&__pyx_n_s_288, __pyx_k_288, sizeof(__pyx_k_288), 0, 0, 1, 1},
+  {&__pyx_n_s_291, __pyx_k_291, sizeof(__pyx_k_291), 0, 0, 1, 1},
+  {&__pyx_n_s_294, __pyx_k_294, sizeof(__pyx_k_294), 0, 0, 1, 1},
+  {&__pyx_kp_s_295, __pyx_k_295, sizeof(__pyx_k_295), 0, 0, 1, 0},
   {&__pyx_kp_u_3, __pyx_k_3, sizeof(__pyx_k_3), 0, 1, 0, 0},
-  {&__pyx_kp_s_30, __pyx_k_30, sizeof(__pyx_k_30), 0, 0, 1, 0},
-  {&__pyx_n_s_301, __pyx_k_301, sizeof(__pyx_k_301), 0, 0, 1, 1},
   {&__pyx_n_s_304, __pyx_k_304, sizeof(__pyx_k_304), 0, 0, 1, 1},
   {&__pyx_n_s_307, __pyx_k_307, sizeof(__pyx_k_307), 0, 0, 1, 1},
-  {&__pyx_kp_s_308, __pyx_k_308, sizeof(__pyx_k_308), 0, 0, 1, 0},
-  {&__pyx_kp_s_31, __pyx_k_31, sizeof(__pyx_k_31), 0, 0, 1, 0},
+  {&__pyx_n_s_310, __pyx_k_310, sizeof(__pyx_k_310), 0, 0, 1, 1},
+  {&__pyx_n_s_313, __pyx_k_313, sizeof(__pyx_k_313), 0, 0, 1, 1},
+  {&__pyx_n_s_316, __pyx_k_316, sizeof(__pyx_k_316), 0, 0, 1, 1},
+  {&__pyx_kp_s_317, __pyx_k_317, sizeof(__pyx_k_317), 0, 0, 1, 0},
   {&__pyx_kp_s_32, __pyx_k_32, sizeof(__pyx_k_32), 0, 0, 1, 0},
-  {&__pyx_kp_s_33, __pyx_k_33, sizeof(__pyx_k_33), 0, 0, 1, 0},
-  {&__pyx_kp_s_34, __pyx_k_34, sizeof(__pyx_k_34), 0, 0, 1, 0},
-  {&__pyx_kp_s_35, __pyx_k_35, sizeof(__pyx_k_35), 0, 0, 1, 0},
-  {&__pyx_kp_s_36, __pyx_k_36, sizeof(__pyx_k_36), 0, 0, 1, 0},
-  {&__pyx_kp_b_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 0, 0},
+  {&__pyx_kp_s_37, __pyx_k_37, sizeof(__pyx_k_37), 0, 0, 1, 0},
   {&__pyx_kp_s_38, __pyx_k_38, sizeof(__pyx_k_38), 0, 0, 1, 0},
+  {&__pyx_kp_s_39, __pyx_k_39, sizeof(__pyx_k_39), 0, 0, 1, 0},
+  {&__pyx_kp_s_40, __pyx_k_40, sizeof(__pyx_k_40), 0, 0, 1, 0},
   {&__pyx_kp_s_41, __pyx_k_41, sizeof(__pyx_k_41), 0, 0, 1, 0},
+  {&__pyx_kp_s_42, __pyx_k_42, sizeof(__pyx_k_42), 0, 0, 1, 0},
   {&__pyx_kp_s_43, __pyx_k_43, sizeof(__pyx_k_43), 0, 0, 1, 0},
-  {&__pyx_kp_s_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 1, 0},
+  {&__pyx_kp_s_44, __pyx_k_44, sizeof(__pyx_k_44), 0, 0, 1, 0},
+  {&__pyx_kp_b_45, __pyx_k_45, sizeof(__pyx_k_45), 0, 0, 0, 0},
   {&__pyx_kp_s_46, __pyx_k_46, sizeof(__pyx_k_46), 0, 0, 1, 0},
-  {&__pyx_kp_s_48, __pyx_k_48, sizeof(__pyx_k_48), 0, 0, 1, 0},
+  {&__pyx_kp_s_49, __pyx_k_49, sizeof(__pyx_k_49), 0, 0, 1, 0},
   {&__pyx_kp_s_5, __pyx_k_5, sizeof(__pyx_k_5), 0, 0, 1, 0},
-  {&__pyx_kp_s_50, __pyx_k_50, sizeof(__pyx_k_50), 0, 0, 1, 0},
+  {&__pyx_kp_s_51, __pyx_k_51, sizeof(__pyx_k_51), 0, 0, 1, 0},
+  {&__pyx_kp_s_53, __pyx_k_53, sizeof(__pyx_k_53), 0, 0, 1, 0},
+  {&__pyx_kp_s_54, __pyx_k_54, sizeof(__pyx_k_54), 0, 0, 1, 0},
   {&__pyx_kp_s_56, __pyx_k_56, sizeof(__pyx_k_56), 0, 0, 1, 0},
   {&__pyx_kp_s_58, __pyx_k_58, sizeof(__pyx_k_58), 0, 0, 1, 0},
   {&__pyx_kp_s_6, __pyx_k_6, sizeof(__pyx_k_6), 0, 0, 1, 0},
-  {&__pyx_kp_s_60, __pyx_k_60, sizeof(__pyx_k_60), 0, 0, 1, 0},
-  {&__pyx_kp_s_62, __pyx_k_62, sizeof(__pyx_k_62), 0, 0, 1, 0},
   {&__pyx_kp_s_64, __pyx_k_64, sizeof(__pyx_k_64), 0, 0, 1, 0},
   {&__pyx_kp_s_66, __pyx_k_66, sizeof(__pyx_k_66), 0, 0, 1, 0},
-  {&__pyx_kp_s_69, __pyx_k_69, sizeof(__pyx_k_69), 0, 0, 1, 0},
+  {&__pyx_kp_s_68, __pyx_k_68, sizeof(__pyx_k_68), 0, 0, 1, 0},
   {&__pyx_kp_s_7, __pyx_k_7, sizeof(__pyx_k_7), 0, 0, 1, 0},
   {&__pyx_kp_s_70, __pyx_k_70, sizeof(__pyx_k_70), 0, 0, 1, 0},
-  {&__pyx_kp_s_71, __pyx_k_71, sizeof(__pyx_k_71), 0, 0, 1, 0},
-  {&__pyx_kp_s_76, __pyx_k_76, sizeof(__pyx_k_76), 0, 0, 1, 0},
+  {&__pyx_kp_s_72, __pyx_k_72, sizeof(__pyx_k_72), 0, 0, 1, 0},
+  {&__pyx_kp_s_74, __pyx_k_74, sizeof(__pyx_k_74), 0, 0, 1, 0},
+  {&__pyx_kp_s_77, __pyx_k_77, sizeof(__pyx_k_77), 0, 0, 1, 0},
+  {&__pyx_kp_s_78, __pyx_k_78, sizeof(__pyx_k_78), 0, 0, 1, 0},
   {&__pyx_kp_s_79, __pyx_k_79, sizeof(__pyx_k_79), 0, 0, 1, 0},
-  {&__pyx_kp_s_82, __pyx_k_82, sizeof(__pyx_k_82), 0, 0, 1, 0},
-  {&__pyx_kp_s_85, __pyx_k_85, sizeof(__pyx_k_85), 0, 0, 1, 0},
+  {&__pyx_kp_s_84, __pyx_k_84, sizeof(__pyx_k_84), 0, 0, 1, 0},
+  {&__pyx_kp_s_87, __pyx_k_87, sizeof(__pyx_k_87), 0, 0, 1, 0},
   {&__pyx_kp_s_9, __pyx_k_9, sizeof(__pyx_k_9), 0, 0, 1, 0},
-  {&__pyx_kp_s_92, __pyx_k_92, sizeof(__pyx_k_92), 0, 0, 1, 0},
-  {&__pyx_kp_s_94, __pyx_k_94, sizeof(__pyx_k_94), 0, 0, 1, 0},
-  {&__pyx_kp_s_97, __pyx_k_97, sizeof(__pyx_k_97), 0, 0, 1, 0},
+  {&__pyx_kp_s_90, __pyx_k_90, sizeof(__pyx_k_90), 0, 0, 1, 0},
+  {&__pyx_kp_s_93, __pyx_k_93, sizeof(__pyx_k_93), 0, 0, 1, 0},
   {&__pyx_kp_s__2scB, __pyx_k__2scB, sizeof(__pyx_k__2scB), 0, 0, 1, 0},
   {&__pyx_kp_s__2scH, __pyx_k__2scH, sizeof(__pyx_k__2scH), 0, 0, 1, 0},
   {&__pyx_kp_s__2scI, __pyx_k__2scI, sizeof(__pyx_k__2scI), 0, 0, 1, 0},
@@ -39556,6 +41499,7 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {&__pyx_n_s__F, __pyx_k__F, sizeof(__pyx_k__F), 0, 0, 1, 1},
   {&__pyx_n_s__FO, __pyx_k__FO, sizeof(__pyx_k__FO), 0, 0, 1, 1},
   {&__pyx_n_s__Fastafile, __pyx_k__Fastafile, sizeof(__pyx_k__Fastafile), 0, 0, 1, 1},
+  {&__pyx_n_s__Fastqfile, __pyx_k__Fastqfile, sizeof(__pyx_k__Fastqfile), 0, 0, 1, 1},
   {&__pyx_n_s__GO, __pyx_k__GO, sizeof(__pyx_k__GO), 0, 0, 1, 1},
   {&__pyx_n_s__H, __pyx_k__H, sizeof(__pyx_k__H), 0, 0, 1, 1},
   {&__pyx_n_s__HD, __pyx_k__HD, sizeof(__pyx_k__HD), 0, 0, 1, 1},
@@ -39806,26 +41750,26 @@ static __Pyx_StringTabEntry __pyx_string_tab[] = {
   {0, 0, 0, 0, 0, 0, 0}
 };
 static int __Pyx_InitCachedBuiltins(void) {
-  __pyx_builtin_object = __Pyx_GetName(__pyx_b, __pyx_n_s__object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_object = __Pyx_GetName(__pyx_b, __pyx_n_s__object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_builtin_TypeError = __Pyx_GetName(__pyx_b, __pyx_n_s__TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_builtin_enumerate = __Pyx_GetName(__pyx_b, __pyx_n_s__enumerate); if (!__pyx_builtin_enumerate) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_builtin_ord = __Pyx_GetName(__pyx_b, __pyx_n_s__ord); if (!__pyx_builtin_ord) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_map = __Pyx_GetName(__pyx_b, __pyx_n_s__map); if (!__pyx_builtin_map) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 261; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_IOError = __Pyx_GetName(__pyx_b, __pyx_n_s__IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_OverflowError = __Pyx_GetName(__pyx_b, __pyx_n_s__OverflowError); if (!__pyx_builtin_OverflowError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 840; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_OSError = __Pyx_GetName(__pyx_b, __pyx_n_s__OSError); if (!__pyx_builtin_OSError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_AttributeError = __Pyx_GetName(__pyx_b, __pyx_n_s__AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_zip = __Pyx_GetName(__pyx_b, __pyx_n_s__zip); if (!__pyx_builtin_zip) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1310; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_sorted = __Pyx_GetName(__pyx_b, __pyx_n_s__sorted); if (!__pyx_builtin_sorted) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1326; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1392; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_min = __Pyx_GetName(__pyx_b, __pyx_n_s__min); if (!__pyx_builtin_min) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_max = __Pyx_GetName(__pyx_b, __pyx_n_s__max); if (!__pyx_builtin_max) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_chr = __Pyx_GetName(__pyx_b, __pyx_n_s__chr); if (!__pyx_builtin_chr) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2969; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_builtin_UnicodeDecodeError = __Pyx_GetName(__pyx_b, __pyx_n_s__UnicodeDecodeError); if (!__pyx_builtin_UnicodeDecodeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3226; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_map = __Pyx_GetName(__pyx_b, __pyx_n_s__map); if (!__pyx_builtin_map) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 268; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_ValueError = __Pyx_GetName(__pyx_b, __pyx_n_s__ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_IOError = __Pyx_GetName(__pyx_b, __pyx_n_s__IOError); if (!__pyx_builtin_IOError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_StopIteration = __Pyx_GetName(__pyx_b, __pyx_n_s__StopIteration); if (!__pyx_builtin_StopIteration) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 617; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_OverflowError = __Pyx_GetName(__pyx_b, __pyx_n_s__OverflowError); if (!__pyx_builtin_OverflowError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 966; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_NotImplementedError = __Pyx_GetName(__pyx_b, __pyx_n_s__NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_OSError = __Pyx_GetName(__pyx_b, __pyx_n_s__OSError); if (!__pyx_builtin_OSError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_AttributeError = __Pyx_GetName(__pyx_b, __pyx_n_s__AttributeError); if (!__pyx_builtin_AttributeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_zip = __Pyx_GetName(__pyx_b, __pyx_n_s__zip); if (!__pyx_builtin_zip) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_sorted = __Pyx_GetName(__pyx_b, __pyx_n_s__sorted); if (!__pyx_builtin_sorted) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1452; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_KeyError = __Pyx_GetName(__pyx_b, __pyx_n_s__KeyError); if (!__pyx_builtin_KeyError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1518; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_min = __Pyx_GetName(__pyx_b, __pyx_n_s__min); if (!__pyx_builtin_min) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_max = __Pyx_GetName(__pyx_b, __pyx_n_s__max); if (!__pyx_builtin_max) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2776; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_chr = __Pyx_GetName(__pyx_b, __pyx_n_s__chr); if (!__pyx_builtin_chr) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3186; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_open = __Pyx_GetName(__pyx_b, __pyx_n_s__open); if (!__pyx_builtin_open) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_UnicodeDecodeError = __Pyx_GetName(__pyx_b, __pyx_n_s__UnicodeDecodeError); if (!__pyx_builtin_UnicodeDecodeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3443; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   return 0;
   __pyx_L1_error:;
   return -1;
@@ -39857,841 +41801,863 @@ static int __Pyx_InitCachedConstants(void) {
   __Pyx_GOTREF(__pyx_k_tuple_4);
   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_4));
 
-  /* "pysam/csamtools.pyx":398
+  /* "pysam/csamtools.pyx":405
  *     def __len__(self):
  *         if self.fastafile == NULL:
  *             raise ValueError( "calling len() on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         return faidx_fetch_nseq(self.fastafile)
  */
-  __pyx_k_tuple_8 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_7)); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_8 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_7)); if (unlikely(!__pyx_k_tuple_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_k_tuple_8);
   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_8));
 
-  /* "pysam/csamtools.pyx":431
+  /* "pysam/csamtools.pyx":438
  *         '''number of :term:`filename` associated with this object.'''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             return self._filename
  * 
  */
-  __pyx_k_tuple_11 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_11 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_k_tuple_11);
   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_11));
 
-  /* "pysam/csamtools.pyx":456
+  /* "pysam/csamtools.pyx":463
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         cdef int length
  */
-  __pyx_k_tuple_12 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_12 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 463; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_k_tuple_12);
   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_12));
 
-  /* "pysam/csamtools.pyx":462
+  /* "pysam/csamtools.pyx":469
  * 
  *         if not region:
  *             if reference is None: raise ValueError( 'no sequence/region supplied.' )             # <<<<<<<<<<<<<<
  *             if start is None: start = 0
  *             if end is None: end = max_pos -1
  */
-  __pyx_k_tuple_14 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_13)); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 462; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_14 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_13)); if (unlikely(!__pyx_k_tuple_14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 469; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_k_tuple_14);
   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_14));
 
-  /* "pysam/csamtools.pyx":481
+  /* "pysam/csamtools.pyx":488
  *             region = "%s:%i-%i" % (reference, start+1, end)
  *             if PY_MAJOR_VERSION >= 3:
  *                 region = region.encode('ascii')             # <<<<<<<<<<<<<<
  *             seq = fai_fetch( self.fastafile,
  *                              region,
  */
-  __pyx_k_tuple_20 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 481; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_20 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 488; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_k_tuple_20);
   __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_20));
 
-  /* "pysam/csamtools.pyx":663
+  /* "pysam/csamtools.pyx":593
+ *         '''number of :term:`filename` associated with this object.'''
+ *         def __get__(self):
+ *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
+ *             return self._filename
+ * 
+ */
+  __pyx_k_tuple_22 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 593; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_22);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_22));
+
+  /* "pysam/csamtools.pyx":597
+ * 
+ *     def __iter__(self):
+ *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
+ *         return self
+ * 
+ */
+  __pyx_k_tuple_23 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_23);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_23));
+
+  /* "pysam/csamtools.pyx":789
  *         if self._filename != NULL: free(self._filename )
  *         filename = _my_encodeFilename(filename)
  *         cdef bytes bmode = mode.encode('ascii')             # <<<<<<<<<<<<<<
  *         #cdef char* cfilename
  *         #cfilename = filename.encode(_FILENAME_ENCODING)
  */
-  __pyx_k_tuple_25 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_25)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 663; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_25);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_25));
+  __pyx_k_tuple_33 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_33)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 789; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_33);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_33));
 
-  /* "pysam/csamtools.pyx":791
+  /* "pysam/csamtools.pyx":917
  *         returns -1 if reference is not known.
  *         '''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         reference = _force_bytes(reference)
  *         return pysam_reference2tid( self.samfile.header, reference )
  */
-  __pyx_k_tuple_39 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_39)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 791; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_39);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_39));
+  __pyx_k_tuple_47 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 917; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_47);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47));
 
-  /* "pysam/csamtools.pyx":798
+  /* "pysam/csamtools.pyx":924
  *         '''
  *         convert numerical :term:`tid` into :term:`reference` name.'''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
  */
-  __pyx_k_tuple_40 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_40)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 798; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_40);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_40));
+  __pyx_k_tuple_48 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_48)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 924; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_48);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_48));
 
-  /* "pysam/csamtools.pyx":806
+  /* "pysam/csamtools.pyx":932
  *         '''
  *         convert numerical :term:`tid` into :term:`reference` name.'''
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not 0 <= tid < self.samfile.header.n_targets:
  *             raise ValueError( "tid %i out of range 0<=tid<%i" % (tid, self.samfile.header.n_targets ) )
  */
-  __pyx_k_tuple_42 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_42)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 806; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_42);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_42));
+  __pyx_k_tuple_50 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_50)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 932; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_50);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_50));
 
-  /* "pysam/csamtools.pyx":856
+  /* "pysam/csamtools.pyx":982
  *             if len(parts) >= 3: rend = int(parts[2])
  * 
  *         if not reference: return 0, 0, 0, 0             # <<<<<<<<<<<<<<
  * 
  *         rtid = self.gettid( reference )
  */
-  __pyx_k_tuple_44 = PyTuple_Pack(4, __pyx_int_0, __pyx_int_0, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_k_tuple_44)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 856; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_44);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_44));
+  __pyx_k_tuple_52 = PyTuple_Pack(4, __pyx_int_0, __pyx_int_0, __pyx_int_0, __pyx_int_0); if (unlikely(!__pyx_k_tuple_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 982; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_52);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_52));
 
-  /* "pysam/csamtools.pyx":876
+  /* "pysam/csamtools.pyx":1002
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")
  */
-  __pyx_k_tuple_47 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_47)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 876; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_47);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_47));
+  __pyx_k_tuple_55 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1002; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_55);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_55));
 
-  /* "pysam/csamtools.pyx":878
+  /* "pysam/csamtools.pyx":1004
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")             # <<<<<<<<<<<<<<
  *         if self.isstream:
  *             raise OSError("seek no available in streams")
  */
-  __pyx_k_tuple_49 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_48)); if (unlikely(!__pyx_k_tuple_49)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 878; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_49);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_49));
+  __pyx_k_tuple_57 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_56)); if (unlikely(!__pyx_k_tuple_57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1004; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_57);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_57));
 
-  /* "pysam/csamtools.pyx":880
+  /* "pysam/csamtools.pyx":1006
  *             raise NotImplementedError("seek only available in bam files")
  *         if self.isstream:
  *             raise OSError("seek no available in streams")             # <<<<<<<<<<<<<<
  * 
  *         return bam_seek( self.samfile.x.bam, offset, where )
  */
-  __pyx_k_tuple_51 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_50)); if (unlikely(!__pyx_k_tuple_51)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 880; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_51);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_51));
+  __pyx_k_tuple_59 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_58)); if (unlikely(!__pyx_k_tuple_59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1006; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_59);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59));
 
-  /* "pysam/csamtools.pyx":889
+  /* "pysam/csamtools.pyx":1015
  *         '''
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")
  */
-  __pyx_k_tuple_52 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_52)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 889; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_52);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_52));
+  __pyx_k_tuple_60 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_60)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1015; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_60);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_60));
 
-  /* "pysam/csamtools.pyx":891
+  /* "pysam/csamtools.pyx":1017
  *             raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam:
  *             raise NotImplementedError("seek only available in bam files")             # <<<<<<<<<<<<<<
  * 
  *         return bam_tell( self.samfile.x.bam )
  */
-  __pyx_k_tuple_53 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_48)); if (unlikely(!__pyx_k_tuple_53)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 891; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_53);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_53));
+  __pyx_k_tuple_61 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_56)); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1017; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_61);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61));
 
-  /* "pysam/csamtools.pyx":926
+  /* "pysam/csamtools.pyx":1052
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  */
-  __pyx_k_tuple_55 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_55)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 926; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_55);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_55));
+  __pyx_k_tuple_63 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1052; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_63);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_63));
 
-  /* "pysam/csamtools.pyx":935
+  /* "pysam/csamtools.pyx":1061
  *         if self.isbam:
  *             if not until_eof and not self._hasIndex() and not self.isremote:
  *                 raise ValueError( "fetch called on bamfile without index" )             # <<<<<<<<<<<<<<
  * 
  *             if callback:
  */
-  __pyx_k_tuple_57 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_56)); if (unlikely(!__pyx_k_tuple_57)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 935; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_57);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_57));
+  __pyx_k_tuple_65 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_64)); if (unlikely(!__pyx_k_tuple_65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1061; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_65);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_65));
 
-  /* "pysam/csamtools.pyx":938
+  /* "pysam/csamtools.pyx":1064
  * 
  *             if callback:
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )             # <<<<<<<<<<<<<<
  *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )
  *                 return bam_fetch(self.samfile.x.bam,
  */
-  __pyx_k_tuple_59 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_58)); if (unlikely(!__pyx_k_tuple_59)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 938; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_59);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_59));
+  __pyx_k_tuple_67 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_66)); if (unlikely(!__pyx_k_tuple_67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1064; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_67);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_67));
 
-  /* "pysam/csamtools.pyx":939
+  /* "pysam/csamtools.pyx":1065
  *             if callback:
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )
  *                 if not self._hasIndex(): raise ValueError( "no index available for fetch" )             # <<<<<<<<<<<<<<
  *                 return bam_fetch(self.samfile.x.bam,
  *                                  self.index,
  */
-  __pyx_k_tuple_61 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_60)); if (unlikely(!__pyx_k_tuple_61)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 939; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_61);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_61));
+  __pyx_k_tuple_69 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_68)); if (unlikely(!__pyx_k_tuple_69)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1065; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_69);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_69));
 
-  /* "pysam/csamtools.pyx":959
+  /* "pysam/csamtools.pyx":1085
  *         else:
  *             if has_coord:
  *                 raise ValueError ("fetching by region is not available for sam files" )             # <<<<<<<<<<<<<<
  * 
  *             if callback:
  */
-  __pyx_k_tuple_63 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_62)); if (unlikely(!__pyx_k_tuple_63)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_63);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_63));
+  __pyx_k_tuple_71 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_70)); if (unlikely(!__pyx_k_tuple_71)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1085; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_71);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_71));
 
-  /* "pysam/csamtools.pyx":962
+  /* "pysam/csamtools.pyx":1088
  * 
  *             if callback:
  *                 raise NotImplementedError( "callback not implemented yet" )             # <<<<<<<<<<<<<<
  * 
  *             if self.samfile.header == NULL:
  */
-  __pyx_k_tuple_65 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_64)); if (unlikely(!__pyx_k_tuple_65)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 962; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_65);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_65));
+  __pyx_k_tuple_73 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_72)); if (unlikely(!__pyx_k_tuple_73)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1088; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_73);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_73));
 
-  /* "pysam/csamtools.pyx":965
+  /* "pysam/csamtools.pyx":1091
  * 
  *             if self.samfile.header == NULL:
  *                 raise ValueError( "fetch called for samfile without header")             # <<<<<<<<<<<<<<
  * 
  *             # check if targets are defined
  */
-  __pyx_k_tuple_67 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_66)); if (unlikely(!__pyx_k_tuple_67)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 965; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_67);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_67));
+  __pyx_k_tuple_75 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_74)); if (unlikely(!__pyx_k_tuple_75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1091; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_75);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_75));
 
-  /* "pysam/csamtools.pyx":970
+  /* "pysam/csamtools.pyx":1096
  *             # give warning, sam_read1 segfaults
  *             if self.samfile.header.n_targets == 0:
  *                 warnings.warn( "fetch called for samfile without header")             # <<<<<<<<<<<<<<
  * 
  *             return IteratorRowAll( self, reopen=reopen )
  */
-  __pyx_k_tuple_68 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_66)); if (unlikely(!__pyx_k_tuple_68)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 970; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_68);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_68));
+  __pyx_k_tuple_76 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_74)); if (unlikely(!__pyx_k_tuple_76)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1096; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_76);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_76));
 
-  /* "pysam/csamtools.pyx":1011
+  /* "pysam/csamtools.pyx":1137
  * 
  *         if mate_data.mate == NULL:
  *             raise ValueError( "mate not found" )             # <<<<<<<<<<<<<<
  * 
  *         cdef AlignedRead dest = AlignedRead.__new__(AlignedRead)
  */
-  __pyx_k_tuple_72 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_71)); if (unlikely(!__pyx_k_tuple_72)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1011; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_72);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_72));
+  __pyx_k_tuple_80 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_79)); if (unlikely(!__pyx_k_tuple_80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_80);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_80));
 
-  /* "pysam/csamtools.pyx":1036
+  /* "pysam/csamtools.pyx":1162
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         region, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  */
-  __pyx_k_tuple_74 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_74)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1036; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_74);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_74));
+  __pyx_k_tuple_82 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_82)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1162; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_82);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_82));
 
-  /* "pysam/csamtools.pyx":1045
+  /* "pysam/csamtools.pyx":1171
  *         if self.isbam:
  *             if not until_eof and not self._hasIndex() and not self.isremote:
  *                 raise ValueError( "fetch called on bamfile without index" )             # <<<<<<<<<<<<<<
  * 
  *             if not region:
  */
-  __pyx_k_tuple_75 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_56)); if (unlikely(!__pyx_k_tuple_75)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1045; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_75);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_75));
+  __pyx_k_tuple_83 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_64)); if (unlikely(!__pyx_k_tuple_83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_83);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_83));
 
-  /* "pysam/csamtools.pyx":1048
+  /* "pysam/csamtools.pyx":1174
  * 
  *             if not region:
  *                 raise ValueError( "counting functionality requires a region/reference" )             # <<<<<<<<<<<<<<
  *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )
  *             bam_fetch(self.samfile.x.bam,
  */
-  __pyx_k_tuple_77 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_76)); if (unlikely(!__pyx_k_tuple_77)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1048; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_77);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_77));
+  __pyx_k_tuple_85 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_84)); if (unlikely(!__pyx_k_tuple_85)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_85);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_85));
 
-  /* "pysam/csamtools.pyx":1049
+  /* "pysam/csamtools.pyx":1175
  *             if not region:
  *                 raise ValueError( "counting functionality requires a region/reference" )
  *             if not self._hasIndex(): raise ValueError( "no index available for fetch" )             # <<<<<<<<<<<<<<
  *             bam_fetch(self.samfile.x.bam,
  *                              self.index,
  */
-  __pyx_k_tuple_78 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_60)); if (unlikely(!__pyx_k_tuple_78)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1049; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_78);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_78));
+  __pyx_k_tuple_86 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_68)); if (unlikely(!__pyx_k_tuple_86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_86);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_86));
 
-  /* "pysam/csamtools.pyx":1059
+  /* "pysam/csamtools.pyx":1185
  *             return counter
  *         else:
  *             raise ValueError ("count for a region is not available for sam files" )             # <<<<<<<<<<<<<<
  * 
  *     def pileup( self,
  */
-  __pyx_k_tuple_80 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_79)); if (unlikely(!__pyx_k_tuple_80)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1059; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_80);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_80));
+  __pyx_k_tuple_88 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_87)); if (unlikely(!__pyx_k_tuple_88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_88);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_88));
 
-  /* "pysam/csamtools.pyx":1118
+  /* "pysam/csamtools.pyx":1244
  * 
  *         if not self._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         has_coord, rtid, rstart, rend = self._parseRegion( reference, start, end, region )
  */
-  __pyx_k_tuple_81 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_81)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1118; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_81);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_81));
+  __pyx_k_tuple_89 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_89)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1244; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_89);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_89));
 
-  /* "pysam/csamtools.pyx":1123
+  /* "pysam/csamtools.pyx":1249
  * 
  *         if self.isbam:
  *             if not self._hasIndex(): raise ValueError( "no index available for pileup" )             # <<<<<<<<<<<<<<
  * 
  *             if callback:
  */
-  __pyx_k_tuple_83 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_82)); if (unlikely(!__pyx_k_tuple_83)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_83);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_83));
+  __pyx_k_tuple_91 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_90)); if (unlikely(!__pyx_k_tuple_91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1249; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_91);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_91));
 
-  /* "pysam/csamtools.pyx":1126
+  /* "pysam/csamtools.pyx":1252
  * 
  *             if callback:
  *                 if not has_coord: raise ValueError( "callback functionality requires a region/reference" )             # <<<<<<<<<<<<<<
  * 
  *                 buf = bam_plbuf_init( <bam_pileup_f>pileup_callback, <void*>callback )
  */
-  __pyx_k_tuple_84 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_58)); if (unlikely(!__pyx_k_tuple_84)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1126; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_84);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_84));
+  __pyx_k_tuple_92 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_66)); if (unlikely(!__pyx_k_tuple_92)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_92);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_92));
 
-  /* "pysam/csamtools.pyx":1147
+  /* "pysam/csamtools.pyx":1273
  * 
  *         else:
  *             raise NotImplementedError( "pileup of samfiles not implemented yet" )             # <<<<<<<<<<<<<<
  * 
  *     def close( self ):
  */
-  __pyx_k_tuple_86 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_85)); if (unlikely(!__pyx_k_tuple_86)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1147; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_86);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_86));
+  __pyx_k_tuple_94 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_93)); if (unlikely(!__pyx_k_tuple_94)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1273; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_94);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_94));
 
-  /* "pysam/csamtools.pyx":1191
+  /* "pysam/csamtools.pyx":1317
  *         '''number of :term:`filename` associated with this object.'''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             return self._filename
  * 
  */
-  __pyx_k_tuple_87 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_87)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1191; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_87);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_87));
+  __pyx_k_tuple_95 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1317; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_95);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_95));
 
-  /* "pysam/csamtools.pyx":1197
+  /* "pysam/csamtools.pyx":1323
  *         '''number of :term:`reference` sequences in the file.'''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             return self.samfile.header.n_targets
  * 
  */
-  __pyx_k_tuple_88 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_88)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1197; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_88);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_88));
+  __pyx_k_tuple_96 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_96)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_96);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_96));
 
-  /* "pysam/csamtools.pyx":1203
+  /* "pysam/csamtools.pyx":1329
  *         """tuple with the names of :term:`reference` sequences."""
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:
  */
-  __pyx_k_tuple_89 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_89)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_89);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_89));
+  __pyx_k_tuple_97 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_97)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_97);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_97));
 
-  /* "pysam/csamtools.pyx":1214
+  /* "pysam/csamtools.pyx":1340
  *         """
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             t = []
  *             for x from 0 <= x < self.samfile.header.n_targets:
  */
-  __pyx_k_tuple_90 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_90)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1214; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_90);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_90));
+  __pyx_k_tuple_98 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_98)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_98);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_98));
 
-  /* "pysam/csamtools.pyx":1224
+  /* "pysam/csamtools.pyx":1350
  *         """
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             if not self.isbam: raise AttributeError( "Samfile.mapped only available in bam files" )
  *             if self.index == NULL:
  */
-  __pyx_k_tuple_91 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_91)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_91);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_91));
+  __pyx_k_tuple_99 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_99)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_99);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_99));
 
-  /* "pysam/csamtools.pyx":1225
+  /* "pysam/csamtools.pyx":1351
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             if not self.isbam: raise AttributeError( "Samfile.mapped only available in bam files" )             # <<<<<<<<<<<<<<
  *             if self.index == NULL:
  *                 raise ValueError( "mapping information not recorded in index or index not available")
  */
-  __pyx_k_tuple_93 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_92)); if (unlikely(!__pyx_k_tuple_93)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1225; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_93);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_93));
+  __pyx_k_tuple_101 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_100)); if (unlikely(!__pyx_k_tuple_101)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1351; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_101);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_101));
 
-  /* "pysam/csamtools.pyx":1227
+  /* "pysam/csamtools.pyx":1353
  *             if not self.isbam: raise AttributeError( "Samfile.mapped only available in bam files" )
  *             if self.index == NULL:
  *                 raise ValueError( "mapping information not recorded in index or index not available")             # <<<<<<<<<<<<<<
  * 
  *             cdef int tid
  */
-  __pyx_k_tuple_95 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_94)); if (unlikely(!__pyx_k_tuple_95)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_95);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_95));
+  __pyx_k_tuple_103 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_102)); if (unlikely(!__pyx_k_tuple_103)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1353; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_103);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_103));
 
-  /* "pysam/csamtools.pyx":1239
+  /* "pysam/csamtools.pyx":1365
  *         """
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             if not self.isbam: raise AttributeError( "Samfile.unmapped only available in bam files" )
  *             cdef int tid
  */
-  __pyx_k_tuple_96 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_96)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1239; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_96);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_96));
+  __pyx_k_tuple_104 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_104)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_104);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_104));
 
-  /* "pysam/csamtools.pyx":1240
+  /* "pysam/csamtools.pyx":1366
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *             if not self.isbam: raise AttributeError( "Samfile.unmapped only available in bam files" )             # <<<<<<<<<<<<<<
  *             cdef int tid
  *             cdef uint32_t total = 0
  */
-  __pyx_k_tuple_98 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_97)); if (unlikely(!__pyx_k_tuple_98)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_98);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_98));
+  __pyx_k_tuple_106 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_105)); if (unlikely(!__pyx_k_tuple_106)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_106);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_106));
 
-  /* "pysam/csamtools.pyx":1252
+  /* "pysam/csamtools.pyx":1378
  *         '''full contents of the :term:`sam file` header as a string.'''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *             return from_string_and_size(self.samfile.header.text, self.samfile.header.l_text)
  * 
  */
-  __pyx_k_tuple_99 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_99)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1252; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_99);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_99));
+  __pyx_k_tuple_107 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_107)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1378; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_107);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_107));
 
-  /* "pysam/csamtools.pyx":1260
+  /* "pysam/csamtools.pyx":1386
  *         '''
  *         def __get__(self):
  *             if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *             result = {}
  */
-  __pyx_k_tuple_100 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_100);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_100));
+  __pyx_k_tuple_108 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_108)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1386; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_108);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_108));
 
-  /* "pysam/csamtools.pyx":1267
+  /* "pysam/csamtools.pyx":1393
  *                 # convert to python string (note: call self.text to create 0-terminated string)
  *                 t = self.text
  *                 for line in t.split("\n"):             # <<<<<<<<<<<<<<
  *                     if not line.strip(): continue
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
  */
-  __pyx_k_tuple_101 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_6)); if (unlikely(!__pyx_k_tuple_101)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_101);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_101));
+  __pyx_k_tuple_109 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_6)); if (unlikely(!__pyx_k_tuple_109)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1393; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_109);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_109));
 
-  /* "pysam/csamtools.pyx":1269
+  /* "pysam/csamtools.pyx":1395
  *                 for line in t.split("\n"):
  *                     if not line.strip(): continue
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line             # <<<<<<<<<<<<<<
  *                     fields = line[1:].split("\t")
  *                     record = fields[0]
  */
-  __pyx_k_tuple_103 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_102)); if (unlikely(!__pyx_k_tuple_103)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1269; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_103);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_103));
+  __pyx_k_tuple_111 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_110)); if (unlikely(!__pyx_k_tuple_111)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1395; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_111);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_111));
 
-  /* "pysam/csamtools.pyx":1270
+  /* "pysam/csamtools.pyx":1396
  *                     if not line.strip(): continue
  *                     assert line.startswith("@"), "header line without '@': '%s'" % line
  *                     fields = line[1:].split("\t")             # <<<<<<<<<<<<<<
  *                     record = fields[0]
  *                     assert record in VALID_HEADER_TYPES, "header line with invalid type '%s': '%s'" % (record, line)
  */
-  __pyx_k_tuple_105 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_5)); if (unlikely(!__pyx_k_tuple_105)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1270; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_105);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_105));
+  __pyx_k_tuple_113 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_5)); if (unlikely(!__pyx_k_tuple_113)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1396; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_113);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_113));
 
-  /* "pysam/csamtools.pyx":1283
+  /* "pysam/csamtools.pyx":1409
  *                     for field in fields[1:]:
  *                         if ":" not in field:
  *                             raise ValueError("malformatted header: no ':' in field" )             # <<<<<<<<<<<<<<
  *                         key, value = field.split(":",1)
  *                         # uppercase keys must be valid
  */
-  __pyx_k_tuple_109 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_108)); if (unlikely(!__pyx_k_tuple_109)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1283; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_109);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_109));
+  __pyx_k_tuple_117 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_116)); if (unlikely(!__pyx_k_tuple_117)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1409; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_117);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_117));
 
-  /* "pysam/csamtools.pyx":1284
+  /* "pysam/csamtools.pyx":1410
  *                         if ":" not in field:
  *                             raise ValueError("malformatted header: no ':' in field" )
  *                         key, value = field.split(":",1)             # <<<<<<<<<<<<<<
  *                         # uppercase keys must be valid
  *                         # lowercase are permitted for user fields
  */
-  __pyx_k_tuple_110 = PyTuple_Pack(2, ((PyObject *)__pyx_kp_s_107), __pyx_int_1); if (unlikely(!__pyx_k_tuple_110)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1284; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_110);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_110));
+  __pyx_k_tuple_118 = PyTuple_Pack(2, ((PyObject *)__pyx_kp_s_115), __pyx_int_1); if (unlikely(!__pyx_k_tuple_118)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_118);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_118));
 
-  /* "pysam/csamtools.pyx":1382
+  /* "pysam/csamtools.pyx":1508
  *         dest.text = <char*>calloc( len(text), sizeof(char))
  *         dest.l_text = len(text)
  *         cdef bytes btext = text.encode('ascii')             # <<<<<<<<<<<<<<
  *         strncpy( dest.text, btext, dest.l_text )
  * 
  */
-  __pyx_k_tuple_116 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_116)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_116);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_116));
+  __pyx_k_tuple_124 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_124)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1508; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_124);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_124));
 
-  /* "pysam/csamtools.pyx":1402
+  /* "pysam/csamtools.pyx":1528
  *                 seqname, seqlen = seqs[x]
  *                 dest.target_name[x] = <char*>calloc( len( seqname ) + 1, sizeof(char) )
  *                 bseqname = seqname.encode('ascii')             # <<<<<<<<<<<<<<
  *                 strncpy( dest.target_name[x], bseqname, len(seqname) + 1 )
  *                 dest.target_len[x] = seqlen
  */
-  __pyx_k_tuple_118 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_118)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1402; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_118);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_118));
+  __pyx_k_tuple_126 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_126)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1528; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_126);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_126));
 
-  /* "pysam/csamtools.pyx":1417
+  /* "pysam/csamtools.pyx":1543
  *     ###############################################################
  *     def __iter__(self):
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  *         if not self.isbam and self.samfile.header.n_targets == 0:
  *                 raise NotImplementedError( "can not iterate over samfile without header")
  */
-  __pyx_k_tuple_119 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_119)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1417; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_119);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_119));
+  __pyx_k_tuple_127 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_127)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1543; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_127);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_127));
 
-  /* "pysam/csamtools.pyx":1419
+  /* "pysam/csamtools.pyx":1545
  *         if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
  *         if not self.isbam and self.samfile.header.n_targets == 0:
  *                 raise NotImplementedError( "can not iterate over samfile without header")             # <<<<<<<<<<<<<<
  *         return self
  * 
  */
-  __pyx_k_tuple_121 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_120)); if (unlikely(!__pyx_k_tuple_121)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1419; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_121);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_121));
+  __pyx_k_tuple_129 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_128)); if (unlikely(!__pyx_k_tuple_129)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_129);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_129));
 
-  /* "pysam/csamtools.pyx":1489
+  /* "pysam/csamtools.pyx":1625
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         if not samfile._hasIndex():
  */
-  __pyx_k_tuple_122 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_122)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1489; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_122);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_122));
+  __pyx_k_tuple_130 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_130)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1625; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_130);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_130));
 
-  /* "pysam/csamtools.pyx":1492
+  /* "pysam/csamtools.pyx":1628
  * 
  *         if not samfile._hasIndex():
  *             raise ValueError( "no index available for iteration" )             # <<<<<<<<<<<<<<
  * 
  *         # makes sure that samfile stays alive as long as the
  */
-  __pyx_k_tuple_124 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_123)); if (unlikely(!__pyx_k_tuple_124)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1492; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_124);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_124));
+  __pyx_k_tuple_132 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_131)); if (unlikely(!__pyx_k_tuple_132)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1628; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_132);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_132));
 
-  /* "pysam/csamtools.pyx":1558
+  /* "pysam/csamtools.pyx":1700
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         if samfile.isbam: mode = b"rb"
  */
-  __pyx_k_tuple_125 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_125)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1558; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_125);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_125));
+  __pyx_k_tuple_133 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_133)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1700; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_133);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_133));
 
-  /* "pysam/csamtools.pyx":1609
+  /* "pysam/csamtools.pyx":1755
  *     def __cinit__(self, Samfile samfile):
  *         assert samfile._isOpen()
  *         if not samfile._hasIndex(): raise ValueError("no index available for fetch")             # <<<<<<<<<<<<<<
  *         self.samfile = samfile
  *         self.tid = -1
  */
-  __pyx_k_tuple_126 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_60)); if (unlikely(!__pyx_k_tuple_126)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1609; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_126);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_126));
+  __pyx_k_tuple_134 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_68)); if (unlikely(!__pyx_k_tuple_134)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1755; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_134);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_134));
 
-  /* "pysam/csamtools.pyx":1655
+  /* "pysam/csamtools.pyx":1805
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         if not samfile._isOpen():
  */
-  __pyx_k_tuple_127 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_127)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1655; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_127);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_127));
+  __pyx_k_tuple_135 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_135)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1805; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_135);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_135));
 
-  /* "pysam/csamtools.pyx":1658
+  /* "pysam/csamtools.pyx":1808
  * 
  *         if not samfile._isOpen():
  *             raise ValueError( "I/O operation on closed file" )             # <<<<<<<<<<<<<<
  * 
  *         assert samfile.isbam, "can only use this iterator on bam files"
  */
-  __pyx_k_tuple_128 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_128)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1658; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_128);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_128));
+  __pyx_k_tuple_136 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_10)); if (unlikely(!__pyx_k_tuple_136)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1808; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_136);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_136));
 
-  /* "pysam/csamtools.pyx":1959
+  /* "pysam/csamtools.pyx":2106
  *             self.cnext()
  *             if self.n_plp < 0:
  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
  * 
  *             if self.plp == NULL:
  */
-  __pyx_k_tuple_134 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_133)); if (unlikely(!__pyx_k_tuple_134)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1959; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_134);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_134));
+  __pyx_k_tuple_142 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_141)); if (unlikely(!__pyx_k_tuple_142)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_142);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_142));
 
-  /* "pysam/csamtools.pyx":1995
+  /* "pysam/csamtools.pyx":2142
  * 
  *             if self.n_plp < 0:
  *                 raise ValueError("error during iteration" )             # <<<<<<<<<<<<<<
  * 
  *             # return result, if within same reference
  */
-  __pyx_k_tuple_135 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_133)); if (unlikely(!__pyx_k_tuple_135)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1995; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_135);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_135));
+  __pyx_k_tuple_143 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_141)); if (unlikely(!__pyx_k_tuple_143)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_143);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_143));
 
-  /* "pysam/csamtools.pyx":2158
+  /* "pysam/csamtools.pyx":2305
  *             qual = self.qual
  *         else:
  *             seq = self.seq.decode('ascii')             # <<<<<<<<<<<<<<
  *             qual = self.qual.decode('ascii')
  *         return "\t".join(map(str, (self.qname,
  */
-  __pyx_k_tuple_137 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_137)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2158; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_137);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_137));
+  __pyx_k_tuple_145 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_145)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2305; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_145);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_145));
 
-  /* "pysam/csamtools.pyx":2159
+  /* "pysam/csamtools.pyx":2306
  *         else:
  *             seq = self.seq.decode('ascii')
  *             qual = self.qual.decode('ascii')             # <<<<<<<<<<<<<<
  *         return "\t".join(map(str, (self.qname,
  *                                    self.flag,
  */
-  __pyx_k_tuple_138 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_138)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_138);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_138));
+  __pyx_k_tuple_146 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_146)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2306; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_146);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_146));
 
-  /* "pysam/csamtools.pyx":2587
+  /* "pysam/csamtools.pyx":2766
  *                 for pytag, value in tags:
  *                     if not type(pytag) is bytes:
  *                         pytag = pytag.encode('ascii')             # <<<<<<<<<<<<<<
  *                     t = type(value)
  * 
  */
-  __pyx_k_tuple_143 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_143)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2587; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_143);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_143));
+  __pyx_k_tuple_151 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_151)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2766; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_151);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_151));
 
-  /* "pysam/csamtools.pyx":2615
+  /* "pysam/csamtools.pyx":2794
  *                         datafmt = "2sccI%i%s" % (len(value), datafmt)
  *                         args.extend( [pytag[:2],
  *                                       pytype.encode('ascii'),             # <<<<<<<<<<<<<<
  *                                       datatype.encode('ascii'),
  *                                       len(value)] + list(value) )
  */
-  __pyx_k_tuple_146 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_146)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2615; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_146);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_146));
+  __pyx_k_tuple_154 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_154)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2794; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_154);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_154));
 
-  /* "pysam/csamtools.pyx":2616
+  /* "pysam/csamtools.pyx":2795
  *                         args.extend( [pytag[:2],
  *                                       pytype.encode('ascii'),
  *                                       datatype.encode('ascii'),             # <<<<<<<<<<<<<<
  *                                       len(value)] + list(value) )
  *                         fmts.append( datafmt )
  */
-  __pyx_k_tuple_147 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_147)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2616; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_147);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_147));
+  __pyx_k_tuple_155 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_155)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2795; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_155);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_155));
 
-  /* "pysam/csamtools.pyx":2639
+  /* "pysam/csamtools.pyx":2818
  *                         # Note: hex strings (H) are not supported yet
  *                         if t is not bytes:
  *                             value = value.encode('ascii')             # <<<<<<<<<<<<<<
  *                         if len(value) == 1:
  *                             fmt, pytype = "2scc", 'A'
  */
-  __pyx_k_tuple_148 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_148)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2639; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_148);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_148));
+  __pyx_k_tuple_156 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_156)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2818; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_156);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_156));
 
-  /* "pysam/csamtools.pyx":2646
+  /* "pysam/csamtools.pyx":2825
  * 
  *                     args.extend( [pytag[:2],
  *                                   pytype.encode('ascii'),             # <<<<<<<<<<<<<<
  *                                   value ] )
  * 
  */
-  __pyx_k_tuple_150 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_150)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_150);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_150));
+  __pyx_k_tuple_158 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__ascii)); if (unlikely(!__pyx_k_tuple_158)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2825; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_158);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_158));
 
-  /* "pysam/csamtools.pyx":3047
+  /* "pysam/csamtools.pyx":3264
  *     '''
  *     def __init__(self):
  *         raise TypeError("This class cannot be instantiated from Python")             # <<<<<<<<<<<<<<
  * 
  *     def __str__(self):
  */
-  __pyx_k_tuple_176 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_175)); if (unlikely(!__pyx_k_tuple_176)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3047; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_176);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_176));
+  __pyx_k_tuple_184 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_183)); if (unlikely(!__pyx_k_tuple_184)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3264; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_184);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_184));
 
-  /* "pysam/csamtools.pyx":3073
+  /* "pysam/csamtools.pyx":3290
  * 
- *             if self.plp[0] == NULL:
+ *             if self.plp == NULL or self.plp[0] == NULL:
  *                 raise ValueError("PileupProxy accessed after iterator finished")             # <<<<<<<<<<<<<<
  * 
  *             # warning: there could be problems if self.n and self.buf are
  */
-  __pyx_k_tuple_178 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_177)); if (unlikely(!__pyx_k_tuple_178)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3073; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_178);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_178));
+  __pyx_k_tuple_186 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_185)); if (unlikely(!__pyx_k_tuple_186)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3290; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_186);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_186));
 
-  /* "pysam/csamtools.pyx":3086
+  /* "pysam/csamtools.pyx":3303
  * 
  *     def __init__(self):
  *         raise TypeError("This class cannot be instantiated from Python")             # <<<<<<<<<<<<<<
  * 
  *     def __str__(self):
  */
-  __pyx_k_tuple_179 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_175)); if (unlikely(!__pyx_k_tuple_179)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3086; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_179);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_179));
+  __pyx_k_tuple_187 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_183)); if (unlikely(!__pyx_k_tuple_187)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3303; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_187);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_187));
 
-  /* "pysam/csamtools.pyx":3199
+  /* "pysam/csamtools.pyx":3416
  *         # recover. Thus redirect output to file with -o option.
  *         if method == "view":
  *             if "-o" in args: raise ValueError("option -o is forbidden in samtools view")             # <<<<<<<<<<<<<<
  *             args = ( "-o", stdout_f ) + args
  * 
  */
-  __pyx_k_tuple_184 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_183)); if (unlikely(!__pyx_k_tuple_184)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3199; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_184);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_184));
+  __pyx_k_tuple_192 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_191)); if (unlikely(!__pyx_k_tuple_192)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3416; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_192);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_192));
 
-  /* "pysam/csamtools.pyx":3224
+  /* "pysam/csamtools.pyx":3441
  *         stdout_save.restore()
  *         try:
  *             with open( stdout_f, "r") as inf:             # <<<<<<<<<<<<<<
  *                 out_stdout = inf.readlines()
  *         except UnicodeDecodeError:
  */
-  __pyx_k_tuple_185 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_tuple_185)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3224; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_185);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_185));
+  __pyx_k_tuple_193 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_tuple_193)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3441; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_193);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_193));
 
-  /* "pysam/csamtools.pyx":3227
+  /* "pysam/csamtools.pyx":3444
  *                 out_stdout = inf.readlines()
  *         except UnicodeDecodeError:
  *             with open( stdout_f, "rb") as inf:             # <<<<<<<<<<<<<<
  *                 # read binary output
  *                 out_stdout = inf.read()
  */
-  __pyx_k_tuple_186 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_tuple_186)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3227; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_186);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_186));
+  __pyx_k_tuple_194 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_tuple_194)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3444; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_194);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_194));
 
-  /* "pysam/csamtools.pyx":3237
+  /* "pysam/csamtools.pyx":3454
  *     pysam_unset_stderr()
  *     try:
  *         with open( stderr_f, "r") as inf:             # <<<<<<<<<<<<<<
  *             out_stderr = inf.readlines()
  *     except UnicodeDecodeError:
  */
-  __pyx_k_tuple_187 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_tuple_187)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3237; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_187);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_187));
+  __pyx_k_tuple_195 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_tuple_195)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3454; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_195);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_195));
 
-  /* "pysam/csamtools.pyx":3240
+  /* "pysam/csamtools.pyx":3457
  *             out_stderr = inf.readlines()
  *     except UnicodeDecodeError:
  *         with open( stderr_f, "rb") as inf:             # <<<<<<<<<<<<<<
  *             # read binary output
  *             out_stderr = inf.read()
  */
-  __pyx_k_tuple_188 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_tuple_188)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3240; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_188);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_188));
+  __pyx_k_tuple_196 = PyTuple_Pack(3, Py_None, Py_None, Py_None); if (unlikely(!__pyx_k_tuple_196)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3457; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_196);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_196));
 
   /* "pysam/csamtools.pyx":143
  * else:
@@ -40700,235 +42666,235 @@ static int __Pyx_InitCachedConstants(void) {
  * 
  * #####################################################################
  */
-  __pyx_k_tuple_256 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_255)); if (unlikely(!__pyx_k_tuple_256)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_256);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_256));
+  __pyx_k_tuple_265 = PyTuple_Pack(1, ((PyObject *)__pyx_kp_s_264)); if (unlikely(!__pyx_k_tuple_265)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_265);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_265));
 
-  /* "pysam/csamtools.pyx":260
+  /* "pysam/csamtools.pyx":267
  *         list of reads (:class:`pysam.PileupRead`) aligned to this column
  *     '''
  *     def __str__(self):             # <<<<<<<<<<<<<<
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
  *             "\n" + "\n".join( map(str, self.pileups) )
  */
-  __pyx_k_tuple_258 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_258)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_258);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_258));
-  __pyx_k_codeobj_259 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_258, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s____str__, 260, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_259)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_267 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_267)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_267);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_267));
+  __pyx_k_codeobj_268 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_267, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s____str__, 267, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_268)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":308
+  /* "pysam/csamtools.pyx":315
  *     stderr is captured.
  *     '''
  *     def __init__(self):             # <<<<<<<<<<<<<<
  *         return
  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
  */
-  __pyx_k_tuple_264 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_264)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_264);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_264));
-  __pyx_k_codeobj_265 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_264, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s____init__, 308, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_265)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_273 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_273)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_273);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_273));
+  __pyx_k_codeobj_274 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_273, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s____init__, 315, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_274)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":314
+  /* "pysam/csamtools.pyx":321
  *         self.stderr_save.setfd( self.stderr_h )
  * 
  *     def readAndRelease( self ):             # <<<<<<<<<<<<<<
  *         return []
  *         self.stderr_save.restore()
  */
-  __pyx_k_tuple_267 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_267)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_267);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_267));
-  __pyx_k_codeobj_268 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_267, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s__readAndRelease, 314, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_268)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_276 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_276)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_276);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_276));
+  __pyx_k_codeobj_277 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_276, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s__readAndRelease, 321, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_277)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":323
+  /* "pysam/csamtools.pyx":330
  *         return lines
  * 
  *     def release(self):             # <<<<<<<<<<<<<<
  *         return
  *         self.stderr_save.restore()
  */
-  __pyx_k_tuple_270 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_270)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_270);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_270));
-  __pyx_k_codeobj_271 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_270, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s__release, 323, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_271)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_279 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_279)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_279);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_279));
+  __pyx_k_codeobj_280 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_279, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s__release, 330, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_280)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":329
+  /* "pysam/csamtools.pyx":336
  *             os.remove( self.stderr_f )
  * 
  *     def __del__(self):             # <<<<<<<<<<<<<<
  *         self.release()
  * 
  */
-  __pyx_k_tuple_273 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_273)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_273);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_273));
-  __pyx_k_codeobj_274 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_273, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s____del__, 329, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_274)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_282 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_282)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_282);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_282));
+  __pyx_k_codeobj_283 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_282, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s____del__, 336, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_283)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":334
+  /* "pysam/csamtools.pyx":341
  * class StderrStoreWindows():
  *     '''does nothing. stderr can't be redirected on windows'''
  *     def __init__(self): pass             # <<<<<<<<<<<<<<
  *     def readAndRelease(self): return []
  *     def release(self): pass
  */
-  __pyx_k_tuple_277 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_277)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_277);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_277));
-  __pyx_k_codeobj_278 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_277, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s____init__, 334, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_278)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_286 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_286)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_286);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_286));
+  __pyx_k_codeobj_287 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_286, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s____init__, 341, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_287)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":335
+  /* "pysam/csamtools.pyx":342
  *     '''does nothing. stderr can't be redirected on windows'''
  *     def __init__(self): pass
  *     def readAndRelease(self): return []             # <<<<<<<<<<<<<<
  *     def release(self): pass
  * 
  */
-  __pyx_k_tuple_280 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_280)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_280);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_280));
-  __pyx_k_codeobj_281 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_280, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s__readAndRelease, 335, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_281)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_289 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_289)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_289);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_289));
+  __pyx_k_codeobj_290 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_289, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s__readAndRelease, 342, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_290)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":336
+  /* "pysam/csamtools.pyx":343
  *     def __init__(self): pass
  *     def readAndRelease(self): return []
  *     def release(self): pass             # <<<<<<<<<<<<<<
  * 
  * if platform.system()=='Windows':
  */
-  __pyx_k_tuple_283 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_283)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_283);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_283));
-  __pyx_k_codeobj_284 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_283, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s__release, 336, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_284)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_292 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_292)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_292);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_292));
+  __pyx_k_codeobj_293 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_292, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s__release, 343, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_293)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":354
+  /* "pysam/csamtools.pyx":361
  * 
  * # order of records within sam headers
  * VALID_HEADERS = ("HD", "SQ", "RG", "PG", "CO" )             # <<<<<<<<<<<<<<
  * 
  * # type conversions within sam header records
  */
-  __pyx_k_tuple_287 = PyTuple_Pack(5, ((PyObject *)__pyx_n_s__HD), ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_n_s__RG), ((PyObject *)__pyx_n_s__PG), ((PyObject *)__pyx_n_s__CO)); if (unlikely(!__pyx_k_tuple_287)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_287);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_287));
+  __pyx_k_tuple_296 = PyTuple_Pack(5, ((PyObject *)__pyx_n_s__HD), ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_n_s__RG), ((PyObject *)__pyx_n_s__PG), ((PyObject *)__pyx_n_s__CO)); if (unlikely(!__pyx_k_tuple_296)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_296);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_296));
 
-  /* "pysam/csamtools.pyx":364
+  /* "pysam/csamtools.pyx":371
  * 
  * # output order of fields within records
  * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),             # <<<<<<<<<<<<<<
  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL", "FO", "KS", "PG" ),
  */
-  __pyx_k_tuple_288 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__VN), ((PyObject *)__pyx_n_s__SO), ((PyObject *)__pyx_n_s__GO)); if (unlikely(!__pyx_k_tuple_288)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_288);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_288));
+  __pyx_k_tuple_297 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__VN), ((PyObject *)__pyx_n_s__SO), ((PyObject *)__pyx_n_s__GO)); if (unlikely(!__pyx_k_tuple_297)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_297);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_297));
 
-  /* "pysam/csamtools.pyx":365
+  /* "pysam/csamtools.pyx":372
  * # output order of fields within records
  * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),
  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),             # <<<<<<<<<<<<<<
  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL", "FO", "KS", "PG" ),
  *                        "PG" : ( "PN", "ID", "VN", "CL", "PP" ), }
  */
-  __pyx_k_tuple_289 = PyTuple_Pack(6, ((PyObject *)__pyx_n_s__SN), ((PyObject *)__pyx_n_s__LN), ((PyObject *)__pyx_n_s__AS), ((PyObject *)__pyx_n_s__M5), ((PyObject *)__pyx_n_s__UR), ((PyObject *)__pyx_n_s__SP)); if (unlikely(!__pyx_k_tuple_289)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_289);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_289));
+  __pyx_k_tuple_298 = PyTuple_Pack(6, ((PyObject *)__pyx_n_s__SN), ((PyObject *)__pyx_n_s__LN), ((PyObject *)__pyx_n_s__AS), ((PyObject *)__pyx_n_s__M5), ((PyObject *)__pyx_n_s__UR), ((PyObject *)__pyx_n_s__SP)); if (unlikely(!__pyx_k_tuple_298)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 372; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_298);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_298));
 
-  /* "pysam/csamtools.pyx":366
+  /* "pysam/csamtools.pyx":373
  * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),
  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL", "FO", "KS", "PG" ),             # <<<<<<<<<<<<<<
  *                        "PG" : ( "PN", "ID", "VN", "CL", "PP" ), }
  * 
  */
-  __pyx_k_tuple_290 = PyTuple_Pack(12, ((PyObject *)__pyx_n_s__ID), ((PyObject *)__pyx_n_s__SM), ((PyObject *)__pyx_n_s__LB), ((PyObject *)__pyx_n_s__DS), ((PyObject *)__pyx_n_s__PU), ((PyObject *)__pyx_n_s__PI), ((PyObject *)__pyx_n_s__CN), ((PyObject *)__pyx_n_s__DT), ((PyObject *)__pyx_n_s__PL), ((PyObject *)__pyx_n_s__FO), ((PyObject *)__pyx_n_s__KS), ((PyObject *)__pyx_n_s__PG)); if (unlikely(!__pyx_k_tuple_290)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LI [...]
-  __Pyx_GOTREF(__pyx_k_tuple_290);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_290));
+  __pyx_k_tuple_299 = PyTuple_Pack(12, ((PyObject *)__pyx_n_s__ID), ((PyObject *)__pyx_n_s__SM), ((PyObject *)__pyx_n_s__LB), ((PyObject *)__pyx_n_s__DS), ((PyObject *)__pyx_n_s__PU), ((PyObject *)__pyx_n_s__PI), ((PyObject *)__pyx_n_s__CN), ((PyObject *)__pyx_n_s__DT), ((PyObject *)__pyx_n_s__PL), ((PyObject *)__pyx_n_s__FO), ((PyObject *)__pyx_n_s__KS), ((PyObject *)__pyx_n_s__PG)); if (unlikely(!__pyx_k_tuple_299)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 373; __pyx_clineno = __LI [...]
+  __Pyx_GOTREF(__pyx_k_tuple_299);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_299));
 
-  /* "pysam/csamtools.pyx":367
+  /* "pysam/csamtools.pyx":374
  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL", "FO", "KS", "PG" ),
  *                        "PG" : ( "PN", "ID", "VN", "CL", "PP" ), }             # <<<<<<<<<<<<<<
  * 
  * 
  */
-  __pyx_k_tuple_291 = PyTuple_Pack(5, ((PyObject *)__pyx_n_s__PN), ((PyObject *)__pyx_n_s__ID), ((PyObject *)__pyx_n_s__VN), ((PyObject *)__pyx_n_s__CL), ((PyObject *)__pyx_n_s__PP)); if (unlikely(!__pyx_k_tuple_291)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 367; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_291);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_291));
+  __pyx_k_tuple_300 = PyTuple_Pack(5, ((PyObject *)__pyx_n_s__PN), ((PyObject *)__pyx_n_s__ID), ((PyObject *)__pyx_n_s__VN), ((PyObject *)__pyx_n_s__CL), ((PyObject *)__pyx_n_s__PP)); if (unlikely(!__pyx_k_tuple_300)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 374; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_300);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_300));
 
-  /* "pysam/csamtools.pyx":3119
+  /* "pysam/csamtools.pyx":3336
  * class Outs:
  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
  *     def __init__(self, id = 1):             # <<<<<<<<<<<<<<
  *         self.streams = []
  *         self.id = id
  */
-  __pyx_k_tuple_292 = PyTuple_Pack(2, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_n_s__id)); if (unlikely(!__pyx_k_tuple_292)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_292);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_292));
-  __pyx_k_codeobj_293 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_292, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s____init__, 3119, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_293)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_k_tuple_294 = PyTuple_Pack(1, ((PyObject *)__pyx_int_1)); if (unlikely(!__pyx_k_tuple_294)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_294);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_294));
+  __pyx_k_tuple_301 = PyTuple_Pack(2, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_n_s__id)); if (unlikely(!__pyx_k_tuple_301)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_301);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_301));
+  __pyx_k_codeobj_302 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_301, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s____init__, 3336, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_302)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_303 = PyTuple_Pack(1, ((PyObject *)__pyx_int_1)); if (unlikely(!__pyx_k_tuple_303)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_303);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_303));
 
-  /* "pysam/csamtools.pyx":3123
+  /* "pysam/csamtools.pyx":3340
  *         self.id = id
  * 
  *     def setdevice(self, filename):             # <<<<<<<<<<<<<<
  *         '''open an existing file, like "/dev/null"'''
  *         fd = os.open(filename, os.O_WRONLY)
  */
-  __pyx_k_tuple_296 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_n_s__filename), ((PyObject *)__pyx_n_s__fd)); if (unlikely(!__pyx_k_tuple_296)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_296);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_296));
-  __pyx_k_codeobj_297 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_296, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s__setdevice, 3123, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_297)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_305 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_n_s__filename), ((PyObject *)__pyx_n_s__fd)); if (unlikely(!__pyx_k_tuple_305)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_305);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_305));
+  __pyx_k_codeobj_306 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_305, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s__setdevice, 3340, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_306)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":3128
+  /* "pysam/csamtools.pyx":3345
  *         self.setfd(fd)
  * 
  *     def setfile(self, filename):             # <<<<<<<<<<<<<<
  *         '''open a new file.'''
  *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);
  */
-  __pyx_k_tuple_299 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_n_s__filename), ((PyObject *)__pyx_n_s__fd)); if (unlikely(!__pyx_k_tuple_299)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_299);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_299));
-  __pyx_k_codeobj_300 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_299, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s__setfile, 3128, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_300)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_308 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_n_s__filename), ((PyObject *)__pyx_n_s__fd)); if (unlikely(!__pyx_k_tuple_308)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_308);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_308));
+  __pyx_k_codeobj_309 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_308, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s__setfile, 3345, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_309)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":3133
+  /* "pysam/csamtools.pyx":3350
  *         self.setfd(fd)
  * 
  *     def setfd(self, fd):             # <<<<<<<<<<<<<<
  *         ofd = os.dup(self.id)      #  Save old stream on new unit.
  *         self.streams.append(ofd)
  */
-  __pyx_k_tuple_302 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_n_s__fd), ((PyObject *)__pyx_n_s__ofd)); if (unlikely(!__pyx_k_tuple_302)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_302);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_302));
-  __pyx_k_codeobj_303 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_302, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s__setfd, 3133, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_303)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_311 = PyTuple_Pack(3, ((PyObject *)__pyx_n_s__self), ((PyObject *)__pyx_n_s__fd), ((PyObject *)__pyx_n_s__ofd)); if (unlikely(!__pyx_k_tuple_311)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_311);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_311));
+  __pyx_k_codeobj_312 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_311, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s__setfd, 3350, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_312)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":3141
+  /* "pysam/csamtools.pyx":3358
  *         os.close(fd)                #  Close other unit (look out, caller.)
  * 
  *     def restore(self):             # <<<<<<<<<<<<<<
  *         '''restore previous output stream'''
  *         if self.streams:
  */
-  __pyx_k_tuple_305 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_305)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __Pyx_GOTREF(__pyx_k_tuple_305);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_305));
-  __pyx_k_codeobj_306 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_305, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s__restore, 3141, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_306)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_314 = PyTuple_Pack(1, ((PyObject *)__pyx_n_s__self)); if (unlikely(!__pyx_k_tuple_314)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_k_tuple_314);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_314));
+  __pyx_k_codeobj_315 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_314, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s__restore, 3358, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_315)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":3152
+  /* "pysam/csamtools.pyx":3369
  *             del self.streams[-1]
  * 
  * def _samtools_dispatch( method,             # <<<<<<<<<<<<<<
  *                         args = (),
  *                         catch_stdout = True ):
  */
-  __pyx_k_tuple_309 = PyTuple_Pack(16, ((PyObject *)__pyx_n_s__method), ((PyObject *)__pyx_n_s__args), ((PyObject *)__pyx_n_s__catch_stdout), ((PyObject *)__pyx_n_s__stderr_h), ((PyObject *)__pyx_n_s__stderr_f), ((PyObject *)__pyx_n_s__stdout_h), ((PyObject *)__pyx_n_s__stdout_f), ((PyObject *)__pyx_n_s__stdout_save), ((PyObject *)__pyx_n_s__cargs), ((PyObject *)__pyx_n_s__i), ((PyObject *)__pyx_n_s__n), ((PyObject *)__pyx_n_s__retval), ((PyObject *)__pyx_n_s__inf), ((PyObject *)__pyx_n_ [...]
-  __Pyx_GOTREF(__pyx_k_tuple_309);
-  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_309));
-  __pyx_k_codeobj_310 = (PyObject*)__Pyx_PyCode_New(3, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_309, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_260, __pyx_n_s___samtools_dispatch, 3152, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_310)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_k_tuple_318 = PyTuple_Pack(16, ((PyObject *)__pyx_n_s__method), ((PyObject *)__pyx_n_s__args), ((PyObject *)__pyx_n_s__catch_stdout), ((PyObject *)__pyx_n_s__stderr_h), ((PyObject *)__pyx_n_s__stderr_f), ((PyObject *)__pyx_n_s__stdout_h), ((PyObject *)__pyx_n_s__stdout_f), ((PyObject *)__pyx_n_s__stdout_save), ((PyObject *)__pyx_n_s__cargs), ((PyObject *)__pyx_n_s__i), ((PyObject *)__pyx_n_s__n), ((PyObject *)__pyx_n_s__retval), ((PyObject *)__pyx_n_s__inf), ((PyObject *)__pyx_n_ [...]
+  __Pyx_GOTREF(__pyx_k_tuple_318);
+  __Pyx_GIVEREF(((PyObject *)__pyx_k_tuple_318));
+  __pyx_k_codeobj_319 = (PyObject*)__Pyx_PyCode_New(3, 0, 16, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_k_tuple_318, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_269, __pyx_n_s___samtools_dispatch, 3369, __pyx_empty_bytes); if (unlikely(!__pyx_k_codeobj_319)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_RefNannyFinishContext();
   return 0;
   __pyx_L1_error:;
@@ -41043,14 +43009,34 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   /*--- Type init code ---*/
   __pyx_vtabptr_5pysam_9csamtools_Fastafile = &__pyx_vtable_5pysam_9csamtools_Fastafile;
   __pyx_vtable_5pysam_9csamtools_Fastafile._fetch = (char *(*)(struct __pyx_obj_5pysam_9csamtools_Fastafile *, char *, int, int, int *))__pyx_f_5pysam_9csamtools_9Fastafile__fetch;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_Fastafile.tp_dict, __pyx_vtabptr_5pysam_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "Fastafile", (PyObject *)&__pyx_type_5pysam_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 375; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_Fastafile.tp_dict, __pyx_vtabptr_5pysam_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "Fastafile", (PyObject *)&__pyx_type_5pysam_9csamtools_Fastafile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 382; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_Fastafile = &__pyx_type_5pysam_9csamtools_Fastafile;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_FastqProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "FastqProxy", (PyObject *)&__pyx_type_5pysam_9csamtools_FastqProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 523; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_5pysam_9csamtools_FastqProxy = &__pyx_type_5pysam_9csamtools_FastqProxy;
+  __pyx_vtabptr_5pysam_9csamtools_Fastqfile = &__pyx_vtable_5pysam_9csamtools_Fastqfile;
+  __pyx_vtable_5pysam_9csamtools_Fastqfile.getCurrent = (kseq_t *(*)(struct __pyx_obj_5pysam_9csamtools_Fastqfile *))__pyx_f_5pysam_9csamtools_9Fastqfile_getCurrent;
+  __pyx_vtable_5pysam_9csamtools_Fastqfile.cnext = (int (*)(struct __pyx_obj_5pysam_9csamtools_Fastqfile *))__pyx_f_5pysam_9csamtools_9Fastqfile_cnext;
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_Fastqfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   #if CYTHON_COMPILING_IN_CPYTHON
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_AlignedRead, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_Fastqfile, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_5pysam_9csamtools_9Fastqfile_12__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_5pysam_9csamtools_9Fastqfile_12__next__.doc = __pyx_doc_5pysam_9csamtools_9Fastqfile_12__next__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_5pysam_9csamtools_9Fastqfile_12__next__;
+    }
+  }
+  #endif
+  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_Fastqfile.tp_dict, __pyx_vtabptr_5pysam_9csamtools_Fastqfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "Fastqfile", (PyObject *)&__pyx_type_5pysam_9csamtools_Fastqfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 546; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_5pysam_9csamtools_Fastqfile = &__pyx_type_5pysam_9csamtools_Fastqfile;
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #if CYTHON_COMPILING_IN_CPYTHON
+  {
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_AlignedRead, "__str__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_5pysam_9csamtools_11AlignedRead_4__str__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_5pysam_9csamtools_11AlignedRead_4__str__.doc = __pyx_doc_5pysam_9csamtools_11AlignedRead_4__str__;
@@ -41058,7 +43044,7 @@ PyMODINIT_FUNC PyInit_csamtools(void)
     }
   }
   #endif
-  if (__Pyx_SetAttrString(__pyx_m, "AlignedRead", (PyObject *)&__pyx_type_5pysam_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2099; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "AlignedRead", (PyObject *)&__pyx_type_5pysam_9csamtools_AlignedRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_AlignedRead = &__pyx_type_5pysam_9csamtools_AlignedRead;
   __pyx_vtabptr_5pysam_9csamtools_Samfile = &__pyx_vtable_5pysam_9csamtools_Samfile;
   __pyx_vtable_5pysam_9csamtools_Samfile._buildHeader = (bam_header_t *(*)(struct __pyx_obj_5pysam_9csamtools_Samfile *, PyObject *))__pyx_f_5pysam_9csamtools_7Samfile__buildHeader;
@@ -41066,10 +43052,10 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   __pyx_vtable_5pysam_9csamtools_Samfile.cnext = (int (*)(struct __pyx_obj_5pysam_9csamtools_Samfile *))__pyx_f_5pysam_9csamtools_7Samfile_cnext;
   __pyx_vtable_5pysam_9csamtools_Samfile.write = (int (*)(struct __pyx_obj_5pysam_9csamtools_Samfile *, struct __pyx_obj_5pysam_9csamtools_AlignedRead *, int __pyx_skip_dispatch))__pyx_f_5pysam_9csamtools_7Samfile_write;
   __pyx_vtable_5pysam_9csamtools_Samfile._getrname = (char *(*)(struct __pyx_obj_5pysam_9csamtools_Samfile *, int))__pyx_f_5pysam_9csamtools_7Samfile__getrname;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   #if CYTHON_COMPILING_IN_CPYTHON
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_Samfile, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_Samfile, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_5pysam_9csamtools_7Samfile_42__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_5pysam_9csamtools_7Samfile_42__next__.doc = __pyx_doc_5pysam_9csamtools_7Samfile_42__next__;
@@ -41077,26 +43063,26 @@ PyMODINIT_FUNC PyInit_csamtools(void)
     }
   }
   #endif
-  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_Samfile.tp_dict, __pyx_vtabptr_5pysam_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "Samfile", (PyObject *)&__pyx_type_5pysam_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_Samfile.tp_dict, __pyx_vtabptr_5pysam_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "Samfile", (PyObject *)&__pyx_type_5pysam_9csamtools_Samfile) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 671; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_Samfile = &__pyx_type_5pysam_9csamtools_Samfile;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "PileupProxy", (PyObject *)&__pyx_type_5pysam_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3029; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "PileupProxy", (PyObject *)&__pyx_type_5pysam_9csamtools_PileupProxy) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3246; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_PileupProxy = &__pyx_type_5pysam_9csamtools_PileupProxy;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "PileupRead", (PyObject *)&__pyx_type_5pysam_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "PileupRead", (PyObject *)&__pyx_type_5pysam_9csamtools_PileupRead) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3298; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_PileupRead = &__pyx_type_5pysam_9csamtools_PileupRead;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRow", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRow", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRow) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1572; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_IteratorRow = &__pyx_type_5pysam_9csamtools_IteratorRow;
   __pyx_vtabptr_5pysam_9csamtools_IteratorRowRegion = &__pyx_vtable_5pysam_9csamtools_IteratorRowRegion;
   __pyx_vtable_5pysam_9csamtools_IteratorRowRegion.getCurrent = (bam1_t *(*)(struct __pyx_obj_5pysam_9csamtools_IteratorRowRegion *))__pyx_f_5pysam_9csamtools_17IteratorRowRegion_getCurrent;
   __pyx_vtable_5pysam_9csamtools_IteratorRowRegion.cnext = (int (*)(struct __pyx_obj_5pysam_9csamtools_IteratorRowRegion *))__pyx_f_5pysam_9csamtools_17IteratorRowRegion_cnext;
   __pyx_type_5pysam_9csamtools_IteratorRowRegion.tp_base = __pyx_ptype_5pysam_9csamtools_IteratorRow;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   #if CYTHON_COMPILING_IN_CPYTHON
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowRegion, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowRegion, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_5pysam_9csamtools_17IteratorRowRegion_4__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_5pysam_9csamtools_17IteratorRowRegion_4__next__.doc = __pyx_doc_5pysam_9csamtools_17IteratorRowRegion_4__next__;
@@ -41104,17 +43090,17 @@ PyMODINIT_FUNC PyInit_csamtools(void)
     }
   }
   #endif
-  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_IteratorRowRegion.tp_dict, __pyx_vtabptr_5pysam_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowRegion", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1466; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_IteratorRowRegion.tp_dict, __pyx_vtabptr_5pysam_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowRegion", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1597; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_IteratorRowRegion = &__pyx_type_5pysam_9csamtools_IteratorRowRegion;
   __pyx_vtabptr_5pysam_9csamtools_IteratorRowAll = &__pyx_vtable_5pysam_9csamtools_IteratorRowAll;
   __pyx_vtable_5pysam_9csamtools_IteratorRowAll.getCurrent = (bam1_t *(*)(struct __pyx_obj_5pysam_9csamtools_IteratorRowAll *))__pyx_f_5pysam_9csamtools_14IteratorRowAll_getCurrent;
   __pyx_vtable_5pysam_9csamtools_IteratorRowAll.cnext = (int (*)(struct __pyx_obj_5pysam_9csamtools_IteratorRowAll *))__pyx_f_5pysam_9csamtools_14IteratorRowAll_cnext;
   __pyx_type_5pysam_9csamtools_IteratorRowAll.tp_base = __pyx_ptype_5pysam_9csamtools_IteratorRow;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   #if CYTHON_COMPILING_IN_CPYTHON
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowAll, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowAll, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_5pysam_9csamtools_14IteratorRowAll_4__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_5pysam_9csamtools_14IteratorRowAll_4__next__.doc = __pyx_doc_5pysam_9csamtools_14IteratorRowAll_4__next__;
@@ -41122,14 +43108,14 @@ PyMODINIT_FUNC PyInit_csamtools(void)
     }
   }
   #endif
-  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_IteratorRowAll.tp_dict, __pyx_vtabptr_5pysam_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowAll", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1545; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_IteratorRowAll.tp_dict, __pyx_vtabptr_5pysam_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowAll", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowAll) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1681; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_IteratorRowAll = &__pyx_type_5pysam_9csamtools_IteratorRowAll;
   __pyx_type_5pysam_9csamtools_IteratorRowAllRefs.tp_base = __pyx_ptype_5pysam_9csamtools_IteratorRow;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   #if CYTHON_COMPILING_IN_CPYTHON
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowAllRefs, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowAllRefs, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_5pysam_9csamtools_18IteratorRowAllRefs_6__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_5pysam_9csamtools_18IteratorRowAllRefs_6__next__.doc = __pyx_doc_5pysam_9csamtools_18IteratorRowAllRefs_6__next__;
@@ -41137,16 +43123,16 @@ PyMODINIT_FUNC PyInit_csamtools(void)
     }
   }
   #endif
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowAllRefs", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1603; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowAllRefs", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_IteratorRowAllRefs = &__pyx_type_5pysam_9csamtools_IteratorRowAllRefs;
   __pyx_vtabptr_5pysam_9csamtools_IteratorRowSelection = &__pyx_vtable_5pysam_9csamtools_IteratorRowSelection;
   __pyx_vtable_5pysam_9csamtools_IteratorRowSelection.getCurrent = (bam1_t *(*)(struct __pyx_obj_5pysam_9csamtools_IteratorRowSelection *))__pyx_f_5pysam_9csamtools_20IteratorRowSelection_getCurrent;
   __pyx_vtable_5pysam_9csamtools_IteratorRowSelection.cnext = (int (*)(struct __pyx_obj_5pysam_9csamtools_IteratorRowSelection *))__pyx_f_5pysam_9csamtools_20IteratorRowSelection_cnext;
   __pyx_type_5pysam_9csamtools_IteratorRowSelection.tp_base = __pyx_ptype_5pysam_9csamtools_IteratorRow;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   #if CYTHON_COMPILING_IN_CPYTHON
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowSelection, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowSelection, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_5pysam_9csamtools_20IteratorRowSelection_4__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_5pysam_9csamtools_20IteratorRowSelection_4__next__.doc = __pyx_doc_5pysam_9csamtools_20IteratorRowSelection_4__next__;
@@ -41154,8 +43140,8 @@ PyMODINIT_FUNC PyInit_csamtools(void)
     }
   }
   #endif
-  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_IteratorRowSelection.tp_dict, __pyx_vtabptr_5pysam_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowSelection", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1646; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_IteratorRowSelection.tp_dict, __pyx_vtabptr_5pysam_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorRowSelection", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorRowSelection) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1792; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_IteratorRowSelection = &__pyx_type_5pysam_9csamtools_IteratorRowSelection;
   __pyx_vtabptr_5pysam_9csamtools_IteratorColumn = &__pyx_vtable_5pysam_9csamtools_IteratorColumn;
   __pyx_vtable_5pysam_9csamtools_IteratorColumn.cnext = (int (*)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *))__pyx_f_5pysam_9csamtools_14IteratorColumn_cnext;
@@ -41163,17 +43149,17 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   __pyx_vtable_5pysam_9csamtools_IteratorColumn.setMask = (PyObject *(*)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *, PyObject *))__pyx_f_5pysam_9csamtools_14IteratorColumn_setMask;
   __pyx_vtable_5pysam_9csamtools_IteratorColumn.setupIteratorData = (PyObject *(*)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *, int, int, int, struct __pyx_opt_args_5pysam_9csamtools_14IteratorColumn_setupIteratorData *__pyx_optional_args))__pyx_f_5pysam_9csamtools_14IteratorColumn_setupIteratorData;
   __pyx_vtable_5pysam_9csamtools_IteratorColumn.reset = (PyObject *(*)(struct __pyx_obj_5pysam_9csamtools_IteratorColumn *, PyObject *, PyObject *, PyObject *))__pyx_f_5pysam_9csamtools_14IteratorColumn_reset;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_IteratorColumn.tp_dict, __pyx_vtabptr_5pysam_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumn", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1771; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_IteratorColumn.tp_dict, __pyx_vtabptr_5pysam_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumn", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorColumn) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1921; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_IteratorColumn = &__pyx_type_5pysam_9csamtools_IteratorColumn;
   __pyx_vtabptr_5pysam_9csamtools_IteratorColumnRegion = &__pyx_vtable_5pysam_9csamtools_IteratorColumnRegion;
   __pyx_vtable_5pysam_9csamtools_IteratorColumnRegion.__pyx_base = *__pyx_vtabptr_5pysam_9csamtools_IteratorColumn;
   __pyx_type_5pysam_9csamtools_IteratorColumnRegion.tp_base = __pyx_ptype_5pysam_9csamtools_IteratorColumn;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   #if CYTHON_COMPILING_IN_CPYTHON
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_IteratorColumnRegion, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_IteratorColumnRegion, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_5pysam_9csamtools_20IteratorColumnRegion_2__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_5pysam_9csamtools_20IteratorColumnRegion_2__next__.doc = __pyx_doc_5pysam_9csamtools_20IteratorColumnRegion_2__next__;
@@ -41181,16 +43167,16 @@ PyMODINIT_FUNC PyInit_csamtools(void)
     }
   }
   #endif
-  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_IteratorColumnRegion.tp_dict, __pyx_vtabptr_5pysam_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumnRegion", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1936; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_IteratorColumnRegion.tp_dict, __pyx_vtabptr_5pysam_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumnRegion", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorColumnRegion) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2083; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_IteratorColumnRegion = &__pyx_type_5pysam_9csamtools_IteratorColumnRegion;
   __pyx_vtabptr_5pysam_9csamtools_IteratorColumnAllRefs = &__pyx_vtable_5pysam_9csamtools_IteratorColumnAllRefs;
   __pyx_vtable_5pysam_9csamtools_IteratorColumnAllRefs.__pyx_base = *__pyx_vtabptr_5pysam_9csamtools_IteratorColumn;
   __pyx_type_5pysam_9csamtools_IteratorColumnAllRefs.tp_base = __pyx_ptype_5pysam_9csamtools_IteratorColumn;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   #if CYTHON_COMPILING_IN_CPYTHON
   {
-    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_IteratorColumnAllRefs, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    PyObject *wrapper = __Pyx_GetAttrString((PyObject *)&__pyx_type_5pysam_9csamtools_IteratorColumnAllRefs, "__next__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
       __pyx_wrapperbase_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__ = *((PyWrapperDescrObject *)wrapper)->d_base;
       __pyx_wrapperbase_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__.doc = __pyx_doc_5pysam_9csamtools_21IteratorColumnAllRefs_2__next__;
@@ -41198,14 +43184,14 @@ PyMODINIT_FUNC PyInit_csamtools(void)
     }
   }
   #endif
-  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_IteratorColumnAllRefs.tp_dict, __pyx_vtabptr_5pysam_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumnAllRefs", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1973; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetVtable(__pyx_type_5pysam_9csamtools_IteratorColumnAllRefs.tp_dict, __pyx_vtabptr_5pysam_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IteratorColumnAllRefs", (PyObject *)&__pyx_type_5pysam_9csamtools_IteratorColumnAllRefs) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 2120; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_IteratorColumnAllRefs = &__pyx_type_5pysam_9csamtools_IteratorColumnAllRefs;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IndexedReads) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "IndexedReads", (PyObject *)&__pyx_type_5pysam_9csamtools_IndexedReads) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3804; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_IndexedReads) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "IndexedReads", (PyObject *)&__pyx_type_5pysam_9csamtools_IndexedReads) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4021; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_IndexedReads = &__pyx_type_5pysam_9csamtools_IndexedReads;
-  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (__Pyx_SetAttrString(__pyx_m, "SNPCall", (PyObject *)&__pyx_type_5pysam_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3250; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyType_Ready(&__pyx_type_5pysam_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__Pyx_SetAttrString(__pyx_m, "SNPCall", (PyObject *)&__pyx_type_5pysam_9csamtools_SNPCall) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3467; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools_SNPCall = &__pyx_type_5pysam_9csamtools_SNPCall;
   if (PyType_Ready(&__pyx_type_5pysam_9csamtools___pyx_scope_struct__genexpr) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __pyx_ptype_5pysam_9csamtools___pyx_scope_struct__genexpr = &__pyx_type_5pysam_9csamtools___pyx_scope_struct__genexpr;
@@ -41378,7 +43364,7 @@ PyMODINIT_FUNC PyInit_csamtools(void)
  */
   __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s_253); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s_262); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -41459,7 +43445,7 @@ PyMODINIT_FUNC PyInit_csamtools(void)
  * if IS_PYTHON3:
  *     CIGAR2CODE = dict( [y,x] for x,y in enumerate( CODE2CIGAR) )
  */
-  __pyx_v_5pysam_9csamtools_CODE2CIGAR = __pyx_k_254;
+  __pyx_v_5pysam_9csamtools_CODE2CIGAR = __pyx_k_263;
 
   /* "pysam/csamtools.pyx":139
  * 
@@ -41531,7 +43517,7 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   __pyx_t_2 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__compile); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_256), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_2, ((PyObject *)__pyx_k_tuple_265), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
   if (PyObject_SetAttr(__pyx_m, __pyx_n_s__CIGAR_REGEX, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 143; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
@@ -41553,7 +43539,7 @@ PyMODINIT_FUNC PyInit_csamtools(void)
  * cdef int max_pos = 2 << 29
  * 
  */
-  __pyx_v_5pysam_9csamtools_bam_nt16_rev_table = __pyx_k_257;
+  __pyx_v_5pysam_9csamtools_bam_nt16_rev_table = __pyx_k_266;
 
   /* "pysam/csamtools.pyx":152
  * # hard-coded constants
@@ -41564,601 +43550,601 @@ PyMODINIT_FUNC PyInit_csamtools(void)
  */
   __pyx_v_5pysam_9csamtools_max_pos = 1073741824;
 
-  /* "pysam/csamtools.pyx":247
+  /* "pysam/csamtools.pyx":254
  *     (<object>f)(a)
  * 
  * class PileupColumn(object):             # <<<<<<<<<<<<<<
  *     '''A pileup column. A pileup column contains
  *     all the reads that map to a certain target base.
  */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
-  /* "pysam/csamtools.pyx":260
+  /* "pysam/csamtools.pyx":267
  *         list of reads (:class:`pysam.PileupRead`) aligned to this column
  *     '''
  *     def __str__(self):             # <<<<<<<<<<<<<<
  *         return "\t".join( map(str, (self.tid, self.pos, self.n))) +\
  *             "\n" + "\n".join( map(str, self.pileups) )
  */
-  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_12PileupColumn_1__str__, 0, __pyx_n_s_261, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_259)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_12PileupColumn_1__str__, 0, __pyx_n_s_270, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_268)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____str__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 260; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____str__, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 267; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
 
-  /* "pysam/csamtools.pyx":247
+  /* "pysam/csamtools.pyx":254
  *     (<object>f)(a)
  * 
  * class PileupColumn(object):             # <<<<<<<<<<<<<<
  *     '''A pileup column. A pileup column contains
  *     all the reads that map to a certain target base.
  */
-  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_2);
   __Pyx_INCREF(__pyx_builtin_object);
   PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_object);
   __Pyx_GIVEREF(__pyx_builtin_object);
-  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_263)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_4 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__PileupColumn, __pyx_n_s__PileupColumn, __pyx_n_s_262); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_272)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_CreateClass(((PyObject *)__pyx_t_2), ((PyObject *)__pyx_t_1), __pyx_n_s__PileupColumn, __pyx_n_s__PileupColumn, __pyx_n_s_271); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(((PyObject *)__pyx_t_2)); __pyx_t_2 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PileupColumn, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 247; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__PileupColumn, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 254; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":304
+  /* "pysam/csamtools.pyx":311
  *     return 0
  * 
  * class StderrStore():             # <<<<<<<<<<<<<<
  *     '''
  *     stderr is captured.
  */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
-  /* "pysam/csamtools.pyx":308
+  /* "pysam/csamtools.pyx":315
  *     stderr is captured.
  *     '''
  *     def __init__(self):             # <<<<<<<<<<<<<<
  *         return
  *         self.stderr_h, self.stderr_f = tempfile.mkstemp()
  */
-  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_11StderrStore_1__init__, 0, __pyx_n_s_266, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_265)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_11StderrStore_1__init__, 0, __pyx_n_s_275, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_274)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____init__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 308; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____init__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 315; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":314
+  /* "pysam/csamtools.pyx":321
  *         self.stderr_save.setfd( self.stderr_h )
  * 
  *     def readAndRelease( self ):             # <<<<<<<<<<<<<<
  *         return []
  *         self.stderr_save.restore()
  */
-  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_11StderrStore_3readAndRelease, 0, __pyx_n_s_269, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_268)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_11StderrStore_3readAndRelease, 0, __pyx_n_s_278, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_277)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__readAndRelease, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 314; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__readAndRelease, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 321; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":323
+  /* "pysam/csamtools.pyx":330
  *         return lines
  * 
  *     def release(self):             # <<<<<<<<<<<<<<
  *         return
  *         self.stderr_save.restore()
  */
-  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_11StderrStore_5release, 0, __pyx_n_s_272, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_271)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_11StderrStore_5release, 0, __pyx_n_s_281, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_280)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__release, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 323; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__release, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 330; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":329
+  /* "pysam/csamtools.pyx":336
  *             os.remove( self.stderr_f )
  * 
  *     def __del__(self):             # <<<<<<<<<<<<<<
  *         self.release()
  * 
  */
-  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_11StderrStore_7__del__, 0, __pyx_n_s_275, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_274)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_11StderrStore_7__del__, 0, __pyx_n_s_284, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_283)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____del__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 329; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____del__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":304
+  /* "pysam/csamtools.pyx":311
  *     return 0
  * 
  * class StderrStore():             # <<<<<<<<<<<<<<
  *     '''
  *     stderr is captured.
  */
-  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_276)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_4 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s__StderrStore, __pyx_n_s__StderrStore, __pyx_n_s_262); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_285)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s__StderrStore, __pyx_n_s__StderrStore, __pyx_n_s_271); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStore, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 304; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStore, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 311; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":332
+  /* "pysam/csamtools.pyx":339
  *         self.release()
  * 
  * class StderrStoreWindows():             # <<<<<<<<<<<<<<
  *     '''does nothing. stderr can't be redirected on windows'''
  *     def __init__(self): pass
  */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
 
-  /* "pysam/csamtools.pyx":334
+  /* "pysam/csamtools.pyx":341
  * class StderrStoreWindows():
  *     '''does nothing. stderr can't be redirected on windows'''
  *     def __init__(self): pass             # <<<<<<<<<<<<<<
  *     def readAndRelease(self): return []
  *     def release(self): pass
  */
-  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_18StderrStoreWindows_1__init__, 0, __pyx_n_s_279, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_278)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_18StderrStoreWindows_1__init__, 0, __pyx_n_s_288, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_287)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____init__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s____init__, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 341; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":335
+  /* "pysam/csamtools.pyx":342
  *     '''does nothing. stderr can't be redirected on windows'''
  *     def __init__(self): pass
  *     def readAndRelease(self): return []             # <<<<<<<<<<<<<<
  *     def release(self): pass
  * 
  */
-  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_18StderrStoreWindows_3readAndRelease, 0, __pyx_n_s_282, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_281)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_18StderrStoreWindows_3readAndRelease, 0, __pyx_n_s_291, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_290)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__readAndRelease, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 335; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__readAndRelease, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 342; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":336
+  /* "pysam/csamtools.pyx":343
  *     def __init__(self): pass
  *     def readAndRelease(self): return []
  *     def release(self): pass             # <<<<<<<<<<<<<<
  * 
  * if platform.system()=='Windows':
  */
-  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_18StderrStoreWindows_5release, 0, __pyx_n_s_285, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_284)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_18StderrStoreWindows_5release, 0, __pyx_n_s_294, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_293)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__release, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_t_1, __pyx_n_s__release, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 343; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":332
+  /* "pysam/csamtools.pyx":339
  *         self.release()
  * 
  * class StderrStoreWindows():             # <<<<<<<<<<<<<<
  *     '''does nothing. stderr can't be redirected on windows'''
  *     def __init__(self): pass
  */
-  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_286)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_4 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s__StderrStoreWindows, __pyx_n_s__StderrStoreWindows, __pyx_n_s_262); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItemString(((PyObject *)__pyx_t_1), "__doc__", ((PyObject *)__pyx_kp_s_295)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_1), __pyx_n_s__StderrStoreWindows, __pyx_n_s__StderrStoreWindows, __pyx_n_s_271); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStoreWindows, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 332; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStoreWindows, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":338
+  /* "pysam/csamtools.pyx":345
  *     def release(self): pass
  * 
  * if platform.system()=='Windows':             # <<<<<<<<<<<<<<
  *     del StderrStore
  *     StderrStore = StderrStoreWindows
  */
-  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__platform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_GetName(__pyx_m, __pyx_n_s__platform); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__system); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_GetAttr(__pyx_t_1, __pyx_n_s__system); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyObject_Call(__pyx_t_4, ((PyObject *)__pyx_empty_tuple), NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
-  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__Windows), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyObject_RichCompare(__pyx_t_1, ((PyObject *)__pyx_n_s__Windows), Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
-  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 338; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
   if (__pyx_t_3) {
 
-    /* "pysam/csamtools.pyx":339
+    /* "pysam/csamtools.pyx":346
  * 
  * if platform.system()=='Windows':
  *     del StderrStore             # <<<<<<<<<<<<<<
  *     StderrStore = StderrStoreWindows
  * 
  */
-    if (__Pyx_DelAttrString(__pyx_m, "StderrStore") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 339; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__Pyx_DelAttrString(__pyx_m, "StderrStore") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 346; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-    /* "pysam/csamtools.pyx":340
+    /* "pysam/csamtools.pyx":347
  * if platform.system()=='Windows':
  *     del StderrStore
  *     StderrStore = StderrStoreWindows             # <<<<<<<<<<<<<<
  * 
  * 
  */
-    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStoreWindows); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_4 = __Pyx_GetName(__pyx_m, __pyx_n_s__StderrStoreWindows); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_GOTREF(__pyx_t_4);
-    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStore, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (PyObject_SetAttr(__pyx_m, __pyx_n_s__StderrStore, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
     __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
     goto __pyx_L5;
   }
   __pyx_L5:;
 
-  /* "pysam/csamtools.pyx":347
+  /* "pysam/csamtools.pyx":354
  * ######################################################################
  * # valid types for sam headers
  * VALID_HEADER_TYPES = { "HD" : dict,             # <<<<<<<<<<<<<<
  *                        "SQ" : list,
  *                        "RG" : list,
  */
-  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__HD), ((PyObject *)((PyObject*)(&PyDict_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__HD), ((PyObject *)((PyObject*)(&PyDict_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":348
+  /* "pysam/csamtools.pyx":355
  * # valid types for sam headers
  * VALID_HEADER_TYPES = { "HD" : dict,
  *                        "SQ" : list,             # <<<<<<<<<<<<<<
  *                        "RG" : list,
  *                        "PG" : list,
  */
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)((PyObject*)(&PyList_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)((PyObject*)(&PyList_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":349
+  /* "pysam/csamtools.pyx":356
  * VALID_HEADER_TYPES = { "HD" : dict,
  *                        "SQ" : list,
  *                        "RG" : list,             # <<<<<<<<<<<<<<
  *                        "PG" : list,
  *                        "CO" : list }
  */
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__RG), ((PyObject *)((PyObject*)(&PyList_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__RG), ((PyObject *)((PyObject*)(&PyList_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":350
+  /* "pysam/csamtools.pyx":357
  *                        "SQ" : list,
  *                        "RG" : list,
  *                        "PG" : list,             # <<<<<<<<<<<<<<
  *                        "CO" : list }
  * 
  */
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__PG), ((PyObject *)((PyObject*)(&PyList_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__PG), ((PyObject *)((PyObject*)(&PyList_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":351
+  /* "pysam/csamtools.pyx":358
  *                        "RG" : list,
  *                        "PG" : list,
  *                        "CO" : list }             # <<<<<<<<<<<<<<
  * 
  * # order of records within sam headers
  */
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__CO), ((PyObject *)((PyObject*)(&PyList_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 347; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__CO), ((PyObject *)((PyObject*)(&PyList_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_TYPES, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":354
+  /* "pysam/csamtools.pyx":361
  * 
  * # order of records within sam headers
  * VALID_HEADERS = ("HD", "SQ", "RG", "PG", "CO" )             # <<<<<<<<<<<<<<
  * 
  * # type conversions within sam header records
  */
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADERS, ((PyObject *)__pyx_k_tuple_287)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 354; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADERS, ((PyObject *)__pyx_k_tuple_296)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":357
+  /* "pysam/csamtools.pyx":364
  * 
  * # type conversions within sam header records
  * VALID_HEADER_FIELDS = { "HD" : { "VN" : str, "SO" : str, "GO" : str },             # <<<<<<<<<<<<<<
  *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },
  *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str,
  */
-  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__VN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SO), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__GO), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__HD), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__VN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SO), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__GO), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__HD), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":358
+  /* "pysam/csamtools.pyx":365
  * # type conversions within sam header records
  * VALID_HEADER_FIELDS = { "HD" : { "VN" : str, "SO" : str, "GO" : str },
  *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },             # <<<<<<<<<<<<<<
  *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str,
  *                                  "CN" : str, "DT" : str, "PL" : str, "FO" : str, "KS" : str, "PG" : str,},
  */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__LN), ((PyObject *)((PyObject*)(&PyInt_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__AS), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__M5), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__UR), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SP), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__LN), ((PyObject *)((PyObject*)(&PyInt_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__AS), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__M5), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__UR), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SP), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 365; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":359
+  /* "pysam/csamtools.pyx":366
  * VALID_HEADER_FIELDS = { "HD" : { "VN" : str, "SO" : str, "GO" : str },
  *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },
  *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str,             # <<<<<<<<<<<<<<
  *                                  "CN" : str, "DT" : str, "PL" : str, "FO" : str, "KS" : str, "PG" : str,},
  *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str, "PP" : str }, }
  */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__ID), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SM), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__LB), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__DS), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PU), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PI), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-
-  /* "pysam/csamtools.pyx":360
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__ID), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__SM), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__LB), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__DS), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PU), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PI), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "pysam/csamtools.pyx":367
  *                         "SQ" : { "SN" : str, "LN" : int, "AS" : str, "M5" : str, "UR" : str, "SP" : str },
  *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str,
  *                                  "CN" : str, "DT" : str, "PL" : str, "FO" : str, "KS" : str, "PG" : str,},             # <<<<<<<<<<<<<<
  *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str, "PP" : str }, }
  * 
  */
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__DT), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PL), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FO), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__KS), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PG), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 359; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__RG), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__DT), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PL), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__FO), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__KS), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PG), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 366; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__RG), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":361
+  /* "pysam/csamtools.pyx":368
  *                         "RG" : { "ID" : str, "SM" : str, "LB" : str, "DS" : str, "PU" : str, "PI" : str,
  *                                  "CN" : str, "DT" : str, "PL" : str, "FO" : str, "KS" : str, "PG" : str,},
  *                         "PG" : { "PN" : str, "ID" : str, "VN" : str, "CL" : str, "PP" : str }, }             # <<<<<<<<<<<<<<
  * 
  * # output order of fields within records
  */
-  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_1));
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__ID), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__VN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CL), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PP), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 361; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__PG), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__ID), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__VN), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__CL), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, ((PyObject *)__pyx_n_s__PP), ((PyObject *)((PyObject*)(&PyString_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 368; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__PG), ((PyObject *)__pyx_t_1)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_1)); __pyx_t_1 = 0;
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 357; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_FIELDS, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":364
+  /* "pysam/csamtools.pyx":371
  * 
  * # output order of fields within records
  * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),             # <<<<<<<<<<<<<<
  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL", "FO", "KS", "PG" ),
  */
-  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_4));
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__HD), ((PyObject *)__pyx_k_tuple_288)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__HD), ((PyObject *)__pyx_k_tuple_297)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":365
+  /* "pysam/csamtools.pyx":372
  * # output order of fields within records
  * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),
  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),             # <<<<<<<<<<<<<<
  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL", "FO", "KS", "PG" ),
  *                        "PG" : ( "PN", "ID", "VN", "CL", "PP" ), }
  */
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_k_tuple_289)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__SQ), ((PyObject *)__pyx_k_tuple_298)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":366
+  /* "pysam/csamtools.pyx":373
  * VALID_HEADER_ORDER = { "HD" : ( "VN", "SO", "GO" ),
  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL", "FO", "KS", "PG" ),             # <<<<<<<<<<<<<<
  *                        "PG" : ( "PN", "ID", "VN", "CL", "PP" ), }
  * 
  */
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__RG), ((PyObject *)__pyx_k_tuple_290)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__RG), ((PyObject *)__pyx_k_tuple_299)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
 
-  /* "pysam/csamtools.pyx":367
+  /* "pysam/csamtools.pyx":374
  *                        "SQ" : ( "SN", "LN", "AS", "M5" , "UR" , "SP" ),
  *                        "RG" : ( "ID", "SM", "LB", "DS" , "PU" , "PI" , "CN" , "DT", "PL", "FO", "KS", "PG" ),
  *                        "PG" : ( "PN", "ID", "VN", "CL", "PP" ), }             # <<<<<<<<<<<<<<
  * 
  * 
  */
-  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__PG), ((PyObject *)__pyx_k_tuple_291)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_ORDER, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 364; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_4, ((PyObject *)__pyx_n_s__PG), ((PyObject *)__pyx_k_tuple_300)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__VALID_HEADER_ORDER, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":619
+  /* "pysam/csamtools.pyx":745
  *                header = None,
  *                port = None,
  *                add_sq_text = True,             # <<<<<<<<<<<<<<
  *                check_header = True,
  *                check_sq = True,
  */
-  __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 619; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 745; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_k_21 = __pyx_t_4;
+  __pyx_k_29 = __pyx_t_4;
   __Pyx_GIVEREF(__pyx_t_4);
   __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":620
+  /* "pysam/csamtools.pyx":746
  *                port = None,
  *                add_sq_text = True,
  *                check_header = True,             # <<<<<<<<<<<<<<
  *                check_sq = True,
  *               ):
  */
-  __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 620; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 746; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_k_22 = __pyx_t_4;
+  __pyx_k_30 = __pyx_t_4;
   __Pyx_GIVEREF(__pyx_t_4);
   __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":621
+  /* "pysam/csamtools.pyx":747
  *                add_sq_text = True,
  *                check_header = True,
  *                check_sq = True,             # <<<<<<<<<<<<<<
  *               ):
  *         '''open a sam/bam file.
  */
-  __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 621; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 747; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_k_23 = __pyx_t_4;
+  __pyx_k_31 = __pyx_t_4;
   __Pyx_GIVEREF(__pyx_t_4);
   __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":901
+  /* "pysam/csamtools.pyx":1027
  *                region = None,
  *                callback = None,
  *                until_eof = False ):             # <<<<<<<<<<<<<<
  *         '''
  *         fetch aligned reads in a :term:`region` using 0-based indexing. The region is specified by
  */
-  __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 901; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1027; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_k_54 = __pyx_t_4;
+  __pyx_k_62 = __pyx_t_4;
   __Pyx_GIVEREF(__pyx_t_4);
   __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":1022
+  /* "pysam/csamtools.pyx":1148
  *                end = None,
  *                region = None,
  *                until_eof = False ):             # <<<<<<<<<<<<<<
  *         '''*(reference = None, start = None, end = None, region = None, callback = None, until_eof = False)*
  * 
  */
-  __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1022; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyBool_FromLong(0); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1148; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_k_73 = __pyx_t_4;
+  __pyx_k_81 = __pyx_t_4;
   __Pyx_GIVEREF(__pyx_t_4);
   __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":1942
+  /* "pysam/csamtools.pyx":2089
  *                   int tid = 0,
  *                   int start = 0,
  *                   int end = max_pos,             # <<<<<<<<<<<<<<
  *                   int truncate = False,
  *                   **kwargs ):
  */
-  __pyx_k_132 = __pyx_v_5pysam_9csamtools_max_pos;
+  __pyx_k_140 = __pyx_v_5pysam_9csamtools_max_pos;
 
-  /* "pysam/csamtools.pyx":3117
+  /* "pysam/csamtools.pyx":3334
  *             return self._level
  * 
  * class Outs:             # <<<<<<<<<<<<<<
  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
  *     def __init__(self, id = 1):
  */
-  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyDict_New(); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(((PyObject *)__pyx_t_4));
 
-  /* "pysam/csamtools.pyx":3119
+  /* "pysam/csamtools.pyx":3336
  * class Outs:
  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
  *     def __init__(self, id = 1):             # <<<<<<<<<<<<<<
  *         self.streams = []
  *         self.id = id
  */
-  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_4Outs_1__init__, 0, __pyx_n_s_295, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_293)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_4Outs_1__init__, 0, __pyx_n_s_304, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_302)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, ((PyObject *)__pyx_k_tuple_294));
-  if (PyObject_SetItem(__pyx_t_4, __pyx_n_s____init__, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_1, ((PyObject *)__pyx_k_tuple_303));
+  if (PyObject_SetItem(__pyx_t_4, __pyx_n_s____init__, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3336; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3123
+  /* "pysam/csamtools.pyx":3340
  *         self.id = id
  * 
  *     def setdevice(self, filename):             # <<<<<<<<<<<<<<
  *         '''open an existing file, like "/dev/null"'''
  *         fd = os.open(filename, os.O_WRONLY)
  */
-  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_4Outs_3setdevice, 0, __pyx_n_s_298, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_297)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_4Outs_3setdevice, 0, __pyx_n_s_307, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_306)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetItem(__pyx_t_4, __pyx_n_s__setdevice, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3123; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_t_4, __pyx_n_s__setdevice, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3340; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3128
+  /* "pysam/csamtools.pyx":3345
  *         self.setfd(fd)
  * 
  *     def setfile(self, filename):             # <<<<<<<<<<<<<<
  *         '''open a new file.'''
  *         fd = os.open(filename, os.O_WRONLY|os.O_CREAT, 0660);
  */
-  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_4Outs_5setfile, 0, __pyx_n_s_301, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_300)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_4Outs_5setfile, 0, __pyx_n_s_310, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_309)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetItem(__pyx_t_4, __pyx_n_s__setfile, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_t_4, __pyx_n_s__setfile, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3345; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3133
+  /* "pysam/csamtools.pyx":3350
  *         self.setfd(fd)
  * 
  *     def setfd(self, fd):             # <<<<<<<<<<<<<<
  *         ofd = os.dup(self.id)      #  Save old stream on new unit.
  *         self.streams.append(ofd)
  */
-  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_4Outs_7setfd, 0, __pyx_n_s_304, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_303)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_4Outs_7setfd, 0, __pyx_n_s_313, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_312)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetItem(__pyx_t_4, __pyx_n_s__setfd, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_t_4, __pyx_n_s__setfd, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3350; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3141
+  /* "pysam/csamtools.pyx":3358
  *         os.close(fd)                #  Close other unit (look out, caller.)
  * 
  *     def restore(self):             # <<<<<<<<<<<<<<
  *         '''restore previous output stream'''
  *         if self.streams:
  */
-  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_4Outs_9restore, 0, __pyx_n_s_307, NULL, __pyx_n_s_262, ((PyObject *)__pyx_k_codeobj_306)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_CyFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_4Outs_9restore, 0, __pyx_n_s_316, NULL, __pyx_n_s_271, ((PyObject *)__pyx_k_codeobj_315)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetItem(__pyx_t_4, __pyx_n_s__restore, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetItem(__pyx_t_4, __pyx_n_s__restore, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3358; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
 
-  /* "pysam/csamtools.pyx":3117
+  /* "pysam/csamtools.pyx":3334
  *             return self._level
  * 
  * class Outs:             # <<<<<<<<<<<<<<
  *     '''http://mail.python.org/pipermail/python-list/2000-June/038406.html'''
  *     def __init__(self, id = 1):
  */
-  if (PyDict_SetItemString(((PyObject *)__pyx_t_4), "__doc__", ((PyObject *)__pyx_kp_s_308)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
-  __pyx_t_1 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_4), __pyx_n_s__Outs, __pyx_n_s__Outs, __pyx_n_s_262); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItemString(((PyObject *)__pyx_t_4), "__doc__", ((PyObject *)__pyx_kp_s_317)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __Pyx_CreateClass(((PyObject *)__pyx_empty_tuple), ((PyObject *)__pyx_t_4), __pyx_n_s__Outs, __pyx_n_s__Outs, __pyx_n_s_271); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_1);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Outs, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s__Outs, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3334; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":3154
+  /* "pysam/csamtools.pyx":3371
  * def _samtools_dispatch( method,
  *                         args = (),
  *                         catch_stdout = True ):             # <<<<<<<<<<<<<<
  *     '''call ``method`` in samtools providing arguments in args.
  * 
  */
-  __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = __Pyx_PyBool_FromLong(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3371; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  __pyx_k_180 = __pyx_t_4;
+  __pyx_k_188 = __pyx_t_4;
   __Pyx_GIVEREF(__pyx_t_4);
   __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":3152
+  /* "pysam/csamtools.pyx":3369
  *             del self.streams[-1]
  * 
  * def _samtools_dispatch( method,             # <<<<<<<<<<<<<<
  *                         args = (),
  *                         catch_stdout = True ):
  */
-  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_1_samtools_dispatch, NULL, __pyx_n_s_262); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyCFunction_NewEx(&__pyx_mdef_5pysam_9csamtools_1_samtools_dispatch, NULL, __pyx_n_s_271); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___samtools_dispatch, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s___samtools_dispatch, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3369; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
 
-  /* "pysam/csamtools.pyx":3864
+  /* "pysam/csamtools.pyx":4081
  *         if self.owns_samfile: samclose( self.fp )
  * 
  * __all__ = ["Samfile",             # <<<<<<<<<<<<<<
  *            "Fastafile",
- *            "IteratorRow",
+ *            "Fastqfile",
  */
-  __pyx_t_4 = PyList_New(9); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyList_New(10); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_GOTREF(__pyx_t_4);
   __Pyx_INCREF(((PyObject *)__pyx_n_s__Samfile));
   PyList_SET_ITEM(__pyx_t_4, 0, ((PyObject *)__pyx_n_s__Samfile));
@@ -42166,28 +44152,31 @@ PyMODINIT_FUNC PyInit_csamtools(void)
   __Pyx_INCREF(((PyObject *)__pyx_n_s__Fastafile));
   PyList_SET_ITEM(__pyx_t_4, 1, ((PyObject *)__pyx_n_s__Fastafile));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Fastafile));
+  __Pyx_INCREF(((PyObject *)__pyx_n_s__Fastqfile));
+  PyList_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_n_s__Fastqfile));
+  __Pyx_GIVEREF(((PyObject *)__pyx_n_s__Fastqfile));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorRow));
-  PyList_SET_ITEM(__pyx_t_4, 2, ((PyObject *)__pyx_n_s__IteratorRow));
+  PyList_SET_ITEM(__pyx_t_4, 3, ((PyObject *)__pyx_n_s__IteratorRow));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorRow));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__IteratorColumn));
-  PyList_SET_ITEM(__pyx_t_4, 3, ((PyObject *)__pyx_n_s__IteratorColumn));
+  PyList_SET_ITEM(__pyx_t_4, 4, ((PyObject *)__pyx_n_s__IteratorColumn));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IteratorColumn));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__AlignedRead));
-  PyList_SET_ITEM(__pyx_t_4, 4, ((PyObject *)__pyx_n_s__AlignedRead));
+  PyList_SET_ITEM(__pyx_t_4, 5, ((PyObject *)__pyx_n_s__AlignedRead));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__AlignedRead));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupColumn));
-  PyList_SET_ITEM(__pyx_t_4, 5, ((PyObject *)__pyx_n_s__PileupColumn));
+  PyList_SET_ITEM(__pyx_t_4, 6, ((PyObject *)__pyx_n_s__PileupColumn));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupColumn));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupProxy));
-  PyList_SET_ITEM(__pyx_t_4, 6, ((PyObject *)__pyx_n_s__PileupProxy));
+  PyList_SET_ITEM(__pyx_t_4, 7, ((PyObject *)__pyx_n_s__PileupProxy));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupProxy));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__PileupRead));
-  PyList_SET_ITEM(__pyx_t_4, 7, ((PyObject *)__pyx_n_s__PileupRead));
+  PyList_SET_ITEM(__pyx_t_4, 8, ((PyObject *)__pyx_n_s__PileupRead));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__PileupRead));
   __Pyx_INCREF(((PyObject *)__pyx_n_s__IndexedReads));
-  PyList_SET_ITEM(__pyx_t_4, 8, ((PyObject *)__pyx_n_s__IndexedReads));
+  PyList_SET_ITEM(__pyx_t_4, 9, ((PyObject *)__pyx_n_s__IndexedReads));
   __Pyx_GIVEREF(((PyObject *)__pyx_n_s__IndexedReads));
-  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 3864; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyObject_SetAttr(__pyx_m, __pyx_n_s____all__, ((PyObject *)__pyx_t_4)) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4081; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
   __Pyx_DECREF(((PyObject *)__pyx_t_4)); __pyx_t_4 = 0;
 
   /* "pysam/csamtools.pyx":1
diff --git a/pysam/csamtools.pxd b/pysam/csamtools.pxd
index a490283..8341814 100644
--- a/pysam/csamtools.pxd
+++ b/pysam/csamtools.pxd
@@ -388,6 +388,26 @@ cdef extern from "pysam_util.h":
 
 #    void pysam_dump_glf( glf1_t * g, bam_maqcns_t * c )
 
+    ctypedef struct gzFile:
+        pass  
+
+    ctypedef struct kstring_t:
+        size_t l
+        size_t m
+        char *s
+
+    ctypedef struct kseq_t:
+        kstring_t name
+        kstring_t comment
+        kstring_t seq
+        kstring_t qual
+
+    gzFile gzopen( char *, char * )
+    kseq_t * kseq_init( gzFile )
+    int kseq_read( kseq_t * )
+    void kseq_destroy( kseq_t * )
+    void gzclose( gzFile )
+
 ####################################################################
 # Utility types
 
@@ -412,6 +432,17 @@ cdef class Fastafile:
 
     cdef char * _fetch( self, char * reference, int start, int end, int * length )
 
+cdef class FastqProxy:
+    cdef kseq_t * _delegate
+
+cdef class Fastqfile:
+    cdef char * _filename
+    cdef gzFile fastqfile
+    cdef kseq_t * entry 
+
+    cdef kseq_t * getCurrent( self )
+    cdef int cnext(self)
+
 cdef class AlignedRead:
 
     # object that this AlignedRead represents
diff --git a/pysam/csamtools.pyx b/pysam/csamtools.pyx
index 58fed03..763798f 100644
--- a/pysam/csamtools.pyx
+++ b/pysam/csamtools.pyx
@@ -185,6 +185,13 @@ cdef makePileupRead( bam_pileup1_t * src ):
     dest._is_tail = src.is_tail
     return dest
 
+cdef class FastqProxy
+cdef makeFastqProxy( kseq_t * src):
+    '''enter src into AlignedRead.'''
+    cdef FastqProxy dest = FastqProxy.__new__(FastqProxy)
+    dest._delegate = src
+    return dest
+
 cdef convertBinaryTagToList( uint8_t * s ):
     """return bytesize, number of values list of values in s."""
     cdef char auxtype
@@ -506,6 +513,109 @@ cdef class Fastafile:
                                end-1,
                                length )
 
+
+######################################################################
+######################################################################
+######################################################################
+## Fastq file
+######################################################################
+
+cdef class FastqProxy:
+    def __init__(self): pass
+
+    property name:
+        def __get__(self):
+            return self._delegate.name.s
+
+    property sequence:
+        def __get__(self):
+            return self._delegate.seq.s
+
+    property comment:
+        def __get__(self):
+            if self._delegate.comment.l:
+                return self._delegate.comment.s
+            else: return None
+
+    property quality:
+        def __get__(self):
+            if self._delegate.qual.l:
+                return self._delegate.qual.s
+            else: return None
+
+cdef class Fastqfile:
+    '''*(filename)*
+
+    A *FASTQ* file. The file is automatically opened.
+
+    '''
+
+    def __cinit__(self, *args, **kwargs ):
+        # self.fastqfile = NULL
+        self._filename = NULL
+        self._open( *args, **kwargs )
+
+    def _isOpen( self ):
+        '''return true if samfile has been opened.'''
+        return self._filename != NULL
+
+    def _open( self,
+               filename ):
+        '''open an indexed fasta file.
+
+        This method expects an indexed fasta file.
+        '''
+
+        if not os.path.exists( filename ):
+            raise IOError( "No such file or directory: %s" % filename )
+
+        # close a previously opened file
+        # if self.fastqfile != NULL: self.close()
+        if self._filename != NULL: free(self._filename)
+        filename = _my_encodeFilename(filename)
+        self._filename = strdup(filename)
+        self.fastqfile = gzopen( filename, "r" )
+        self.entry = kseq_init( self.fastqfile )
+
+    def close( self ):
+        '''close file.'''
+        if self._filename != NULL:
+            gzclose( self.fastqfile )
+            free(self._filename)
+
+    def __dealloc__(self):
+        kseq_destroy(self.entry)
+        self.close()
+
+    property filename:
+        '''number of :term:`filename` associated with this object.'''
+        def __get__(self):
+            if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
+            return self._filename
+
+    def __iter__(self):
+        if not self._isOpen(): raise ValueError( "I/O operation on closed file" )
+        return self
+
+    cdef kseq_t * getCurrent( self ):
+        return self.entry
+
+    cdef int cnext(self):
+        '''C version of iterator
+        '''
+        return kseq_read(self.entry)
+
+    def __next__(self):
+        """
+        python version of next().
+        """
+        cdef int l
+        l = kseq_read( self.entry)
+        if (l > 0):
+            return makeFastqProxy( self.entry )
+        else:
+            raise StopIteration
+
 #------------------------------------------------------------------------
 #------------------------------------------------------------------------
 #------------------------------------------------------------------------
@@ -1459,6 +1569,11 @@ cdef class IteratorRow:
         iterate over all reads in all reference sequences.
 
     The method :meth:`Samfile.fetch` returns an IteratorRow.
+
+    .. note::
+        It is usually not necessary to create an object of this class
+        explicitely. It is returned as a result of call to a :meth:`Samfile.fetch`.
+
     '''
     pass
 
@@ -1481,6 +1596,11 @@ cdef class IteratorRowRegion(IteratorRow):
 
     Note that the index will be shared between
     samfile and the iterator.
+
+    .. note::
+        It is usually not necessary to create an object of this class
+        explicitely. It is returned as a result of call to a :meth:`Samfile.fetch`.
+
     """
 
     def __cinit__(self, Samfile samfile, int tid, int beg, int end, int reopen = True ):
@@ -1550,6 +1670,12 @@ cdef class IteratorRowAll(IteratorRow):
     By default, the file is re-openend to avoid conflicts between
     multiple iterators working on the same file. Set *reopen* = False
     to not re-open *samfile*.
+
+    .. note::
+        It is usually not necessary to create an object of this class
+        explicitely. It is returned as a result of call to a :meth:`Samfile.fetch`.
+        
+
     """
 
     def __cinit__(self, Samfile samfile, int reopen = True ):
@@ -1602,6 +1728,10 @@ cdef class IteratorRowAll(IteratorRow):
 
 cdef class IteratorRowAllRefs(IteratorRow):
     """iterates over all mapped reads by chaining iterators over each reference
+
+    .. note::
+        It is usually not necessary to create an object of this class
+        explicitely. It is returned as a result of call to a :meth:`Samfile.fetch`.
     """
 
     def __cinit__(self, Samfile samfile):
@@ -1647,6 +1777,10 @@ cdef class IteratorRowSelection(IteratorRow):
     """*(Samfile samfile)*
 
     iterate over reads in *samfile* at a given list of file positions.
+
+    .. note::
+        It is usually not necessary to create an object of this class
+        explicitely. It is returned as a result of call to a :meth:`Samfile.fetch`.
     """
 
     def __cinit__(self, Samfile samfile, positions, int reopen = True ):
@@ -1828,15 +1962,11 @@ cdef class IteratorColumn:
         self.plp = NULL
         self.pileup_iter = <bam_plp_t>NULL
 
-
     def __iter__(self):
         return self
 
     cdef int cnext(self):
         '''perform next iteration.
-
-        This method is analogous to the samtools bam_plp_auto method.
-        It has been re-implemented to permit for filtering.
         '''
         self.plp = bam_plp_auto( self.pileup_iter,
                                  &self.tid,
@@ -1922,12 +2052,13 @@ cdef class IteratorColumn:
         bam_plp_reset(self.pileup_iter)
 
     def __dealloc__(self):
-        # reset in order to avoid memory leak messages for iterators that have
-        # not been fully consumed
+        # reset in order to avoid memory leak messages for iterators 
+        # that have not been fully consumed
         if self.pileup_iter != <bam_plp_t>NULL:
             bam_plp_reset(self.pileup_iter)
             bam_plp_destroy(self.pileup_iter)
             self.pileup_iter = <bam_plp_t>NULL
+            self.plp = <const_bam_pileup1_t_ptr>NULL
 
         if self.iterdata.seq != NULL:
             free(self.iterdata.seq)
@@ -2203,6 +2334,10 @@ cdef class AlignedRead:
     def __hash__(self):
         return _Py_HashPointer(<void *>self)
 
+    #######################################################################
+    #######################################################################
+    ## Basic properties
+    #######################################################################
     property qname:
         """the query name (None if not present)"""
         def __get__(self):
@@ -2348,9 +2483,22 @@ cdef class AlignedRead:
             self.cigar = [ (CIGAR2CODE[ord(y)], int(x)) for x,y in parts ]
 
     property seq:
-        """read sequence bases, including :term:`soft clipped` bases (None if not present).
+        """read sequence bases, including :term:`soft clipped` bases 
+        (None if not present).
+
+        In Python 3, this property is of type bytes and assigning a
+        unicode string to it consisting of ASCII characters only will
+        work, but is inefficient.
 
-        In Python 3, this property is of type bytes and assigning a unicode string to it consisting of ASCII characters only will work, but is inefficient."""
+        Note that assigning to seq will invalidate any quality scores.
+        Thus, to in-place edit the sequence and quality scores, copies of
+        the quality scores need to be taken. Consider trimming for example::
+
+           q = read.qual
+           read.seq = read.seq[5:10]
+           read.qual = q[5:10]
+
+        """
         def __get__(self):
             cdef bam1_t * src
             cdef char * s
@@ -2363,48 +2511,63 @@ cdef class AlignedRead:
         def __set__(self,seq):
             # samtools manages sequence and quality length memory together
             # if no quality information is present, the first byte says 0xff.
-
-            if seq == None or len(seq) == 0: return
-            seq = _force_bytes(seq)
             cdef bam1_t * src
             cdef uint8_t * p
             cdef char * s
             cdef int l, k, nbytes_new, nbytes_old
 
-            src = self._delegate
+            if seq == None:
+                l = 0
+            else:
+                l = len(seq)                
+                seq = _force_bytes(seq)
 
-            l = len(seq)
+            src = self._delegate
 
             # as the sequence is stored in half-bytes, the total length (sequence
             # plus quality scores) is (l+1)/2 + l
             nbytes_new = (l+1)/2 + l
             nbytes_old = (src.core.l_qseq+1)/2 + src.core.l_qseq
+
             # acquire pointer to location in memory
             p = bam1_seq( src )
             src.core.l_qseq = l
 
+            # change length of data field
             pysam_bam_update( src,
                               nbytes_old,
                               nbytes_new,
                               p)
-            # re-acquire pointer to location in memory
-            # as it might have moved
-            p = bam1_seq( src )
-            for k from 0 <= k < nbytes_new: p[k] = 0
-            # convert to C string
-            s = seq
-            for k from 0 <= k < l:
-                p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)
-
-            # erase qualities
-            p = bam1_qual( src )
-            p[0] = 0xff
 
+            if l > 0:
+                # re-acquire pointer to location in memory
+                # as it might have moved
+                p = bam1_seq( src )
+                for k from 0 <= k < nbytes_new: p[k] = 0
+                # convert to C string
+                s = seq
+                for k from 0 <= k < l:
+                    p[k/2] |= pysam_translate_sequence(s[k]) << 4 * (1 - k % 2)
+
+                # erase qualities
+                p = bam1_qual( src )
+                p[0] = 0xff
 
     property qual:
-        """read sequence base qualities, including :term:`soft clipped` bases (None if not present).
+        """read sequence base qualities, including :term:`soft
+        clipped` bases (None if not present).
 
-        In Python 3, this property is of type bytes and assigning a unicode string to it consisting of ASCII characters only will work, but is inefficient."""
+        In Python 3, this property is of type bytes and assigning a
+        unicode string to it consisting of ASCII characters only will
+        work, but is inefficient.
+
+        Note that to set quality scores the sequence has to be set
+        previously as this will determine the permitted length of
+        the quality score array.
+
+        This method raises a ValueError if the length of the 
+        quality scores and the sequence are not the same.
+        """
         def __get__(self):
 
             cdef bam1_t * src
@@ -2784,6 +2947,10 @@ cdef class AlignedRead:
         """the position of the mate"""
         def __get__(self): return self._delegate.core.mpos
         def __set__(self, mpos): self._delegate.core.mpos = mpos
+    #######################################################################
+    #######################################################################
+    ## Flags
+    #######################################################################
     property isize:
         """the insert size
         deprecated: use tlen instead"""
@@ -2859,6 +3026,11 @@ cdef class AlignedRead:
         def __set__(self,val):
             if val: self._delegate.core.flag |= BAM_FDUP
             else: self._delegate.core.flag &= ~BAM_FDUP
+
+    #######################################################################
+    #######################################################################
+    ## Derived properties
+    #######################################################################
     property positions:
         """a list of reference positions that this read aligns to."""
         def __get__(self):
@@ -2886,6 +3058,32 @@ cdef class AlignedRead:
 
             return result
 
+    property inferred_length:
+        """inferred read length from CIGAR string.
+
+        Returns 0 if CIGAR string is not present.
+        """
+        def __get__(self):
+           cdef uint32_t k, qpos
+           cdef int op
+           cdef uint32_t * cigar_p
+           cdef bam1_t * src 
+
+           src = self._delegate
+           if src.core.n_cigar == 0: return 0
+
+           qpos = 0
+           cigar_p = bam1_cigar(src)
+
+           for k from 0 <= k < src.core.n_cigar:
+               op = cigar_p[k] & BAM_CIGAR_MASK
+
+               if op == BAM_CMATCH or op == BAM_CINS or op == BAM_CSOFT_CLIP:
+                   qpos += cigar_p[k] >> BAM_CIGAR_SHIFT
+
+           return qpos
+            
+
     property aligned_pairs:
        """a list of aligned read and reference positions.
 
@@ -2927,7 +3125,10 @@ cdef class AlignedRead:
                        
            return result
 
-
+    #######################################################################
+    #######################################################################
+    ## 
+    #######################################################################
     def overlap( self, uint32_t start, uint32_t end ):
         """return number of aligned bases of read overlapping the interval *start* and *end*
         on the reference sequence.
@@ -3069,7 +3270,7 @@ cdef class PileupProxy:
             cdef int x
             pileups = []
 
-            if self.plp[0] == NULL:
+            if self.plp == NULL or self.plp[0] == NULL:
                 raise ValueError("PileupProxy accessed after iterator finished")
 
             # warning: there could be problems if self.n and self.buf are
@@ -3863,6 +4064,7 @@ cdef class IndexedReads:
 
 __all__ = ["Samfile",
            "Fastafile",
+           "Fastqfile",
            "IteratorRow",
            "IteratorColumn",
            "AlignedRead",
diff --git a/pysam/ctabix.c b/pysam/ctabix.c
index 88603ad..3d639f2 100644
--- a/pysam/ctabix.c
+++ b/pysam/ctabix.c
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.18 on Fri Jun 28 06:37:45 2013 */
+/* Generated by Cython 0.18 on Fri Sep 20 00:20:26 2013 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
@@ -348,163 +348,147 @@ static const char *__pyx_f[] = {
 };
 
 /*--- Type declarations ---*/
-struct __pyx_obj_5pysam_10TabProxies_TupleProxy;
-struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy;
-struct __pyx_obj_5pysam_10TabProxies_BedProxy;
 struct __pyx_obj_5pysam_6ctabix_Parser;
-struct __pyx_obj_5pysam_6ctabix_asTuple;
-struct __pyx_obj_5pysam_6ctabix_TabixIteratorParsed;
-struct __pyx_obj_5pysam_6ctabix_Tabixfile;
-struct __pyx_obj_5pysam_6ctabix_asGTF;
-struct __pyx_obj_5pysam_6ctabix_tabix_copy_iterator;
-struct __pyx_obj_5pysam_6ctabix_TabixHeaderIterator;
-struct __pyx_obj_5pysam_10TabProxies_VCFProxy;
-struct __pyx_obj_5pysam_6ctabix_asVCF;
 struct __pyx_obj_5pysam_6ctabix_asBed;
+struct __pyx_obj_5pysam_6ctabix_asVCF;
+struct __pyx_obj_5pysam_6ctabix_tabix_inplace_iterator;
 struct __pyx_obj_5pysam_6ctabix_TabixIterator;
+struct __pyx_obj_5pysam_6ctabix_TabixHeaderIterator;
+struct __pyx_obj_5pysam_10TabProxies_TupleProxy;
 struct __pyx_obj_5pysam_10TabProxies_GTFProxy;
-struct __pyx_obj_5pysam_6ctabix_tabix_inplace_iterator;
+struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy;
+struct __pyx_obj_5pysam_10TabProxies_VCFProxy;
+struct __pyx_obj_5pysam_6ctabix_asGTF;
+struct __pyx_obj_5pysam_6ctabix_Tabixfile;
+struct __pyx_obj_5pysam_6ctabix_TabixIteratorParsed;
+struct __pyx_obj_5pysam_10TabProxies_BedProxy;
+struct __pyx_obj_5pysam_6ctabix_tabix_copy_iterator;
+struct __pyx_obj_5pysam_6ctabix_asTuple;
 
-/* "TabProxies.pxd":41
- *   ctypedef int uint64_t
+/* "pysam/ctabix.pxd":190
+ *     cdef tabix_t * tabixfile
  * 
- * cdef class TupleProxy:             # <<<<<<<<<<<<<<
+ * cdef class Parser:             # <<<<<<<<<<<<<<
+ *      pass
  * 
- *     cdef:
  */
-struct __pyx_obj_5pysam_10TabProxies_TupleProxy {
+struct __pyx_obj_5pysam_6ctabix_Parser {
   PyObject_HEAD
-  struct __pyx_vtabstruct_5pysam_10TabProxies_TupleProxy *__pyx_vtab;
-  char *data;
-  char **fields;
-  int nfields;
-  int index;
-  int nbytes;
-  int offset;
-  int is_modified;
 };
 
 
-/* "TabProxies.pxd":69
- *     cdef char * getAttributes( self )
+/* "pysam/ctabix.pxd":199
+ *      pass
  * 
- * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
- *     pass
+ * cdef class asBed(Parser):             # <<<<<<<<<<<<<<
+ *      pass
  * 
  */
-struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy {
-  struct __pyx_obj_5pysam_10TabProxies_TupleProxy __pyx_base;
+struct __pyx_obj_5pysam_6ctabix_asBed {
+  struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
 };
 
 
-/* "TabProxies.pxd":72
- *     pass
+/* "pysam/ctabix.pxd":202
+ *      pass
  * 
- * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * cdef class asVCF(Parser):             # <<<<<<<<<<<<<<
+ *      pass
  * 
- *     cdef:
  */
-struct __pyx_obj_5pysam_10TabProxies_BedProxy {
-  struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
-  char *contig;
-  uint32_t start;
-  uint32_t end;
-  int bedfields;
+struct __pyx_obj_5pysam_6ctabix_asVCF {
+  struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
 };
 
 
-/* "pysam/ctabix.pxd":190
- *     cdef tabix_t * tabixfile
- * 
- * cdef class Parser:             # <<<<<<<<<<<<<<
- *      pass
+/* "pysam/ctabix.pxd":210
+ *     cdef Parser parser
  * 
+ * cdef class tabix_inplace_iterator:             # <<<<<<<<<<<<<<
+ *     cdef FILE * infile
+ *     cdef char * buffer
  */
-struct __pyx_obj_5pysam_6ctabix_Parser {
+struct __pyx_obj_5pysam_6ctabix_tabix_inplace_iterator {
   PyObject_HEAD
+  struct __pyx_vtabstruct_5pysam_6ctabix_tabix_inplace_iterator *__pyx_vtab;
+  FILE *infile;
+  char *buffer;
+  size_t size;
+  struct __pyx_obj_5pysam_6ctabix_Parser *parser;
 };
 
 
-/* "pysam/ctabix.pxd":193
- *      pass
- * 
- * cdef class asTuple(Parser):             # <<<<<<<<<<<<<<
- *      pass
+/* "pysam/ctabix.pxd":182
+ *     cdef char * _filename
  * 
+ * cdef class TabixIterator:             # <<<<<<<<<<<<<<
+ *     cdef ti_iter_t iterator
+ *     cdef tabix_t * tabixfile
  */
-struct __pyx_obj_5pysam_6ctabix_asTuple {
-  struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
+struct __pyx_obj_5pysam_6ctabix_TabixIterator {
+  PyObject_HEAD
+  ti_iter_t iterator;
+  tabix_t *tabixfile;
 };
 
 
-/* "pysam/ctabix.pxd":205
- *      pass
+/* "pysam/ctabix.pxd":186
+ *     cdef tabix_t * tabixfile
  * 
- * cdef class TabixIteratorParsed:             # <<<<<<<<<<<<<<
+ * cdef class TabixHeaderIterator:             # <<<<<<<<<<<<<<
  *     cdef ti_iter_t iterator
  *     cdef tabix_t * tabixfile
  */
-struct __pyx_obj_5pysam_6ctabix_TabixIteratorParsed {
+struct __pyx_obj_5pysam_6ctabix_TabixHeaderIterator {
   PyObject_HEAD
   ti_iter_t iterator;
   tabix_t *tabixfile;
-  struct __pyx_obj_5pysam_6ctabix_Parser *parser;
 };
 
 
-/* "pysam/ctabix.pxd":172
- *   # char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len)
+/* "TabProxies.pxd":41
+ *   ctypedef int uint64_t
  * 
- * cdef class Tabixfile:             # <<<<<<<<<<<<<<
+ * cdef class TupleProxy:             # <<<<<<<<<<<<<<
  * 
- *     # pointer to tabixfile
+ *     cdef:
  */
-struct __pyx_obj_5pysam_6ctabix_Tabixfile {
+struct __pyx_obj_5pysam_10TabProxies_TupleProxy {
   PyObject_HEAD
-  tabix_t *tabixfile;
-  int isremote;
-  char *_filename;
+  struct __pyx_vtabstruct_5pysam_10TabProxies_TupleProxy *__pyx_vtab;
+  char *data;
+  char **fields;
+  int nfields;
+  int index;
+  int nbytes;
+  int offset;
+  int is_modified;
 };
 
 
-/* "pysam/ctabix.pxd":196
- *      pass
+/* "TabProxies.pxd":60
+ *     cdef update( self, char * buffer, size_t nbytes )
  * 
- * cdef class asGTF(Parser):             # <<<<<<<<<<<<<<
- *      pass
+ * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
  * 
+ *     cdef:
  */
-struct __pyx_obj_5pysam_6ctabix_asGTF {
-  struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
+struct __pyx_obj_5pysam_10TabProxies_GTFProxy {
+  struct __pyx_obj_5pysam_10TabProxies_TupleProxy __pyx_base;
+  char *_attributes;
+  int hasOwnAttributes;
 };
 
 
-/* "pysam/ctabix.pxd":218
- *     cdef __cnext__(self)
+/* "TabProxies.pxd":69
+ *     cdef char * getAttributes( self )
  * 
- * cdef class tabix_copy_iterator:             # <<<<<<<<<<<<<<
- *     cdef FILE * infile
- *     cdef Parser parser
- */
-struct __pyx_obj_5pysam_6ctabix_tabix_copy_iterator {
-  PyObject_HEAD
-  struct __pyx_vtabstruct_5pysam_6ctabix_tabix_copy_iterator *__pyx_vtab;
-  FILE *infile;
-  struct __pyx_obj_5pysam_6ctabix_Parser *parser;
-};
-
-
-/* "pysam/ctabix.pxd":186
- *     cdef tabix_t * tabixfile
+ * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ *     pass
  * 
- * cdef class TabixHeaderIterator:             # <<<<<<<<<<<<<<
- *     cdef ti_iter_t iterator
- *     cdef tabix_t * tabixfile
  */
-struct __pyx_obj_5pysam_6ctabix_TabixHeaderIterator {
-  PyObject_HEAD
-  ti_iter_t iterator;
-  tabix_t *tabixfile;
+struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy {
+  struct __pyx_obj_5pysam_10TabProxies_TupleProxy __pyx_base;
 };
 
 
@@ -522,75 +506,91 @@ struct __pyx_obj_5pysam_10TabProxies_VCFProxy {
 };
 
 
-/* "pysam/ctabix.pxd":202
+/* "pysam/ctabix.pxd":196
  *      pass
  * 
- * cdef class asVCF(Parser):             # <<<<<<<<<<<<<<
+ * cdef class asGTF(Parser):             # <<<<<<<<<<<<<<
  *      pass
  * 
  */
-struct __pyx_obj_5pysam_6ctabix_asVCF {
+struct __pyx_obj_5pysam_6ctabix_asGTF {
   struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
 };
 
 
-/* "pysam/ctabix.pxd":199
- *      pass
+/* "pysam/ctabix.pxd":172
+ *   # char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len)
  * 
- * cdef class asBed(Parser):             # <<<<<<<<<<<<<<
- *      pass
+ * cdef class Tabixfile:             # <<<<<<<<<<<<<<
  * 
+ *     # pointer to tabixfile
  */
-struct __pyx_obj_5pysam_6ctabix_asBed {
-  struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
+struct __pyx_obj_5pysam_6ctabix_Tabixfile {
+  PyObject_HEAD
+  tabix_t *tabixfile;
+  int isremote;
+  char *_filename;
 };
 
 
-/* "pysam/ctabix.pxd":182
- *     cdef char * _filename
+/* "pysam/ctabix.pxd":205
+ *      pass
  * 
- * cdef class TabixIterator:             # <<<<<<<<<<<<<<
+ * cdef class TabixIteratorParsed:             # <<<<<<<<<<<<<<
  *     cdef ti_iter_t iterator
  *     cdef tabix_t * tabixfile
  */
-struct __pyx_obj_5pysam_6ctabix_TabixIterator {
+struct __pyx_obj_5pysam_6ctabix_TabixIteratorParsed {
   PyObject_HEAD
   ti_iter_t iterator;
   tabix_t *tabixfile;
+  struct __pyx_obj_5pysam_6ctabix_Parser *parser;
 };
 
 
-/* "TabProxies.pxd":60
- *     cdef update( self, char * buffer, size_t nbytes )
+/* "TabProxies.pxd":72
+ *     pass
  * 
- * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
  * 
  *     cdef:
  */
-struct __pyx_obj_5pysam_10TabProxies_GTFProxy {
-  struct __pyx_obj_5pysam_10TabProxies_TupleProxy __pyx_base;
-  char *_attributes;
-  int hasOwnAttributes;
+struct __pyx_obj_5pysam_10TabProxies_BedProxy {
+  struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
+  char *contig;
+  uint32_t start;
+  uint32_t end;
+  int bedfields;
 };
 
 
-/* "pysam/ctabix.pxd":210
- *     cdef Parser parser
+/* "pysam/ctabix.pxd":218
+ *     cdef __cnext__(self)
  * 
- * cdef class tabix_inplace_iterator:             # <<<<<<<<<<<<<<
+ * cdef class tabix_copy_iterator:             # <<<<<<<<<<<<<<
  *     cdef FILE * infile
- *     cdef char * buffer
+ *     cdef Parser parser
  */
-struct __pyx_obj_5pysam_6ctabix_tabix_inplace_iterator {
+struct __pyx_obj_5pysam_6ctabix_tabix_copy_iterator {
   PyObject_HEAD
-  struct __pyx_vtabstruct_5pysam_6ctabix_tabix_inplace_iterator *__pyx_vtab;
+  struct __pyx_vtabstruct_5pysam_6ctabix_tabix_copy_iterator *__pyx_vtab;
   FILE *infile;
-  char *buffer;
-  size_t size;
   struct __pyx_obj_5pysam_6ctabix_Parser *parser;
 };
 
 
+/* "pysam/ctabix.pxd":193
+ *      pass
+ * 
+ * cdef class asTuple(Parser):             # <<<<<<<<<<<<<<
+ *      pass
+ * 
+ */
+struct __pyx_obj_5pysam_6ctabix_asTuple {
+  struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
+};
+
+
 
 /* "TabProxies.pxd":41
  *   ctypedef int uint64_t
@@ -638,19 +638,32 @@ struct __pyx_vtabstruct_5pysam_10TabProxies_VCFProxy {
 static struct __pyx_vtabstruct_5pysam_10TabProxies_VCFProxy *__pyx_vtabptr_5pysam_10TabProxies_VCFProxy;
 
 
-/* "TabProxies.pxd":60
- *     cdef update( self, char * buffer, size_t nbytes )
+/* "pysam/ctabix.pyx":709
+ * ## Iterators for parsing through unindexed files.
+ * #########################################################
+ * ctypedef class tabix_inplace_iterator:             # <<<<<<<<<<<<<<
+ *     '''iterate over ``infile``.
  * 
- * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ */
+
+struct __pyx_vtabstruct_5pysam_6ctabix_tabix_inplace_iterator {
+  PyObject *(*__pyx___cnext__)(struct __pyx_obj_5pysam_6ctabix_tabix_inplace_iterator *);
+};
+static struct __pyx_vtabstruct_5pysam_6ctabix_tabix_inplace_iterator *__pyx_vtabptr_5pysam_6ctabix_tabix_inplace_iterator;
+
+
+/* "TabProxies.pxd":72
+ *     pass
+ * 
+ * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
  * 
  *     cdef:
  */
 
-struct __pyx_vtabstruct_5pysam_10TabProxies_GTFProxy {
-  struct __pyx_vtabstruct_5pysam_10TabProxies_TupleProxy __pyx_base;
-  char *(*getAttributes)(struct __pyx_obj_5pysam_10TabProxies_GTFProxy *);
+struct __pyx_vtabstruct_5pysam_10TabProxies_BedProxy {
+  struct __pyx_vtabstruct_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
 };
-static struct __pyx_vtabstruct_5pysam_10TabProxies_GTFProxy *__pyx_vtabptr_5pysam_10TabProxies_GTFProxy;
+static struct __pyx_vtabstruct_5pysam_10TabProxies_BedProxy *__pyx_vtabptr_5pysam_10TabProxies_BedProxy;
 
 
 /* "pysam/ctabix.pyx":771
@@ -667,32 +680,19 @@ struct __pyx_vtabstruct_5pysam_6ctabix_tabix_copy_iterator {
 static struct __pyx_vtabstruct_5pysam_6ctabix_tabix_copy_iterator *__pyx_vtabptr_5pysam_6ctabix_tabix_copy_iterator;
 
 
-/* "TabProxies.pxd":72
- *     pass
+/* "TabProxies.pxd":60
+ *     cdef update( self, char * buffer, size_t nbytes )
  * 
- * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
  * 
  *     cdef:
  */
 
-struct __pyx_vtabstruct_5pysam_10TabProxies_BedProxy {
-  struct __pyx_vtabstruct_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
-};
-static struct __pyx_vtabstruct_5pysam_10TabProxies_BedProxy *__pyx_vtabptr_5pysam_10TabProxies_BedProxy;
-
-
-/* "pysam/ctabix.pyx":709
- * ## Iterators for parsing through unindexed files.
- * #########################################################
- * ctypedef class tabix_inplace_iterator:             # <<<<<<<<<<<<<<
- *     '''iterate over ``infile``.
- * 
- */
-
-struct __pyx_vtabstruct_5pysam_6ctabix_tabix_inplace_iterator {
-  PyObject *(*__pyx___cnext__)(struct __pyx_obj_5pysam_6ctabix_tabix_inplace_iterator *);
+struct __pyx_vtabstruct_5pysam_10TabProxies_GTFProxy {
+  struct __pyx_vtabstruct_5pysam_10TabProxies_TupleProxy __pyx_base;
+  char *(*getAttributes)(struct __pyx_obj_5pysam_10TabProxies_GTFProxy *);
 };
-static struct __pyx_vtabstruct_5pysam_6ctabix_tabix_inplace_iterator *__pyx_vtabptr_5pysam_6ctabix_tabix_inplace_iterator;
+static struct __pyx_vtabstruct_5pysam_10TabProxies_GTFProxy *__pyx_vtabptr_5pysam_10TabProxies_GTFProxy;
 #ifndef CYTHON_REFNANNY
   #define CYTHON_REFNANNY 0
 #endif
diff --git a/pysam/cvcf.c b/pysam/cvcf.c
index 8456837..51f2cf0 100644
--- a/pysam/cvcf.c
+++ b/pysam/cvcf.c
@@ -1,4 +1,4 @@
-/* Generated by Cython 0.18 on Fri Jun 28 06:37:45 2013 */
+/* Generated by Cython 0.18 on Fri Sep 20 00:20:26 2013 */
 
 #define PY_SSIZE_T_CLEAN
 #include "Python.h"
@@ -346,26 +346,26 @@ static const char *__pyx_f[] = {
 
 /*--- Type declarations ---*/
 struct __pyx_obj_5pysam_6ctabix_Parser;
-struct __pyx_obj_5pysam_6ctabix_asTuple;
-struct __pyx_obj_5pysam_6ctabix_tabix_copy_iterator;
-struct __pyx_obj_5pysam_4cvcf_asVCFRecord;
-struct __pyx_obj_5pysam_10TabProxies_TupleProxy;
-struct __pyx_obj_5pysam_4cvcf_VCFRecord;
-struct __pyx_obj_5pysam_6ctabix_TabixHeaderIterator;
-struct __pyx_obj_5pysam_6ctabix_Tabixfile;
+struct __pyx_obj_5pysam_6ctabix_asBed;
 struct __pyx_obj_5pysam_6ctabix_TabixIteratorParsed;
-struct __pyx_obj_5pysam_4cvcf___pyx_scope_struct__parse_data;
-struct __pyx_obj_5pysam_6ctabix_tabix_inplace_iterator;
 struct __pyx_obj_5pysam_4cvcf___pyx_scope_struct_2__parse;
-struct __pyx_obj_5pysam_6ctabix_asVCF;
+struct __pyx_obj_5pysam_10TabProxies_TupleProxy;
 struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy;
-struct __pyx_obj_5pysam_10TabProxies_BedProxy;
+struct __pyx_obj_5pysam_10TabProxies_VCFProxy;
+struct __pyx_obj_5pysam_4cvcf_VCFRecord;
+struct __pyx_obj_5pysam_4cvcf_asVCFRecord;
+struct __pyx_obj_5pysam_6ctabix_asVCF;
+struct __pyx_obj_5pysam_4cvcf___pyx_scope_struct__parse_data;
 struct __pyx_obj_5pysam_10TabProxies_GTFProxy;
-struct __pyx_obj_5pysam_4cvcf___pyx_scope_struct_1_genexpr;
+struct __pyx_obj_5pysam_6ctabix_TabixHeaderIterator;
 struct __pyx_obj_5pysam_6ctabix_asGTF;
+struct __pyx_obj_5pysam_6ctabix_Tabixfile;
 struct __pyx_obj_5pysam_6ctabix_TabixIterator;
-struct __pyx_obj_5pysam_6ctabix_asBed;
-struct __pyx_obj_5pysam_10TabProxies_VCFProxy;
+struct __pyx_obj_5pysam_4cvcf___pyx_scope_struct_1_genexpr;
+struct __pyx_obj_5pysam_6ctabix_tabix_inplace_iterator;
+struct __pyx_obj_5pysam_10TabProxies_BedProxy;
+struct __pyx_obj_5pysam_6ctabix_tabix_copy_iterator;
+struct __pyx_obj_5pysam_6ctabix_asTuple;
 struct __pyx_defaults;
 typedef struct __pyx_defaults __pyx_defaults;
 struct __pyx_defaults1;
@@ -405,43 +405,49 @@ struct __pyx_obj_5pysam_6ctabix_Parser {
 };
 
 
-/* "ctabix.pxd":193
+/* "ctabix.pxd":199
  *      pass
  * 
- * cdef class asTuple(Parser):             # <<<<<<<<<<<<<<
+ * cdef class asBed(Parser):             # <<<<<<<<<<<<<<
  *      pass
  * 
  */
-struct __pyx_obj_5pysam_6ctabix_asTuple {
+struct __pyx_obj_5pysam_6ctabix_asBed {
   struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
 };
 
 
-/* "ctabix.pxd":218
- *     cdef __cnext__(self)
+/* "ctabix.pxd":205
+ *      pass
  * 
- * cdef class tabix_copy_iterator:             # <<<<<<<<<<<<<<
- *     cdef FILE * infile
- *     cdef Parser parser
+ * cdef class TabixIteratorParsed:             # <<<<<<<<<<<<<<
+ *     cdef ti_iter_t iterator
+ *     cdef tabix_t * tabixfile
  */
-struct __pyx_obj_5pysam_6ctabix_tabix_copy_iterator {
+struct __pyx_obj_5pysam_6ctabix_TabixIteratorParsed {
   PyObject_HEAD
-  struct __pyx_vtabstruct_5pysam_6ctabix_tabix_copy_iterator *__pyx_vtab;
-  FILE *infile;
+  ti_iter_t iterator;
+  tabix_t *tabixfile;
   struct __pyx_obj_5pysam_6ctabix_Parser *parser;
 };
 
 
-/* "pysam/cvcf.pyx":229
- * 
+/* "pysam/cvcf.pyx":902
+ *         return line
  * 
- * cdef class asVCFRecord( ctabix.Parser ):             # <<<<<<<<<<<<<<
- *     '''converts a :term:`tabix row` into a VCF record.'''
- *     cdef vcffile
+ *     def _parse(self, line, stream):             # <<<<<<<<<<<<<<
+ *         # deal with files with header only
+ *         if line.startswith("##"): return
  */
-struct __pyx_obj_5pysam_4cvcf_asVCFRecord {
-  struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
-  PyObject *vcffile;
+struct __pyx_obj_5pysam_4cvcf___pyx_scope_struct_2__parse {
+  PyObject_HEAD
+  PyObject *__pyx_v_d;
+  PyObject *__pyx_v_line;
+  PyObject *__pyx_v_self;
+  PyObject *__pyx_v_stream;
+  Py_ssize_t __pyx_t_0;
+  PyObject *__pyx_t_1;
+  PyObject *(*__pyx_t_2)(PyObject *);
 };
 
 
@@ -465,6 +471,32 @@ struct __pyx_obj_5pysam_10TabProxies_TupleProxy {
 };
 
 
+/* "TabProxies.pxd":69
+ *     cdef char * getAttributes( self )
+ * 
+ * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ *     pass
+ * 
+ */
+struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy {
+  struct __pyx_obj_5pysam_10TabProxies_TupleProxy __pyx_base;
+};
+
+
+/* "TabProxies.pxd":83
+ *     cdef update( self, char * buffer, size_t nbytes )
+ * 
+ * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
+ */
+struct __pyx_obj_5pysam_10TabProxies_VCFProxy {
+  struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
+  char *contig;
+  uint32_t pos;
+};
+
+
 /* "pysam/cvcf.pyx":95
  * ###########################################################################################################
  * 
@@ -480,47 +512,28 @@ struct __pyx_obj_5pysam_4cvcf_VCFRecord {
 };
 
 
-/* "ctabix.pxd":186
- *     cdef tabix_t * tabixfile
- * 
- * cdef class TabixHeaderIterator:             # <<<<<<<<<<<<<<
- *     cdef ti_iter_t iterator
- *     cdef tabix_t * tabixfile
- */
-struct __pyx_obj_5pysam_6ctabix_TabixHeaderIterator {
-  PyObject_HEAD
-  ti_iter_t iterator;
-  tabix_t *tabixfile;
-};
-
-
-/* "ctabix.pxd":172
- *   # char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len)
+/* "pysam/cvcf.pyx":229
  * 
- * cdef class Tabixfile:             # <<<<<<<<<<<<<<
  * 
- *     # pointer to tabixfile
+ * cdef class asVCFRecord( ctabix.Parser ):             # <<<<<<<<<<<<<<
+ *     '''converts a :term:`tabix row` into a VCF record.'''
+ *     cdef vcffile
  */
-struct __pyx_obj_5pysam_6ctabix_Tabixfile {
-  PyObject_HEAD
-  tabix_t *tabixfile;
-  int isremote;
-  char *_filename;
+struct __pyx_obj_5pysam_4cvcf_asVCFRecord {
+  struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
+  PyObject *vcffile;
 };
 
 
-/* "ctabix.pxd":205
+/* "ctabix.pxd":202
+ *      pass
+ * 
+ * cdef class asVCF(Parser):             # <<<<<<<<<<<<<<
  *      pass
  * 
- * cdef class TabixIteratorParsed:             # <<<<<<<<<<<<<<
- *     cdef ti_iter_t iterator
- *     cdef tabix_t * tabixfile
  */
-struct __pyx_obj_5pysam_6ctabix_TabixIteratorParsed {
-  PyObject_HEAD
-  ti_iter_t iterator;
-  tabix_t *tabixfile;
-  struct __pyx_obj_5pysam_6ctabix_Parser *parser;
+struct __pyx_obj_5pysam_6ctabix_asVCF {
+  struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
 };
 
 
@@ -537,93 +550,72 @@ struct __pyx_obj_5pysam_4cvcf___pyx_scope_struct__parse_data {
 };
 
 
-/* "ctabix.pxd":210
- *     cdef Parser parser
+/* "TabProxies.pxd":60
+ *     cdef update( self, char * buffer, size_t nbytes )
  * 
- * cdef class tabix_inplace_iterator:             # <<<<<<<<<<<<<<
- *     cdef FILE * infile
- *     cdef char * buffer
+ * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
  */
-struct __pyx_obj_5pysam_6ctabix_tabix_inplace_iterator {
-  PyObject_HEAD
-  struct __pyx_vtabstruct_5pysam_6ctabix_tabix_inplace_iterator *__pyx_vtab;
-  FILE *infile;
-  char *buffer;
-  size_t size;
-  struct __pyx_obj_5pysam_6ctabix_Parser *parser;
+struct __pyx_obj_5pysam_10TabProxies_GTFProxy {
+  struct __pyx_obj_5pysam_10TabProxies_TupleProxy __pyx_base;
+  char *_attributes;
+  int hasOwnAttributes;
 };
 
 
-/* "pysam/cvcf.pyx":902
- *         return line
+/* "ctabix.pxd":186
+ *     cdef tabix_t * tabixfile
  * 
- *     def _parse(self, line, stream):             # <<<<<<<<<<<<<<
- *         # deal with files with header only
- *         if line.startswith("##"): return
+ * cdef class TabixHeaderIterator:             # <<<<<<<<<<<<<<
+ *     cdef ti_iter_t iterator
+ *     cdef tabix_t * tabixfile
  */
-struct __pyx_obj_5pysam_4cvcf___pyx_scope_struct_2__parse {
+struct __pyx_obj_5pysam_6ctabix_TabixHeaderIterator {
   PyObject_HEAD
-  PyObject *__pyx_v_d;
-  PyObject *__pyx_v_line;
-  PyObject *__pyx_v_self;
-  PyObject *__pyx_v_stream;
-  Py_ssize_t __pyx_t_0;
-  PyObject *__pyx_t_1;
-  PyObject *(*__pyx_t_2)(PyObject *);
+  ti_iter_t iterator;
+  tabix_t *tabixfile;
 };
 
 
-/* "ctabix.pxd":202
+/* "ctabix.pxd":196
  *      pass
  * 
- * cdef class asVCF(Parser):             # <<<<<<<<<<<<<<
+ * cdef class asGTF(Parser):             # <<<<<<<<<<<<<<
  *      pass
  * 
  */
-struct __pyx_obj_5pysam_6ctabix_asVCF {
+struct __pyx_obj_5pysam_6ctabix_asGTF {
   struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
 };
 
 
-/* "TabProxies.pxd":69
- *     cdef char * getAttributes( self )
- * 
- * cdef class NamedTupleProxy( TupleProxy) :             # <<<<<<<<<<<<<<
- *     pass
- * 
- */
-struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy {
-  struct __pyx_obj_5pysam_10TabProxies_TupleProxy __pyx_base;
-};
-
-
-/* "TabProxies.pxd":72
- *     pass
+/* "ctabix.pxd":172
+ *   # char *ti_iter_read(BGZF *fp, ti_iter_t iter, int *len)
  * 
- * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * cdef class Tabixfile:             # <<<<<<<<<<<<<<
  * 
- *     cdef:
+ *     # pointer to tabixfile
  */
-struct __pyx_obj_5pysam_10TabProxies_BedProxy {
-  struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
-  char *contig;
-  uint32_t start;
-  uint32_t end;
-  int bedfields;
+struct __pyx_obj_5pysam_6ctabix_Tabixfile {
+  PyObject_HEAD
+  tabix_t *tabixfile;
+  int isremote;
+  char *_filename;
 };
 
 
-/* "TabProxies.pxd":60
- *     cdef update( self, char * buffer, size_t nbytes )
- * 
- * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+/* "ctabix.pxd":182
+ *     cdef char * _filename
  * 
- *     cdef:
+ * cdef class TabixIterator:             # <<<<<<<<<<<<<<
+ *     cdef ti_iter_t iterator
+ *     cdef tabix_t * tabixfile
  */
-struct __pyx_obj_5pysam_10TabProxies_GTFProxy {
-  struct __pyx_obj_5pysam_10TabProxies_TupleProxy __pyx_base;
-  char *_attributes;
-  int hasOwnAttributes;
+struct __pyx_obj_5pysam_6ctabix_TabixIterator {
+  PyObject_HEAD
+  ti_iter_t iterator;
+  tabix_t *tabixfile;
 };
 
 
@@ -644,55 +636,63 @@ struct __pyx_obj_5pysam_4cvcf___pyx_scope_struct_1_genexpr {
 };
 
 
-/* "ctabix.pxd":196
- *      pass
- * 
- * cdef class asGTF(Parser):             # <<<<<<<<<<<<<<
- *      pass
+/* "ctabix.pxd":210
+ *     cdef Parser parser
  * 
+ * cdef class tabix_inplace_iterator:             # <<<<<<<<<<<<<<
+ *     cdef FILE * infile
+ *     cdef char * buffer
  */
-struct __pyx_obj_5pysam_6ctabix_asGTF {
-  struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
+struct __pyx_obj_5pysam_6ctabix_tabix_inplace_iterator {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_5pysam_6ctabix_tabix_inplace_iterator *__pyx_vtab;
+  FILE *infile;
+  char *buffer;
+  size_t size;
+  struct __pyx_obj_5pysam_6ctabix_Parser *parser;
 };
 
 
-/* "ctabix.pxd":182
- *     cdef char * _filename
+/* "TabProxies.pxd":72
+ *     pass
  * 
- * cdef class TabixIterator:             # <<<<<<<<<<<<<<
- *     cdef ti_iter_t iterator
- *     cdef tabix_t * tabixfile
+ * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
  */
-struct __pyx_obj_5pysam_6ctabix_TabixIterator {
-  PyObject_HEAD
-  ti_iter_t iterator;
-  tabix_t *tabixfile;
+struct __pyx_obj_5pysam_10TabProxies_BedProxy {
+  struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
+  char *contig;
+  uint32_t start;
+  uint32_t end;
+  int bedfields;
 };
 
 
-/* "ctabix.pxd":199
- *      pass
- * 
- * cdef class asBed(Parser):             # <<<<<<<<<<<<<<
- *      pass
+/* "ctabix.pxd":218
+ *     cdef __cnext__(self)
  * 
+ * cdef class tabix_copy_iterator:             # <<<<<<<<<<<<<<
+ *     cdef FILE * infile
+ *     cdef Parser parser
  */
-struct __pyx_obj_5pysam_6ctabix_asBed {
-  struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
+struct __pyx_obj_5pysam_6ctabix_tabix_copy_iterator {
+  PyObject_HEAD
+  struct __pyx_vtabstruct_5pysam_6ctabix_tabix_copy_iterator *__pyx_vtab;
+  FILE *infile;
+  struct __pyx_obj_5pysam_6ctabix_Parser *parser;
 };
 
 
-/* "TabProxies.pxd":83
- *     cdef update( self, char * buffer, size_t nbytes )
+/* "ctabix.pxd":193
+ *      pass
  * 
- * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * cdef class asTuple(Parser):             # <<<<<<<<<<<<<<
+ *      pass
  * 
- *     cdef:
  */
-struct __pyx_obj_5pysam_10TabProxies_VCFProxy {
-  struct __pyx_obj_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
-  char *contig;
-  uint32_t pos;
+struct __pyx_obj_5pysam_6ctabix_asTuple {
+  struct __pyx_obj_5pysam_6ctabix_Parser __pyx_base;
 };
 
 
@@ -729,89 +729,89 @@ struct __pyx_vtabstruct_5pysam_10TabProxies_NamedTupleProxy {
 static struct __pyx_vtabstruct_5pysam_10TabProxies_NamedTupleProxy *__pyx_vtabptr_5pysam_10TabProxies_NamedTupleProxy;
 
 
-/* "TabProxies.pxd":72
- *     pass
+/* "TabProxies.pxd":83
+ *     cdef update( self, char * buffer, size_t nbytes )
  * 
- * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+ * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
  * 
  *     cdef:
  */
 
-struct __pyx_vtabstruct_5pysam_10TabProxies_BedProxy {
+struct __pyx_vtabstruct_5pysam_10TabProxies_VCFProxy {
   struct __pyx_vtabstruct_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
 };
-static struct __pyx_vtabstruct_5pysam_10TabProxies_BedProxy *__pyx_vtabptr_5pysam_10TabProxies_BedProxy;
+static struct __pyx_vtabstruct_5pysam_10TabProxies_VCFProxy *__pyx_vtabptr_5pysam_10TabProxies_VCFProxy;
 
 
-/* "TabProxies.pxd":60
- *     cdef update( self, char * buffer, size_t nbytes )
+/* "pysam/cvcf.pyx":95
+ * ###########################################################################################################
  * 
- * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ * cdef class VCFRecord( TabProxies.TupleProxy):             # <<<<<<<<<<<<<<
+ *     '''vcf record.
  * 
- *     cdef:
  */
 
-struct __pyx_vtabstruct_5pysam_10TabProxies_GTFProxy {
+struct __pyx_vtabstruct_5pysam_4cvcf_VCFRecord {
   struct __pyx_vtabstruct_5pysam_10TabProxies_TupleProxy __pyx_base;
-  char *(*getAttributes)(struct __pyx_obj_5pysam_10TabProxies_GTFProxy *);
 };
-static struct __pyx_vtabstruct_5pysam_10TabProxies_GTFProxy *__pyx_vtabptr_5pysam_10TabProxies_GTFProxy;
+static struct __pyx_vtabstruct_5pysam_4cvcf_VCFRecord *__pyx_vtabptr_5pysam_4cvcf_VCFRecord;
 
 
-/* "ctabix.pxd":218
- *     cdef __cnext__(self)
+/* "ctabix.pxd":210
+ *     cdef Parser parser
  * 
- * cdef class tabix_copy_iterator:             # <<<<<<<<<<<<<<
+ * cdef class tabix_inplace_iterator:             # <<<<<<<<<<<<<<
  *     cdef FILE * infile
- *     cdef Parser parser
+ *     cdef char * buffer
  */
 
-struct __pyx_vtabstruct_5pysam_6ctabix_tabix_copy_iterator {
-  PyObject *(*__pyx___cnext__)(struct __pyx_obj_5pysam_6ctabix_tabix_copy_iterator *);
+struct __pyx_vtabstruct_5pysam_6ctabix_tabix_inplace_iterator {
+  PyObject *(*__pyx___cnext__)(struct __pyx_obj_5pysam_6ctabix_tabix_inplace_iterator *);
 };
-static struct __pyx_vtabstruct_5pysam_6ctabix_tabix_copy_iterator *__pyx_vtabptr_5pysam_6ctabix_tabix_copy_iterator;
+static struct __pyx_vtabstruct_5pysam_6ctabix_tabix_inplace_iterator *__pyx_vtabptr_5pysam_6ctabix_tabix_inplace_iterator;
 
 
-/* "pysam/cvcf.pyx":95
- * ###########################################################################################################
+/* "TabProxies.pxd":72
+ *     pass
  * 
- * cdef class VCFRecord( TabProxies.TupleProxy):             # <<<<<<<<<<<<<<
- *     '''vcf record.
+ * cdef class BedProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
  * 
+ *     cdef:
  */
 
-struct __pyx_vtabstruct_5pysam_4cvcf_VCFRecord {
-  struct __pyx_vtabstruct_5pysam_10TabProxies_TupleProxy __pyx_base;
+struct __pyx_vtabstruct_5pysam_10TabProxies_BedProxy {
+  struct __pyx_vtabstruct_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
 };
-static struct __pyx_vtabstruct_5pysam_4cvcf_VCFRecord *__pyx_vtabptr_5pysam_4cvcf_VCFRecord;
+static struct __pyx_vtabstruct_5pysam_10TabProxies_BedProxy *__pyx_vtabptr_5pysam_10TabProxies_BedProxy;
 
 
-/* "TabProxies.pxd":83
- *     cdef update( self, char * buffer, size_t nbytes )
- * 
- * cdef class VCFProxy( NamedTupleProxy) :             # <<<<<<<<<<<<<<
+/* "ctabix.pxd":218
+ *     cdef __cnext__(self)
  * 
- *     cdef:
+ * cdef class tabix_copy_iterator:             # <<<<<<<<<<<<<<
+ *     cdef FILE * infile
+ *     cdef Parser parser
  */
 
-struct __pyx_vtabstruct_5pysam_10TabProxies_VCFProxy {
-  struct __pyx_vtabstruct_5pysam_10TabProxies_NamedTupleProxy __pyx_base;
+struct __pyx_vtabstruct_5pysam_6ctabix_tabix_copy_iterator {
+  PyObject *(*__pyx___cnext__)(struct __pyx_obj_5pysam_6ctabix_tabix_copy_iterator *);
 };
-static struct __pyx_vtabstruct_5pysam_10TabProxies_VCFProxy *__pyx_vtabptr_5pysam_10TabProxies_VCFProxy;
+static struct __pyx_vtabstruct_5pysam_6ctabix_tabix_copy_iterator *__pyx_vtabptr_5pysam_6ctabix_tabix_copy_iterator;
 
 
-/* "ctabix.pxd":210
- *     cdef Parser parser
+/* "TabProxies.pxd":60
+ *     cdef update( self, char * buffer, size_t nbytes )
  * 
- * cdef class tabix_inplace_iterator:             # <<<<<<<<<<<<<<
- *     cdef FILE * infile
- *     cdef char * buffer
+ * cdef class GTFProxy( TupleProxy) :             # <<<<<<<<<<<<<<
+ * 
+ *     cdef:
  */
 
-struct __pyx_vtabstruct_5pysam_6ctabix_tabix_inplace_iterator {
-  PyObject *(*__pyx___cnext__)(struct __pyx_obj_5pysam_6ctabix_tabix_inplace_iterator *);
+struct __pyx_vtabstruct_5pysam_10TabProxies_GTFProxy {
+  struct __pyx_vtabstruct_5pysam_10TabProxies_TupleProxy __pyx_base;
+  char *(*getAttributes)(struct __pyx_obj_5pysam_10TabProxies_GTFProxy *);
 };
-static struct __pyx_vtabstruct_5pysam_6ctabix_tabix_inplace_iterator *__pyx_vtabptr_5pysam_6ctabix_tabix_inplace_iterator;
+static struct __pyx_vtabstruct_5pysam_10TabProxies_GTFProxy *__pyx_vtabptr_5pysam_10TabProxies_GTFProxy;
 #ifndef CYTHON_REFNANNY
   #define CYTHON_REFNANNY 0
 #endif
diff --git a/pysam/pysam_util.c b/pysam/pysam_util.c
index 4990e64..82c959c 100644
--- a/pysam/pysam_util.c
+++ b/pysam/pysam_util.c
@@ -8,6 +8,9 @@
 #include "pysam_util.h"
 #include "errmod.h" // for pysam_dump 
 
+// for sequence parsing
+#include "kseq.h"
+
 #ifndef inline
 #define inline __inline
 #endif
diff --git a/pysam/pysam_util.h b/pysam/pysam_util.h
index 90a9378..ce6c753 100644
--- a/pysam/pysam_util.h
+++ b/pysam/pysam_util.h
@@ -1,6 +1,12 @@
 #ifndef PYSAM_UTIL_H
 #define PYSAM_UTIL_H
 
+#include "kseq.h"
+
+// #######################################################
+// fastq parsing
+KSEQ_INIT(gzFile, gzread)
+
 //////////////////////////////////////////////////////////////////
 /*! set pysam standard error to point to file descriptor
 
diff --git a/pysam/tabix_util.c b/pysam/tabix_util.c
index b06a614..0305de1 100644
--- a/pysam/tabix_util.c
+++ b/pysam/tabix_util.c
@@ -2,3 +2,25 @@
 #include "stdio.h"
 FILE * pysamerr = NULL;
 
+#if !(_POSIX_C_SOURCE >= 200809L || _XOPEN_SOURCE >= 700)
+/*
+ * A rudimentary emulation of getline() for systems that dont support it
+ * natively.  Since this is used for PPD file reading, it assumes (possibly
+ * falsely) that BUFSIZ is big enough.
+ */
+ssize_t
+getline(char **line, size_t *linelen, FILE *fp)
+{
+  if (*linelen == 0) 
+    {
+      *linelen = BUFSIZ;
+      *line = malloc(*linelen);
+    }
+
+  memset(*line, 0, *linelen);
+  fgets(*line, *linelen, fp);
+
+  return (strlen(*line));
+
+}
+#endif
diff --git a/pysam/version.py b/pysam/version.py
index 52609de..0dfb2cf 100644
--- a/pysam/version.py
+++ b/pysam/version.py
@@ -1,6 +1,6 @@
 # pysam versioning information
 
-__version__ = "0.7.5"
+__version__ = "0.7.6"
 
 __samtools_version__ = "0.1.19"
 
diff --git a/setup.py b/setup.py
index 1b4a325..5fa876f 100644
--- a/setup.py
+++ b/setup.py
@@ -126,11 +126,12 @@ if len(sys.argv) >= 2 and sys.argv[1] == "refresh":
 # cp samtools/*.h pysam/*.h pysam/include
 # cp samtools/win32/*.h pysam/include/win32
 
-
-from distribute_setup import use_setuptools
-use_setuptools()
-
-from setuptools import Extension, setup, find_packages
+try:
+    from setuptools import Extension, setup, find_packages
+except ImportError:
+    from ez_setup import use_setuptools
+    use_setuptools()
+    from setuptools import Extension, setup, find_packages
 
 #######################################################
 #######################################################
diff --git a/tests/Makefile b/tests/Makefile
index 7774778..05963e5 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -12,8 +12,7 @@ all: ex1.pileup.gz ex1.bam.bai \
 	example_unmapped_reads_no_sq.bam \
 	example_user_header.bam \
 	example_btag.bam \
-	example_bai.bam 
-	
+	example_bai.bam \
 
 ex2.sam.gz: ex1.bam ex1.bam.bai
 		samtools view -h ex1.bam | gzip > ex2.sam.gz
diff --git a/tests/pysam_test.py b/tests/pysam_test.py
index 5cfed74..67f205f 100755
--- a/tests/pysam_test.py
+++ b/tests/pysam_test.py
@@ -812,6 +812,14 @@ class TestIteratorColumn2(unittest.TestCase):
         self.assertEqual( len(columns), 3)
         self.assertEqual( columns, [169,170,171] )
 
+    def testAccessOnClosedIterator( self ):
+        '''see issue 131
+
+        Accessing pileup data after iterator has closed.
+        '''
+        pcolumn = self.samfile.pileup( 'chr1', 170, 180).__next__()
+        self.assertRaises( ValueError, getattr, pcolumn, "pileups" )
+
 class TestAlignedReadFromBam(unittest.TestCase):
 
     def setUp(self):
@@ -1163,6 +1171,30 @@ class TestFastaFile(unittest.TestCase):
     def tearDown(self):
         self.file.close()
 
+class TestFastqFile(unittest.TestCase):
+
+    def setUp(self):
+        self.file=pysam.Fastqfile( "ex1.fq" )
+
+    def testCounts( self ):
+        self.assertEqual( len( [ x for x in self.file ] ), 3270 )
+
+    def testMissingFile( self ):
+        self.assertRaises( IOError, pysam.Fastqfile, "nothere.fq" )
+
+    def testSequence( self ):
+        s = self.file.__next__()
+        # test first entry
+        self.assertEqual( s.sequence, b"GGGAACAGGGGGGTGCACTAATGCGCTCCACGCCC")
+        self.assertEqual( s.quality, b"<<86<<;<78<<<)<;4<67<;<;<74-7;,;8,;")
+        self.assertEqual( s.name, b"B7_589:1:101:825:28" )
+
+        for s in self.file: pass
+        # test last entry
+        self.assertEqual( s.sequence, b"TAATTGAAAAATTCATTTAAGAAATTACAAAATAT")
+        self.assertEqual( s.quality, b"<<<<<;<<<<<<<<<<<<<<<;;;<<<;<<8;<;<")
+        self.assertEqual( s.name, b"EAS56_65:8:64:507:478" )
+
 class TestAlignedRead(unittest.TestCase):
     '''tests to check if aligned read can be constructed
     and manipulated.
@@ -1264,6 +1296,23 @@ class TestAlignedRead(unittest.TestCase):
             self.assertEqual( getattr(b, x), False )
             self.checkFieldEqual( a, b )
 
+    def testUpdate( self ):
+        '''issue 135: inplace update of sequence and quality score.
+        
+        This does not work as setting the sequence will erase
+        the quality scores.
+        '''
+        a = self.buildRead()
+        a.seq = a.seq[5:10]
+        self.assertEqual( a.qual, None )
+        
+        a = self.buildRead()
+        s = a.qual
+        a.seq = a.seq[5:10]
+        a.qual = s[5:10]
+        
+        self.assertEqual( a.qual, s[5:10])
+
     def testLargeRead( self ):
         '''build an example read.'''
         

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-pysam.git



More information about the debian-med-commit mailing list